Skip to content

Commit

Permalink
Add view option for default Fred blueprint
Browse files Browse the repository at this point in the history
Resolves #264
  • Loading branch information
theboxer committed Jun 7, 2019
1 parent 9a328fa commit 4f9498b
Show file tree
Hide file tree
Showing 16 changed files with 5,436 additions and 1,748 deletions.
24 changes: 20 additions & 4 deletions _build/assets/js/Sidebar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ export default config => (fred, Plugin, pluginTools) => {
getBlueprints(true, state.theme)
.then(categories => {
const groups = [];
var defaultBlueprint = view.blueprint || value.customProperties.default_blueprint;

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

if (value.customProperties.default_blueprint && (blueprint.id === value.customProperties.default_blueprint)) {
if (defaultBlueprint && (blueprint.id === defaultBlueprint)) {
blueprintOption.selected = true;
state.blueprint = blueprint.id;
}
Expand Down Expand Up @@ -311,14 +312,29 @@ export default config => (fred, Plugin, pluginTools) => {
const templateInput = choices({
name: 'template',
label: pluginTools.fredConfig.lng('fred.fe.pages.template'),
}, state.parent, onChangeChoices, (setting, label, select, choicesInstance, defaultValue) => {
}, state.template, onChangeChoices, (setting, label, select, choicesInstance, defaultValue) => {
choicesInstance.ajax(callback => {
getTemplates()
.then(data => {
if (data.data.templates[0]) {
onChangeChoices('template', data.data.templates[0]);
let defaultSet = false;
let defaultTemplate = null;

for (let template of data.data.templates) {
if (parseInt(template.id) === parseInt(state.template)) {
template.selected = true;
defaultTemplate = template;
defaultSet = true;
break;
}
}

if (!defaultSet && data.data.templates[0]) {
defaultTemplate = data.data.templates[0];
data.data.templates[0].selected = true;
}

onChangeChoices('template', defaultTemplate);

callback(data.data.templates, 'value', 'name');
})
.catch(error => {
Expand Down
30 changes: 29 additions & 1 deletion assets/components/collections/js/mgr/extra/collections.combo.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ collections.combo.Resource = function(config) {
Ext.extend(collections.combo.Resource,MODx.combo.ComboBox);
Ext.reg('collections-combo-resource',collections.combo.Resource);


collections.combo.ViewFor = function(config) {
config = config || {};
Ext.applyIf(config,{
Expand Down Expand Up @@ -325,3 +324,32 @@ collections.combo.SortType = function(config) {
};
Ext.extend(collections.combo.SortType,MODx.combo.ComboBox);
Ext.reg('collections-combo-sort-type',collections.combo.SortType);

collections.combo.FredBlueprints = function(config) {
config = config || {};
Ext.applyIf(config,{
name: 'blueprint',
hiddenName: 'blueprint',
displayField: 'name',
valueField: 'uuid',
fields: ['name','uuid', 'category_name', 'theme_name'],
pageSize: 20,
minChars: 1,
editable: true,
triggerAction: 'all',
typeAhead: false,
forceSelection: true,
selectOnFocus: false,
url: collections.config.connectorUrl,
baseParams:{
action: 'mgr/extra/fredgetblueprints',
addNone: config.addNone || 0
},
tpl: new Ext.XTemplate('<tpl for="."><div class="x-combo-list-item"><span style="font-weight: bold">{name:htmlEncode}</span><br />',
'<tpl if="category_name">Category: <span>{category_name:htmlEncode}</span><br />Theme: <span>{theme_name:htmlEncode}</span></tpl>',
'</div></tpl>')
});
collections.combo.FredBlueprints.superclass.constructor.call(this,config);
};
Ext.extend(collections.combo.FredBlueprints,MODx.combo.ComboBox);
Ext.reg('collections-combo-fred-blueprints',collections.combo.FredBlueprints);
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ collections.page.Template = function(config) {
xtype: 'collections-panel-template'
,renderTo: 'collections-panel-template-div'
,isUpdate: config.isUpdate
,fredInstalled: !!config.fredInstalled
}]
});
collections.page.Template.superclass.constructor.call(this,config);
Expand Down
Loading

0 comments on commit 4f9498b

Please sign in to comment.