Pman.Dialog.MTrackMilestone.bjs
[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 : 300,
36             modal : true,
37             resizable : false,
38             title : "Edit / Create Milestone",
39             width : 400,
40             items : [
41                 {
42                     xtype: 'ContentPanel',
43                     xns: Roo,
44                     region : 'center',
45                     items : [
46                         {
47                             xtype: 'Form',
48                             xns: Roo.form,
49                             listeners : {
50                                 actioncomplete : function(_self,action)
51                                 {
52                                     if (action.type == 'setdata') {
53                                         if (_this.data.id) {
54                                            this.load({ method: 'GET', params: { '_id' : _this.data.id }});
55                                        }
56                                        return;
57                                        
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: 'TextField',
86                                     xns: Roo.form,
87                                     fieldLabel : 'Name',
88                                     name : 'name',
89                                     width : 200
90                                 },
91                                 {
92                                     xtype: 'ComboBox',
93                                     xns: Roo.form,
94                                     allowBlank : 'false',
95                                     displayField : 'name',
96                                     editable : false,
97                                     emptyText : "Select Projects",
98                                     fieldLabel : 'Projects',
99                                     forceSelection : true,
100                                     hiddenName : 'project_id',
101                                     listWidth : 400,
102                                     loadingText : "Searching...",
103                                     minChars : 2,
104                                     name : 'project_id_name',
105                                     pageSize : 50,
106                                     qtip : "Select Projects",
107                                     queryParam : '',
108                                     selectOnFocus : true,
109                                     tpl : '<div class="x-grid-cell-text x-btn button"><b>{code}</b> {name}</div>',
110                                     triggerAction : 'all',
111                                     typeAhead : true,
112                                     valueField : 'id',
113                                     width : 200,
114                                     store : {
115                                         xtype: 'Store',
116                                         xns: Roo.data,
117                                         listeners : {
118                                             beforeload : function (_self, o){
119                                                 o.params = o.params || {};
120                                                 // set more here
121                                             }
122                                         },
123                                         remoteSort : true,
124                                         sortInfo : { direction : 'ASC', field: 'code' },
125                                         proxy : {
126                                             xtype: 'HttpProxy',
127                                             xns: Roo.data,
128                                             method : 'GET',
129                                             url : baseURL + '/Roo/Projects.php'
130                                         },
131                                         reader : {
132                                             xtype: 'JsonReader',
133                                             xns: Roo.data,
134                                             id : 'id',
135                                             root : 'data',
136                                             totalProperty : 'total',
137                                             fields : [{"name":"id","type":"int"},{"name":"name","type":"string"}]
138                                         }
139                                     }
140                                 },
141                                 {
142                                     xtype: 'TextArea',
143                                     xns: Roo.form,
144                                     fieldLabel : 'Description',
145                                     name : 'description',
146                                     width : 200,
147                                     height : 100
148                                 },
149                                 {
150                                     xtype: 'DateField',
151                                     xns: Roo.form,
152                                     altFormats : 'Y-m-d H:i:s',
153                                     fieldLabel : 'Startdate',
154                                     format : 'Y-m-d',
155                                     name : 'startdate',
156                                     width : 100
157                                 },
158                                 {
159                                     xtype: 'DateField',
160                                     xns: Roo.form,
161                                     altFormats : 'Y-m-d H:i:s',
162                                     fieldLabel : 'Duedate',
163                                     format : 'Y-m-d',
164                                     name : 'duedate',
165                                     width : 100
166                                 },
167                                 {
168                                     xtype: 'DateField',
169                                     xns: Roo.form,
170                                     altFormats : 'Y-m-d H:i:s',
171                                     fieldLabel : 'Completed',
172                                     format : 'Y-m-d',
173                                     name : 'completed',
174                                     width : 100
175                                 },
176                                 {
177                                     xtype: 'Hidden',
178                                     xns: Roo.form,
179                                     name : 'project_id'
180                                 },
181                                 {
182                                     xtype: 'Hidden',
183                                     xns: Roo.form,
184                                     name : 'id'
185                                 }
186                             ]
187                         }
188                     ]
189                 }
190             ],
191             center : {
192                 xtype: 'LayoutRegion',
193                 xns: Roo
194             },
195             buttons : [
196                 {
197                     xtype: 'Button',
198                     xns: Roo,
199                     listeners : {
200                         click : function (_self, e)
201                         {
202                             _this.dialog.hide();
203                         }
204                     },
205                     text : "Cancel"
206                 },
207                 {
208                     xtype: 'Button',
209                     xns: Roo,
210                     listeners : {
211                         click : function (_self, e)
212                         {
213                             // do some checks?
214                              
215                             
216                          
217                             _this.form.doAction("submit");
218                         
219                         }
220                     },
221                     text : "Save"
222                 }
223             ]
224         });
225     }
226 };