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 : 320,
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                                     store : {
174                                         xtype: 'Store',
175                                         xns: Roo.data,
176                                         listeners : {
177                                             beforeload : function (_self, o){
178                                                 o.params = o.params || {};
179                                                 // set more here
180                                             }
181                                         },
182                                         remoteSort : true,
183                                         sortInfo : { direction : 'ASC', field: 'name' },
184                                         proxy : {
185                                             xtype: 'HttpProxy',
186                                             xns: Roo.data,
187                                             method : 'GET',
188                                             url : baseURL + '/Roo/Mtrack_milestone.php'
189                                         },
190                                         reader : {
191                                             xtype: 'JsonReader',
192                                             xns: Roo.data,
193                                             id : 'id',
194                                             root : 'data',
195                                             totalProperty : 'total',
196                                             fields : [{"name":"id","type":"int"},{"name":"name","type":"string"}]
197                                         }
198                                     }
199                                 },
200                                 {
201                                     xtype: 'Row',
202                                     xns: Roo.form,
203                                     items : [
204                                         {
205                                             xtype: 'DateField',
206                                             xns: Roo.form,
207                                             fieldLabel : 'Startdate',
208                                             format : 'Y-m-d',
209                                             name : 'startdate',
210                                             width : 75,
211                                             value : (function() { (new Date()).format('Y-m-d')})()
212                                         },
213                                         {
214                                             xtype: 'DateField',
215                                             xns: Roo.form,
216                                             fieldLabel : 'Duedate',
217                                             format : 'Y-m-d',
218                                             name : 'duedate',
219                                             width : 75
220                                         }
221                                     ]
222                                 },
223                                 {
224                                     xtype: 'DateField',
225                                     xns: Roo.form,
226                                     fieldLabel : 'Completed',
227                                     format : 'Y-m-d',
228                                     name : 'completed',
229                                     width : 75
230                                 },
231                                 {
232                                     xtype: 'Hidden',
233                                     xns: Roo.form,
234                                     name : 'id'
235                                 }
236                             ]
237                         }
238                     ]
239                 }
240             ],
241             center : {
242                 xtype: 'LayoutRegion',
243                 xns: Roo
244             },
245             buttons : [
246                 {
247                     xtype: 'Button',
248                     xns: Roo,
249                     listeners : {
250                         click : function (_self, e)
251                         {
252                             _this.dialog.hide();
253                         }
254                     },
255                     text : "Cancel"
256                 },
257                 {
258                     xtype: 'Button',
259                     xns: Roo,
260                     listeners : {
261                         click : function (_self, e)
262                         {
263                             // do some checks?
264                              
265                             
266                             _this.dialog.el.mask("Saving");
267                             _this.form.doAction("submit");
268                         
269                         }
270                     },
271                     text : "Save"
272                 }
273             ]
274         });
275     }
276 };