View | Details | Raw Unified | Return to bug 39320
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ModuleDashboard/ModuleDashboard.vue (-7 / +5 lines)
Lines 56-68 Link Here
56
<script>
56
<script>
57
import { onMounted, ref, watch, inject } from "vue";
57
import { onMounted, ref, watch, inject } from "vue";
58
import WidgetPicker from "./WidgetPicker.vue";
58
import WidgetPicker from "./WidgetPicker.vue";
59
import VueCookies from "vue-cookies";
60
import { $__ } from "@koha-vue/i18n";
59
import { $__ } from "@koha-vue/i18n";
61
import { VueDraggableNext } from "vue-draggable-next";
60
import { VueDraggableNext } from "vue-draggable-next";
62
61
63
export default {
62
export default {
64
    props: {
63
    props: {
65
        availableWidgets: Array
64
        availableWidgets: Array,
66
    },
65
    },
67
    setup(props) {
66
    setup(props) {
68
        const availableWidgets = props.availableWidgets;
67
        const availableWidgets = props.availableWidgets;
Lines 186-194 export default { Link Here
186
        };
185
        };
187
186
188
        onMounted(() => {
187
        onMounted(() => {
189
            const storedWidgets = VueCookies.get("dashboard-widgets");
188
            const storedWidgets = localStorage.getItem("dashboard-widgets");
190
            if (storedWidgets) {
189
            if (storedWidgets) {
191
                const { left, right } = storedWidgets;
190
                const { left, right } = JSON.parse(storedWidgets);
192
                left.forEach(widgetName => {
191
                left.forEach(widgetName => {
193
                    const widget = availableWidgets.find(
192
                    const widget = availableWidgets.find(
194
                        widget => widget.name === widgetName
193
                        widget => widget.name === widgetName
Lines 215-227 export default { Link Here
215
            ([left, right]) => {
214
            ([left, right]) => {
216
                const leftWidgetNames = left.map(widget => widget.name);
215
                const leftWidgetNames = left.map(widget => widget.name);
217
                const rightWidgetNames = right.map(widget => widget.name);
216
                const rightWidgetNames = right.map(widget => widget.name);
218
                VueCookies.set(
217
                localStorage.setItem(
219
                    "dashboard-widgets",
218
                    "dashboard-widgets",
220
                    JSON.stringify({
219
                    JSON.stringify({
221
                        left: leftWidgetNames,
220
                        left: leftWidgetNames,
222
                        right: rightWidgetNames,
221
                        right: rightWidgetNames,
223
                    }),
222
                    })
224
                    "30d"
225
                );
223
                );
226
            },
224
            },
227
            { deep: true }
225
            { deep: true }
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/composables/base-widget.js (-9 / +7 lines)
Lines 1-6 Link Here
1
// composables/useBaseWidget.js
1
// composables/useBaseWidget.js
2
import { ref, computed, watch, provide, onMounted, onBeforeMount } from "vue";
2
import { ref, computed, watch, provide, onMounted, onBeforeMount } from "vue";
3
import VueCookies from "vue-cookies";
4
3
5
export function useBaseWidget(widgetConfig, emit) {
4
export function useBaseWidget(widgetConfig, emit) {
6
    const loading = ref(
5
    const loading = ref(
Lines 37-53 export function useBaseWidget(widgetConfig, emit) { Link Here
37
    }));
36
    }));
38
37
39
    const getWidgetSavedSettings = () => {
38
    const getWidgetSavedSettings = () => {
40
        const cookie = VueCookies.get(
39
        const savedSettings = localStorage.getItem(
41
            "widget-" + widgetConfig.id + "-settings"
40
            "widget-" + widgetConfig.id + "-settings"
42
        );
41
        );
43
        return cookie || null;
42
        return savedSettings || null;
44
    };
43
    };
45
44
46
    onBeforeMount(() => {
45
    onBeforeMount(() => {
47
        if (widgetConfig.display === "dashboard") {
46
        if (widgetConfig.display === "dashboard") {
48
            const cookie = getWidgetSavedSettings();
47
            const savedSettings = getWidgetSavedSettings();
49
            if (cookie) {
48
            if (savedSettings) {
50
                settings.value = cookie;
49
                settings.value = savedSettings;
51
            }
50
            }
52
        }
51
        }
53
    });
52
    });
Lines 74-83 export function useBaseWidget(widgetConfig, emit) { Link Here
74
        settings,
73
        settings,
75
        newSettings => {
74
        newSettings => {
76
            if (widgetConfig.display === "dashboard" && newSettings !== null) {
75
            if (widgetConfig.display === "dashboard" && newSettings !== null) {
77
                VueCookies.set(
76
                localStorage.setItem(
78
                    "widget-" + widgetConfig.id + "-settings",
77
                    "widget-" + widgetConfig.id + "-settings",
79
                    JSON.stringify(newSettings),
78
                    JSON.stringify(newSettings)
80
                    "30d"
81
                );
79
                );
82
            }
80
            }
83
        },
81
        },
(-)a/package.json (-2 lines)
Lines 40-46 Link Here
40
    "sass": "^1.58.1",
40
    "sass": "^1.58.1",
41
    "style-loader": "^3.3.1",
41
    "style-loader": "^3.3.1",
42
    "vue": "^3.5.4",
42
    "vue": "^3.5.4",
43
    "vue-cookies": "^1.8.6",
44
    "vue-draggable-next": "^2.2.1",
43
    "vue-draggable-next": "^2.2.1",
45
    "vue-flatpickr-component": "^9",
44
    "vue-flatpickr-component": "^9",
46
    "vue-router": "^4.0.14",
45
    "vue-router": "^4.0.14",
47
- 

Return to bug 39320