Fix #5640 - prevent multiple no milestone being created
[Pman.MTrack] / Pman.Dialog.MTrackTicket.js
1 //<script type="text/javascript">
2
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
4
5 Pman.Dialog.MTrackTicket = {
6
7     dialog : false,
8     callback:  false,
9
10     show : function(data, cb)
11     {
12         if (!this.dialog) {
13             this.create();
14         }
15
16         this.callback = cb;
17         this.data = data;
18         this.dialog.show(this.data._el);
19         if (this.form) {
20            this.form.reset();
21            this.form.setValues(data);
22            this.form.fireEvent('actioncomplete', this.form,  { type: 'setdata', data: data });
23         }
24
25     },
26
27     create : function()
28     {
29         var _this = this;
30         this.dialog = Roo.factory({
31             xtype: 'LayoutDialog',
32             xns: Roo,
33             listeners : {
34                 resize : function (_self, width, height)
35                 {
36                     var bw = width - 320;
37                     _this.form.findField('description').el.setWidth(bw);
38                     _this.summaryBox.el.setWidth(bw+30);
39                         _this.summaryCol.el.setWidth(bw+45);
40                           _this.descCol.el.setWidth(bw+35);
41                           
42                 }
43             },
44             closable : false,
45             collapsible : false,
46             height : 450,
47             modal : true,
48             resizable : true,
49             title : "Edit or Create Ticket",
50             width : 700,
51             items : [
52                 {
53                     xtype: 'ContentPanel',
54                     xns: Roo,
55                     region : 'center',
56                     items : [
57                         {
58                             xtype: 'Form',
59                             xns: Roo.form,
60                             listeners : {
61                                 actioncomplete : function(_self,action)
62                                 {
63                                     if (action.type == 'setdata') {
64                                   
65                                        this.load({ method: 'GET', params: { '_id' : _this.data.id  || 0}});
66                                           
67                                        return;
68                                     }
69                                     if (action.type == 'load') {
70                                        if (!_this.data.id) {
71                                             this.setValues(_this.data);
72                                         }
73                                         return;
74                                     }
75                                     
76                                     
77                                     if (action.type =='submit') {
78                                     
79                                         if (!_this.data.id * 1) {
80                                             Roo.MessageBox.confirm("Close?", 
81                                                 "The new ticket id is #" + action.result.data.id + ", Press yes to close, or no to keep editing",
82                                                 function (res) {
83                                                     if (res == 'yes') {
84                                                     
85                                                     
86                                                         _this.dialog.hide();
87                                                     
88                                                          if (_this.callback) {
89                                                             _this.callback.call(_this, _this.form.getValues());
90                                                          }
91                                                          _this.form.reset();            
92                                                          return;
93                                                      }
94                                                      _this.data.id = action.result.data.id;
95                                                      _this.form.fireEvent('actioncomplete', _this.form, { type : 'setdata', data : {}});
96                                                      return;
97                                                  }
98                                              );
99                                         
100                                         
101                                         
102                                         
103                                             return;
104                                         }
105                                         
106                                         _this.dialog.hide();
107                                     
108                                          if (_this.callback) {
109                                             _this.callback.call(_this, _this.form.getValues());
110                                          }
111                                          _this.form.reset();        
112                                 
113                                          return;
114                                     }
115                                 },
116                                 rendered : function (form)
117                                 {
118                                     _this.form= form;
119                                 }
120                             },
121                             method : 'POST',
122                             style : 'margin:10px;width:1000px;margin-top:0px;',
123                             url : baseURL + '/Roo/mtrack_ticket.php',
124                             items : [
125                                 {
126                                     xtype: 'Column',
127                                     xns: Roo.form,
128                                     width : 210,
129                                     items : [
130                                         {
131                                             xtype: 'FieldSet',
132                                             xns: Roo.form,
133                                             labelAlign : 'top',
134                                             legend : "Properties",
135                                             style : 'width:190px;',
136                                             items : [
137                                                 {
138                                                     xtype: 'ComboBox',
139                                                     xns: Roo.form,
140                                                     allowBlank : 'false',
141                                                     displayField : 'name',
142                                                     editable : 'false',
143                                                     emptyText : "Select Project",
144                                                     fieldLabel : 'Project',
145                                                     forceSelection : true,
146                                                     hiddenName : 'project_id',
147                                                     listWidth : 400,
148                                                     loadingText : "Searching...",
149                                                     minChars : 2,
150                                                     name : 'project_id_name',
151                                                     pageSize : 20,
152                                                     qtip : "Select Projects",
153                                                     queryParam : 'query[name]',
154                                                     selectOnFocus : true,
155                                                     tpl : '<div class="x-grid-cell-text x-btn button "><b>{name}</b> </div>',
156                                                     triggerAction : 'all',
157                                                     typeAhead : true,
158                                                     valueField : 'id',
159                                                     width : 180,
160                                                     store : {
161                                                         xtype: 'Store',
162                                                         xns: Roo.data,
163                                                         listeners : {
164                                                             beforeload : function (_self, o){
165                                                                 o.params = o.params || {};
166                                                                 // set more here
167                                                             }
168                                                         },
169                                                         remoteSort : true,
170                                                         sortInfo : { direction : 'ASC', field: 'name' },
171                                                         proxy : {
172                                                             xtype: 'HttpProxy',
173                                                             xns: Roo.data,
174                                                             method : 'GET',
175                                                             url : baseURL + '/Roo/Projects.php'
176                                                         },
177                                                         reader : {
178                                                             xtype: 'JsonReader',
179                                                             xns: Roo.data,
180                                                             id : 'id',
181                                                             root : 'data',
182                                                             totalProperty : 'total',
183                                                             fields : [{"name":"id","type":"int"},{"name":"name","type":"string"}]
184                                                         }
185                                                     }
186                                                 },
187                                                 {
188                                                     xtype: 'ComboBox',
189                                                     xns: Roo.form,
190                                                     alwaysQuery : true,
191                                                     displayField : 'name',
192                                                     editable : 'false',
193                                                     emptyText : "Select milestone",
194                                                     fieldLabel : 'Milestone',
195                                                     forceSelection : true,
196                                                     hiddenName : 'milestone_id',
197                                                     listWidth : 400,
198                                                     loadingText : "Searching...",
199                                                     minChars : 2,
200                                                     name : 'milestone_id_name',
201                                                     pageSize : 20,
202                                                     qtip : "Select mtrack_milestone",
203                                                     queryParam : 'query[name]',
204                                                     selectOnFocus : true,
205                                                     tpl : '<div class="x-grid-cell-text x-btn button  RdYlGn-q{seqid}-{seqmax}"><b>{name}</b> </div>',
206                                                     triggerAction : 'all',
207                                                     typeAhead : true,
208                                                     valueField : 'id',
209                                                     width : 180,
210                                                     store : {
211                                                         xtype: 'Store',
212                                                         xns: Roo.data,
213                                                         listeners : {
214                                                             beforeload : function (_self, o){
215                                                                 o.params = o.params || {};
216                                                                 // set more here
217                                                                 o.params.etype = 'milestone';
218                                                                 o.params.project_id = _this.form.findField('project_id').getValue();
219                                                                 if (!o.params.project_id) {
220                                                                     Roo.MessageBox.alert("Error", "Select Project");
221                                                                     return false;
222                                                                 }
223                                                             }
224                                                         },
225                                                         remoteSort : true,
226                                                         sortInfo : { direction : 'ASC', field: 'startdate' },
227                                                         proxy : {
228                                                             xtype: 'HttpProxy',
229                                                             xns: Roo.data,
230                                                             method : 'GET',
231                                                             url : baseURL + '/Roo/mtrack_milestone.php'
232                                                         },
233                                                         reader : {
234                                                             xtype: 'JsonReader',
235                                                             xns: Roo.data,
236                                                             id : 'id',
237                                                             root : 'data',
238                                                             totalProperty : 'total',
239                                                             fields : [{"name":"id","type":"int"},{"name":"name","type":"string"}]
240                                                         }
241                                                     }
242                                                 },
243                                                 {
244                                                     xtype: 'ComboBox',
245                                                     xns: Roo.form,
246                                                     allowBlank : false,
247                                                     alwaysQuery : true,
248                                                     displayField : 'name',
249                                                     editable : 'false',
250                                                     emptyText : "Select Priority",
251                                                     fieldLabel : 'Priority',
252                                                     forceSelection : true,
253                                                     hiddenName : 'priority_id',
254                                                     listWidth : 400,
255                                                     loadingText : "Searching...",
256                                                     minChars : 2,
257                                                     name : 'priority_id_name',
258                                                     pageSize : 20,
259                                                     qtip : "Select core_enum",
260                                                     queryParam : 'query[etype]',
261                                                     selectOnFocus : true,
262                                                     tpl : '<div class="x-grid-cell-text x-btn button  RdYlGn-q{seqid}-{seqmax}"><b>{name}</b> </div>',
263                                                     triggerAction : 'all',
264                                                     typeAhead : true,
265                                                     valueField : 'id',
266                                                     width : 180,
267                                                     store : {
268                                                         xtype: 'Store',
269                                                         xns: Roo.data,
270                                                         listeners : {
271                                                             beforeload : function (_self, o){
272                                                                 o.params = o.params || {};
273                                                                 // set more here
274                                                                     o.params.etype = 'priority';
275                                                             }
276                                                         },
277                                                         remoteSort : true,
278                                                         sortInfo : { direction : 'ASC', field: 'seqid' },
279                                                         proxy : {
280                                                             xtype: 'HttpProxy',
281                                                             xns: Roo.data,
282                                                             method : 'GET',
283                                                             url : baseURL + '/Roo/core_enum.php'
284                                                         },
285                                                         reader : {
286                                                             xtype: 'JsonReader',
287                                                             xns: Roo.data,
288                                                             id : 'id',
289                                                             root : 'data',
290                                                             totalProperty : 'total',
291                                                             fields : [{"name":"id","type":"int"},{"name":"etype","type":"string"}]
292                                                         }
293                                                     }
294                                                 },
295                                                 {
296                                                     xtype: 'ComboBox',
297                                                     xns: Roo.form,
298                                                     allowBlank : false,
299                                                     alwaysQuery : true,
300                                                     displayField : 'name',
301                                                     editable : 'false',
302                                                     emptyText : "Select Severity",
303                                                     fieldLabel : 'Severity',
304                                                     forceSelection : true,
305                                                     hiddenName : 'severity_id',
306                                                     listWidth : 400,
307                                                     loadingText : "Searching...",
308                                                     minChars : 2,
309                                                     name : 'severity_id_name',
310                                                     pageSize : 20,
311                                                     qtip : "Select core_enum",
312                                                     queryParam : 'query[etype]',
313                                                     selectOnFocus : true,
314                                                     tpl : '<div class="x-grid-cell-text x-btn button RdYlGn-q{seqid}-{seqmax}"><b>{name}</b> </div>',
315                                                     triggerAction : 'all',
316                                                     typeAhead : true,
317                                                     valueField : 'id',
318                                                     width : 180,
319                                                     store : {
320                                                         xtype: 'Store',
321                                                         xns: Roo.data,
322                                                         listeners : {
323                                                             beforeload : function (_self, o){
324                                                                 o.params = o.params || {};
325                                                                 // set more here
326                                                                     o.params.etype = 'severity';
327                                                             }
328                                                         },
329                                                         remoteSort : true,
330                                                         sortInfo : { direction : 'ASC', field: 'seqid' },
331                                                         proxy : {
332                                                             xtype: 'HttpProxy',
333                                                             xns: Roo.data,
334                                                             method : 'GET',
335                                                             url : baseURL + '/Roo/core_enum.php'
336                                                         },
337                                                         reader : {
338                                                             xtype: 'JsonReader',
339                                                             xns: Roo.data,
340                                                             id : 'id',
341                                                             root : 'data',
342                                                             totalProperty : 'total',
343                                                             fields : [{"name":"id","type":"int"},{"name":"etype","type":"string"}]
344                                                         }
345                                                     }
346                                                 },
347                                                 {
348                                                     xtype: 'ComboBox',
349                                                     xns: Roo.form,
350                                                     allowBlank : false,
351                                                     alwaysQuery : true,
352                                                     displayField : 'name',
353                                                     editable : 'false',
354                                                     emptyText : "Select Classification",
355                                                     fieldLabel : 'Classification',
356                                                     forceSelection : true,
357                                                     hiddenName : 'classification_id',
358                                                     listWidth : 400,
359                                                     loadingText : "Searching...",
360                                                     minChars : 2,
361                                                     name : 'classification_id_name',
362                                                     pageSize : 20,
363                                                     qtip : "Select core_enum",
364                                                     queryParam : 'query[etype]',
365                                                     selectOnFocus : true,
366                                                     tpl : '<div class="x-grid-cell-text x-btn button RdYlGn-q{seqid}-{seqmax}"><b>{name}</b> </div>',
367                                                     triggerAction : 'all',
368                                                     typeAhead : true,
369                                                     valueField : 'id',
370                                                     width : 180,
371                                                     store : {
372                                                         xtype: 'Store',
373                                                         xns: Roo.data,
374                                                         listeners : {
375                                                             beforeload : function (_self, o){
376                                                                 o.params = o.params || {};
377                                                                 // set more here
378                                                                     o.params.etype = 'classification';
379                                                             }
380                                                         },
381                                                         remoteSort : true,
382                                                         sortInfo : { direction : 'ASC', field: 'seqid' },
383                                                         proxy : {
384                                                             xtype: 'HttpProxy',
385                                                             xns: Roo.data,
386                                                             method : 'GET',
387                                                             url : baseURL + '/Roo/core_enum.php'
388                                                         },
389                                                         reader : {
390                                                             xtype: 'JsonReader',
391                                                             xns: Roo.data,
392                                                             id : 'id',
393                                                             root : 'data',
394                                                             totalProperty : 'total',
395                                                             fields : [{"name":"id","type":"int"},{"name":"etype","type":"string"}]
396                                                         }
397                                                     }
398                                                 }
399                                             ]
400                                         },
401                                         {
402                                             xtype: 'FieldSet',
403                                             xns: Roo.form,
404                                             legend : "Resources",
405                                             style : 'width: 190px',
406                                             items : [
407                                                 {
408                                                     xtype: 'Column',
409                                                     xns: Roo.form,
410                                                     labelAlign : 'top',
411                                                     width : 190,
412                                                     items : [
413                                                         {
414                                                             xtype: 'ComboBox',
415                                                             xns: Roo.form,
416                                                             allowBlank : 'false',
417                                                             alwaysQuery : true,
418                                                             displayField : 'name',
419                                                             editable : 'false',
420                                                             emptyText : "Select Person",
421                                                             fieldLabel : 'Developer',
422                                                             forceSelection : true,
423                                                             hiddenName : 'developer_id',
424                                                             listWidth : 400,
425                                                             loadingText : "Searching...",
426                                                             minChars : 2,
427                                                             name : 'developer_id_name',
428                                                             pageSize : 20,
429                                                             qtip : "Select Person",
430                                                             queryParam : 'query[name]',
431                                                             selectOnFocus : true,
432                                                             tpl : '<div class="x-grid-cell-text x-btn button"><b>{name}</b> &lt;{email}&gt; </div>',
433                                                             triggerAction : 'all',
434                                                             typeAhead : true,
435                                                             valueField : 'id',
436                                                             width : 180,
437                                                             store : {
438                                                                 xtype: 'Store',
439                                                                 xns: Roo.data,
440                                                                 listeners : {
441                                                                     beforeload : function (_self, o){
442                                                                         o.params = o.params || {};
443                                                                         
444                                                                         // set more here
445                                                                         o.params['query[project_id]'] = _this.form.findField('project_id').getValue();
446                                                                         if (!o.params['query[project_id]']) {
447                                                                             Roo.MessageBox.alert("Error", "Select Project");
448                                                                             return false;
449                                                                         }
450                                                                         o.params['query[role]'] = 'DEVELOPER';
451                                                                     }
452                                                                 },
453                                                                 remoteSort : true,
454                                                                 sortInfo : { direction : 'ASC', field: 'name' },
455                                                                 proxy : {
456                                                                     xtype: 'HttpProxy',
457                                                                     xns: Roo.data,
458                                                                     method : 'GET',
459                                                                     url : baseURL + '/Roo/Person.php'
460                                                                 },
461                                                                 reader : {
462                                                                     xtype: 'JsonReader',
463                                                                     xns: Roo.data,
464                                                                     id : 'id',
465                                                                     root : 'data',
466                                                                     totalProperty : 'total',
467                                                                     fields : [{"name":"id","type":"int"},{"name":"name","type":"string"}]
468                                                                 }
469                                                             }
470                                                         },
471                                                         {
472                                                             xtype: 'ComboBox',
473                                                             xns: Roo.form,
474                                                             allowBlank : 'false',
475                                                             alwaysQuery : true,
476                                                             displayField : 'name',
477                                                             editable : 'false',
478                                                             emptyText : "Select Person",
479                                                             fieldLabel : 'Owner',
480                                                             forceSelection : true,
481                                                             hiddenName : 'owner_id',
482                                                             listWidth : 400,
483                                                             loadingText : "Searching...",
484                                                             minChars : 2,
485                                                             name : 'owner_id_name',
486                                                             pageSize : 20,
487                                                             qtip : "Select Person",
488                                                             queryParam : 'query[name]',
489                                                             selectOnFocus : true,
490                                                             tpl : '<div class="x-grid-cell-text x-btn button"><b>{name}</b> </div>',
491                                                             triggerAction : 'all',
492                                                             typeAhead : true,
493                                                             valueField : 'id',
494                                                             width : 180,
495                                                             store : {
496                                                                 xtype: 'Store',
497                                                                 xns: Roo.data,
498                                                                 listeners : {
499                                                                     beforeload : function (_self, o){
500                                                                         o.params = o.params || {};
501                                                                         // set more here
502                                                                         o.params['query[project_id]']= _this.form.findField('project_id').getValue();
503                                                                         if (!o.params['query[project_id]'])  {
504                                                                             Roo.MessageBox.alert("Error", "Select Project");
505                                                                             return false;
506                                                                         }
507                                                                     }
508                                                                 },
509                                                                 remoteSort : true,
510                                                                 sortInfo : { direction : 'ASC', field: 'name' },
511                                                                 proxy : {
512                                                                     xtype: 'HttpProxy',
513                                                                     xns: Roo.data,
514                                                                     method : 'GET',
515                                                                     url : baseURL + '/Roo/Person.php'
516                                                                 },
517                                                                 reader : {
518                                                                     xtype: 'JsonReader',
519                                                                     xns: Roo.data,
520                                                                     id : 'id',
521                                                                     root : 'data',
522                                                                     totalProperty : 'total',
523                                                                     fields : [{"name":"id","type":"int"},{"name":"name","type":"string"}]
524                                                                 }
525                                                             }
526                                                         }
527                                                     ]
528                                                 },
529                                                 {
530                                                     xtype: 'Column',
531                                                     xns: Roo.form,
532                                                     labelAlign : 'right',
533                                                     labelWidth : 100,
534                                                     width : 190,
535                                                     items : [
536                                                         {
537                                                             xtype: 'NumberField',
538                                                             xns: Roo.form,
539                                                             style : 'align:right;',
540                                                             fieldLabel : 'Estimated',
541                                                             name : 'estimated',
542                                                             width : 75
543                                                         }
544                                                     ]
545                                                 }
546                                             ]
547                                         }
548                                     ]
549                                 },
550                                 {
551                                     xtype: 'Column',
552                                     xns: Roo.form,
553                                     listeners : {
554                                         show : function (_self)
555                                         {
556                                         
557                                         },
558                                         render : function (_self)
559                                         {
560                                           _this.summaryCol = _self;
561                                         }
562                                     },
563                                     style : 'margin-left:10px',
564                                     width : 430,
565                                     items : [
566                                         {
567                                             xtype: 'FieldSet',
568                                             xns: Roo.form,
569                                             listeners : {
570                                                 show : function (_self)
571                                                 {
572                                                 
573                                                 },
574                                                 render : function (_self)
575                                                 {
576                                                   _this.summaryBox = _self;
577                                                 }
578                                             },
579                                             legend : "Summary / Details",
580                                             style : 'width:410px',
581                                             items : [
582                                                 {
583                                                     xtype: 'Column',
584                                                     xns: Roo.form,
585                                                     labelAlign : 'top',
586                                                     width : 400,
587                                                     items : [
588                                                         {
589                                                             xtype: 'TextField',
590                                                             xns: Roo.form,
591                                                             fieldLabel : 'Summary',
592                                                             name : 'summary',
593                                                             width : 400
594                                                         }
595                                                     ]
596                                                 },
597                                                 {
598                                                     xtype: 'Row',
599                                                     xns: Roo.form,
600                                                     labelWidth : 70,
601                                                     style : 'float:left; width:400px',
602                                                     width : 400,
603                                                     items : [
604                                                         {
605                                                             xtype: 'Checkbox',
606                                                             xns: Roo.form,
607                                                             listeners : {
608                                                                 check : function (_self, checked)
609                                                                 {
610                                                                 
611                                                                     if (!_this.form) {
612                                                                         return;
613                                                                     }
614                                                                     if (checked) {
615                                                                     
616                                                                          _this.form.findField('view_as').setValue('text');
617                                                                      }
618                                                                          
619                                                                     
620                                                                     
621                                                                      if (this.radio) {
622                                                                         return;
623                                                                     }
624                                                                      var md = _this.form.findField('view_as_markdown');
625                                                                 
626                                                                     md.radio = true;
627                                                                     md.setValue(checked ? 0 : 1);
628                                                                     
629                                                                     md.radio = false;
630                                                                 }
631                                                             },
632                                                             boxLabel : 'text',
633                                                             fieldLabel : 'View as',
634                                                             name : 'view_as_text',
635                                                             value : 1,
636                                                             width : 100
637                                                         },
638                                                         {
639                                                             xtype: 'Row',
640                                                             xns: Roo.form,
641                                                             hideLabels : true,
642                                                             style : 'float: left',
643                                                             width : 100,
644                                                             items : [
645                                                                 {
646                                                                     xtype: 'Checkbox',
647                                                                     xns: Roo.form,
648                                                                     listeners : {
649                                                                         check : function (_self, checked)
650                                                                         {
651                                                                                if (!_this.form) {
652                                                                                 return;
653                                                                             }
654                                                                             
655                                                                                 if (checked) {
656                                                                             
657                                                                                  _this.form.findField('view_as').setValue('markdown');
658                                                                              }
659                                                                             
660                                                                              if (this.radio) {
661                                                                                 return;
662                                                                             }
663                                                                              var md = _this.form.findField('view_as_text');
664                                                                         
665                                                                             md.radio = true;
666                                                                             md.setValue(checked ? 0 : 1);
667                                                                             md.radio = false;
668                                                                         }
669                                                                     },
670                                                                     boxLabel : 'markdown',
671                                                                     name : 'view_as_markdown',
672                                                                     value : 1
673                                                                 }
674                                                             ]
675                                                         }
676                                                     ]
677                                                 },
678                                                 {
679                                                     xtype: 'Column',
680                                                     xns: Roo.form,
681                                                     listeners : {
682                                                         show : function (_self)
683                                                         {
684                                                         
685                                                         },
686                                                         render : function (_self)
687                                                         {
688                                                           _this.descCol = _self;
689                                                         }
690                                                     },
691                                                     labelAlign : 'top',
692                                                     width : 400,
693                                                     items : [
694                                                         {
695                                                             xtype: 'TextArea',
696                                                             xns: Roo.form,
697                                                             fieldLabel : 'Description',
698                                                             height : 250,
699                                                             name : 'description',
700                                                             width : 400
701                                                         }
702                                                     ]
703                                                 }
704                                             ]
705                                         }
706                                     ]
707                                 },
708                                 {
709                                     xtype: 'Hidden',
710                                     xns: Roo.form,
711                                     name : 'id'
712                                 },
713                                 {
714                                     xtype: 'Hidden',
715                                     xns: Roo.form,
716                                     name : 'view_as'
717                                 }
718                             ]
719                         }
720                     ]
721                 }
722             ],
723             center : {
724                 xtype: 'LayoutRegion',
725                 xns: Roo
726             },
727             buttons : [
728                 {
729                     xtype: 'Button',
730                     xns: Roo,
731                     listeners : {
732                         click : function (_self, e)
733                         {
734                             _this.dialog.hide();
735                         }
736                     },
737                     text : "Cancel"
738                 },
739                 {
740                     xtype: 'Button',
741                     xns: Roo,
742                     listeners : {
743                         click : function (_self, e)
744                         {
745                             // do some checks?
746                              
747                             
748                          
749                             _this.form.doAction("submit");
750                         
751                         }
752                     },
753                     text : "Save"
754                 }
755             ]
756         });
757     }
758 };