Mercurial > lada > lada-client
comparison app/controller/grid/Status.js @ 964:5b86baa038bc
removed delete button for messung-status
author | Dustin Demuth <dustin@intevation.de> |
---|---|
date | Thu, 12 Nov 2015 12:19:02 +0100 |
parents | 023e622f9551 |
children | a2c2039bb5d9 |
comparison
equal
deleted
inserted
replaced
963:6a6f2c6fe8ee | 964:5b86baa038bc |
---|---|
23 canceledit: this.cancelEdit, | 23 canceledit: this.cancelEdit, |
24 select: this.toggleAllowedPermissions | 24 select: this.toggleAllowedPermissions |
25 }, | 25 }, |
26 'statusgrid button[action=add]': { | 26 'statusgrid button[action=add]': { |
27 click: this.add | 27 click: this.add |
28 }, | |
29 'statusgrid button[action=delete]': { | |
30 click: this.remove | |
31 } | 28 } |
32 }); | 29 }); |
33 }, | 30 }, |
34 | 31 |
35 /** | 32 /** |
85 var lastrow = button.up('statusgrid').store.count() | 82 var lastrow = button.up('statusgrid').store.count() |
86 button.up('statusgrid').store.insert(lastrow, record); | 83 button.up('statusgrid').store.insert(lastrow, record); |
87 button.up('statusgrid').rowEditing.startEdit(lastrow, 1); | 84 button.up('statusgrid').rowEditing.startEdit(lastrow, 1); |
88 }, | 85 }, |
89 | 86 |
90 /** | |
91 * A row can be removed from the grid with the remove | |
92 * function. It asks the user for confirmation | |
93 * If the removal was confirmed, it reloads the parent window on success, | |
94 * on failure, an error message is shown. | |
95 */ | |
96 remove: function(button) { | |
97 var grid = button.up('grid'); | |
98 var selection = grid.getView().getSelectionModel().getSelection()[0]; | |
99 Ext.MessageBox.confirm('Messwert löschen', 'Sind Sie sicher?', function(btn) { | |
100 if (btn === 'yes') { | |
101 selection.destroy({ | |
102 success: function() { | |
103 button.up('window').initData(); | |
104 grid.initData(); | |
105 }, | |
106 failure: function(request, response) { | |
107 var json = response.request.scope.reader.jsonData; | |
108 if (json) { | |
109 if (json.message){ | |
110 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.delete.title') | |
111 +' #'+json.message, | |
112 Lada.getApplication().bundle.getMsg(json.message)); | |
113 } else { | |
114 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.delete.title'), | |
115 Lada.getApplication().bundle.getMsg('err.msg.generic.body')); | |
116 } | |
117 } else { | |
118 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.delete.title'), | |
119 Lada.getApplication().bundle.getMsg('err.msg.response.body')); | |
120 } | |
121 } | |
122 }); | |
123 } | |
124 }); | |
125 grid.down('button[action=delete]').disable(); | |
126 }, | |
127 | 87 |
128 /** | 88 /** |
129 * When a row in a grid is selected, | 89 * When a row in a grid is selected, |
130 * this function checks if the row may be edited, | 90 * this function checks if the row may be edited, |
131 * or if the row can be removed | 91 * or if the row can be removed |
138 var readonlyRec = record.get('readonly'); | 98 var readonlyRec = record.get('readonly'); |
139 var grid = context.view.up('grid'); | 99 var grid = context.view.up('grid'); |
140 | 100 |
141 //retrieve the last record of the store | 101 //retrieve the last record of the store |
142 var lastRecord = context.getStore().last() | 102 var lastRecord = context.getStore().last() |
143 //Check if remove is allowed | |
144 if (lastRecord == record && | |
145 readonlyWin == false && | |
146 readonlyRec == false) { | |
147 grid.down('button[action=delete]').enable(); | |
148 } | |
149 else { | |
150 grid.down('button[action=delete]').disable(); | |
151 } | |
152 | |
153 | 103 |
154 //Check if edit is allowed | 104 //Check if edit is allowed |
155 if (lastRecord == record && | 105 if (lastRecord == record && |
156 readonlyWin == false && | 106 readonlyWin == false && |
157 readonlyRec == false) { | 107 readonlyRec == false) { |