From a6d54924b99be94007d2d40a3d4d74de56585caf Mon Sep 17 00:00:00 2001 From: Remko Date: Tue, 22 Oct 2024 17:45:05 +0200 Subject: [PATCH] Semi fixed settings page --- appinfo/routes.php | 3 + lib/Controller/SettingsController.php | 2 +- src/settings.js | 6 +- src/views/settings/Settings.vue | 127 ++++++++++++++++++++------ 4 files changed, 108 insertions(+), 30 deletions(-) diff --git a/appinfo/routes.php b/appinfo/routes.php index e87c1c4..b1cc408 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -38,5 +38,8 @@ ['name' => 'taken#page','url' => '/taken', 'verb' => 'GET'], ['name' => 'klanten#page','url' => '/klanten', 'verb' => 'GET'], ['name' => 'berichten#index','url' => '/berichten', 'verb' => 'GET'], + // user Settings + ['name' => 'settings#index','url' => '/settings', 'verb' => 'GET'], + ['name' => 'settings#create', 'url' => '/settings', 'verb' => 'POST'], ] ]; diff --git a/lib/Controller/SettingsController.php b/lib/Controller/SettingsController.php index c38fbd4..e6c57ba 100644 --- a/lib/Controller/SettingsController.php +++ b/lib/Controller/SettingsController.php @@ -7,7 +7,7 @@ use OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\Http\JSONResponse; use OCP\IRequest; -use OCA\OpenCatalogi\Service\ObjectService; +use OCA\ZaakAfhandelApp\Service\ObjectService; /** * Class SettingsController diff --git a/src/settings.js b/src/settings.js index 75d607a..138884e 100644 --- a/src/settings.js +++ b/src/settings.js @@ -1,10 +1,10 @@ import Vue from 'vue' -import AdminSettings from './views/settings/Settings.vue' +import Settings from './views/settings/Settings.vue' Vue.mixin({ methods: { t, n } }) new Vue( { - render: h => h(AdminSettings), + render: h => h(Settings), }, -).$mount('#admin-settings') +).$mount('#settings') diff --git a/src/views/settings/Settings.vue b/src/views/settings/Settings.vue index 27ff42e..f971fba 100644 --- a/src/views/settings/Settings.vue +++ b/src/views/settings/Settings.vue @@ -42,33 +42,33 @@
+ :loading="getDataProperty(objectType.id).loading" + :disabled="loading || getDataProperty(objectType.id).loading" /> - + :loading="getDataProperty(objectType.id).loading" + :disabled="loading || getDataProperty(objectType.id).loading" /> - + :loading="getDataProperty(objectType.id).loading" + :disabled="loading || getDataProperty(objectType.id).loading" /> Opslaan @@ -91,7 +91,7 @@ import Plus from 'vue-material-design-icons/Plus.vue' import Restart from 'vue-material-design-icons/Restart.vue' export default { - name: 'AdminSettings', + name: 'Settings', components: { NcSettingsSection, NcNoteCard, @@ -109,7 +109,77 @@ export default { saving: false, settingsData: {}, availableRegisters: [], - objectTypes: {}, + objectTypes: [], + berichten: { + selectedSource: '', + selectedRegister: '', + selectedSchema: '', + availableSchemas: [], + loading: false, + }, + besluiten: { + selectedSource: '', + selectedRegister: '', + selectedSchema: '', + availableSchemas: [], + loading: false, + }, + documenten: { + selectedSource: '', + selectedRegister: '', + selectedSchema: '', + availableSchemas: [], + loading: false, + }, + klanten: { + selectedSource: '', + selectedRegister: '', + selectedSchema: '', + availableSchemas: [], + loading: false, + }, + resultaten: { + selectedSource: '', + selectedRegister: '', + selectedSchema: '', + availableSchemas: [], + loading: false, + }, + taken: { + selectedSource: '', + selectedRegister: '', + selectedSchema: '', + availableSchemas: [], + loading: false, + }, + informatieobjecten: { + selectedSource: '', + selectedRegister: '', + selectedSchema: '', + availableSchemas: [], + loading: false, + }, + organisaties: { + selectedSource: '', + selectedRegister: '', + selectedSchema: '', + availableSchemas: [], + loading: false, + }, + personen: { + selectedSource: '', + selectedRegister: '', + selectedSchema: '', + availableSchemas: [], + loading: false, + }, + themas: { + selectedSource: '', + selectedRegister: '', + selectedSchema: '', + availableSchemas: [], + loading: false, + }, labelOptions: { options: [ { label: 'Internal', value: 'internal' }, @@ -136,6 +206,10 @@ export default { this.fetchAll() }, methods: { + getDataProperty(name) { + return this[name] + + }, setRegisterSchemaOptions(registerId, property) { const selectedRegister = this.settingsData.availableRegisters.find((register) => register.id.toString() === registerId) @@ -149,7 +223,7 @@ export default { fetchAll() { this.loading = true - fetch('/index.php/apps/opencatalogi/settings', + fetch('/index.php/apps/zaakafhandelapp/settings', { method: 'GET', }, @@ -160,6 +234,7 @@ export default { this.openRegisterInstalled = data.openRegisters this.settingsData = data this.availableRegisters = data.availableRegisters + this.objectTypes = data.objectTypes this.availableRegisters = { options: data.availableRegisters.map((register) => ({ @@ -193,9 +268,9 @@ export default { }) }, saveConfig(configId) { - this.objectTypes[configId].loading = true + this[configId].loading = true this.saving = true - console.log(`Saving ${configId} config`) + console.info(`Saving ${configId} config`) const settingsDataCopy = this.settingsData @@ -203,14 +278,14 @@ export default { delete settingsDataCopy.openRegisters delete settingsDataCopy.availableRegisters - fetch('/index.php/apps/opencatalogi/settings', + fetch('/index.php/apps/zaakafhandelapp/settings', { method: 'POST', body: JSON.stringify({ ...settingsDataCopy, - [configId + '_register']: this.objectTypes[configId].selectedRegister?.value ?? '', - [configId + '_schema']: this.objectTypes[configId].selectedSchema?.value ?? '', - [configId + '_source']: this.objectTypes[configId].selectedSource?.value ?? 'internal', + [configId + '_register']: this[configId].selectedRegister?.value ?? '', + [configId + '_schema']: this[configId].selectedSchema?.value ?? '', + [configId + '_source']: this[configId].selectedSource?.value ?? 'internal', }), headers: { 'Content-Type': 'application/json', @@ -219,7 +294,7 @@ export default { ) .then((response) => { response.json().then((data) => { - this.objectTypes[configId].loading = false + this[configId].loading = false this.saving = false this.settingsData = { @@ -232,7 +307,7 @@ export default { }) .catch((err) => { console.error(err) - this.objectTypes[configId].loading = false + this[configId].loading = false this.saving = false return err }) @@ -253,7 +328,7 @@ export default { return acc }, {}) - fetch('/index.php/apps/opencatalogi/settings', + fetch('/index.php/apps/zaakafhandelapp/settings', { method: 'POST', body: JSON.stringify({