1 /***************************************************************
4 * (c) 2010 Workspaces Team (http://forge.typo3.org/projects/show/typo3v4-workspaces)
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.
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.
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.
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
27 Ext
.ns('TYPO3.Workspaces');
28 TYPO3
.Workspaces
.Configuration
= {};
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)
40 dataIndex
: 'workspace_Title'
44 dataIndex
: 'languageValue'
48 dataIndex
: 'label_Live'
52 dataIndex
: 'label_Workspace'
61 TYPO3
.Workspaces
.Configuration
.Integrity
= new Ext
.grid
.Column({
65 header
: '<span class="' + TYPO3
.settings
.Workspaces
.icons
.integrity
+ '"> </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
;
72 return '<span class="' + cls
+ '" ext:qtitle="' + title
+ '" ext:qtip="' + message
+ '"> </span>';
76 TYPO3
.Workspaces
.Configuration
.WsPath
= {
78 dataIndex
: 'path_Workspace',
83 header
: TYPO3
.l10n
.localize('column.wsPath'),
84 renderer: function(value
, metaData
, record
, rowIndex
, colIndex
, store
) {
85 var path
= record
.json
.path_Workspace
;
88 filter
: {type
: 'string'}
91 TYPO3
.Workspaces
.Configuration
.LivePath
= {
93 dataIndex
: 'path_Live',
98 header
: TYPO3
.l10n
.localize('column.livePath'),
99 renderer: function(value
, metaData
, record
, rowIndex
, colIndex
, store
) {
100 var path
= record
.json
.path_Live
;
103 filter
: {type
: 'string'}
106 TYPO3
.Workspaces
.Configuration
.WsTitleWithIcon
= {
107 id
: 'label_Workspace',
108 dataIndex
: 'label_Workspace',
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
) {
119 return "<span class=\"" + record
.json
.icon_Workspace
+ "\"> </span> " + value
;
123 filter
: {type
: 'string'}
126 TYPO3
.Workspaces
.Configuration
.Language
= {
128 dataIndex
: 'languageValue',
132 header
: '<span class="' + TYPO3
.settings
.Workspaces
.icons
.language
+ '"> </span>',
133 filter
: { type
: 'string '},
134 renderer: function(value
, metaData
, record
) {
135 return '<span class="' + record
.json
.language
.cls
+ '" title="' + record
.json
.language
.title
+ '"> </span>';
139 TYPO3
.Workspaces
.Configuration
.TitleWithIcon
= {
141 dataIndex
: 'label_Live',
145 header
: TYPO3
.l10n
.localize('column.liveTitle'),
146 renderer: function(value
, metaData
, record
, rowIndex
, colIndex
, store
) {
148 if (record
.json
.state_Workspace
== 'unhidden') {
149 dekoClass
= 'item-state-hidden';
152 value
= "<span class=\"" + dekoClass
+ "\">" + value
+ "</span>";
153 return "<span class=\"" + record
.json
.icon_Live
+ "\"> </span> " + value
;
155 filter
: {type
: 'string'}
158 TYPO3
.Workspaces
.Configuration
.ChangeDate
= {
159 id
: 'workspace_Tstamp',
160 dataIndex
: 'workspace_Tstamp',
163 header
: TYPO3
.l10n
.localize('column.changeDate'),
164 renderer: function(value
, metaData
, record
, rowIndex
, colIndex
, store
) {
165 return record
.json
.workspace_Formated_Tstamp
;
168 filter
: {type
: 'string'}
171 TYPO3
.Workspaces
.Configuration
.SendToPrevStageButton
= {
172 xtype
: 'actioncolumn',
175 hidden
: (TYPO3
.settings
.Workspaces
.allView
=== '1'),
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
);
188 TYPO3
.Workspaces
.Configuration
.SendToNextStageButton
= {
189 xtype
: 'actioncolumn',
192 hidden
: (TYPO3
.settings
.Workspaces
.allView
=== '1'),
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
);
205 TYPO3
.Workspaces
.Configuration
.Stage
= {
207 dataIndex
: 'label_Stage',
210 header
: TYPO3
.l10n
.localize('column.stage'),
215 renderer: function(value
, metaData
, record
, rowIndex
, colIndex
, store
) {
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
+= ' "'+ record
.json
.label_prevStage
+ '"';
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
;
224 returnCode
+= "<span class=\"t3-icon t3-icon-empty t3-icon-empty-empty\"> </span>";
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
+= ' "'+ record
.json
.label_nextStage
+ '"';
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
;
234 returnCode
+= "<span class=\"t3-icon t3-icon-empty t3-icon-empty-empty\"> </span>";
238 processEvent : function(name
, e
, grid
, rowIndex
, colIndex
){
239 var m
= e
.getTarget().className
.match(/x-action-col-(\d+)/);
241 TYPO3
.Workspaces
.Configuration
.SendToPrevStageButton
.items
[0].handler(grid
, rowIndex
, colIndex
);
243 } else if (m
&& m
[1] == 1 ) {
244 TYPO3
.Workspaces
.Configuration
.SendToNextStageButton
.items
[1].handler(grid
, rowIndex
, colIndex
);
247 return Ext
.grid
.ActionColumn
.superclass
.processEvent
.apply(this, arguments
);
251 TYPO3
.Workspaces
.Configuration
.RowButtons
= {
252 xtype
: 'actioncolumn',
253 header
: TYPO3
.l10n
.localize('column.actions'),
256 hidden
: (TYPO3
.settings
.Workspaces
.allView
=== '1'),
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
);
266 getClass: function(v
, meta
, rec
) {
267 if(!rec
.json
.allowedAction_view
) {
268 return 'icon-hidden';
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
;
282 getClass: function(v
, meta
, rec
) {
283 if(!rec
.json
.allowedAction_edit
) {
284 return 'icon-hidden';
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
);
298 top
.loadEditId(record
.json
.livepid
);
301 getClass: function(v
, meta
, rec
) {
302 if(!rec
.json
.allowedAction_editVersionedPage
|| !top
.TYPO3
.configuration
.pageModule
) {
303 return 'icon-hidden';
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
);
324 top
.TYPO3
.Dialog
.QuestionDialog(configuration
);
326 getClass: function(v
, meta
, rec
) {
327 if(!rec
.json
.allowedAction_delete
) {
328 return 'icon-hidden';
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
348 TYPO3
.Workspaces
.Configuration
.SwapButton
= {
349 xtype
: 'actioncolumn',
355 hidden
: (TYPO3
.settings
.Workspaces
.allView
=== '1'),
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
);
365 table
: record
.json
.table
,
366 versionId
: record
.json
.uid
,
367 liveId
: record
.json
.t3ver_oid
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
);
381 TYPO3
.Workspaces
.Actions
.checkIntegrity(parameters
, function() {
382 top
.TYPO3
.Dialog
.QuestionDialog(configuration
);
385 getClass: function(v
, meta
, rec
) {
386 if(!rec
.json
.allowedAction_swap
) {
387 return 'icon-hidden';