1 | dojo.provide("dojox.gantt.TabMenu"); |
---|
2 | |
---|
3 | dojo.require("dijit.dijit"); |
---|
4 | dojo.require("dijit.Menu"); |
---|
5 | dojo.require("dijit.Dialog"); |
---|
6 | dojo.require("dijit.form.NumberSpinner"); |
---|
7 | dojo.require("dijit.form.Button"); |
---|
8 | dojo.require("dijit.form.CheckBox"); |
---|
9 | dojo.require("dijit.form.DateTextBox"); |
---|
10 | dojo.require("dijit.form.TimeTextBox"); |
---|
11 | dojo.require("dojo.date.locale"); |
---|
12 | |
---|
13 | dojo.require("dijit.form.Form"); |
---|
14 | dojo.require("dojo.parser"); |
---|
15 | |
---|
16 | (function(){ |
---|
17 | dojo.declare("dojox.gantt.TabMenu", null, { |
---|
18 | constructor: function(chart){ |
---|
19 | this.ganttChart = chart; |
---|
20 | this.menuPanel = null; |
---|
21 | this.paneContentArea = null; |
---|
22 | this.paneActionBar = null; |
---|
23 | this.tabPanelDlg = null; |
---|
24 | this.tabPanelDlgId = null; |
---|
25 | this.arrTabs = []; |
---|
26 | this.isShow = false; |
---|
27 | this.buildContent(); |
---|
28 | }, |
---|
29 | buildContent: function(){ |
---|
30 | this.createMenuPanel(); |
---|
31 | this.createTabPanel(); |
---|
32 | |
---|
33 | //tasks customization |
---|
34 | var taskSucAdd = this.createTab(11, "Add Successor Task", "t", true, this); |
---|
35 | taskSucAdd.addItem(1, "Id", "id", true); |
---|
36 | taskSucAdd.addItem(2, "Name", "name"); |
---|
37 | taskSucAdd.addItem(3, "Start Time", "startTime"); |
---|
38 | taskSucAdd.addItem(4, "Duration (hours)", "duration"); |
---|
39 | taskSucAdd.addItem(5, "Percent Complete (%)", "percentage"); |
---|
40 | taskSucAdd.addItem(6, "Task Assignee", "taskOwner"); |
---|
41 | taskSucAdd.addAction("addSuccessorTaskAction"); |
---|
42 | |
---|
43 | var taskChildAdd = this.createTab(10, "Add Child Task", "t", true, this); |
---|
44 | taskChildAdd.addItem(1, "Id", "id", true); |
---|
45 | taskChildAdd.addItem(2, "Name", "name"); |
---|
46 | taskChildAdd.addItem(3, "Start Time", "startTime"); |
---|
47 | taskChildAdd.addItem(4, "Duration (hours)", "duration"); |
---|
48 | taskChildAdd.addItem(5, "Percent Complete (%)", "percentage"); |
---|
49 | taskChildAdd.addItem(6, "Task Assignee", "taskOwner"); |
---|
50 | taskChildAdd.addAction("addChildTaskAction"); |
---|
51 | |
---|
52 | var taskDuration = this.createTab(4, "Set Duration(hours)", "t", true, this, true); |
---|
53 | taskDuration.addItem(1, "Duration (hours)", "duration", true); |
---|
54 | taskDuration.addAction("durationUpdateAction"); |
---|
55 | |
---|
56 | var taskCP = this.createTab(5, "Set Complete Percentage (%)", "t", true, this, true); |
---|
57 | taskCP.addItem(1, "Percent Complete (%)", "percentage", true); |
---|
58 | taskCP.addAction("cpUpdateAction"); |
---|
59 | |
---|
60 | var taskOwner = this.createTab(20, "Set Owner", "t", true, this, true); |
---|
61 | taskOwner.addItem(1, "Task Assignee", "taskOwner", true); |
---|
62 | taskOwner.addAction("ownerUpdateAction"); |
---|
63 | |
---|
64 | var taskPrevious = this.createTab(13, "Set Previous Task", "t", true, this); |
---|
65 | taskPrevious.addItem(1, "Previous Task Id", "previousTaskId", true); |
---|
66 | taskPrevious.addAction("ptUpdateAction"); |
---|
67 | |
---|
68 | var taskRename = this.createTab(1, "Rename Task", "t", true, this, true); |
---|
69 | taskRename.addItem(1, "New Name", "name", true); |
---|
70 | taskRename.addAction("renameTaskAction"); |
---|
71 | |
---|
72 | var taskDelete = this.createTab(2, "Delete Task", "t", true, this); |
---|
73 | taskDelete.addAction("deleteAction"); |
---|
74 | |
---|
75 | //projects customization |
---|
76 | var projectAdd = this.createTab(12, "Add New Project", "p", false, this); |
---|
77 | projectAdd.addItem(1, "Id", "id", true); |
---|
78 | projectAdd.addItem(2, "Name", "name", true); |
---|
79 | projectAdd.addItem(3, "Start Date", "startDate", true); |
---|
80 | projectAdd.addAction("addProjectAction"); |
---|
81 | |
---|
82 | var projectCP = this.createTab(8, "Set Complete Percentage (%)", "p", true, this, true); |
---|
83 | projectCP.addItem(1, "Percent Complete (%)", "percentage", true); |
---|
84 | projectCP.addAction("cpProjectAction"); |
---|
85 | |
---|
86 | var projectRename = this.createTab(6, "Rename Project", "p", true, this, true); |
---|
87 | projectRename.addItem(1, "New Name", "name", true); |
---|
88 | projectRename.addAction("renameProjectAction"); |
---|
89 | |
---|
90 | var projectDelete = this.createTab(7, "Delete Project", "p", true, this); |
---|
91 | projectDelete.addAction("deleteProjectAction"); |
---|
92 | |
---|
93 | //task relative |
---|
94 | var projectTaskAdd = this.createTab(9, "Add New Task", "p", true, this); |
---|
95 | projectTaskAdd.addItem(1, "Id", "id", true); |
---|
96 | projectTaskAdd.addItem(2, "Name", "name"); |
---|
97 | projectTaskAdd.addItem(3, "Start Time", "startTime"); |
---|
98 | projectTaskAdd.addItem(4, "Duration (hours)", "duration"); |
---|
99 | projectTaskAdd.addItem(5, "Percent Complete (%)", "percentage"); |
---|
100 | projectTaskAdd.addItem(6, "Task Assignee", "taskOwner"); |
---|
101 | projectTaskAdd.addItem(7, "Parent Task Id", "parentTaskId"); |
---|
102 | projectTaskAdd.addItem(8, "Previous Task Id", "previousTaskId"); |
---|
103 | projectTaskAdd.addAction("addTaskAction"); |
---|
104 | }, |
---|
105 | createMenuPanel: function(){ |
---|
106 | this.menuPanel = dojo.create("div", { |
---|
107 | innerHTML: "<table></table>", |
---|
108 | className: "ganttMenuPanel" |
---|
109 | }, this.ganttChart.content); |
---|
110 | dojo.addClass(this.menuPanel.firstChild, "ganttContextMenu"); |
---|
111 | this.menuPanel.firstChild.cellPadding = 0; |
---|
112 | this.menuPanel.firstChild.cellSpacing = 0; |
---|
113 | }, |
---|
114 | createTabPanel: function(){ |
---|
115 | this.tabPanelDlg = dijit.byId(this.tabPanelDlgId) || |
---|
116 | new dijit.Dialog({ |
---|
117 | title: "Settings" |
---|
118 | }); |
---|
119 | this.tabPanelDlgId = this.tabPanelDlg.id; |
---|
120 | this.tabPanelDlg.closeButtonNode.style.display = "none"; |
---|
121 | var tabPanel = this.tabPanelDlg.containerNode; |
---|
122 | this.paneContentArea = dojo.create("div", {className: "dijitDialogPaneContentArea"}, tabPanel); |
---|
123 | this.paneActionBar = dojo.create("div", {className: "dijitDialogPaneActionBar"}, tabPanel); |
---|
124 | this.paneContentArea.innerHTML = "<table cellpadding=0 cellspacing=0><tr><th></th></tr><tr><td></td></tr></table>"; |
---|
125 | var headerCell = this.paneContentArea.firstChild.rows[0].cells[0]; |
---|
126 | headerCell.colSpan = 2; |
---|
127 | headerCell.innerHTML = "Description: "; |
---|
128 | dojo.addClass(headerCell, "ganttDialogContentHeader"); |
---|
129 | var contentCell = this.paneContentArea.firstChild.rows[1].cells[0]; |
---|
130 | contentCell.innerHTML = "<table></table>"; |
---|
131 | dojo.addClass(contentCell.firstChild, "ganttDialogContentCell"); |
---|
132 | contentCell.align = "center"; |
---|
133 | this.ok = new dijit.form.Button({label: "OK"}); |
---|
134 | this.cancel = new dijit.form.Button({label: "Cancel"}); |
---|
135 | this.paneActionBar.appendChild(this.ok.domNode); |
---|
136 | this.paneActionBar.appendChild(this.cancel.domNode); |
---|
137 | }, |
---|
138 | addItemMenuPanel: function(tab){ |
---|
139 | var row = this.menuPanel.firstChild.insertRow(this.menuPanel.firstChild.rows.length); |
---|
140 | var cell = dojo.create("td", { |
---|
141 | className: "ganttContextMenuItem", |
---|
142 | innerHTML: tab.Description |
---|
143 | }); |
---|
144 | dojo.attr(cell, "tabIndex", 0); |
---|
145 | this.ganttChart._events.push( |
---|
146 | dojo.connect(cell, "onclick", this, function(){ |
---|
147 | try{ |
---|
148 | this.hide(); |
---|
149 | tab.show(); |
---|
150 | }catch(e){ |
---|
151 | console.log("dialog open exception: " + e.message); |
---|
152 | } |
---|
153 | }) |
---|
154 | ); |
---|
155 | this.ganttChart._events.push( |
---|
156 | dojo.connect(cell, "onkeydown", this, function(e){ |
---|
157 | if(e.keyCode != dojo.keys.ENTER){return;} |
---|
158 | try{ |
---|
159 | this.hide(); |
---|
160 | tab.show(); |
---|
161 | }catch(e){ |
---|
162 | console.log("dialog open exception: " + e.message); |
---|
163 | } |
---|
164 | }) |
---|
165 | ); |
---|
166 | this.ganttChart._events.push( |
---|
167 | dojo.connect(cell, "onmouseover", this, function(){ |
---|
168 | dojo.addClass(cell, "ganttContextMenuItemHover"); |
---|
169 | }) |
---|
170 | ); |
---|
171 | this.ganttChart._events.push( |
---|
172 | dojo.connect(cell, "onmouseout", this, function(){ |
---|
173 | dojo.removeClass(cell, "ganttContextMenuItemHover"); |
---|
174 | }) |
---|
175 | ); |
---|
176 | row.appendChild(cell); |
---|
177 | }, |
---|
178 | show: function(elem, object){ |
---|
179 | if(object.constructor == dojox.gantt.GanttTaskControl){ |
---|
180 | dojo.forEach(this.arrTabs, function(tab){ |
---|
181 | if(tab.type == "t"){ |
---|
182 | tab.object = object; |
---|
183 | this.addItemMenuPanel(tab); |
---|
184 | } |
---|
185 | }, this); |
---|
186 | }else if(object.constructor == dojox.gantt.GanttProjectControl){ |
---|
187 | dojo.forEach(this.arrTabs, function(tab){ |
---|
188 | if(tab.type == "p"){ |
---|
189 | tab.object = object; |
---|
190 | this.addItemMenuPanel(tab); |
---|
191 | } |
---|
192 | }, this); |
---|
193 | } |
---|
194 | this.isShow = true; |
---|
195 | dojo.style(this.menuPanel, { |
---|
196 | zIndex: 15, |
---|
197 | visibility: "visible" |
---|
198 | }); |
---|
199 | //make sure menu box inside gantt's bounding box |
---|
200 | var menuBox = dojo.position(this.menuPanel, true), |
---|
201 | bBox = dojo.position(this.ganttChart.content, true), |
---|
202 | pos = dojo.coords(elem, true); |
---|
203 | if((pos.y + menuBox.h) > (bBox.y + bBox.h + 50)){ |
---|
204 | this.menuPanel.style.top = pos.y - menuBox.h + pos.h + "px"; |
---|
205 | }else{ |
---|
206 | this.menuPanel.style.top = pos.y + "px"; |
---|
207 | } |
---|
208 | if(dojo._isBodyLtr()){ |
---|
209 | this.menuPanel.style.left = pos.x + pos.w + 5 + "px"; |
---|
210 | }else{ |
---|
211 | this.menuPanel.style.left = pos.x - menuBox.w - 5 + "px"; |
---|
212 | } |
---|
213 | }, |
---|
214 | hide: function(){ |
---|
215 | this.isShow = false; |
---|
216 | this.menuPanel.style.visibility = "hidden"; |
---|
217 | }, |
---|
218 | clear: function(){ |
---|
219 | this.menuPanel.removeChild(this.menuPanel.firstChild); |
---|
220 | this.menuPanel.innerHTML = "<table></table>"; |
---|
221 | dojo.addClass(this.menuPanel.firstChild, "ganttContextMenu"); |
---|
222 | this.menuPanel.firstChild.cellPadding = 0; |
---|
223 | this.menuPanel.firstChild.cellSpacing = 0; |
---|
224 | }, |
---|
225 | createTab: function(id, desc, type, showOInfo, menu, withDefaultValue){ |
---|
226 | var tab = new dojox.gantt.contextMenuTab(id, desc, type, showOInfo, menu, withDefaultValue); |
---|
227 | this.arrTabs.push(tab); |
---|
228 | return tab; |
---|
229 | } |
---|
230 | }); |
---|
231 | |
---|
232 | dojo.declare("dojox.gantt.contextMenuTab", null, { |
---|
233 | constructor: function(id, description, type, showOInfo, tabMenu, withDefaultValue){ |
---|
234 | this.id = id; |
---|
235 | this.arrItems = []; |
---|
236 | this.TabItemContainer = null; |
---|
237 | this.Description = description; |
---|
238 | this.tabMenu = tabMenu; |
---|
239 | this.type = type; |
---|
240 | this.object = null; |
---|
241 | this.showObjectInfo = showOInfo; |
---|
242 | this.withDefaultValue = withDefaultValue; |
---|
243 | }, |
---|
244 | preValueValidation: function(items){ |
---|
245 | for(var i = 0; i < items.length; i++){ |
---|
246 | var item = items[i]; |
---|
247 | //TODO add more validation for Id, Name, ..... |
---|
248 | if(item.required && !item.control.textbox.value){ |
---|
249 | return false; |
---|
250 | } |
---|
251 | } |
---|
252 | return true; |
---|
253 | }, |
---|
254 | encodeDate: function(date){ |
---|
255 | return date.getFullYear() + "." + (date.getMonth() + 1) + "." + date.getDate(); |
---|
256 | }, |
---|
257 | decodeDate: function(dateStr){ |
---|
258 | var arr = dateStr.split("."); |
---|
259 | return (arr.length < 3) ? "" : (new Date(arr[0], parseInt(arr[1]) - 1, arr[2])); |
---|
260 | }, |
---|
261 | renameTaskAction: function(){ |
---|
262 | var name = this.arrItems[0].control.textbox.value; |
---|
263 | if(dojo.trim(name).length <= 0){ |
---|
264 | return; |
---|
265 | } |
---|
266 | if(!this.preValueValidation(this.arrItems)){ |
---|
267 | return; |
---|
268 | } |
---|
269 | this.object.setName(name); |
---|
270 | this.hide(); |
---|
271 | }, |
---|
272 | deleteAction: function(){ |
---|
273 | if(!this.preValueValidation(this.arrItems)){ |
---|
274 | return; |
---|
275 | } |
---|
276 | this.object.project.deleteTask(this.object.taskItem.id); |
---|
277 | this.hide(); |
---|
278 | this.tabMenu.ganttChart.resource && this.tabMenu.ganttChart.resource.reConstruct(); |
---|
279 | }, |
---|
280 | durationUpdateAction: function(){ |
---|
281 | var d = this.arrItems[0].control.textbox.value; |
---|
282 | if(!this.preValueValidation(this.arrItems)){ |
---|
283 | return; |
---|
284 | } |
---|
285 | if(this.object.setDuration(d)){ |
---|
286 | this.hide(); |
---|
287 | }else{ |
---|
288 | alert("Duration out of Range"); |
---|
289 | return; |
---|
290 | } |
---|
291 | this.tabMenu.ganttChart.resource && this.tabMenu.ganttChart.resource.refresh(); |
---|
292 | }, |
---|
293 | cpUpdateAction: function(){ |
---|
294 | var p = this.arrItems[0].control.textbox.value; |
---|
295 | if(!this.preValueValidation(this.arrItems)){ |
---|
296 | return; |
---|
297 | } |
---|
298 | if(this.object.setPercentCompleted(p)){ |
---|
299 | this.hide(); |
---|
300 | }else{ |
---|
301 | alert("Complete Percentage out of Range"); |
---|
302 | return; |
---|
303 | } |
---|
304 | }, |
---|
305 | ownerUpdateAction: function(){ |
---|
306 | var to = this.arrItems[0].control.textbox.value; |
---|
307 | if(!this.preValueValidation(this.arrItems)){ |
---|
308 | return; |
---|
309 | } |
---|
310 | if(this.object.setTaskOwner(to)){ |
---|
311 | this.hide(); |
---|
312 | }else{ |
---|
313 | alert("Task owner not Valid"); |
---|
314 | return; |
---|
315 | } |
---|
316 | this.tabMenu.ganttChart.resource && this.tabMenu.ganttChart.resource.reConstruct(); |
---|
317 | }, |
---|
318 | ptUpdateAction: function(){ |
---|
319 | var p = this.arrItems[0].control.textbox.value; |
---|
320 | if(!this.preValueValidation(this.arrItems)){ |
---|
321 | return; |
---|
322 | } |
---|
323 | if(this.object.setPreviousTask(p)){ |
---|
324 | this.hide(); |
---|
325 | }else{ |
---|
326 | alert("Please verify the Previous Task (" + p + ") and adjust its Time Range"); |
---|
327 | return; |
---|
328 | } |
---|
329 | }, |
---|
330 | renameProjectAction: function(){ |
---|
331 | var name = this.arrItems[0].control.textbox.value; |
---|
332 | if(dojo.trim(name).length <= 0){ |
---|
333 | return; |
---|
334 | } |
---|
335 | if(!this.preValueValidation(this.arrItems)){ |
---|
336 | return; |
---|
337 | } |
---|
338 | this.object.setName(name); |
---|
339 | this.hide(); |
---|
340 | }, |
---|
341 | deleteProjectAction: function(){ |
---|
342 | if(!this.preValueValidation(this.arrItems)){ |
---|
343 | return; |
---|
344 | } |
---|
345 | this.object.ganttChart.deleteProject(this.object.project.id); |
---|
346 | this.hide(); |
---|
347 | this.tabMenu.ganttChart.resource && this.tabMenu.ganttChart.resource.reConstruct(); |
---|
348 | }, |
---|
349 | cpProjectAction: function(){ |
---|
350 | var p = this.arrItems[0].control.textbox.value; |
---|
351 | if(!this.preValueValidation(this.arrItems)){ |
---|
352 | return; |
---|
353 | } |
---|
354 | if(this.object.setPercentCompleted(p)){ |
---|
355 | this.hide(); |
---|
356 | }else{ |
---|
357 | alert("Percentage not Acceptable"); |
---|
358 | return; |
---|
359 | } |
---|
360 | }, |
---|
361 | addTaskAction: function(){ |
---|
362 | if(!this.preValueValidation(this.arrItems)){ |
---|
363 | return; |
---|
364 | } |
---|
365 | var id = this.arrItems[0].control.textbox.value, |
---|
366 | name = this.arrItems[1].control.textbox.value, |
---|
367 | startTime = this.decodeDate(this.arrItems[2].control.textbox.value), |
---|
368 | duration = this.arrItems[3].control.textbox.value, |
---|
369 | pc = this.arrItems[4].control.textbox.value, |
---|
370 | owner = this.arrItems[5].control.textbox.value, |
---|
371 | parentTaskId = this.arrItems[6].control.textbox.value, |
---|
372 | predTaskId = this.arrItems[7].control.textbox.value; |
---|
373 | if(dojo.trim(id).length <= 0){ |
---|
374 | return; |
---|
375 | } |
---|
376 | if(this.object.insertTask(id, name, startTime, duration, pc, predTaskId, owner, parentTaskId)){ |
---|
377 | this.hide(); |
---|
378 | }else{ |
---|
379 | alert("Please adjust your Customization"); |
---|
380 | return; |
---|
381 | } |
---|
382 | this.tabMenu.ganttChart.resource && this.tabMenu.ganttChart.resource.reConstruct(); |
---|
383 | }, |
---|
384 | addSuccessorTaskAction: function(){ |
---|
385 | if(!this.preValueValidation(this.arrItems)){ |
---|
386 | return; |
---|
387 | } |
---|
388 | var pr = this.object.project, |
---|
389 | id = this.arrItems[0].control.textbox.value, |
---|
390 | name = this.arrItems[1].control.textbox.value, |
---|
391 | startTime = this.decodeDate(this.arrItems[2].control.textbox.value), |
---|
392 | duration = this.arrItems[3].control.textbox.value, |
---|
393 | pc = this.arrItems[4].control.textbox.value, |
---|
394 | owner = this.arrItems[5].control.textbox.value; |
---|
395 | if(dojo.trim(id).length <= 0){ |
---|
396 | return; |
---|
397 | } |
---|
398 | var parentTaskId = !this.object.parentTask ? "" : this.object.parentTask.taskItem.id; |
---|
399 | var predTaskId = this.object.taskItem.id; |
---|
400 | if(pr.insertTask(id, name, startTime, duration, pc, predTaskId, owner, parentTaskId)){ |
---|
401 | this.hide(); |
---|
402 | }else{ |
---|
403 | alert("Please adjust your Customization"); |
---|
404 | return; |
---|
405 | } |
---|
406 | this.tabMenu.ganttChart.resource && this.tabMenu.ganttChart.resource.reConstruct(); |
---|
407 | }, |
---|
408 | addChildTaskAction: function(){ |
---|
409 | if(!this.preValueValidation(this.arrItems)){ |
---|
410 | return; |
---|
411 | } |
---|
412 | var pr = this.object.project, |
---|
413 | id = this.arrItems[0].control.textbox.value, |
---|
414 | name = this.arrItems[1].control.textbox.value, |
---|
415 | startTime = this.decodeDate(this.arrItems[2].control.textbox.value), |
---|
416 | duration = this.arrItems[3].control.textbox.value, |
---|
417 | pc = this.arrItems[4].control.textbox.value, |
---|
418 | owner = this.arrItems[5].control.textbox.value, |
---|
419 | parentTaskId = this.object.taskItem.id, |
---|
420 | predTaskId = ""; |
---|
421 | if(dojo.trim(id).length <= 0){ |
---|
422 | return; |
---|
423 | } |
---|
424 | if(pr.insertTask(id, name, startTime, duration, pc, predTaskId, owner, parentTaskId)){ |
---|
425 | this.hide(); |
---|
426 | }else{ |
---|
427 | alert("Please adjust your Customization"); |
---|
428 | return; |
---|
429 | } |
---|
430 | this.tabMenu.ganttChart.resource && this.tabMenu.ganttChart.resource.reConstruct(); |
---|
431 | }, |
---|
432 | addProjectAction: function(){ |
---|
433 | if(!this.preValueValidation(this.arrItems)){ |
---|
434 | return; |
---|
435 | } |
---|
436 | var id = this.arrItems[0].control.textbox.value, |
---|
437 | namePr = this.arrItems[1].control.textbox.value, |
---|
438 | startDatePr = this.decodeDate(this.arrItems[2].control.textbox.value); |
---|
439 | if(dojo.trim(id).length <= 0 || dojo.trim(namePr).length <= 0){ |
---|
440 | return; |
---|
441 | } |
---|
442 | if(this.tabMenu.ganttChart.insertProject(id, namePr, startDatePr)){ |
---|
443 | this.hide(); |
---|
444 | }else{ |
---|
445 | alert("Please adjust your Customization"); |
---|
446 | return; |
---|
447 | } |
---|
448 | this.tabMenu.ganttChart.resource && this.tabMenu.ganttChart.resource.reConstruct(); |
---|
449 | }, |
---|
450 | |
---|
451 | addAction: function(handler){ |
---|
452 | this.actionFunc = this[handler]; |
---|
453 | }, |
---|
454 | addItem: function(id, name, key, required){ |
---|
455 | var inputControl; |
---|
456 | if(key == "startTime" || key == "startDate"){ |
---|
457 | inputControl = new dijit.form.DateTextBox({type:"text", constraints:{datePattern:"yyyy.M.d", strict:true}}); |
---|
458 | }else if(key == "percentage"){ |
---|
459 | inputControl = new dijit.form.NumberSpinner({ constraints:{ max:100, min:0 }}); |
---|
460 | }else if(key == "duration"){ |
---|
461 | inputControl = new dijit.form.NumberSpinner({ constraints:{ min:0 }}); |
---|
462 | }else{ |
---|
463 | inputControl = new dijit.form.TextBox(); |
---|
464 | } |
---|
465 | this.arrItems.push({ |
---|
466 | id: id, |
---|
467 | name: name, |
---|
468 | control: inputControl, |
---|
469 | tab: this, |
---|
470 | key: key, |
---|
471 | required: required |
---|
472 | }); |
---|
473 | }, |
---|
474 | show: function(){ |
---|
475 | this.tabMenu.tabPanelDlg = this.tabMenu.tabPanelDlg || dijit.byId(this.tabMenu.tabPanelDlgId) || |
---|
476 | new dijit.Dialog({ |
---|
477 | title: "Settings" |
---|
478 | }); |
---|
479 | try{ |
---|
480 | this.tabMenu.tabPanelDlg.show(); |
---|
481 | }catch(e){ |
---|
482 | console.log("dialog show exception: " + e.message); |
---|
483 | return; |
---|
484 | } |
---|
485 | this.tabMenu.tabPanelDlg.titleNode.innerHTML = this.Description; |
---|
486 | var content = this.tabMenu.paneContentArea.firstChild.rows[1].cells[0].firstChild, |
---|
487 | action = this.tabMenu.paneActionBar; |
---|
488 | var cell, cellValue, row = null; |
---|
489 | |
---|
490 | if(this.showObjectInfo){ |
---|
491 | if(this.object){ |
---|
492 | if(this.object.constructor == dojox.gantt.GanttTaskControl){ |
---|
493 | this.insertData(content, "Id", this.object.taskItem.id); |
---|
494 | this.insertData(content, "Name", this.object.taskItem.name); |
---|
495 | this.insertData(content, "Start Time", this.encodeDate(this.object.taskItem.startTime)); |
---|
496 | this.insertData(content, "Duration (hours)", this.object.taskItem.duration + " hours"); |
---|
497 | this.insertData(content, "Percent Complete (%)", this.object.taskItem.percentage + "%"); |
---|
498 | this.insertData(content, "Task Assignee", this.object.taskItem.taskOwner); |
---|
499 | this.insertData(content, "Previous Task Id", this.object.taskItem.previousTaskId); |
---|
500 | }else{ |
---|
501 | this.insertData(content, "Id", this.object.project.id); |
---|
502 | this.insertData(content, "Name", this.object.project.name); |
---|
503 | this.insertData(content, "Start date", this.encodeDate(this.object.project.startDate)); |
---|
504 | } |
---|
505 | } |
---|
506 | } |
---|
507 | //separator |
---|
508 | row = content.insertRow(content.rows.length); |
---|
509 | cell = row.insertCell(row.cells.length); |
---|
510 | cell.colSpan = 2; |
---|
511 | cell.innerHTML = "<hr/>"; |
---|
512 | //input section header |
---|
513 | row = content.insertRow(content.rows.length); |
---|
514 | cell = row.insertCell(row.cells.length); |
---|
515 | cell.colSpan = 2; |
---|
516 | dojo.addClass(cell, "ganttMenuDialogInputCellHeader"); |
---|
517 | cell.innerHTML = "Customization: " + this.Description; |
---|
518 | //input details |
---|
519 | dojo.forEach(this.arrItems, function(item){ |
---|
520 | row = content.insertRow(content.rows.length); |
---|
521 | cell = row.insertCell(row.cells.length); |
---|
522 | dojo.addClass(cell, "ganttMenuDialogInputCell"); |
---|
523 | cellValue = row.insertCell(row.cells.length); |
---|
524 | dojo.addClass(cellValue, "ganttMenuDialogInputCellValue"); |
---|
525 | cell.innerHTML = item.name; |
---|
526 | cellValue.appendChild(item.control.domNode); |
---|
527 | //initialize default value |
---|
528 | if(this.withDefaultValue && this.object){ |
---|
529 | if(this.object.constructor == dojox.gantt.GanttTaskControl){ |
---|
530 | if(item.key == "startTime"){ |
---|
531 | item.control.textbox.value = this.encodeDate(this.object.taskItem.startTime); |
---|
532 | }else{ |
---|
533 | item.control.textbox.value = item.key ? this.object.taskItem[item.key] : ""; |
---|
534 | } |
---|
535 | }else{ |
---|
536 | if(item.key == "startDate"){ |
---|
537 | item.control.textbox.value = this.encodeDate(this.object.project.startDate); |
---|
538 | }else{ |
---|
539 | item.control.textbox.value = item.key ? (this.object.project[item.key] || this.object[item.key] || "") : ""; |
---|
540 | } |
---|
541 | } |
---|
542 | }else{ |
---|
543 | //HTML5 placeholder property |
---|
544 | item.control.textbox.placeholder = item.required ? "---required---" : "---optional---"; |
---|
545 | } |
---|
546 | }, this); |
---|
547 | this.tabMenu.ok.onClick = dojo.hitch(this, this.actionFunc); |
---|
548 | this.tabMenu.cancel.onClick = dojo.hitch(this, this.hide); |
---|
549 | }, |
---|
550 | hide: function(){ |
---|
551 | try{ |
---|
552 | this.tabMenu.tabPanelDlg.hide(); |
---|
553 | }catch(e){ |
---|
554 | console.log("dialog show exception: " + e.message); |
---|
555 | this.tabMenu.tabPanelDlg.destroy(); |
---|
556 | } |
---|
557 | var cell = this.tabMenu.paneContentArea.firstChild.rows[1].cells[0]; |
---|
558 | cell.firstChild.parentNode.removeChild(cell.firstChild); |
---|
559 | cell.innerHTML = "<table></table>"; |
---|
560 | dojo.addClass(cell.firstChild, "ganttDialogContentCell"); |
---|
561 | }, |
---|
562 | insertData: function(content, name, value){ |
---|
563 | var cell, cellValue, row = null; |
---|
564 | row = content.insertRow(content.rows.length); |
---|
565 | cell = row.insertCell(row.cells.length); |
---|
566 | dojo.addClass(cell, "ganttMenuDialogDescCell"); |
---|
567 | cell.innerHTML = name; |
---|
568 | cellValue = row.insertCell(row.cells.length); |
---|
569 | dojo.addClass(cellValue, "ganttMenuDialogDescCellValue"); |
---|
570 | cellValue.innerHTML = value; |
---|
571 | } |
---|
572 | }); |
---|
573 | })(); |
---|