Fixed empty setting groups showing in nav bar

refs bc5be1a808

- after removing duplication for groups in the template we were showing empty groups because the group construction wasn't considering there may be no settings for a group
This commit is contained in:
Kevin Ansfield 2021-10-12 09:12:58 +01:00
parent d12090cc14
commit d3539655a0

View File

@ -36,18 +36,24 @@ export default class DesignMenuComponent extends Component {
get settingGroups() {
const groupKeys = this.KNOWN_GROUPS.map(g => g.key);
const groups = [];
const groups = [{
key: 'site-wide',
name: 'Site-wide',
icon: 'house',
settings: this.themeSettings.filter(setting => !groupKeys.includes(setting.group))
}];
const siteWideSettings = this.themeSettings.filter(setting => !groupKeys.includes(setting.group));
if (siteWideSettings.length) {
groups.push({
key: 'site-wide',
name: 'Site-wide',
icon: 'house',
settings: siteWideSettings
});
}
this.KNOWN_GROUPS.forEach((knownGroup) => {
groups.push(Object.assign({}, knownGroup, {
settings: this.themeSettings.filter(setting => setting.group === knownGroup.key)
}));
const settings = this.themeSettings.filter(setting => setting.group === knownGroup.key);
if (settings.length) {
groups.push(Object.assign({}, knownGroup, {settings}));
}
});
return groups;