Move plugin/theme settings modals to the modal manager

This commit is contained in:
Samuel Elliott 2018-02-13 17:06:09 +00:00
parent 21a8554d6f
commit 3b66d320e8
5 changed files with 32 additions and 31 deletions

View File

@ -32,28 +32,26 @@
<div class="bd-spinner-2"></div> <div class="bd-spinner-2"></div>
</div> </div>
</div> </div>
<PluginSettingsModal v-if="settingsOpen !== null" :plugin="settingsOpen" :close="closeSettings" />
</SettingsWrapper> </SettingsWrapper>
</template> </template>
<script> <script>
// Imports // Imports
import { PluginManager } from 'modules'; import { PluginManager } from 'modules';
import { Modals } from 'ui';
import { SettingsWrapper } from './'; import { SettingsWrapper } from './';
import PluginCard from './PluginCard.vue'; import PluginCard from './PluginCard.vue';
import PluginSettingsModal from './PluginSettingsModal.vue';
import { MiRefresh } from '../common'; import { MiRefresh } from '../common';
export default { export default {
data() { data() {
return { return {
local: true, local: true,
settingsOpen: null,
localPlugins: PluginManager.localPlugins localPlugins: PluginManager.localPlugins
} }
}, },
components: { components: {
SettingsWrapper, PluginCard, PluginSettingsModal, SettingsWrapper, PluginCard,
MiRefresh MiRefresh
}, },
methods: { methods: {
@ -91,12 +89,8 @@
})(); })();
}, },
showSettings(plugin) { showSettings(plugin) {
this.settingsOpen = plugin; return Modals.pluginSettings(plugin);
},
closeSettings() {
this.settingsOpen = null;
} }
} }
} }
</script> </script>

View File

@ -32,29 +32,26 @@
<div class="bd-spinner-2"></div> <div class="bd-spinner-2"></div>
</div> </div>
</div> </div>
<ThemeSettingsModal v-if="settingsOpen !== null" :theme="settingsOpen" :close="closeSettings" />
</SettingsWrapper> </SettingsWrapper>
</template> </template>
<script> <script>
// Imports // Imports
import { ThemeManager } from 'modules'; import { ThemeManager } from 'modules';
import { Modals } from 'ui';
import { SettingsWrapper } from './'; import { SettingsWrapper } from './';
import { MiRefresh } from '../common'; import { MiRefresh } from '../common';
import ThemeSettingsModal from './ThemeSettingsModal.vue';
import ThemeCard from './ThemeCard.vue'; import ThemeCard from './ThemeCard.vue';
export default { export default {
data() { data() {
return { return {
local: true, local: true,
settingsOpen: null,
localThemes: ThemeManager.localThemes localThemes: ThemeManager.localThemes
} }
}, },
components: { components: {
SettingsWrapper, ThemeCard, SettingsWrapper, ThemeCard,
ThemeSettingsModal,
MiRefresh MiRefresh
}, },
methods: { methods: {
@ -92,12 +89,8 @@
})(); })();
}, },
showSettings(theme) { showSettings(theme) {
this.settingsOpen = theme; return Modals.themeSettings(theme);
},
closeSettings() {
this.settingsOpen = null;
} }
} }
} }
</script> </script>

View File

@ -10,8 +10,7 @@
<template> <template>
<div class="bd-plugin-settings-modal" :class="{'bd-edited': changed}"> <div class="bd-plugin-settings-modal" :class="{'bd-edited': changed}">
<div class="bd-backdrop" @click="attemptToClose" :class="{'bd-backdrop-out': closing}"></div> <Modal :headerText="plugin.name + ' Settings'" :close="attemptToClose" :class="{'bd-modal-out': modal.closing}">
<Modal :headerText="plugin.name + ' Settings'" :close="attemptToClose" :class="{'bd-modal-out': closing}">
<SettingsPanel :settings="configCache" :change="settingChange" slot="body" class="bd-plugin-settings-body" /> <SettingsPanel :settings="configCache" :change="settingChange" slot="body" class="bd-plugin-settings-body" />
<div slot="footer" class="bd-footer-alert" :class ="{'bd-active': changed, 'bd-warn': warnclose}"> <div slot="footer" class="bd-footer-alert" :class ="{'bd-active': changed, 'bd-warn': warnclose}">
<div class="bd-footer-alert-text">Unsaved changes</div> <div class="bd-footer-alert-text">Unsaved changes</div>
@ -27,11 +26,11 @@
<script> <script>
// Imports // Imports
import Vue from 'vue'; import Vue from 'vue';
import { Modal } from '../common'; import { Modal } from '../../common';
import SettingsPanel from './SettingsPanel.vue'; import SettingsPanel from '../SettingsPanel.vue';
export default { export default {
props: ['plugin','close'], props: ['modal'],
data() { data() {
return { return {
changed: false, changed: false,
@ -43,7 +42,10 @@
}, },
components: { components: {
Modal, Modal,
SettingsPanel, SettingsPanel
},
computed: {
plugin() { return this.modal.plugin; }
}, },
methods: { methods: {
checkForChanges() { checkForChanges() {
@ -96,7 +98,7 @@
if (!this.changed) { if (!this.changed) {
this.closing = true; this.closing = true;
setTimeout(() => { setTimeout(() => {
this.close(); this.modal.close();
}, 200); }, 200);
return; return;
} }

View File

@ -10,8 +10,7 @@
<template> <template>
<div class="bd-plugin-settings-modal" :class="{'bd-edited': changed}"> <div class="bd-plugin-settings-modal" :class="{'bd-edited': changed}">
<div class="bd-backdrop" @click="attemptToClose" :class="{'bd-backdrop-out': closing}"></div> <Modal :headerText="theme.name + ' Settings'" :close="attemptToClose" :class="{'bd-modal-out': modal.closing}">
<Modal :headerText="theme.name + ' Settings'" :close="attemptToClose" :class="{'bd-modal-out': closing}">
<SettingsPanel :settings="configCache" :change="settingChange" slot="body" class="bd-plugin-settings-body" /> <SettingsPanel :settings="configCache" :change="settingChange" slot="body" class="bd-plugin-settings-body" />
<div slot="footer" class="bd-footer-alert" :class ="{'bd-active': changed, 'bd-warn': warnclose}"> <div slot="footer" class="bd-footer-alert" :class ="{'bd-active': changed, 'bd-warn': warnclose}">
<div class="bd-footer-alert-text">Unsaved changes</div> <div class="bd-footer-alert-text">Unsaved changes</div>
@ -27,11 +26,11 @@
<script> <script>
// Imports // Imports
import Vue from 'vue'; import Vue from 'vue';
import { Modal } from '../common'; import { Modal } from '../../common';
import SettingsPanel from './SettingsPanel.vue'; import SettingsPanel from '../SettingsPanel.vue';
export default { export default {
props: ['theme', 'close'], props: ['modal'],
data() { data() {
return { return {
changed: false, changed: false,
@ -45,6 +44,9 @@
Modal, Modal,
SettingsPanel SettingsPanel
}, },
computed: {
theme() { return this.modal.theme; }
},
methods: { methods: {
checkForChanges() { checkForChanges() {
let changed = false; let changed = false;
@ -96,7 +98,7 @@
if (!this.changed) { if (!this.changed) {
this.closing = true; this.closing = true;
setTimeout(() => { setTimeout(() => {
this.close(); this.modal.close();
}, 200); }, 200);
return; return;
} }

View File

@ -12,6 +12,8 @@ import { FileUtils } from 'common';
import { Events, PluginManager, ThemeManager } from 'modules'; import { Events, PluginManager, ThemeManager } from 'modules';
import BasicModal from './components/bd/modals/BasicModal.vue'; import BasicModal from './components/bd/modals/BasicModal.vue';
import ErrorModal from './components/bd/modals/ErrorModal.vue'; import ErrorModal from './components/bd/modals/ErrorModal.vue';
import PluginSettingsModal from './components/bd/modals/PluginSettingsModal.vue';
import ThemeSettingsModal from './components/bd/modals/ThemeSettingsModal.vue';
export default class { export default class {
@ -76,6 +78,14 @@ export default class {
}); });
} }
static pluginSettings(plugin) {
return this.add({ plugin }, PluginSettingsModal);
}
static themeSettings(theme) {
return this.add({ theme }, ThemeSettingsModal);
}
static get stack() { static get stack() {
return this._stack ? this._stack : (this._stack = []); return this._stack ? this._stack : (this._stack = []);
} }