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                                     boxWidth : 300,
153                                     allowBlank : 'false',
154                                     displayField : 'name',
155                                     editable : 'false',
156                                     emptyText : "Select Projects",
157                                     fieldLabel : 'Projects',
158                                     forceSelection : true,
159                                     hiddenName : '',
160                                     listWidth : 400,
161                                     loadingText : "Searching...",
162                                     minChars : 2,
163                                     name : '',
164                                     pageSize : 20,
165                                     qtip : "Select Projects",
166                                     queryParam : '',
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                                         remoteSort : true,
177                                         sortInfo : { direction : 'ASC', field: 'id' },
178                                         listeners : {
179                                             beforeload : function (_self, o){
180                                                 o.params = o.params || {};
181                                                 // set more here
182                                             }
183                                         },
184                                         proxy : {
185                                             xtype: 'HttpProxy',
186                                             xns: Roo.data,
187                                             method : 'GET',
188                                             url : baseURL + '/Roo/Projects.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: 'DateField',
202                                     xns: Roo.form,
203                                     fieldLabel : 'Startdate',
204                                     format : 'Y-m-d',
205                                     name : 'startdate',
206                                     width : 75,
207                                     value : (function() { (new Date()).format('Y-m-d')})()
208                                 },
209                                 {
210                                     xtype: 'DateField',
211                                     xns: Roo.form,
212                                     fieldLabel : 'Duedate',
213                                     format : 'Y-m-d',
214                                     name : 'duedate',
215                                     width : 75
216                                 },
217                                 {
218                                     xtype: 'DateField',
219                                     xns: Roo.form,
220                                     fieldLabel : 'Completed',
221                                     format : 'Y-m-d',
222                                     name : 'completed',
223                                     width : 75
224                                 },
225                                 {
226                                     xtype: 'Hidden',
227                                     xns: Roo.form,
228                                     name : 'id'
229                                 }
230                             ]
231                         }
232                     ]
233                 }
234             ],
235             center : {
236                 xtype: 'LayoutRegion',
237                 xns: Roo
238             },
239             buttons : [
240                 {
241                     xtype: 'Button',
242                     xns: Roo,
243                     listeners : {
244                         click : function (_self, e)
245                         {
246                             _this.dialog.hide();
247                         }
248                     },
249                     text : "Cancel"
250                 },
251                 {
252                     xtype: 'Button',
253                     xns: Roo,
254                     listeners : {
255                         click : function (_self, e)
256                         {
257                             // do some checks?
258                              
259                             
260                             _this.dialog.el.mask("Saving");
261                             _this.form.doAction("submit");
262                         
263                         }
264                     },
265                     text : "Save"
266                 }
267             ]
268         });
269     }
270 };