-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAppForm.js
More file actions
148 lines (118 loc) · 3.67 KB
/
Copy pathAppForm.js
File metadata and controls
148 lines (118 loc) · 3.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
var p = MindFusion.Scheduling;
var AppForm = function (calendar, item, type) {
p.BaseForm.call(this, calendar, item);
this._id = "AppForm";
this._type = type;
this.states = [{ value: 0, text: "confirmed" }, { value: 1, text: "pending" }, { value: 2, text: "cancelled" }];
}
AppForm.prototype = Object.create(p.BaseForm.prototype);
AppForm.prototype.constructor = AppForm;
AppForm.prototype.drawContent = function () {
p.BaseForm.prototype.drawContent.call(this);
var content = this.content;
var row = this.row();
row.className = "header-row";
row.innerText = "From";
content.appendChild(row);
row = this.row();
row.className = "data-row";
row.innerHTML = this.item.startTime.toString(this.formatInfo.dateFormats.longDate, this.formatInfo);
content.appendChild(row);
var row = this.row();
row.className = "header-row";
row.innerText = "To";
content.appendChild(row);
row = this.row();
row.className = "data-row";
row.innerHTML = this.item.endTime.toString(this.formatInfo.dateFormats.longDate, this.formatInfo);
content.appendChild(row);
row = this.row();
row.className = "header-row";
row.innerHTML = this.localInfo.locationCaption;
content.appendChild(row);
row = this.row();
row.className = "data-row";
row.innerText = this.item.location.toString();
content.appendChild(row);
var row = this.row();
row.className = "header-row";
row.innerHTML = "Name";
content.appendChild(row);
if (this.type === "new") {
// create a text-area for the item subject
var control = this.createTextBox({ id: "subject", initValue: this.item.subject });
control.element.style.width = "200px";
this.addControl(control);
row = this.row();
row.className = "input-row";
row.appendChild(control.element);
content.appendChild(row);
}
else {
row = this.row();
row.className = "data-row";
row.innerText = this.item.subject.toString() || "<unknown>";
content.appendChild(row);
}
// create a drop-down list for status
row = this.row();
row.className = "header-row";
row.innerHTML = "Status";
content.appendChild(row);
var item = this.item;
control = this.createDropDownList({ id: "status", items: this.states, initValue: item.tag, addEmptyValue: false });
control.element.style.width = "200px";
this.addControl(control);
row = this.row();
row.className = "input-row";
row.appendChild(control.element);
content.appendChild(row);
return content;
};
// override BaseForm's drawButtons method to create form buttons
AppForm.prototype.drawButtons = function () {
var thisObj = this;
var btnSave = this.createButton({
id: "btnSave",
text: "✔",
events: {
"click": function click(e) {
return thisObj.onSaveButtonClick(e);
}
}
});
btnSave.element.className = "form-button-save";
var btnCancel = this.createButton({
id: "btnCancel",
text: "✖",
events: {
click: function click(e) {
return thisObj.onCancelButtonClick(e);
}
}
});
btnCancel.element.className = "form-button-cancel";
var buttons = this.row();
buttons.classList.add("form-buttons");
buttons.appendChild(btnSave.element);
buttons.appendChild(btnCancel.element);
return buttons;
};
AppForm.prototype.onSaveButtonClick = function (e) {
// update the item with the form data
if (this.controls.get("subject"))
this.item.subject = this.getControlValue("subject");
var status = +this.getControlValue("status");
this.item.tag = status;
// if a new item is created, add it to the schedule.items collection
if (this.type === "new")
this.calendar.schedule.items.add(this.item);
// close the form
this.closeForm();
// repaint the calendar
this.calendar.render(true);
};
AppForm.prototype.onCancelButtonClick = function (e) {
// close the form
this.closeForm();
};