Pman.Dialog.MTrackMilestone.js
[Pman.MTrack] / Pman.Dialog.MTrackMilestone.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.MTrackMilestone = {
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             closable : false,
34             collapsible : false,
35             height : 380,
36             resizable : false,
37             title : "Edit / Create mtrack_milestone",
38             width : 450,
39             items : [
40                 {
41                     xtype: 'ContentPanel',
42                     xns: Roo,
43                     region : 'center',
44                     items : [
45                         {
46                             xtype: 'Form',
47                             xns: Roo.form,
48                             listeners : {
49                                 actioncomplete : function(_self,action)
50                                 {
51                                     if (action.type == 'setdata') {
52                                        if (_this.data.id) {
53                                 
54                                          this.load({ method: 'GET', params: { '_id' : _this.data.id }});
55                                          return;
56                                        }
57                                        return;
58                                     }
59                                     if (action.type == 'load') {
60                                         
61                                         return;
62                                     }
63                                     if (action.type =='submit') {
64                                     
65                                         
66                                         _this.dialog.hide();
67                                     
68                                          if (_this.callback) {
69                                             _this.callback.call(_this, _this.form.getValues());
70                                          }
71                                          _this.form.reset();
72                                          return;
73                                     }
74                                 },
75                                 rendered : function (form)
76                                 {
77                                     _this.form= form;
78                                 }
79                             },
80                             method : 'POST',
81                             style : 'margin:10px;',
82                             url : baseURL + '/Roo/mtrack_milestone.php',
83                             items : [
84                                 {
85                                     xtype: 'ComboBox',
86                                     xns: Roo.form,
87                                     allowBlank : 'false',
88                                     displayField : 'name',
89                                     editable : 'false',
90                                     emptyText : "Select Project",
91                                     fieldLabel : 'Project',
92                                     forceSelection : true,
93                                     hiddenName : 'project_id',
94                                     listWidth : 400,
95                                     loadingText : "Searching...",
96                                     minChars : 2,
97                                     name : 'project_id_name',
98                                     pageSize : 20,
99                                     qtip : "Select Projects",
100                                     queryParam : 'query[name]',
101                                     selectOnFocus : true,
102                                     tpl : '<div class="x-grid-cell-text x-btn button"><b>{CODE} - {name}</b> </div>',
103                                     triggerAction : 'all',
104                                     typeAhead : true,
105                                     valueField : 'id',
106                                     width : 300,
107                                     store : {
108                                         xtype: 'Store',
109                                         xns: Roo.data,
110                                         listeners : {
111                                             beforeload : function (_self, o){
112                                                 o.params = o.params || {};
113                                                 // set more here
114                                             }
115                                         },
116                                         remoteSort : true,
117                                         sortInfo : { direction : 'ASC', field: 'name' },
118                                         proxy : {
119                                             xtype: 'HttpProxy',
120                                             xns: Roo.data,
121                                             method : 'GET',
122                                             url : baseURL + '/Roo/Projects.php'
123                                         },
124                                         reader : {
125                                             xtype: 'JsonReader',
126                                             xns: Roo.data,
127                                             id : 'id',
128                                             root : 'data',
129                                             totalProperty : 'total',
130                                             fields : [{"name":"id","type":"int"},{"name":"name","type":"string"}]
131                                         }
132                                     }
133                                 },
134                                 {
135                                     xtype: 'TextField',
136                                     xns: Roo.form,
137                                     fieldLabel : 'Name',
138                                     name : 'name',
139                                     width : 300
140                                 },
141                                 {
142                                     xtype: 'TextArea',
143                                     xns: Roo.form,
144                                     fieldLabel : 'Description',
145                                     height : 100,
146                                     name : 'description',
147                                     width : 300
148                                 },
149                                 {
150                                     xtype: 'ComboBoxLister',
151                                     xns: Roo.form,
152                                     allowBlank : 'false',
153                                     boxWidth : 300,
154                                     displayField : 'name',
155                                     editable : true,
156                                     emptyText : "Select Milestones",
157                                     fieldLabel : 'Depends On',
158                                     forceSelection : true,
159                                     hiddenName : 'depends_on',
160                                     listWidth : 400,
161                                     loadingText : "Searching...",
162                                     minChars : 2,
163                                     name : 'depends_on_list',
164                                     pageSize : 20,
165                                     qtip : "Select Milestones",
166                                     queryParam : 'query[name]',
167                                     selectOnFocus : true,
168                                     tpl : '<div class="x-grid-cell-text x-btn button"><b>{name}</b> </div>',
169                                     triggerAction : 'all',
170                                     typeAhead : true,
171                                     valueField : 'id',
172                                     width : 150,
173                                     toList : function() {
174                                                         var ret = [];
175                                                         this.items.each(function(a) {
176                                                             ret.push(a.data);
177                                                         });
178                                                         return ret;
179                                                     },
180                                     setList : function(ar) {
181                                                         var _this = this;
182                                                         Roo.each(ar, function(a) {
183                                                             _this.addItem(a);
184                                                         });
185                                                     },
186                                     store : {
187                                         xtype: 'Store',
188                                         xns: Roo.data,
189                                         listeners : {
190                                             beforeload : function (_self, o){
191                                                 o.params = o.params || {};
192                                                 // set more here
193                                                 var pid = _this.form.findField('project_id').getValue() * 1; 
194                                                 if (!pid) {
195                                                     Roo.MessageBox.alert("Error","Select Project");
196                                                     return false;
197                                                 }
198                                                 o.params.project_id = pid;
199                                             }
200                                         },
201                                         remoteSort : true,
202                                         sortInfo : { direction : 'ASC', field: 'name' },
203                                         proxy : {
204                                             xtype: 'HttpProxy',
205                                             xns: Roo.data,
206                                             method : 'GET',
207                                             url : baseURL + '/Roo/Mtrack_milestone.php'
208                                         },
209                                         reader : {
210                                             xtype: 'JsonReader',
211                                             xns: Roo.data,
212                                             id : 'id',
213                                             root : 'data',
214                                             totalProperty : 'total',
215                                             fields : [{"name":"id","type":"int"},{"name":"name","type":"string"}]
216                                         }
217                                     }
218                                 },
219                                 {
220                                     xtype: 'Row',
221                                     xns: Roo.form,
222                                     items : [
223                                         {
224                                             xtype: 'DateField',
225                                             xns: Roo.form,
226                                             fieldLabel : 'Startdate',
227                                             format : 'Y-m-d',
228                                             name : 'startdate',
229                                             width : 75,
230                                             value : (function() { (new Date()).format('Y-m-d')})()
231                                         },
232                                         {
233                                             xtype: 'DateField',
234                                             xns: Roo.form,
235                                             fieldLabel : 'Duedate',
236                                             format : 'Y-m-d',
237                                             name : 'duedate',
238                                             width : 75
239                                         }
240                                     ]
241                                 },
242                                 {
243                                     xtype: 'DateField',
244                                     xns: Roo.form,
245                                     fieldLabel : 'Completed',
246                                     format : 'Y-m-d',
247                                     name : 'completed',
248                                     width : 75
249                                 },
250                                 {
251                                     xtype: 'Hidden',
252                                     xns: Roo.form,
253                                     name : 'id'
254                                 }
255                             ]
256                         }
257                     ]
258                 }
259             ],
260             center : {
261                 xtype: 'LayoutRegion',
262                 xns: Roo
263             },
264             buttons : [
265                 {
266                     xtype: 'Button',
267                     xns: Roo,
268                     listeners : {
269                         click : function (_self, e)
270                         {
271                             _this.dialog.hide();
272                         }
273                     },
274                     text : "Cancel"
275                 },
276                 {
277                     xtype: 'Button',
278                     xns: Roo,
279                     listeners : {
280                         click : function (_self, e)
281                         {
282                             // do some checks?
283                              
284                             
285                             _this.dialog.el.mask("Saving");
286                             _this.form.doAction("submit");
287                         
288                         }
289                     },
290                     text : "Save"
291                 }
292             ]
293         });
294     }
295 };