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

(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/BaseResource.vue (-3 / +34 lines)
Lines 2-16 Link Here
2
import { inject } from "vue"
2
import { inject } from "vue"
3
3
4
export default {
4
export default {
5
    setup() {
5
    setup(props) {
6
        //global setup for all resource (list and show for now, but maybe others?) components here
6
        //global setup for all resource (list and show for now, but maybe others?) components here
7
        const { setConfirmationDialog, setMessage, setError } =
7
        const { setConfirmationDialog, setMessage, setError } =
8
            inject("mainStore")
8
            inject("mainStore")
9
        return { setConfirmationDialog, setMessage, setError }
9
        return { ...props, setConfirmationDialog, setMessage, setError }
10
    },
10
    },
11
    methods: {
11
    methods: {
12
        // goToResourceEdit: function () {},
12
        /**
13
         * Navigates to the edit page of the given resource.
14
         *
15
         * @param {Object} resource - The resource to navigate to (optional)
16
         * @return {void}
17
         */
18
        goToResourceEdit: function (resource) {
19
            this.$router.push({
20
                name: this.edit_component,
21
                params: {
22
                    [this.id_attr]: resource
23
                        ? resource[this.id_attr]
24
                        : this[this.resource_name][this.id_attr],
25
                },
26
            })
27
        },
28
        /**
29
         * Navigates to the creation page of the given resource.
30
         *
31
         * @return {void}
32
         */
33
        goToResourceAdd: function () {
34
            this.$router.push({
35
                name: this.add_component,
36
            })
37
        },
13
    },
38
    },
14
    name: "BaseResource",
39
    name: "BaseResource",
40
    props: {
41
        resource_name: String,
42
        id_attr: String,
43
        add_component: String,
44
        edit_component: String,
45
    },
15
}
46
}
16
</script>
47
</script>
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementResource.vue (-18 / +8 lines)
Lines 3-30 import BaseResource from "../BaseResource.vue" Link Here
3
3
4
export default {
4
export default {
5
    extends: BaseResource,
5
    extends: BaseResource,
6
    setup() {
6
    setup(props) {
7
        return {
7
        return {
8
            ...BaseResource.setup(),
8
            ...BaseResource.setup({
9
                resource_name: "agreement",
10
                id_attr: "agreement_id",
11
                add_component: "AgreementsFormAdd",
12
                edit_component: "AgreementsFormAddEdit",
13
            }),
9
            //AgreementResource specific setup here
14
            //AgreementResource specific setup here
10
        }
15
        }
11
    },
16
    },
12
    methods: {
17
    methods: {},
13
        /**
14
         * Navigates to the edit page of the given agreement.
15
         *
16
         * @param {Object} agreement - The agreement to navigate to (optional)
17
         * @return {void}
18
         */
19
        goToResourceEdit: function (agreement) {
20
            let agreement_id =
21
                agreement?.agreement_id || this.agreement.agreement_id
22
            this.$router.push({
23
                name: "AgreementsFormAddEdit",
24
                params: { agreement_id: agreement_id },
25
            })
26
        },
27
    },
28
    name: "AgreementResource",
18
    name: "AgreementResource",
29
}
19
}
30
</script>
20
</script>
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsList.vue (-6 / +1 lines)
Lines 4-10 Link Here
4
        <Toolbar v-if="!embedded">
4
        <Toolbar v-if="!embedded">
5
            <ToolbarButton
5
            <ToolbarButton
6
                action="add"
6
                action="add"
7
                @addResource="add_agreement"
7
                @go-to-add-resource="goToResourceAdd"
8
                :title="$__('New agreement')"
8
                :title="$__('New agreement')"
9
            />
9
            />
10
        </Toolbar>
10
        </Toolbar>
Lines 222-232 export default { Link Here
222
                    })
222
                    })
223
                })
223
                })
224
        },
224
        },
225
        add_agreement: function () {
226
            this.$router.push({
227
                name: "AgreementsFormAdd",
228
            })
229
        },
230
        doShow: function ({ agreement_id }, dt, event) {
225
        doShow: function ({ agreement_id }, dt, event) {
231
            event.preventDefault()
226
            event.preventDefault()
232
            this.$router.push({
227
            this.$router.push({
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsShow.vue (-2 / +8 lines)
Lines 2-9 Link Here
2
    <div v-if="!initialized">{{ $__("Loading") }}</div>
2
    <div v-if="!initialized">{{ $__("Loading") }}</div>
3
    <div v-else id="agreements_show">
3
    <div v-else id="agreements_show">
4
        <Toolbar>
4
        <Toolbar>
5
            <ToolbarButton action="edit" @editResource="goToResourceEdit" />
5
            <ToolbarButton
6
            <ToolbarButton action="delete" @deleteResource="delete_agreement" />
6
                action="edit"
7
                @go-to-edit-resource="goToResourceEdit"
8
            />
9
            <ToolbarButton
10
                action="delete"
11
                @delete_resource="delete_agreement"
12
            />
7
        </Toolbar>
13
        </Toolbar>
8
14
9
        <h2>
15
        <h2>
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ToolbarButton.vue (-5 / +7 lines)
Lines 1-16 Link Here
1
<template>
1
<template>
2
    <a v-if="action === 'add'" @click="$emit('addResource')" :class="class"
2
    <a
3
        v-if="action === 'add'"
4
        @click="$emit('go-to-add-resource')"
5
        :class="class"
3
        ><font-awesome-icon icon="plus" /> {{ title }}</a
6
        ><font-awesome-icon icon="plus" /> {{ title }}</a
4
    >
7
    >
5
    <a
8
    <a
6
        v-else-if="action === 'delete'"
9
        v-else-if="action === 'delete'"
7
        @click="$emit('deleteResource')"
10
        @click="$emit('delete-resource')"
8
        :class="class"
11
        :class="class"
9
        ><font-awesome-icon icon="trash" /> {{ $__("Delete") }}</a
12
        ><font-awesome-icon icon="trash" /> {{ $__("Delete") }}</a
10
    >
13
    >
11
    <a
14
    <a
12
        v-else-if="action === 'edit'"
15
        v-else-if="action === 'edit'"
13
        @click="$emit('editResource')"
16
        @click="$emit('go-to-edit-resource')"
14
        :class="class"
17
        :class="class"
15
        ><font-awesome-icon icon="pencil" /> {{ $__("Edit") }}</a
18
        ><font-awesome-icon icon="pencil" /> {{ $__("Edit") }}</a
16
    >
19
    >
Lines 39-45 export default { Link Here
39
            type: String,
42
            type: String,
40
        },
43
        },
41
    },
44
    },
42
    emits: ["addResource", "deleteResource", "editResource"],
45
    emits: ["go-to-add-resource", "go-to-edit-resource", "delete-resource"],
43
    name: "Toolbar",
46
    name: "Toolbar",
44
}
47
}
45
</script>
48
</script>
46
- 

Return to bug 37301