7082e8c19938dd454b335db45de862c5cfe4b41a
[Packages/TYPO3.CMS.git] / typo3 / sysext / workspaces / Resources / Public / JavaScript / configuration.js
1 /***************************************************************
2 * Copyright notice
3 *
4 * (c) 2010 Workspaces Team (http://forge.typo3.org/projects/show/typo3v4-workspaces)
5 * All rights reserved
6 *
7 * This script is part of the TYPO3 project. The TYPO3 project is
8 * free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * The GNU General Public License can be found at
14 * http://www.gnu.org/copyleft/gpl.html.
15 * A copy is found in the textfile GPL.txt and important notices to the license
16 * from the author is found in LICENSE.txt distributed with these scripts.
17 *
18 *
19 * This script is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
26
27 Ext.ns('TYPO3.Workspaces');
28 TYPO3.Workspaces.Configuration = {};
29
30 TYPO3.Workspaces.Configuration.GridFilters = new Ext.ux.grid.GridFilters({
31 encode : false, // json encode the filter query
32 local : true, // defaults to false (remote filtering)
33 filters : [
34 {
35 type : 'numeric',
36 dataIndex : 'uid'
37 },
38 {
39 type : 'string',
40 dataIndex : 'workspace_Title'
41 },
42 {
43 type : 'string',
44 dataIndex : 'label_Live'
45 },
46 {
47 type : 'string',
48 dataIndex : 'label_Workspace'
49 },
50 {
51 type : 'numeric',
52 dataIndex : 'change'
53 }
54 ]
55 });
56
57 TYPO3.Workspaces.Configuration.WsPath = {
58 id: 'path_Workspace',
59 dataIndex : 'path_Workspace',
60 width: 120,
61 hidden: true,
62 hideable: false,
63 sortable: true,
64 header : TYPO3.l10n.localize('column.wsPath'),
65 renderer: function(value, metaData, record, rowIndex, colIndex, store) {
66 var path = record.json.path_Workspace;
67 return path;
68 },
69 filter : {type: 'string'}
70 };
71 TYPO3.Workspaces.Configuration.LivePath = {
72 id: 'path_Live',
73 dataIndex : 'path_Live',
74 width: 120,
75 hidden: true,
76 hideable: true,
77 sortable: true,
78 header : TYPO3.l10n.localize('column.livePath'),
79 renderer: function(value, metaData, record, rowIndex, colIndex, store) {
80 var path = record.json.path_Live;
81 return path;
82 },
83 filter : {type: 'string'}
84 };
85 TYPO3.Workspaces.Configuration.WsTitleWithIcon = {
86 id: 'label_Workspace',
87 dataIndex : 'label_Workspace',
88 width: 120,
89 hideable: true,
90 sortable: true,
91 header : TYPO3.l10n.localize('column.wsTitle'),
92 renderer: function(value, metaData, record, rowIndex, colIndex, store) {
93 var dekoClass = 'item-state-' + record.json.state_Workspace;
94 value = "<span class=\"" + dekoClass + "\">" + value + "</span>";
95 if (record.json.icon_Live === record.json.icon_Workspace) {
96 return value;
97 } else {
98 return "<span class=\"" + record.json.icon_Workspace + "\">&nbsp;</span>&nbsp;" + value;
99 }
100
101 },
102 filter : {type: 'string'}
103 };
104 TYPO3.Workspaces.Configuration.TitleWithIcon = {
105 id: 'label_Live',
106 dataIndex : 'label_Live',
107 width: 120,
108 hideable: false,
109 sortable: true,
110 header : TYPO3.l10n.localize('column.liveTitle'),
111 renderer: function(value, metaData, record, rowIndex, colIndex, store) {
112 if (record.json.state_Workspace == 'unhidden') {
113 var dekoClass = 'item-state-hidden';
114 } else {
115 var dekoClass = '';
116 }
117
118 value = "<span class=\"" + dekoClass + "\">" + value + "</span>";
119 return "<span class=\"" + record.json.icon_Live + "\">&nbsp;</span>&nbsp;" + value;
120 },
121 filter : {type: 'string'}
122 };
123 TYPO3.Workspaces.Configuration.ChangeState = {
124 id: 'state-change',
125 dataIndex : 'change',
126 width: 80,
127 sortable: true,
128 hidden: true,
129 header : TYPO3.l10n.localize('column.difference'),
130 renderer: function(value, metaData) {
131 return value + "%";
132 },
133 filter : {type: 'numeric'}
134 };
135 TYPO3.Workspaces.Configuration.ChangeDate = {
136 id: 'workspace_Tstamp',
137 dataIndex : 'workspace_Tstamp',
138 width: 120,
139 sortable: true,
140 header : TYPO3.l10n.localize('column.changeDate'),
141 renderer: function(value, metaData, record, rowIndex, colIndex, store) {
142 return record.json.workspace_Formated_Tstamp;
143 },
144 hidden: true,
145 filter : {type : 'string'}
146 };
147
148 TYPO3.Workspaces.Configuration.SendToPrevStageButton = {
149 xtype: 'actioncolumn',
150 header:'',
151 width: 18,
152 hidden: (TYPO3.settings.Workspaces.allView === '1'),
153 items:[
154 {
155 iconCls: 't3-icon t3-icon-extensions t3-icon-extensions-workspaces t3-icon-workspaces-sendtoprevstage',
156 tooltip: TYPO3.l10n.localize('tooltip.sendToPrevStage'),
157 handler: function(grid, rowIndex, colIndex) {
158 var record = TYPO3.Workspaces.MainStore.getAt(rowIndex);
159 TYPO3.Workspaces.Actions.sendToPrevStageWindow(record.json.table, record.json.uid);
160 }
161 }
162 ]
163 };
164
165 TYPO3.Workspaces.Configuration.SendToNextStageButton = {
166 xtype: 'actioncolumn',
167 header:'',
168 width: 18,
169 hidden: (TYPO3.settings.Workspaces.allView === '1'),
170 items: [
171 {},{ // empty dummy important!!!!
172 iconCls: 't3-icon t3-icon-extensions t3-icon-extensions-workspaces t3-icon-workspaces-sendtonextstage',
173 tooltip: TYPO3.l10n.localize('tooltip.sendToNextStage'),
174 handler: function(grid, rowIndex, colIndex) {
175 var record = TYPO3.Workspaces.MainStore.getAt(rowIndex);
176 TYPO3.Workspaces.Actions.sendToNextStageWindow(record.json.table, record.json.uid, record.json.t3ver_oid);
177 }
178 }
179 ]
180 };
181
182 TYPO3.Workspaces.Configuration.Stage = {
183 id: 'label_Stage',
184 dataIndex : 'label_Stage',
185 width: 80,
186 sortable: true,
187 header : TYPO3.l10n.localize('column.stage'),
188 hidden: false,
189 filter : {
190 type : 'string'
191 },
192 renderer: function(value, metaData, record, rowIndex, colIndex, store) {
193 var returnCode = '';
194 if (record.json.allowedAction_prevStage && TYPO3.settings.Workspaces.allView !== '1') {
195 var prevButton = new Ext.grid.ActionColumn(TYPO3.Workspaces.Configuration.SendToPrevStageButton);
196 returnCode += prevButton.renderer(1, metaData, record, rowIndex, 1, store);
197 } else {
198 returnCode += "<span class=\"t3-icon t3-icon-empty t3-icon-empty-empty\">&nbsp;</span>";
199 }
200 returnCode += record.json.label_Stage;
201 if (record.json.allowedAction_nextStage && TYPO3.settings.Workspaces.allView !== '1') {
202 var nextButton = new Ext.grid.ActionColumn(TYPO3.Workspaces.Configuration.SendToNextStageButton);
203 returnCode += nextButton.renderer(2, metaData, record, rowIndex, 2, store);
204 } else {
205 returnCode += "<span class=\"t3-icon t3-icon-empty t3-icon-empty-empty\">&nbsp;</span>";
206 }
207 return returnCode;
208 },
209 processEvent : function(name, e, grid, rowIndex, colIndex){
210 var m = e.getTarget().className.match(/x-action-col-(\d+)/);
211 if(m && m[1] == 0) {
212 TYPO3.Workspaces.Configuration.SendToPrevStageButton.items[0].handler(grid, rowIndex, colIndex);
213 return false;
214 } else if (m && m[1] == 1 ) {
215 TYPO3.Workspaces.Configuration.SendToNextStageButton.items[1].handler(grid, rowIndex, colIndex);
216 return false;
217 }
218 return Ext.grid.ActionColumn.superclass.processEvent.apply(this, arguments);
219 }
220 }
221
222 TYPO3.Workspaces.Configuration.RowButtons = {
223 xtype: 'actioncolumn',
224 header: TYPO3.l10n.localize('column.actions'),
225 width: 70,
226 hideable: false,
227 hidden: (TYPO3.settings.Workspaces.allView === '1'),
228 menuDisabled: true,
229 items: [
230 {
231 iconCls:'t3-icon t3-icon-actions t3-icon-actions-version t3-icon-version-workspace-preview'
232 ,tooltip: TYPO3.l10n.localize('tooltip.viewElementAction')
233 ,handler: function(grid, rowIndex, colIndex) {
234 var record = TYPO3.Workspaces.MainStore.getAt(rowIndex);
235 TYPO3.Workspaces.Actions.viewSingleRecord(record.json.table, record.json.uid);
236 },
237 getClass: function(v, meta, rec) {
238 if(!rec.json.allowedAction_view) {
239 return 'icon-hidden';
240 } else {
241 return '';
242 }
243 }
244 },
245 {
246 iconCls:'t3-icon t3-icon-actions t3-icon-actions-document t3-icon-document-open',
247 tooltip: TYPO3.l10n.localize('tooltip.editElementAction'),
248 handler: function(grid, rowIndex, colIndex) {
249 var record = TYPO3.Workspaces.MainStore.getAt(rowIndex);
250 var newUrl = 'alt_doc.php?returnUrl=' + Ext.urlEncode({}, document.location.href).replace("?","%3F").replace("=", "%3D").replace(":","%3A").replace("/", "%2f") + '&id=' + TYPO3.settings.Workspaces.id + '&edit[' + record.json.table + '][' + record.json.uid + ']=edit';
251 window.location.href = newUrl;
252 },
253 getClass: function(v, meta, rec) {
254 if(!rec.json.allowedAction_edit) {
255 return 'icon-hidden';
256 } else {
257 return '';
258 }
259 }
260 },
261 {
262 iconCls:'t3-icon t3-icon-actions t3-icon-actions-system t3-icon-system-pagemodule-open',
263 tooltip: TYPO3.l10n.localize('tooltip.openPage'),
264 handler: function(grid, rowIndex, colIndex) {
265 var record = TYPO3.Workspaces.MainStore.getAt(rowIndex);
266 if (record.json.table == 'pages') {
267 top.loadEditId(record.json.t3ver_oid);
268 } else {
269 top.loadEditId(record.json.livepid);
270 }
271 },
272 getClass: function(v, meta, rec) {
273 if(!rec.json.allowedAction_editVersionedPage || !top.TYPO3.configuration.pageModule) {
274 return 'icon-hidden';
275 } else {
276 return '';
277 }
278 }
279 },
280 {
281 iconCls:'t3-icon t3-icon-actions t3-icon-actions-version t3-icon-version-document-remove',
282 tooltip: TYPO3.l10n.localize('tooltip.discardVersion'),
283 handler: function(grid, rowIndex, colIndex) {
284 var record = TYPO3.Workspaces.MainStore.getAt(rowIndex);
285 var configuration = {
286 title: TYPO3.l10n.localize('window.discard.title'),
287 msg: TYPO3.l10n.localize('window.discard.message'),
288 fn: function(result) {
289 if (result == 'yes') {
290 TYPO3.Workspaces.Actions.deleteSingleRecord(record.json.table, record.json.uid);
291 }
292 }
293 };
294
295 top.TYPO3.Dialog.QuestionDialog(configuration);
296 },
297 getClass: function(v, meta, rec) {
298 if(!rec.json.allowedAction_delete) {
299 return 'icon-hidden';
300 } else {
301 return '';
302 }
303 }
304 }
305 ]
306 };
307
308 TYPO3.Workspaces.Configuration.SwapButton = {
309 xtype: 'actioncolumn',
310 header: '',
311 id: 'wsSwapColumn',
312 width: 18,
313 menuDisabled: true,
314 sortable: false,
315 hidden: (TYPO3.settings.Workspaces.allView === '1'),
316 items: [
317 {
318 iconCls:'t3-icon t3-icon-actions t3-icon-actions-version t3-icon-version-swap-workspace'
319 ,tooltip: TYPO3.l10n.localize('tooltip.swap')
320 ,handler: function(grid, rowIndex, colIndex) {
321 var record = TYPO3.Workspaces.MainStore.getAt(rowIndex);
322 var configuration = {
323 title: TYPO3.l10n.localize('window.swap.title'),
324 msg: TYPO3.l10n.localize('window.swap.message'),
325 fn: function(result) {
326 if (result == 'yes') {
327 TYPO3.Workspaces.Actions.swapSingleRecord(record.json.table, record.json.t3ver_oid, record.json.uid);
328 }
329 }
330 };
331
332 top.TYPO3.Dialog.QuestionDialog(configuration);
333 },
334 getClass: function(v, meta, rec) {
335 if(!rec.json.allowedAction_swap) {
336 return 'icon-hidden';
337 } else {
338 return '';
339 }
340 }
341 }
342 ]
343 };
344