mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-22 01:12:17 +00:00
56 lines
1.3 KiB
JavaScript
56 lines
1.3 KiB
JavaScript
import ApiDashboardWidget from "../../../api/factory/dashboard/widget.js";
|
|
|
|
export default {
|
|
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;
|
|
|
|
this.$api
|
|
.call(ApiDashboardWidget.setAllowed(this.dashboard_id, widget_id, allow))
|
|
.catch(this.$fhcAlert.handleSystemError);
|
|
}
|
|
},
|
|
created() {
|
|
this.$api
|
|
.call(ApiDashboardWidget.list(this.dashboard_id))
|
|
.then(result => {
|
|
this.$emit('assignWidgets', result.data.map(el => ({
|
|
...el,
|
|
allowed: !!el.allowed
|
|
})));
|
|
})
|
|
.catch(this.$fhcAlert.handleSystemError);
|
|
},
|
|
template: /* html */`
|
|
<div class="dashboard-admin-widgets">
|
|
<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>`
|
|
}
|