code quality

This commit is contained in:
chfhtw
2026-04-21 09:34:15 +02:00
parent 28d65ac114
commit 89e0326435
4 changed files with 164 additions and 49 deletions
+88 -25
View File
@@ -33,33 +33,32 @@ export default {
methods: {
dashboardAdd() {
let _name = '';
BsPrompt.popup('New Dashboard name').then(
name => {
_name = name;
BsPrompt
.popup('New Dashboard name')
.then(dashboard_kurzbz => {
const params = {
dashboard_kurzbz: name
dashboard_kurzbz
};
return this.$api
.call(ApiDashboardBoard.add(params))
.then(response =>{
.then(response => {
this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave'));
let newDashboard = {
dashboard_id: response.data,
dashboard_kurzbz: _name,
dashboard_kurzbz,
beschreibung: ''
};
this.dashboards.push(newDashboard);
this.current = newDashboard.dashboard_id;
})
.catch(this.$fhcAlert.handleSystemError);
});
});
},
dashboardUpdate(dashboard) {
return this.$api
this.$api
.call(ApiDashboardBoard.update(dashboard))
.then(response => {
this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave'));
let old = this.dashboards.find(el => el.dashboard_id == dashboard.dashboard_id);
@@ -69,10 +68,11 @@ export default {
.catch(this.$fhcAlert.handleSystemError);
},
dashboardDelete(dashboard_id) {
return this.$api
this.$api
.call(ApiDashboardBoard.delete(dashboard_id))
.then(response => {
this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successDelete'));
this.current = -1;
this.dashboards = this.dashboards.filter(el => el.dashboard_id != dashboard_id);
})
@@ -90,37 +90,100 @@ export default {
})
.catch(this.$fhcAlert.handleSystemError);
},
template: `<div class="dashboard-admin">
template: /* html */`
<div class="dashboard-admin">
<div class="input-group">
<label for="dashboard-select" class="input-group-text">Dashboard:</label>
<select id="dashboard-select" class="form-select" v-model="current">
<option v-for="dashboard in dashboards" :key="dashboard.dashboard_id" :value="dashboard.dashboard_id">{{dashboard.dashboard_kurzbz}}</option>
<label for="dashboard-select" class="input-group-text">
Dashboard:
</label>
<select id="dashboard-select" v-model="current" class="form-select">
<option
v-for="dashboard in dashboards"
:key="dashboard.dashboard_id"
:value="dashboard.dashboard_id"
>{{ dashboard.dashboard_kurzbz }}</option>
</select>
<button class="btn btn-outline-secondary" type="button" @click="dashboardAdd"><i class="fa-solid fa-plus"></i></button>
<button
class="btn btn-outline-secondary"
type="button"
@click="dashboardAdd"
><i class="fa-solid fa-plus"></i></button>
</div>
<div v-if="dashboard">
<ul class="nav nav-tabs mt-3" role="tablist">
<li class="nav-item" role="presentation">
<button class="nav-link" id="edit-tab" data-bs-toggle="tab" data-bs-target="#edit" type="button" role="tab" aria-controls="edit" aria-selected="false">{{this.$p.t('ui', 'bearbeiten')}}</button>
<button
id="edit-tab"
class="nav-link"
data-bs-toggle="tab"
data-bs-target="#edit"
type="button"
role="tab"
aria-controls="edit"
aria-selected="false"
>{{ this.$p.t('ui', 'bearbeiten') }}</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link active" id="widgets-tab" data-bs-toggle="tab" data-bs-target="#widgets" type="button" role="tab" aria-controls="widgets" aria-selected="true">Widgets</button>
<button
id="widgets-tab"
class="nav-link active"
data-bs-toggle="tab"
data-bs-target="#widgets"
type="button"
role="tab"
aria-controls="widgets"
aria-selected="true"
>Widgets</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="presets-tab" data-bs-toggle="tab" data-bs-target="#presets" type="button" role="tab" aria-controls="presets" aria-selected="false">Presets</button>
<button
class="nav-link"
id="presets-tab"
data-bs-toggle="tab"
data-bs-target="#presets"
type="button"
role="tab"
aria-controls="presets"
aria-selected="false"
>Presets</button>
</li>
</ul>
<div class="tab-content pt-3">
<div class="tab-pane fade" id="edit" role="tabpanel" aria-labelledby="edit-tab">
<dashboard-admin-edit v-bind="dashboard" :key="dashboard.dashboard_id" @change="dashboardUpdate($event)" @delete="dashboardDelete($event)"></dashboard-admin-edit>
<div
id="edit"
class="tab-pane fade"
role="tabpanel"
aria-labelledby="edit-tab"
>
<dashboard-admin-edit
v-bind="dashboard"
@change="dashboardUpdate($event)"
@delete="dashboardDelete($event)"
></dashboard-admin-edit>
</div>
<div class="tab-pane fade show active" id="widgets" role="tabpanel" aria-labelledby="widgets-tab">
<dashboard-admin-widgets :key="dashboard.dashboard_id" :dashboard_id="dashboard.dashboard_id" :widgets="widgets" @assign-widgets="assignWidgets"></dashboard-admin-widgets>
<div
id="widgets"
class="tab-pane fade show active"
role="tabpanel"
aria-labelledby="widgets-tab"
>
<dashboard-admin-widgets
:dashboard_id="dashboard.dashboard_id"
:widgets="widgets"
@assign-widgets="assignWidgets"
></dashboard-admin-widgets>
</div>
<div class="tab-pane fade" id="presets" role="tabpanel" aria-labelledby="presets-tab">
<dashboard-admin-presets :dashboard="dashboard.dashboard_kurzbz" :widgets="widgets"></dashboard-admin-presets>
<div
id="presets"
class="tab-pane fade"
role="tabpanel"
aria-labelledby="presets-tab"
>
<dashboard-admin-presets
:dashboard="dashboard.dashboard_kurzbz"
:widgets="widgets"
></dashboard-admin-presets>
</div>
</div>
</div>
+32 -11
View File
@@ -1,15 +1,15 @@
import BsConfirm from '../../Bootstrap/Confirm.js';
export default {
emits: [
"change",
"delete"
],
props: {
dashboard_id: Number,
dashboard_kurzbz: String,
beschreibung: String
},
emits: [
"change",
"delete"
],
data() {
return {
kurzbz: this.dashboard_kurzbz,
@@ -18,22 +18,43 @@ export default {
},
methods: {
sendDelete() {
BsConfirm.popup(this.$p.t('ui', 'confirm_delete') + " " + this.$p.t('ui', 'deleteInfo'))
.then(() => this.$emit('delete', this.dashboard_id)).catch();
BsConfirm
.popup(this.$p.t('ui', 'confirm_delete') + " " + this.$p.t('ui', 'deleteInfo'))
.then(() => this.$emit('delete', this.dashboard_id))
.catch();
}
},
template: `<div class="dashboard-admin-edit px-3">
template: /* html */`
<div class="dashboard-admin-edit px-3">
<div class="mb-3">
<label for="dashboard-admin-edit-kurzbz">Kurz Bezeichnung</label>
<input id="dashboard-admin-edit-kurzbz" type="text" class="form-control" v-model="kurzbz">
<input
id="dashboard-admin-edit-kurzbz"
v-model="kurzbz"
type="text"
class="form-control"
>
</div>
<div class="mb-3">
<label for="dashboard-admin-edit-beschreibung">Beschreibung</label>
<textarea id="dashboard-admin-edit-beschreibung" class="form-control" v-model="desc"></textarea>
<textarea
id="dashboard-admin-edit-beschreibung"
v-model="desc"
class="form-control"
></textarea>
</div>
<div>
<button class="btn btn-danger" @click="sendDelete">{{this.$p.t('ui', 'loeschen')}}</button>
<button class="btn btn-primary" @click="$emit('change', {dashboard_id,dashboard_kurzbz:kurzbz,beschreibung:desc})">{{this.$p.t('ui', 'btnAktualisieren')}}</button>
<button class="btn btn-danger" @click="sendDelete">
{{ this.$p.t('ui', 'loeschen') }}
</button>
<button
class="btn btn-primary"
@click="$emit('change', {
dashboard_id
dashboard_kurzbz: kurzbz,
beschreibung: desc
})"
>{{ this.$p.t('ui', 'btnAktualisieren') }}</button>
</div>
</div>`
}
@@ -1,14 +1,14 @@
import ApiDashboardWidget from "../../../api/factory/dashboard/widget.js";
export default {
emits: [
"change",
"assignWidgets"
],
props: {
dashboard_id: Number,
widgets: Array
},
emits: [
"change",
"assignWidgets"
],
methods: {
sendChange(widget_id) {
let allow = !this.widgets.find(el => el.widget_id == widget_id).allowed;
@@ -29,11 +29,27 @@ export default {
})
.catch(this.$fhcAlert.handleSystemError);
},
template: `
template: /* html */`
<div class="dashboard-admin-widgets">
<div v-for="widget in widgets" :key="widget.widget_id" class="form-check form-switch">
<input class="form-check-input" type="checkbox" role="switch" :id="'dashboard-admin-widgets-' + widget.widget_id" v-model="widget.allowed" @input.prevent="sendChange(widget.widget_id)">
<label class="form-check-label" :for="'dashboard-admin-widgets-' + widget.widget_id">{{(widget.setup && widget.setup.name) || widget.widget_kurzbz}}</label>
<div
v-for="widget in widgets"
:key="widget.widget_id"
class="form-check form-switch"
>
<input
:id="'dashboard-admin-widgets-' + widget.widget_id"
v-model="widget.allowed"
class="form-check-input"
type="checkbox"
role="switch"
@input.prevent="sendChange(widget.widget_id)"
>
<label
class="form-check-label"
:for="'dashboard-admin-widgets-' + widget.widget_id"
>
{{ (widget.setup && widget.setup.name) || widget.widget_kurzbz }}
</label>
</div>
</div>`
}
+20 -5
View File
@@ -35,7 +35,7 @@ export default {
},
provide() {
return {
editMode: Vue.computed(()=>this.editMode),
editMode: Vue.computed(() => this.editMode),
widgetsSetup: Vue.computed(() => this.widgetsSetup)
}
},
@@ -152,13 +152,28 @@ export default {
})
.catch(this.$fhcAlert.handleSystemError);
},
template: `
template: /* html */`
<div class="core-dashboard">
<h3>
{{ $p.t('global/personalGreeting', [ viewData?.name ]) }}
<button style="margin-left: 8px;" class="btn" @click="editMode = !editMode" aria-label="edit dashboard" v-tooltip="{showDelay:1000,value:'edit dashboard'}"><i class="fa-solid fa-gear" aria-hidden="true"></i></button>
<button
class="btn ms-2"
aria-label="edit dashboard"
v-tooltip="{ showDelay: 1000, value: 'edit dashboard' }"
@click="editMode = !editMode"
><i class="fa-solid fa-gear" aria-hidden="true"></i></button>
</h3>
<dashboard-section :seperator="0" name="general" :widgets="widgets" @widget-add="widgetAdd" @widget-update="widgetUpdate" @widget-remove="widgetRemove"></dashboard-section>
<dashboard-widget-picker ref="widgetpicker" :widgets="widgetsSetup"></dashboard-widget-picker>
<dashboard-section
name="general"
:seperator="0"
:widgets="widgets"
@widget-add="widgetAdd"
@widget-update="widgetUpdate"
@widget-remove="widgetRemove"
></dashboard-section>
<dashboard-widget-picker
ref="widgetpicker"
:widgets="widgetsSetup"
></dashboard-widget-picker>
</div>`
}