Skip to content

Commit 4f9498b

Browse files
committed
Add view option for default Fred blueprint
Resolves #264
1 parent 9a328fa commit 4f9498b

File tree

16 files changed

+5436
-1748
lines changed

16 files changed

+5436
-1748
lines changed

Diff for: _build/assets/js/Sidebar/index.js

+20-4
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ export default config => (fred, Plugin, pluginTools) => {
250250
getBlueprints(true, state.theme)
251251
.then(categories => {
252252
const groups = [];
253+
var defaultBlueprint = view.blueprint || value.customProperties.default_blueprint;
253254

254255
categories.forEach(category => {
255256
const options = [];
@@ -260,7 +261,7 @@ export default config => (fred, Plugin, pluginTools) => {
260261
value: '' + blueprint.id
261262
};
262263

263-
if (value.customProperties.default_blueprint && (blueprint.id === value.customProperties.default_blueprint)) {
264+
if (defaultBlueprint && (blueprint.id === defaultBlueprint)) {
264265
blueprintOption.selected = true;
265266
state.blueprint = blueprint.id;
266267
}
@@ -311,14 +312,29 @@ export default config => (fred, Plugin, pluginTools) => {
311312
const templateInput = choices({
312313
name: 'template',
313314
label: pluginTools.fredConfig.lng('fred.fe.pages.template'),
314-
}, state.parent, onChangeChoices, (setting, label, select, choicesInstance, defaultValue) => {
315+
}, state.template, onChangeChoices, (setting, label, select, choicesInstance, defaultValue) => {
315316
choicesInstance.ajax(callback => {
316317
getTemplates()
317318
.then(data => {
318-
if (data.data.templates[0]) {
319-
onChangeChoices('template', data.data.templates[0]);
319+
let defaultSet = false;
320+
let defaultTemplate = null;
321+
322+
for (let template of data.data.templates) {
323+
if (parseInt(template.id) === parseInt(state.template)) {
324+
template.selected = true;
325+
defaultTemplate = template;
326+
defaultSet = true;
327+
break;
328+
}
329+
}
330+
331+
if (!defaultSet && data.data.templates[0]) {
332+
defaultTemplate = data.data.templates[0];
320333
data.data.templates[0].selected = true;
321334
}
335+
336+
onChangeChoices('template', defaultTemplate);
337+
322338
callback(data.data.templates, 'value', 'name');
323339
})
324340
.catch(error => {

Diff for: assets/components/collections/js/mgr/extra/collections.combo.js

+29-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ collections.combo.Resource = function(config) {
194194
Ext.extend(collections.combo.Resource,MODx.combo.ComboBox);
195195
Ext.reg('collections-combo-resource',collections.combo.Resource);
196196

197-
198197
collections.combo.ViewFor = function(config) {
199198
config = config || {};
200199
Ext.applyIf(config,{
@@ -325,3 +324,32 @@ collections.combo.SortType = function(config) {
325324
};
326325
Ext.extend(collections.combo.SortType,MODx.combo.ComboBox);
327326
Ext.reg('collections-combo-sort-type',collections.combo.SortType);
327+
328+
collections.combo.FredBlueprints = function(config) {
329+
config = config || {};
330+
Ext.applyIf(config,{
331+
name: 'blueprint',
332+
hiddenName: 'blueprint',
333+
displayField: 'name',
334+
valueField: 'uuid',
335+
fields: ['name','uuid', 'category_name', 'theme_name'],
336+
pageSize: 20,
337+
minChars: 1,
338+
editable: true,
339+
triggerAction: 'all',
340+
typeAhead: false,
341+
forceSelection: true,
342+
selectOnFocus: false,
343+
url: collections.config.connectorUrl,
344+
baseParams:{
345+
action: 'mgr/extra/fredgetblueprints',
346+
addNone: config.addNone || 0
347+
},
348+
tpl: new Ext.XTemplate('<tpl for="."><div class="x-combo-list-item"><span style="font-weight: bold">{name:htmlEncode}</span><br />',
349+
'<tpl if="category_name">Category: <span>{category_name:htmlEncode}</span><br />Theme: <span>{theme_name:htmlEncode}</span></tpl>',
350+
'</div></tpl>')
351+
});
352+
collections.combo.FredBlueprints.superclass.constructor.call(this,config);
353+
};
354+
Ext.extend(collections.combo.FredBlueprints,MODx.combo.ComboBox);
355+
Ext.reg('collections-combo-fred-blueprints',collections.combo.FredBlueprints);

Diff for: assets/components/collections/js/mgr/sections/template/template.js

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ collections.page.Template = function(config) {
2121
xtype: 'collections-panel-template'
2222
,renderTo: 'collections-panel-template-div'
2323
,isUpdate: config.isUpdate
24+
,fredInstalled: !!config.fredInstalled
2425
}]
2526
});
2627
collections.page.Template.superclass.constructor.call(this,config);

0 commit comments

Comments
 (0)