From cdf63840b01ef483e12ecbd09890b2399637a101 Mon Sep 17 00:00:00 2001 From: chfhtw Date: Mon, 20 Apr 2026 14:30:31 +0200 Subject: [PATCH] simplify widgetAdd, widgetUpdate and widgetRemove --- public/js/components/Dashboard/Admin/Presets.js | 7 +++---- public/js/components/Dashboard/Dashboard.js | 12 +++++------- public/js/components/Dashboard/Section.js | 8 +++----- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/public/js/components/Dashboard/Admin/Presets.js b/public/js/components/Dashboard/Admin/Presets.js index a28a8afc6..a66159466 100644 --- a/public/js/components/Dashboard/Admin/Presets.js +++ b/public/js/components/Dashboard/Admin/Presets.js @@ -23,7 +23,7 @@ export default { } }, methods: { - widgetAdd(section_name, widget) { + widgetAdd(widget, section_name) { this.$refs.widgetpicker.getWidget().then(widget_id => { widget.widget = widget_id; widget.id = 'loading_' + String((new Date()).valueOf()); @@ -64,8 +64,7 @@ export default { }) .catch(() => {}); }, - widgetUpdate(section_name, payload) { - payload = payload[section_name]; + widgetUpdate(payload, section_name) { for (var k in payload) { const section = this.sections.find(section => section.name == section_name); for (var wid in section.widgets) { @@ -105,7 +104,7 @@ export default { }) .catch(this.$fhcAlert.handleSystemError); }, - widgetRemove(section_name, id) { + widgetRemove(id, section_name) { const params = { db: this.dashboard, funktion_kurzbz: section_name, diff --git a/public/js/components/Dashboard/Dashboard.js b/public/js/components/Dashboard/Dashboard.js index 94b3621d6..f9fff9925 100644 --- a/public/js/components/Dashboard/Dashboard.js +++ b/public/js/components/Dashboard/Dashboard.js @@ -40,8 +40,7 @@ export default { } }, methods: { - widgetAdd(section_name, widget) { - // TODO(chris): remove section_name? (change order of params => get rid of it) + widgetAdd(widget) { this.$refs.widgetpicker .getWidget() .then(widget_id => { @@ -63,8 +62,7 @@ export default { }) .catch(() => {}); }, - widgetUpdate(section_name, payload) { - payload = payload[section_name]; + widgetUpdate(payload) { for (var k in payload) { for (var wid in this.widgets) { if (this.widgets[wid].id == k) { @@ -112,7 +110,7 @@ export default { }) .catch(this.$fhcAlert.handleSystemError); }, - widgetRemove(section_name, id) { + widgetRemove(id) { this.$api .call(ApiDashboardUser.removeWidget(this.dashboard, id)) .then(() => { @@ -148,7 +146,7 @@ export default { } } - remove.forEach(wid => this.widgetRemove('general', wid)); + remove.forEach(wid => this.widgetRemove(wid)); this.widgets = widgets; }) @@ -160,7 +158,7 @@ export default { {{ $p.t('global/personalGreeting', [ viewData?.name ]) }} - + ` } diff --git a/public/js/components/Dashboard/Section.js b/public/js/components/Dashboard/Section.js index cfb8dae05..c2342e7d6 100644 --- a/public/js/components/Dashboard/Section.js +++ b/public/js/components/Dashboard/Section.js @@ -133,7 +133,7 @@ export default { }, removeWidget(item, revert) { if (item.custom) { - BsConfirm.popup(this.$p.t('dashboard', 'alert_deleteWidget')).then(() => this.$emit('widgetRemove', this.name, item.id)); + BsConfirm.popup(this.$p.t('dashboard', 'alert_deleteWidget')).then(() => this.$emit('widgetRemove', item.id, this.name)); } else { let update = {}; update[item.id] = { hidden: !revert }; @@ -187,9 +187,7 @@ export default { this.updatePreset(result); }, updatePreset(update) { - let payload = {}; - payload[this.name] = update; - this.$emit('widgetUpdate', this.name, payload); + this.$emit('widgetUpdate', update, this.name); } }, mounted() { @@ -230,7 +228,7 @@ export default {