961d4972e53deec55e38a6e054b55651ff6912ca
[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 : 'numeric',
44 dataIndex : 'languageValue'
45 },
46 {
47 type : 'string',
48 dataIndex : 'label_Live'
49 },
50 {
51 type : 'string',
52 dataIndex : 'label_Workspace'
53 },
54 {
55 type : 'numeric',
56 dataIndex : 'change'
57 }
58 ]
59 });
60
61 TYPO3.Workspaces.Configuration.Integrity = new Ext.grid.Column({
62 width: 24,
63 hideable: true,
64 sortable: false,
65 header: '<span class="' + TYPO3.settings.Workspaces.icons.integrity + '">&nbsp;</span>',
66 renderer: function(value, meta, record) {
67 if (record.json.integrity.status !== 'success') {
68 var cls = TYPO3.settings.Workspaces.icons[record.json.integrity.status] + ' t3-visible';
69 var title = TYPO3.l10n.localize('status.' + record.json.integrity.status);
70 var message = record.json.integrity.messages;
71
72 return '<span class="' + cls + '" ext:qtitle="' + title + '" ext:qtip="' + message + '">&nbsp;</span>';
73 }
74 }
75 });
76 TYPO3.Workspaces.Configuration.WsPath = {
77 id: 'path_Workspace',
78 dataIndex : 'path_Workspace',
79 width: 120,
80 hidden: true,
81 hideable: false,
82 sortable: true,
83 header : TYPO3.l10n.localize('column.wsPath'),
84 renderer: function(value, metaData, record, rowIndex, colIndex, store) {
85 var path = record.json.path_Workspace;
86 return path;
87 },
88 filter : {type: 'string'}
89 };
90
91 TYPO3.Workspaces.Configuration.LivePath = {
92 id: 'path_Live',
93 dataIndex : 'path_Live',
94 width: 120,
95 hidden: true,
96 hideable: true,
97 sortable: true,
98 header : TYPO3.l10n.localize('column.livePath'),
99 renderer: function(value, metaData, record, rowIndex, colIndex, store) {
100 var path = record.json.path_Live;
101 return path;
102 },
103 filter : {type: 'string'}
104 };
105
106 TYPO3.Workspaces.Configuration.WsTitleWithIcon = {
107 id: 'label_Workspace',
108 dataIndex : 'label_Workspace',
109 width: 120,
110 hideable: true,
111 sortable: true,
112 header : TYPO3.l10n.localize('column.wsTitle'),
113 renderer: function(value, metaData, record, rowIndex, colIndex, store) {
114 var dekoClass = 'item-state-' + record.json.state_Workspace;
115 value = "<span class=\"" + dekoClass + "\">" + value + "</span>";
116 if (record.json.icon_Live === record.json.icon_Workspace) {
117 return value;
118 } else {
119 return "<span class=\"" + record.json.icon_Workspace + "\">&nbsp;</span>&nbsp;" + value;
120 }
121
122 },
123 filter : {type: 'string'}
124 };
125
126 TYPO3.Workspaces.Configuration.Language = {
127 id: 'language',
128 dataIndex: 'languageValue',
129 width: 30,
130 hideable: true,
131 sortable: true,
132 header: '<span class="' + TYPO3.settings.Workspaces.icons.language + '">&nbsp;</span>',
133 filter: { type: 'string '},
134 renderer: function(value, metaData, record) {
135 return '<span class="' + record.json.language.cls + '" title="' + record.json.language.title + '">&nbsp;</span>';
136 }
137 };
138
139 TYPO3.Workspaces.Configuration.TitleWithIcon = {
140 id: 'label_Live',
141 dataIndex : 'label_Live',
142 width: 120,
143 hideable: false,
144 sortable: true,
145 header : TYPO3.l10n.localize('column.liveTitle'),
146 renderer: function(value, metaData, record, rowIndex, colIndex, store) {
147 if (record.json.state_Workspace == 'unhidden') {
148 var dekoClass = 'item-state-hidden';
149 } else {
150 var dekoClass = '';
151 }
152
153 value = "<span class=\"" + dekoClass + "\">" + value + "</span>";
154 return "<span class=\"" + record.json.icon_Live + "\">&nbsp;</span>&nbsp;" + value;
155 },
156 filter : {type: 'string'}
157 };
158
159 TYPO3.Workspaces.Configuration.ChangeDate = {
160 id: 'workspace_Tstamp',
161 dataIndex : 'workspace_Tstamp',
162 width: 120,
163 sortable: true,
164 header : TYPO3.l10n.localize('column.changeDate'),
165 renderer: function(value, metaData, record, rowIndex, colIndex, store) {
166 return record.json.workspace_Formated_Tstamp;
167 },
168 hidden: true,
169 filter : {type : 'string'}
170 };
171
172 TYPO3.Workspaces.Configuration.SendToPrevStageButton = {
173 xtype: 'actioncolumn',
174 header:'',
175 width: 18,
176 hidden: (TYPO3.settings.Workspaces.allView === '1'),
177 items:[
178 {
179 iconCls: 't3-icon t3-icon-extensions t3-icon-extensions-workspaces t3-icon-workspaces-sendtoprevstage',
180 tooltip: TYPO3.l10n.localize('tooltip.sendToPrevStage'),
181 handler: function(grid, rowIndex, colIndex) {
182 var record = TYPO3.Workspaces.MainStore.getAt(rowIndex);
183 TYPO3.Workspaces.Actions.sendToPrevStageWindow(record.json.table, record.json.uid);
184 }
185 }
186 ]
187 };
188
189 TYPO3.Workspaces.Configuration.SendToNextStageButton = {
190 xtype: 'actioncolumn',
191 header:'',
192 width: 18,
193 hidden: (TYPO3.settings.Workspaces.allView === '1'),
194 items: [
195 {},{ // empty dummy important!!!!
196 iconCls: 't3-icon t3-icon-extensions t3-icon-extensions-workspaces t3-icon-workspaces-sendtonextstage',
197 tooltip: TYPO3.l10n.localize('tooltip.sendToNextStage'),
198 handler: function(grid, rowIndex, colIndex) {
199 var record = TYPO3.Workspaces.MainStore.getAt(rowIndex);
200 TYPO3.Workspaces.Actions.sendToNextStageWindow(record.json.table, record.json.uid, record.json.t3ver_oid);
201 }
202 }
203 ]
204 };
205
206 TYPO3.Workspaces.Configuration.Stage = {
207 id: 'label_Stage',
208 dataIndex : 'label_Stage',
209 width: 80,
210 sortable: true,
211 header : TYPO3.l10n.localize('column.stage'),
212 hidden: false,
213 filter : {
214 type : 'string'
215 },
216 renderer: function(value, metaData, record, rowIndex, colIndex, store) {
217 var returnCode = '';
218 if (record.json.allowedAction_prevStage && TYPO3.settings.Workspaces.allView !== '1') {
219 var tempTooltip = TYPO3.Workspaces.Configuration.SendToPrevStageButton.items[0].tooltip;
220 TYPO3.Workspaces.Configuration.SendToPrevStageButton.items[0].tooltip += ' &quot;'+ record.json.label_prevStage + '&quot;';
221 var prevButton = new Ext.grid.ActionColumn(TYPO3.Workspaces.Configuration.SendToPrevStageButton);
222 returnCode += prevButton.renderer(1, metaData, record, rowIndex, 1, store);
223 TYPO3.Workspaces.Configuration.SendToPrevStageButton.items[0].tooltip = tempTooltip;
224 } else {
225 returnCode += "<span class=\"t3-icon t3-icon-empty t3-icon-empty-empty\">&nbsp;</span>";
226 }
227 returnCode += record.json.label_Stage;
228 if (record.json.allowedAction_nextStage && TYPO3.settings.Workspaces.allView !== '1') {
229 var tempTooltip = TYPO3.Workspaces.Configuration.SendToNextStageButton.items[1].tooltip;
230 TYPO3.Workspaces.Configuration.SendToNextStageButton.items[1].tooltip += ' &quot;'+ record.json.label_nextStage + '&quot;';
231 var nextButton = new Ext.grid.ActionColumn(TYPO3.Workspaces.Configuration.SendToNextStageButton);
232 returnCode += nextButton.renderer(2, metaData, record, rowIndex, 2, store);
233 TYPO3.Workspaces.Configuration.SendToNextStageButton.items[1].tooltip = tempTooltip;
234 } else {
235 returnCode += "<span class=\"t3-icon t3-icon-empty t3-icon-empty-empty\">&nbsp;</span>";
236 }
237 return returnCode;
238 },
239 processEvent : function(name, e, grid, rowIndex, colIndex){
240 var m = e.getTarget().className.match(/x-action-col-(\d+)/);
241 if(m && m[1] == 0) {
242 TYPO3.Workspaces.Configuration.SendToPrevStageButton.items[0].handler(grid, rowIndex, colIndex);
243 return false;
244 } else if (m && m[1] == 1 ) {
245 TYPO3.Workspaces.Configuration.SendToNextStageButton.items[1].handler(grid, rowIndex, colIndex);
246 return false;
247 }
248 return Ext.grid.ActionColumn.superclass.processEvent.apply(this, arguments);
249 }
250 }
251
252 TYPO3.Workspaces.Configuration.RowButtons = {
253 xtype: 'actioncolumn',
254 header: TYPO3.l10n.localize('column.actions'),
255 width: 70,
256 hideable: false,
257 hidden: (TYPO3.settings.Workspaces.allView === '1'),
258 menuDisabled: true,
259 items: [
260 {
261 iconCls:'t3-icon t3-icon-actions t3-icon-actions-version t3-icon-version-workspace-preview'
262 ,tooltip: TYPO3.l10n.localize('tooltip.viewElementAction')
263 ,handler: function(grid, rowIndex, colIndex) {
264 var record = TYPO3.Workspaces.MainStore.getAt(rowIndex);
265 TYPO3.Workspaces.Actions.viewSingleRecord(record.json.table, record.json.uid);
266 },
267 getClass: function(v, meta, rec) {
268 if(!rec.json.allowedAction_view) {
269 return 'icon-hidden';
270 } else {
271 return '';
272 }
273 }
274 },
275 {
276 iconCls:'t3-icon t3-icon-actions t3-icon-actions-document t3-icon-document-open',
277 tooltip: TYPO3.l10n.localize('tooltip.editElementAction'),
278 handler: function(grid, rowIndex, colIndex) {
279 var record = TYPO3.Workspaces.MainStore.getAt(rowIndex);
280 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';
281 window.location.href = newUrl;
282 },
283 getClass: function(v, meta, rec) {
284 if(!rec.json.allowedAction_edit) {
285 return 'icon-hidden';
286 } else {
287 return '';
288 }
289 }
290 },
291 {
292 iconCls:'t3-icon t3-icon-actions t3-icon-actions-system t3-icon-system-pagemodule-open',
293 tooltip: TYPO3.l10n.localize('tooltip.openPage'),
294 handler: function(grid, rowIndex, colIndex) {
295 var record = TYPO3.Workspaces.MainStore.getAt(rowIndex);
296 if (record.json.table == 'pages') {
297 top.loadEditId(record.json.t3ver_oid);
298 } else {
299 top.loadEditId(record.json.livepid);
300 }
301 },
302 getClass: function(v, meta, rec) {
303 if(!rec.json.allowedAction_editVersionedPage || !top.TYPO3.configuration.pageModule) {
304 return 'icon-hidden';
305 } else {
306 return '';
307 }
308 }
309 },
310 {
311 iconCls:'t3-icon t3-icon-actions t3-icon-actions-version t3-icon-version-document-remove',
312 tooltip: TYPO3.l10n.localize('tooltip.discardVersion'),
313 handler: function(grid, rowIndex, colIndex) {
314 var record = TYPO3.Workspaces.MainStore.getAt(rowIndex);
315 var configuration = {
316 title: TYPO3.l10n.localize('window.discard.title'),
317 msg: TYPO3.l10n.localize('window.discard.message'),
318 fn: function(result) {
319 if (result == 'yes') {
320 TYPO3.Workspaces.Actions.deleteSingleRecord(record.json.table, record.json.uid);
321 }
322 }
323 };
324
325 top.TYPO3.Dialog.QuestionDialog(configuration);
326 },
327 getClass: function(v, meta, rec) {
328 if(!rec.json.allowedAction_delete) {
329 return 'icon-hidden';
330 } else {
331 return '';
332 }
333 }
334 }
335 ]
336 };
337
338 TYPO3.Workspaces.Configuration.SwapButton = {
339 xtype: 'actioncolumn',
340 header: '',
341 id: 'wsSwapColumn',
342 width: 18,
343 menuDisabled: true,
344 sortable: false,
345 hidden: (TYPO3.settings.Workspaces.allView === '1'),
346 items: [
347 {
348 iconCls:'t3-icon t3-icon-actions t3-icon-actions-version t3-icon-version-swap-workspace'
349 ,tooltip: TYPO3.l10n.localize('tooltip.swap')
350 ,handler: function(grid, rowIndex, colIndex) {
351 var record = TYPO3.Workspaces.MainStore.getAt(rowIndex);
352 var parameters = {
353 type: 'selection',
354 selection: [{
355 table: record.json.table,
356 versionId: record.json.uid,
357 liveId: record.json.t3ver_oid
358 }]
359 };
360
361 var configuration = {
362 title: TYPO3.l10n.localize('window.swap.title'),
363 msg: TYPO3.l10n.localize('window.swap.message'),
364 fn: function(result) {
365 if (result == 'yes') {
366 TYPO3.Workspaces.Actions.swapSingleRecord(record.json.table, record.json.t3ver_oid, record.json.uid);
367 }
368 }
369 };
370
371 TYPO3.Workspaces.Actions.checkIntegrity(parameters, function() {
372 top.TYPO3.Dialog.QuestionDialog(configuration);
373 });
374 },
375 getClass: function(v, meta, rec) {
376 if(!rec.json.allowedAction_swap) {
377 return 'icon-hidden';
378 } else {
379 return '';
380 }
381 }
382 }
383 ]
384 };