Browse Source

add conditional display for config views

pull/46/head
Jonathan Cobb 4 years ago
parent
commit
a4944233bf
1 changed files with 13 additions and 2 deletions
  1. +13
    -2
      src/account/AppPage.vue

+ 13
- 2
src/account/AppPage.vue View File

@@ -94,7 +94,7 @@
}, },
computed: { computed: {
...mapState('apps', ['app', 'sites', 'site']), ...mapState('apps', ['app', 'sites', 'site']),
...mapState('system', ['messages'])
...mapState('system', ['messages', 'configs'])
}, },
created () { created () {
this.appId = this.$route.params.app; this.appId = this.$route.params.app;
@@ -140,6 +140,15 @@
messages: this.messages, messages: this.messages,
errors: this.errors errors: this.errors
}); });
},
viewIsAvailable(view) {
if (typeof view.when === 'undefined' || view.when === null) return true;
try {
return safeEval(view.when, {'configs': this.configs}) === true;
} catch (e) {
console.log('viewIsAvailable: error evaluating when='+view.when+': '+e);
return false;
}
} }
}, },
watch: { watch: {
@@ -162,7 +171,9 @@
const appConfigViews = []; const appConfigViews = [];
for (let i=0; i<allConfigViews.length; i++) { for (let i=0; i<allConfigViews.length; i++) {
if (typeof allConfigViews[i].root !== 'undefined' && allConfigViews[i].root !== null && allConfigViews[i].root === true) { if (typeof allConfigViews[i].root !== 'undefined' && allConfigViews[i].root !== null && allConfigViews[i].root === true) {
appConfigViews.push(allConfigViews[i]);
if (this.viewIsAvailable(allConfigViews[i])) {
appConfigViews.push(allConfigViews[i]);
}
} }
} }
this.appConfigViews = appConfigViews; this.appConfigViews = appConfigViews;


Loading…
Cancel
Save