Mercurial > lada > lada-client
comparison app/controller/grid/MessprogrammeList.js @ 1007:23bfcbdb4527
merged.
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Wed, 20 Jan 2016 17:33:33 +0100 |
parents | 56470a075e6e |
children |
comparison
equal
deleted
inserted
replaced
1002:54179b6043b6 | 1007:23bfcbdb4527 |
---|---|
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz | |
2 * Software engineering by Intevation GmbH | |
3 * | |
4 * This file is Free Software under the GNU GPL (v>=3) | |
5 * and comes with ABSOLUTELY NO WARRANTY! Check out | |
6 * the documentation coming with IMIS-Labordaten-Application for details. | |
7 */ | |
8 | |
9 /** | |
10 * Controller for filter result grid. | |
11 */ | |
12 Ext.define('Lada.controller.grid.MessprogrammeList', { | |
13 extend: 'Ext.app.Controller', | |
14 requires: [ | |
15 'Lada.view.window.Messprogramm', | |
16 'Lada.view.window.GenProbenFromMessprogramm' | |
17 ], | |
18 | |
19 /** | |
20 * Initialize the Controller with listeners | |
21 */ | |
22 init: function() { | |
23 this.control({ | |
24 'messprogrammelistgrid': { | |
25 itemdblclick: this.editItem, | |
26 select: this.activateButtons, | |
27 deselect: this.deactivateButtons | |
28 }, | |
29 'messprogrammelistgrid toolbar button[action=addMessprogramm]': { | |
30 click: this.addMessprogrammItem | |
31 }, | |
32 'messprogrammelistgrid toolbar button[action=genProbenFromMessprogramm]': { | |
33 click: this.genProbenFromMessprogramm | |
34 } | |
35 }); | |
36 this.callParent(arguments); | |
37 }, | |
38 | |
39 /** | |
40 * This function is called after a Row in the | |
41 * {@link Lada.view.grid.MessprogrammeList} | |
42 * was double-clicked. | |
43 * The function opens a {@link Lada.view.window.ProbeEdit} | |
44 * or a {@link Lada.view.window.Messprogramm}. | |
45 * To determine which window has to be opened, the function | |
46 * analyse the records modelname. | |
47 */ | |
48 editItem: function(grid, record) { | |
49 var winname = 'Lada.view.window.Messprogramm'; | |
50 var win = Ext.create(winname, { | |
51 record: record, | |
52 style: 'z-index: -1;' //Fixes an Issue where windows could not be created in IE8 | |
53 }); | |
54 win.show(); | |
55 win.initData(); | |
56 }, | |
57 | |
58 /** | |
59 * This function opens a new window to create a Probe | |
60 * {@link Lada.view.window.Messprogramm} | |
61 */ | |
62 addMessprogrammItem: function() { | |
63 var win = Ext.create('Lada.view.window.Messprogramm'); | |
64 win.show(); | |
65 win.initData(); | |
66 }, | |
67 | |
68 /** | |
69 * This button creates a window to generate Proben | |
70 * from a selected messprogramm. | |
71 */ | |
72 genProbenFromMessprogramm: function(button) { | |
73 var grid = button.up('grid'); | |
74 var selection = grid.getView().getSelectionModel().getSelection(); | |
75 var i18n = Lada.getApplication().bundle; | |
76 var proben = []; | |
77 for (var i = 0; i < selection.length; i++) { | |
78 proben.push(selection[i].get('id')); | |
79 } | |
80 var me = this; | |
81 | |
82 var winname = 'Lada.view.window.GenProbenFromMessprogramm'; | |
83 for (p in proben) { | |
84 grid.setLoading(true); | |
85 Ext.ClassManager.get('Lada.model.Messprogramm').load(proben[p], { | |
86 failure: function(record, action) { | |
87 me.setLoading(false); | |
88 // TODO | |
89 console.log('An unhandled Failure occured. See following Response and Record'); | |
90 console.log(action); | |
91 console.log(record); | |
92 }, | |
93 success: function(record, response) { | |
94 grid.setLoading(false); | |
95 | |
96 var win = Ext.create(winname, { | |
97 record: record, | |
98 parentWindow: null | |
99 }); | |
100 win.show(); | |
101 win.initData(); | |
102 }, | |
103 scope: this | |
104 }); | |
105 } | |
106 }, | |
107 | |
108 /** | |
109 * Toggles the buttons in the toolbar | |
110 **/ | |
111 activateButtons: function(rowModel, record) { | |
112 var grid = rowModel.view.up('grid'); | |
113 this.buttonToggle(true, grid); | |
114 }, | |
115 | |
116 /** | |
117 * Toggles the buttons in the toolbar | |
118 **/ | |
119 deactivateButtons: function(rowModel, record) { | |
120 var grid = rowModel.view.up('grid'); | |
121 // Only disable buttons when nothing is selected | |
122 if (rowModel.selected.items == 0) { | |
123 this.buttonToggle(false, grid); | |
124 } | |
125 }, | |
126 | |
127 /** | |
128 * Enables/Disables a set of buttons | |
129 **/ | |
130 buttonToggle: function(enabled, grid) { | |
131 if (!enabled) { | |
132 grid.down('button[action=genProbenFromMessprogramm]').disable(); | |
133 } | |
134 else { | |
135 grid.down('button[action=genProbenFromMessprogramm]').enable(); | |
136 } | |
137 }, | |
138 | |
139 reload: function(btn) { | |
140 if (btn === 'yes') { | |
141 location.reload(); | |
142 } | |
143 } | |
144 }); | |
145 |