|
1
|
|
|
//{namespace name=backend/plugins/dn/customjscss} |
|
2
|
|
|
// |
|
3
|
|
|
Ext.define('Shopware.apps.DneCustomJsCss.controller.Main', { |
|
|
|
|
|
|
4
|
|
|
/** |
|
5
|
|
|
* Extend from the standard ExtJS 4 controller |
|
6
|
|
|
* @string |
|
7
|
|
|
*/ |
|
8
|
|
|
extend: 'Ext.app.Controller', |
|
9
|
|
|
mainWindow: null, |
|
10
|
|
|
/** |
|
11
|
|
|
* Creates the necessary event listener for this |
|
12
|
|
|
* specific controller and opens a new Ext.window.Window |
|
13
|
|
|
* to display the subapplication |
|
14
|
|
|
* |
|
15
|
|
|
* @return void |
|
16
|
|
|
*/ |
|
17
|
|
|
init: function() { |
|
18
|
|
|
var me = this; |
|
19
|
|
|
|
|
20
|
|
|
me.getStore('JsCss').load({ |
|
21
|
|
|
scope: this, |
|
22
|
|
|
callback: function() { |
|
23
|
|
|
me.mainWindow = me.getView('main.Window').create({ |
|
24
|
|
|
mainStore: me.getStore('JsCss'), |
|
25
|
|
|
record: Ext.create('Shopware.apps.DneCustomJsCss.model.JsCss') |
|
|
|
|
|
|
26
|
|
|
}); |
|
27
|
|
|
} |
|
28
|
|
|
}); |
|
29
|
|
|
|
|
30
|
|
|
me.callParent(arguments); |
|
31
|
|
|
me.control({ |
|
32
|
|
|
'custom-js-css-detail button[action=save]': { |
|
33
|
|
|
'click' : function(btn) { |
|
34
|
|
|
this.onSave(btn); |
|
35
|
|
|
} |
|
36
|
|
|
}, |
|
37
|
|
|
'custom-js-css-detail button[action=saveCompile]': { |
|
38
|
|
|
'click' : function(btn) { |
|
39
|
|
|
this.onSaveCompile(btn); |
|
40
|
|
|
} |
|
41
|
|
|
}, |
|
42
|
|
|
'custom-js-css-detail button[action=reset]': { |
|
43
|
|
|
'click' : function(btn) { |
|
44
|
|
|
this.onReset(btn); |
|
45
|
|
|
} |
|
46
|
|
|
}, |
|
47
|
|
|
'custom-js-css-list button[action=addJs]': { |
|
48
|
|
|
'click' : function (btn) { |
|
49
|
|
|
this.addJs(btn); |
|
50
|
|
|
} |
|
51
|
|
|
}, |
|
52
|
|
|
'custom-js-css-list':{ |
|
53
|
|
|
openJsDetail: me.openJsDetail, |
|
54
|
|
|
deleteJs: me.deleteJs |
|
55
|
|
|
} |
|
56
|
|
|
}); |
|
57
|
|
|
}, |
|
58
|
|
|
|
|
59
|
|
|
onSaveCompile: function(btn) { |
|
60
|
|
|
var me = this; |
|
61
|
|
|
|
|
62
|
|
|
me.onSave(btn); |
|
63
|
|
|
|
|
64
|
|
|
Shopware.app.Application.fireEvent('shopware-theme-cache-warm-up-request'); |
|
|
|
|
|
|
65
|
|
|
}, |
|
66
|
|
|
|
|
67
|
|
|
onSave: function(btn) { |
|
68
|
|
|
var win = btn.up('window'), |
|
69
|
|
|
form = win.down('form'), |
|
70
|
|
|
formBasis = form.getForm(), |
|
71
|
|
|
me = this, |
|
72
|
|
|
store = me.getStore('JsCss'), |
|
73
|
|
|
record = form.getRecord(); |
|
74
|
|
|
|
|
75
|
|
|
if (!(record instanceof Ext.data.Model)) { |
|
|
|
|
|
|
76
|
|
|
record = Ext.create('Shopware.apps.DneCustomJsCss.model.JsCss'); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
formBasis.updateRecord(record); |
|
80
|
|
|
|
|
81
|
|
|
if (formBasis.isValid()) { |
|
82
|
|
|
record.save({ |
|
83
|
|
|
params: { |
|
84
|
|
|
id: record.get("id") |
|
85
|
|
|
}, |
|
86
|
|
|
success: function(rec, op) { |
|
87
|
|
|
var newId = op.request.scope.reader.jsonData["id"]; |
|
88
|
|
|
if(newId){ |
|
89
|
|
|
record.set("id", newId); |
|
90
|
|
|
} |
|
91
|
|
|
store.load(); |
|
92
|
|
|
Shopware.Msg.createGrowlMessage('','{s name="jsSaveSuccess"}JavaScript/CSS wurde erfolgreich gespeichert{/s}', ''); |
|
|
|
|
|
|
93
|
|
|
}, |
|
94
|
|
|
failure: function(rec, op) { |
|
95
|
|
|
store.load(); |
|
96
|
|
|
Shopware.Msg.createGrowlMessage('','{s name="jsSaveError"}Fehler beim Speichern des JavaScript/CSS: {/s}'+op.request.scope.reader.jsonData["message"], ''); |
|
|
|
|
|
|
97
|
|
|
|
|
98
|
|
|
} |
|
99
|
|
|
}); |
|
100
|
|
|
} |
|
101
|
|
|
}, |
|
102
|
|
|
|
|
103
|
|
|
onReset: function(btn) { |
|
104
|
|
|
var win = btn.up('window'), |
|
105
|
|
|
form = win.down('form'), |
|
106
|
|
|
record = form.getRecord(); |
|
107
|
|
|
|
|
108
|
|
|
if (!(record instanceof Ext.data.Model)){ |
|
|
|
|
|
|
109
|
|
|
record = Ext.create('Shopware.apps.DneCustomJsCss.model.JsCss'); |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
form.loadRecord(record); |
|
113
|
|
|
}, |
|
114
|
|
|
|
|
115
|
|
|
openJsDetail: function(view, rowIndex) { |
|
116
|
|
|
var me = this, |
|
117
|
|
|
record = me.getStore('JsCss').getAt(rowIndex); |
|
118
|
|
|
|
|
119
|
|
|
me.record = record; |
|
120
|
|
|
|
|
121
|
|
|
me.detailStore = new Ext.data.Store({ |
|
|
|
|
|
|
122
|
|
|
extend:'Ext.data.Store', |
|
123
|
|
|
remoteFilter : true, |
|
124
|
|
|
model:'Shopware.apps.DneCustomJsCss.model.JsCss' |
|
125
|
|
|
}); |
|
126
|
|
|
|
|
127
|
|
|
me.detailStore.load({ |
|
128
|
|
|
params: { |
|
129
|
|
|
id: record.get("id") |
|
130
|
|
|
}, |
|
131
|
|
|
callback: function(records, operation) { |
|
132
|
|
|
if (operation.success !== true || !records.length) { |
|
133
|
|
|
return; |
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
|
|
me.detailRecord = records[0]; |
|
137
|
|
|
|
|
138
|
|
|
var win = view.up('window'), |
|
139
|
|
|
form = win.down('form'); |
|
140
|
|
|
|
|
141
|
|
|
form.loadRecord(me.detailRecord); |
|
142
|
|
|
} |
|
143
|
|
|
}); |
|
144
|
|
|
|
|
145
|
|
|
}, |
|
146
|
|
|
|
|
147
|
|
|
addJs: function (btn) { |
|
148
|
|
|
var me = this, |
|
149
|
|
|
win = btn.up('window'), |
|
150
|
|
|
form = win.down('form'); |
|
151
|
|
|
|
|
152
|
|
|
me.detailRecord = Ext.create('Shopware.apps.DneCustomJsCss.model.JsCss'); |
|
|
|
|
|
|
153
|
|
|
|
|
154
|
|
|
form.loadRecord(me.detailRecord); |
|
155
|
|
|
}, |
|
156
|
|
|
|
|
157
|
|
|
deleteJs: function(view, rowIndex) { |
|
158
|
|
|
var me = this, |
|
159
|
|
|
store = me.getStore('JsCss'); |
|
160
|
|
|
|
|
161
|
|
|
me.record = store.getAt(rowIndex); |
|
162
|
|
|
|
|
163
|
|
|
if (me.record instanceof Ext.data.Model && me.record.get('id') > 0) { |
|
|
|
|
|
|
164
|
|
|
Ext.MessageBox.confirm('{s name="delete"}Löschen{/s}', '{s name="jsDeleteAlert"}Sind Sie sicher, dass Sie das JavaScript/CSS löschen wollen?{/s}' , function (response) { |
|
165
|
|
|
if (response !== 'yes') { |
|
166
|
|
|
return; |
|
167
|
|
|
} |
|
168
|
|
|
me.record.destroy({ |
|
169
|
|
|
callback: function() { |
|
170
|
|
|
Shopware.Msg.createGrowlMessage('','{s name="jsDeleted"}JavaScript/CSS wurde erfolgreich gelöscht{/s}', 'CustomJsCss'); |
|
|
|
|
|
|
171
|
|
|
store.load(); |
|
172
|
|
|
var win = view.up('window'), |
|
173
|
|
|
form = win.down('form'); |
|
174
|
|
|
me.detailRecord = Ext.create('Shopware.apps.DneCustomJsCss.model.JsCss'); |
|
|
|
|
|
|
175
|
|
|
form.loadRecord(me.detailRecord); |
|
176
|
|
|
} |
|
177
|
|
|
}); |
|
178
|
|
|
}); |
|
179
|
|
|
} |
|
180
|
|
|
} |
|
181
|
|
|
}); |
|
182
|
|
|
|
|
183
|
|
|
|
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.