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

(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/BaseResource.vue (+16 lines)
Line 0 Link Here
1
<script>
2
import { inject } from "vue"
3
4
export default {
5
    setup() {
6
        //global setup for all resource (list and show for now, but maybe others?) components here
7
        const { setConfirmationDialog, setMessage, setError } =
8
            inject("mainStore")
9
        return { setConfirmationDialog, setMessage, setError }
10
    },
11
    methods: {
12
        // goToResourceEdit: function () {},
13
    },
14
    name: "BaseResource",
15
}
16
</script>
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementResource.vue (+30 lines)
Line 0 Link Here
1
<script>
2
import BaseResource from "../BaseResource.vue"
3
4
export default {
5
    extends: BaseResource,
6
    setup() {
7
        return {
8
            ...BaseResource.setup(),
9
            //AgreementResource specific setup here
10
        }
11
    },
12
    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",
29
}
30
</script>
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsList.vue (-7 / +4 lines)
Lines 44-50 Link Here
44
                ref="table"
44
                ref="table"
45
                v-bind="tableOptions"
45
                v-bind="tableOptions"
46
                @show="doShow"
46
                @show="doShow"
47
                @edit="doEdit"
47
                @edit="goToResourceEdit"
48
                @delete="doDelete"
48
                @delete="doDelete"
49
                @select="doSelect"
49
                @select="doSelect"
50
            ></KohaTable>
50
            ></KohaTable>
Lines 64-71 import { APIClient } from "../../fetch/api-client.js" Link Here
64
import { storeToRefs } from "pinia"
64
import { storeToRefs } from "pinia"
65
import { build_url } from "../../composables/datatables"
65
import { build_url } from "../../composables/datatables"
66
import KohaTable from "../KohaTable.vue"
66
import KohaTable from "../KohaTable.vue"
67
import AgreementResource from "./AgreementResource.vue"
67
68
68
export default {
69
export default {
70
    extends: AgreementResource,
69
    setup() {
71
    setup() {
70
        const vendorStore = inject("vendorStore")
72
        const vendorStore = inject("vendorStore")
71
        const { vendors } = storeToRefs(vendorStore)
73
        const { vendors } = storeToRefs(vendorStore)
Lines 83-88 export default { Link Here
83
            by_mine: false,
85
            by_mine: false,
84
        })
86
        })
85
        return {
87
        return {
88
            ...AgreementResource.setup(),
86
            vendors,
89
            vendors,
87
            get_lib_from_av,
90
            get_lib_from_av,
88
            map_av_dt_filter,
91
            map_av_dt_filter,
Lines 186-197 export default { Link Here
186
                params: { agreement_id },
189
                params: { agreement_id },
187
            })
190
            })
188
        },
191
        },
189
        doEdit: function ({ agreement_id }, dt, event) {
190
            this.$router.push({
191
                name: "AgreementsFormAddEdit",
192
                params: { agreement_id },
193
            })
194
        },
195
        doDelete: function (agreement, dt, event) {
192
        doDelete: function (agreement, dt, event) {
196
            this.setConfirmationDialog(
193
            this.setConfirmationDialog(
197
                {
194
                {
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsShow.vue (-8 / +4 lines)
Lines 2-8 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="edit_agreement" />
5
            <ToolbarButton action="edit" @editResource="goToResourceEdit" />
6
            <ToolbarButton action="delete" @deleteResource="delete_agreement" />
6
            <ToolbarButton action="delete" @deleteResource="delete_agreement" />
7
        </Toolbar>
7
        </Toolbar>
8
8
Lines 325-332 import { inject } from "vue" Link Here
325
import { APIClient } from "../../fetch/api-client.js"
325
import { APIClient } from "../../fetch/api-client.js"
326
import Toolbar from "../Toolbar.vue"
326
import Toolbar from "../Toolbar.vue"
327
import ToolbarButton from "../ToolbarButton.vue"
327
import ToolbarButton from "../ToolbarButton.vue"
328
import AgreementResource from "./AgreementResource.vue"
328
329
329
export default {
330
export default {
331
    extends: AgreementResource,
330
    setup() {
332
    setup() {
331
        const format_date = $date
333
        const format_date = $date
332
        const patron_to_html = $patron_to_html
334
        const patron_to_html = $patron_to_html
Lines 337-342 export default { Link Here
337
        const { get_lib_from_av } = AVStore
339
        const { get_lib_from_av } = AVStore
338
340
339
        return {
341
        return {
342
            ...AgreementResource.setup(),
340
            format_date,
343
            format_date,
341
            patron_to_html,
344
            patron_to_html,
342
            get_lib_from_av,
345
            get_lib_from_av,
Lines 383-394 export default { Link Here
383
                error => {}
386
                error => {}
384
            )
387
            )
385
        },
388
        },
386
        edit_agreement: function () {
387
            this.$router.push({
388
                name: "AgreementsFormAddEdit",
389
                params: { agreement_id: this.agreement.agreement_id },
390
            })
391
        },
392
        delete_agreement: function () {
389
        delete_agreement: function () {
393
            let agreement_id = this.agreement.agreement_id
390
            let agreement_id = this.agreement.agreement_id
394
            let agreement_name = this.agreement.name
391
            let agreement_name = this.agreement.name
395
- 

Return to bug 37301