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

(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalTitleResource.vue (+30 lines)
Line 0 Link Here
1
<script>
2
import BaseResource from "../BaseResource.vue"
3
import { APIClient } from "../../fetch/api-client.js"
4
5
export default {
6
    extends: BaseResource,
7
    setup(props) {
8
        return {
9
            ...BaseResource.setup({
10
                resource_name: "title",
11
                name_attr: "publication_title",
12
                id_attr: "title_id",
13
                show_component: "EHoldingsLocalTitlesShow",
14
                list_component: "EHoldingsLocalTitlesList",
15
                add_component: "EHoldingsLocalTitlesFormAdd",
16
                edit_component: "EHoldingsLocalTitlesFormAddEdit",
17
                api_client: APIClient.erm.localTitles,
18
                resource_table_url:
19
                    APIClient.erm._baseURL + "eholdings/local/titles",
20
                i18n: {
21
                    display_name: __("Local title"),
22
                },
23
            }),
24
            //EHoldingsLocalTitleResource specific setup here
25
        }
26
    },
27
    methods: {},
28
    name: "EHoldingsLocalTitleResource",
29
}
30
</script>
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalTitlesList.vue (-53 / +10 lines)
Lines 4-11 Link Here
4
        <div v-else id="titles_list">
4
        <div v-else id="titles_list">
5
            <Toolbar>
5
            <Toolbar>
6
                <ToolbarButton
6
                <ToolbarButton
7
                    :to="{ name: 'EHoldingsLocalTitlesFormAdd' }"
7
                    action="add"
8
                    icon="plus"
8
                    @go-to-add-resource="goToResourceAdd"
9
                    :title="$__('New title')"
9
                    :title="$__('New title')"
10
                />
10
                />
11
                <ToolbarButton
11
                <ToolbarButton
Lines 27-35 Link Here
27
                <KohaTable
27
                <KohaTable
28
                    ref="table"
28
                    ref="table"
29
                    v-bind="tableOptions"
29
                    v-bind="tableOptions"
30
                    @show="doShow"
30
                    @show="goToResourceShow"
31
                    @edit="doEdit"
31
                    @edit="goToResourceEdit"
32
                    @delete="doDelete"
32
                    @delete="doResourceDelete"
33
                ></KohaTable>
33
                ></KohaTable>
34
            </div>
34
            </div>
35
            <div v-else class="alert alert-info">
35
            <div v-else class="alert alert-info">
Lines 46-60 import { inject, ref, reactive } from "vue" Link Here
46
import { storeToRefs } from "pinia"
46
import { storeToRefs } from "pinia"
47
import { APIClient } from "../../fetch/api-client.js"
47
import { APIClient } from "../../fetch/api-client.js"
48
import KohaTable from "../KohaTable.vue"
48
import KohaTable from "../KohaTable.vue"
49
import EHoldingsLocalTitleResource from "./EHoldingsLocalTitleResource.vue"
49
50
50
export default {
51
export default {
52
    extends: EHoldingsLocalTitleResource,
51
    setup() {
53
    setup() {
52
        const AVStore = inject("AVStore")
54
        const AVStore = inject("AVStore")
53
        const { av_title_publication_types } = storeToRefs(AVStore)
55
        const { av_title_publication_types } = storeToRefs(AVStore)
54
        const { get_lib_from_av, map_av_dt_filter } = AVStore
56
        const { get_lib_from_av, map_av_dt_filter } = AVStore
55
57
56
        const { setConfirmationDialog, setMessage } = inject("mainStore")
57
58
        const table = ref()
58
        const table = ref()
59
        const filters = reactive({
59
        const filters = reactive({
60
            publication_title: "",
60
            publication_title: "",
Lines 62-75 export default { Link Here
62
        })
62
        })
63
63
64
        return {
64
        return {
65
            ...EHoldingsLocalTitleResource.setup(),
65
            av_title_publication_types,
66
            av_title_publication_types,
66
            get_lib_from_av,
67
            get_lib_from_av,
67
            map_av_dt_filter,
68
            map_av_dt_filter,
68
            escape_str,
69
            escape_str,
69
            table,
70
            table,
70
            filters,
71
            filters,
71
            setConfirmationDialog,
72
            setMessage,
73
            eholdings_titles_table_settings,
72
            eholdings_titles_table_settings,
74
        }
73
        }
75
    },
74
    },
Lines 85-91 export default { Link Here
85
            initialized: false,
84
            initialized: false,
86
            tableOptions: {
85
            tableOptions: {
87
                columns: this.getTableColumns(),
86
                columns: this.getTableColumns(),
88
                url: "/api/v1/erm/eholdings/local/titles",
87
                url: this.getResourceTableUrl(),
89
                options: {
88
                options: {
90
                    embed: "resources.package",
89
                    embed: "resources.package",
91
                    searchCols: [
90
                    searchCols: [
Lines 124-169 export default { Link Here
124
                error => {}
123
                error => {}
125
            )
124
            )
126
        },
125
        },
127
        doShow: function ({ title_id }, dt, event) {
128
            event.preventDefault()
129
            this.$router.push({
130
                name: "EHoldingsLocalTitlesShow",
131
                params: { title_id },
132
            })
133
        },
134
        doEdit: function ({ title_id }, dt, event) {
135
            this.$router.push({
136
                name: "EHoldingsLocalTitlesFormAddEdit",
137
                params: { title_id },
138
            })
139
        },
140
        doDelete: function (title, dt, event) {
141
            this.setConfirmationDialog(
142
                {
143
                    title: this.$__(
144
                        "Are you sure you want to remove this title?"
145
                    ),
146
                    message: title.publication_title,
147
                    accept_label: this.$__("Yes, delete"),
148
                    cancel_label: this.$__("No, do not delete"),
149
                },
150
                () => {
151
                    const client = APIClient.erm
152
                    client.localTitles.delete(title.title_id).then(
153
                        success => {
154
                            this.setMessage(
155
                                this.$__("Local title %s deleted").format(
156
                                    title.publication_title
157
                                ),
158
                                true
159
                            )
160
                            dt.draw()
161
                        },
162
                        error => {}
163
                    )
164
                }
165
            )
166
        },
167
        getTableColumns: function () {
126
        getTableColumns: function () {
168
            let get_lib_from_av = this.get_lib_from_av
127
            let get_lib_from_av = this.get_lib_from_av
169
            let escape_str = this.escape_str
128
            let escape_str = this.escape_str
Lines 176-184 export default { Link Here
176
                    orderable: true,
135
                    orderable: true,
177
                    render: function (data, type, row, meta) {
136
                    render: function (data, type, row, meta) {
178
                        return (
137
                        return (
179
                            '<a href="/cgi-bin/koha/erm/eholdings/local/titles/' +
138
                            '<a role="button" class="show">' +
180
                            row.title_id +
181
                            '" class="show">' +
182
                            escape_str(
139
                            escape_str(
183
                                `${row.publication_title} (#${row.title_id})`
140
                                `${row.publication_title} (#${row.title_id})`
184
                            ) +
141
                            ) +
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalTitlesShow.vue (-45 / +9 lines)
Lines 3-21 Link Here
3
    <div v-else-if="title" id="eholdings_title_show">
3
    <div v-else-if="title" id="eholdings_title_show">
4
        <Toolbar>
4
        <Toolbar>
5
            <ToolbarButton
5
            <ToolbarButton
6
                :to="{
6
                action="edit"
7
                    name: 'EHoldingsLocalTitlesFormAddEdit',
7
                @go-to-edit-resource="goToResourceEdit"
8
                    params: { title_id: title.title_id },
8
            />
9
                }"
9
            <ToolbarButton
10
                class="btn btn-default"
10
                action="delete"
11
                icon="pencil"
11
                @delete-resource="doResourceDelete"
12
                :title="$__('Edit')"
13
            />
12
            />
14
            <a
15
                @click="delete_title(title.title_id, title.publication_title)"
16
                class="btn btn-default"
17
                ><font-awesome-icon icon="trash" /> {{ $__("Delete") }}</a
18
            >
19
        </Toolbar>
13
        </Toolbar>
20
14
21
        <h2>
15
        <h2>
Lines 267-283 import EHoldingsTitlePackagesList from "./EHoldingsLocalTitlePackagesList.vue" Link Here
267
import { APIClient } from "../../fetch/api-client.js"
261
import { APIClient } from "../../fetch/api-client.js"
268
import Toolbar from "../Toolbar.vue"
262
import Toolbar from "../Toolbar.vue"
269
import ToolbarButton from "../ToolbarButton.vue"
263
import ToolbarButton from "../ToolbarButton.vue"
264
import EHoldingsLocalTitleResource from "./EHoldingsLocalTitleResource.vue"
270
265
271
export default {
266
export default {
267
    extends: EHoldingsLocalTitleResource,
272
    setup() {
268
    setup() {
273
        const AVStore = inject("AVStore")
269
        const AVStore = inject("AVStore")
274
        const { get_lib_from_av } = AVStore
270
        const { get_lib_from_av } = AVStore
275
        const { setConfirmationDialog, setMessage } = inject("mainStore")
276
271
277
        return {
272
        return {
273
            ...EHoldingsLocalTitleResource.setup(),
278
            get_lib_from_av,
274
            get_lib_from_av,
279
            setConfirmationDialog,
280
            setMessage,
281
        }
275
        }
282
    },
276
    },
283
    data() {
277
    data() {
Lines 333-367 export default { Link Here
333
                error => {}
327
                error => {}
334
            )
328
            )
335
        },
329
        },
336
        delete_title: function (title_id, title_publication_title) {
337
            this.setConfirmationDialog(
338
                {
339
                    title: this.$__(
340
                        "Are you sure you want to remove this title?"
341
                    ),
342
                    message: title_publication_title,
343
                    accept_label: this.$__("Yes, delete"),
344
                    cancel_label: this.$__("No, do not delete"),
345
                },
346
                () => {
347
                    const client = APIClient.erm
348
                    client.localTitles.delete(title_id).then(
349
                        success => {
350
                            this.setMessage(
351
                                this.$__("Local title %s deleted").format(
352
                                    title_publication_title
353
                                ),
354
                                true
355
                            )
356
                            this.$router.push({
357
                                name: "EHoldingsLocalTitlesList",
358
                            })
359
                        },
360
                        error => {}
361
                    )
362
                }
363
            )
364
        },
365
    },
330
    },
366
    components: {
331
    components: {
367
        EHoldingsTitlePackagesList,
332
        EHoldingsTitlePackagesList,
368
- 

Return to bug 37301