/
detailpanel.v21.resources.js
195 lines (193 loc) · 9.26 KB
/
detailpanel.v21.resources.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
VersionX.panel.ResourcesDetail.Main = function(config) {
config = config || {};
Ext.apply(config,{
id: 'versionx-panel-resourcesdetail',
border: false,
layout: 'form',
items: [{
html: '<p>'+_('versionx.resources.detail.text')+'</p>',
border: false,
bodyCssClass: 'panel-desc'
},{
layout: 'form',
cls: 'main-wrapper',
items: [{
layout: 'column',
border: false,
items: [{
columnWidth: .5,
layout: 'form',
border: false,
labelWidth: 125,
items: [{
xtype: 'versionx-combo-resourceversions',
fieldLabel: _('versionx.compare_to'),
labelStyle: 'padding: 7px 0 0 5px;',
name: 'compare_to',
baseParams: {
resource: (VersionX.record) ? VersionX.record['content_id'] : 0,
current: (VersionX.record) ? VersionX.record['version_id'] : 0,
action: 'mgr/resources/get_versions'
},
listeners: {
'select': this.compareVersion
}
}]
},{
columnWidth: .5,
layout: 'form',
labelWidth: 125,
border: false,
items: [{
xtype: 'button',
text: _('versionx.resources.revert.options'),
handler: (VersionX.record && VersionX.cmrecord) ? Ext.emptyFn : function() {
this.revertVersion((VersionX.record) ? VersionX.record['version_id'] : 0);
},
scope: this,
menu: (VersionX.record && VersionX.cmrecord) ?
[{
text: _('versionx.resources.revert',{id: VersionX.record['version_id']}),
handler: function() {
this.revertVersion((VersionX.record) ? VersionX.record['version_id'] : 0);
},
scope: this
},{
text: _('versionx.resources.revert',{id: VersionX.cmrecord['version_id']}),
handler: function() {
this.revertVersion((VersionX.cmrecord) ? VersionX.cmrecord['version_id'] : 0);
},
scope: this
}] : undefined
}]
}]
},{
xtype: 'panel',
bodyStyle: 'height: 12px',
border: false
},{
xtype: 'modx-tabs',
bodyStyle: 'padding: 15px;',
width: '98%',
border: true,
defaults: {
border: false,
autoHeight: true,
defaults: {
border: false
}
},
items: [{
title: _('versionx.common.version-details'),
items: [{
id: 'versionx-panel-resourcesdetail-versioninfo',
xtype: 'versionx-panel-common-detailpanel',
vxRecord: config.vxRecord,
vxRecordCmp: config.vxRecordCmp ? config.vxRecordCmp : undefined,
vxFieldMap: [
{ key: 'version_id', lexicon:'versionx.version_id' },
{ key: 'user', lexicon:'user' },
{ key: 'saved', lexicon:'versionx.saved' },
{ key: 'mode', lexicon:'versionx.mode' }
]
}]
},{
title: _('versionx.resources.detail.tabs.resource-fields'),
items: [{
id: 'versionx-panel-resourcesdetail-resource-fields',
xtype: 'versionx-panel-common-detailpanel',
vxRecord: config.vxRecord,
vxRecordCmp: config.vxRecordCmp ? config.vxRecordCmp : undefined,
vxFieldMap: [
{ key: 'pagetitle', lexicon:'resource_pagetitle' },
{ key: 'longtitle', lexicon:'resource_longtitle' },
{ key: 'description', lexicon:'resource_description' },
{ key: 'alias', lexicon:'resource_alias' },
{ key: 'link_attributes', lexicon:'resource_link_attributes' },
{ key: 'summary', lexicon:'resource_summary' },
{ key: 'parent', lexicon:'resource_parent' },
{ key: 'menutitle', lexicon:'resource_menutitle' },
{ key: 'menuindex', lexicon:'resource_menuindex' },
{ key: 'published', lexicon:'resource_published' },
{ key: 'hidemenu', lexicon:'resource_hide_from_menus' }
]
}]
},{
title: _('versionx.resources.detail.tabs.resource-content'),
items: [{
id: 'versionx-panel-resourcesdetail-content',
xtype: 'versionx-panel-common-contentpanel',
border: false,
vxRecord: config.vxRecord,
vxRecordCmp: config.vxRecordCmp ? config.vxRecordCmp : undefined,
vxContentField: 'content'
}]
},{
title: _('versionx.resources.detail.tabs.template-variables'),
// If this tab contains vertical tabs, enable this ---> bodyStyle: 'padding: 0 !important;',
items: [{
id: 'versionx-panel-resourcesdetail-tvs',
xtype: 'versionx-panel-resourcesdetail-tvs',
border: false,
vxRecord: config.vxRecord,
vxRecordCmp: config.vxRecordCmp ? config.vxRecordCmp : undefined
}]
},{
title: _('versionx.resources.detail.tabs.page-settings'),
items: [{
id: 'versionx-panel-resourcesdetail-page-settings',
xtype: 'versionx-panel-common-detailpanel',
border: false,
vxRecord: config.vxRecord,
vxRecordCmp: config.vxRecordCmp ? config.vxRecordCmp : undefined,
vxFieldMap: [
{ key: 'isfolder', lexicon:'resource_folder' },
{ key: 'richtext', lexicon:'resource_richtext' },
{ key: 'publsihedon', lexicon:'resource_publishedon' },
{ key: 'pub_date', lexicon:'resource_publishdate' },
{ key: 'unpub_date', lexicon:'resource_unpublishdate' },
{ key: 'searchable', lexicon:'resource_searchable' },
{ key: 'cacheable', lexicon:'resource_cacheable' },
{ key: 'deleted', lexicon:'deleted' },
{ key: 'content_type', lexicon:'resource_content_type' },
{ key: 'content_dispo', lexicon:'resource_contentdispo' },
{ key: 'class_key', lexicon:'class_key' }
]
}]
}]
}]
}],
listeners: {
}
});
VersionX.panel.ResourcesDetail.Main.superclass.constructor.call(this,config);
};
Ext.extend(VersionX.panel.ResourcesDetail.Main,MODx.FormPanel,{
compareVersion: function (tf) {
var cmid = tf.getValue();
var backTo = (MODx.request.backTo) ? '&backTo='+MODx.request.backTo : '';
window.location.href = '?a='+VersionX.action+'&action=resource&vid='+MODx.request['vid']+'&cmid='+cmid+backTo;
},
revertVersion: function(version) {
if (version < 1) { console.log('Version not properly defined: '+version); }
MODx.msg.confirm({
title: _('versionx.resources.revert.confirm'),
text: _('versionx.resources.revert.confirm.text',{id: version}),
url: VersionX.config.connector_url,
params: {
version_id: version,
content_id: VersionX.record.content_id,
action: 'mgr/resources/revert'
},
listeners: {
success: {fn: function() {
MODx.msg.status({
message: _('versionx.resources.reverted'),
delay: 4
});
}, scope: this }
}
});
}
});
Ext.reg('versionx-panel-resourcesdetail',VersionX.panel.ResourcesDetail.Main);