000b1d3be5260f7ff098fa106a94ac92ed60d3a3
[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 var dekoClass = '';
148 if (record.json.state_Workspace == 'unhidden') {
149 dekoClass = 'item-state-hidden';
150 }
151
152 value = "<span class=\"" + dekoClass + "\">" + value + "</span>";
153 return "<span class=\"" + record.json.icon_Live + "\">&nbsp;</span>&nbsp;" + value;
154 },
155 filter : {type: 'string'}
156 };
157
158 TYPO3.Workspaces.Configuration.ChangeDate = {
159 id: 'workspace_Tstamp',
160 dataIndex : 'workspace_Tstamp',
161 width: 120,
162 sortable: true,
163 header : TYPO3.l10n.localize('column.changeDate'),
164 renderer: function(value, metaData, record, rowIndex, colIndex, store) {
165 return record.json.workspace_Formated_Tstamp;
166 },
167 hidden: true,
168 filter : {type : 'string'}
169 };
170
171 TYPO3.Workspaces.Configuration.SendToPrevStageButton = {
172 xtype: 'actioncolumn',
173 header:'',
174 width: 18,
175 hidden: (TYPO3.settings.Workspaces.allView === '1'),
176 items:[
177 {
178 iconCls: 't3-icon t3-icon-extensions t3-icon-extensions-workspaces t3-icon-workspaces-sendtoprevstage',
179 tooltip: TYPO3.l10n.localize('tooltip.sendToPrevStage'),
180 handler: function(grid, rowIndex, colIndex) {
181 var record = TYPO3.Workspaces.MainStore.getAt(rowIndex);
182 TYPO3.Workspaces.Actions.sendToPrevStageWindow(record.json.table, record.json.uid);
183 }
184 }
185 ]
186 };
187
188 TYPO3.Workspaces.Configuration.SendToNextStageButton = {
189 xtype: 'actioncolumn',
190 header:'',
191 width: 18,
192 hidden: (TYPO3.settings.Workspaces.allView === '1'),
193 items: [
194 {},{ // empty dummy important!!!!
195 iconCls: 't3-icon t3-icon-extensions t3-icon-extensions-workspaces t3-icon-workspaces-sendtonextstage',
196 tooltip: TYPO3.l10n.localize('tooltip.sendToNextStage'),
197 handler: function(grid, rowIndex, colIndex) {
198 var record = TYPO3.Workspaces.MainStore.getAt(rowIndex);
199 TYPO3.Workspaces.Actions.sendToNextStageWindow(record.json.table, record.json.uid, record.json.t3ver_oid);
200 }
201 }
202 ]
203 };
204
205 TYPO3.Workspaces.Configuration.Stage = {
206 id: 'label_Stage',
207 dataIndex : 'label_Stage',
208 width: 80,
209 sortable: true,
210 header : TYPO3.l10n.localize('column.stage'),
211 hidden: false,
212 filter : {
213 type : 'string'
214 },
215 renderer: function(value, metaData, record, rowIndex, colIndex, store) {
216 var returnCode = '';
217 if (record.json.allowedAction_prevStage && TYPO3.settings.Workspaces.allView !== '1') {
218 var tempTooltip = TYPO3.Workspaces.Configuration.SendToPrevStageButton.items[0].tooltip;
219 TYPO3.Workspaces.Configuration.SendToPrevStageButton.items[0].tooltip += ' &quot;'+ record.json.label_prevStage + '&quot;';
220 var prevButton = new Ext.grid.ActionColumn(TYPO3.Workspaces.Configuration.SendToPrevStageButton);
221 returnCode += prevButton.renderer(1, metaData, record, rowIndex, 1, store);
222 TYPO3.Workspaces.Configuration.SendToPrevStageButton.items[0].tooltip = tempTooltip;
223 } else {
224 returnCode += "<span class=\"t3-icon t3-icon-empty t3-icon-empty-empty\">&nbsp;</span>";
225 }
226 returnCode += record.json.label_Stage;
227 if (record.json.allowedAction_nextStage && TYPO3.settings.Workspaces.allView !== '1') {
228 var tempTooltip = TYPO3.Workspaces.Configuration.SendToNextStageButton.items[1].tooltip;
229 TYPO3.Workspaces.Configuration.SendToNextStageButton.items[1].tooltip += ' &quot;'+ record.json.label_nextStage + '&quot;';
230 var nextButton = new Ext.grid.ActionColumn(TYPO3.Workspaces.Configuration.SendToNextStageButton);
231 returnCode += nextButton.renderer(2, metaData, record, rowIndex, 2, store);
232 TYPO3.Workspaces.Configuration.SendToNextStageButton.items[1].tooltip = tempTooltip;
233 } else {
234 returnCode += "<span class=\"t3-icon t3-icon-empty t3-icon-empty-empty\">&nbsp;</span>";
235 }
236 return returnCode;
237 },
238 processEvent : function(name, e, grid, rowIndex, colIndex){
239 var m = e.getTarget().className.match(/x-action-col-(\d+)/);
240 if(m && m[1] == 0) {
241 TYPO3.Workspaces.Configuration.SendToPrevStageButton.items[0].handler(grid, rowIndex, colIndex);
242 return false;
243 } else if (m && m[1] == 1 ) {
244 TYPO3.Workspaces.Configuration.SendToNextStageButton.items[1].handler(grid, rowIndex, colIndex);
245 return false;
246 }
247 return Ext.grid.ActionColumn.superclass.processEvent.apply(this, arguments);
248 }
249 }
250
251 TYPO3.Workspaces.Configuration.RowButtons = {
252 xtype: 'actioncolumn',
253 header: TYPO3.l10n.localize('column.actions'),
254 width: 70,
255 hideable: false,
256 hidden: (TYPO3.settings.Workspaces.allView === '1'),
257 menuDisabled: true,
258 items: [
259 {
260 iconCls:'t3-icon t3-icon-actions t3-icon-actions-version t3-icon-version-workspace-preview'
261 ,tooltip: TYPO3.l10n.localize('tooltip.viewElementAction')
262 ,handler: function(grid, rowIndex, colIndex) {
263 var record = TYPO3.Workspaces.MainStore.getAt(rowIndex);
264 TYPO3.Workspaces.Actions.viewSingleRecord(record.json.table, record.json.uid);
265 },
266 getClass: function(v, meta, rec) {
267 if(!rec.json.allowedAction_view) {
268 return 'icon-hidden';
269 } else {
270 return '';
271 }
272 }
273 },
274 {
275 iconCls:'t3-icon t3-icon-actions t3-icon-actions-document t3-icon-document-open',
276 tooltip: TYPO3.l10n.localize('tooltip.editElementAction'),
277 handler: function(grid, rowIndex, colIndex) {
278 var record = TYPO3.Workspaces.MainStore.getAt(rowIndex);
279 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';
280 window.location.href = newUrl;
281 },
282 getClass: function(v, meta, rec) {
283 if(!rec.json.allowedAction_edit) {
284 return 'icon-hidden';
285 } else {
286 return '';
287 }
288 }
289 },
290 {
291 iconCls:'t3-icon t3-icon-actions t3-icon-actions-system t3-icon-system-pagemodule-open',
292 tooltip: TYPO3.l10n.localize('tooltip.openPage'),
293 handler: function(grid, rowIndex, colIndex) {
294 var record = TYPO3.Workspaces.MainStore.getAt(rowIndex);
295 if (record.json.table == 'pages') {
296 top.loadEditId(record.json.t3ver_oid);
297 } else {
298 top.loadEditId(record.json.livepid);
299 }
300 },
301 getClass: function(v, meta, rec) {
302 if(!rec.json.allowedAction_editVersionedPage || !top.TYPO3.configuration.pageModule) {
303 return 'icon-hidden';
304 } else {
305 return '';
306 }
307 }
308 },
309 {
310 iconCls:'t3-icon t3-icon-actions t3-icon-actions-version t3-icon-version-document-remove',
311 tooltip: TYPO3.l10n.localize('tooltip.discardVersion'),
312 handler: function(grid, rowIndex, colIndex) {
313 var record = TYPO3.Workspaces.MainStore.getAt(rowIndex);
314 var configuration = {
315 title: TYPO3.l10n.localize('window.discard.title'),
316 msg: TYPO3.l10n.localize('window.discard.message'),
317 fn: function(result) {
318 if (result == 'yes') {
319 TYPO3.Workspaces.Actions.deleteSingleRecord(record.json.table, record.json.uid);
320 }
321 }
322 };
323
324 top.TYPO3.Dialog.QuestionDialog(configuration);
325 },
326 getClass: function(v, meta, rec) {
327 if(!rec.json.allowedAction_delete) {
328 return 'icon-hidden';
329 } else {
330 return '';
331 }
332 }
333 },
334 {
335 iconCls: 't3-icon t3-icon-actions t3-icon-actions-document t3-icon-document-history-open',
336 tooltip: TYPO3.l10n.localize('tooltip.showHistory'),
337 handler: function(grid, rowIndex, colIndex) {
338 var record = TYPO3.Workspaces.MainStore.getAt(rowIndex);
339 TYPO3.Workspaces.Helpers.getHistoryWindow({
340 table: record.json.table,
341 versionId: record.json.uid
342 });
343 }
344 }
345 ]
346 };
347
348 TYPO3.Workspaces.Configuration.SwapButton = {
349 xtype: 'actioncolumn',
350 header: '',
351 id: 'wsSwapColumn',
352 width: 18,
353 menuDisabled: true,
354 sortable: false,
355 hidden: (TYPO3.settings.Workspaces.allView === '1'),
356 items: [
357 {
358 iconCls:'t3-icon t3-icon-actions t3-icon-actions-version t3-icon-version-swap-workspace'
359 ,tooltip: TYPO3.l10n.localize('tooltip.swap')
360 ,handler: function(grid, rowIndex, colIndex) {
361 var record = TYPO3.Workspaces.MainStore.getAt(rowIndex);
362 var parameters = {
363 type: 'selection',
364 selection: [{
365 table: record.json.table,
366 versionId: record.json.uid,
367 liveId: record.json.t3ver_oid
368 }]
369 };
370
371 var configuration = {
372 title: TYPO3.l10n.localize('window.swap.title'),
373 msg: TYPO3.l10n.localize('window.swap.message'),
374 fn: function(result) {
375 if (result == 'yes') {
376 TYPO3.Workspaces.Actions.swapSingleRecord(record.json.table, record.json.t3ver_oid, record.json.uid);
377 }
378 }
379 };
380
381 TYPO3.Workspaces.Actions.checkIntegrity(parameters, function() {
382 top.TYPO3.Dialog.QuestionDialog(configuration);
383 });
384 },
385 getClass: function(v, meta, rec) {
386 if(!rec.json.allowedAction_swap) {
387 return 'icon-hidden';
388 } else {
389 return '';
390 }
391 }
392 }
393 ]
394 };