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

(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalPackageResource.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: "erm_package",
11
                name_attr: "name",
12
                id_attr: "package_id",
13
                show_component: "EHoldingsLocalPackagesShow",
14
                list_component: "EHoldingsLocalPackagesList",
15
                add_component: "EHoldingsLocalPackagesFormAdd",
16
                edit_component: "EHoldingsLocalPackagesFormAddEdit",
17
                api_client: APIClient.erm.localPackages,
18
                resource_table_url:
19
                    APIClient.erm._baseURL + "eholdings/local/packages",
20
                i18n: {
21
                    display_name: __("Local package"),
22
                },
23
            }),
24
            //EHoldingsLocalPackageResource specific setup here
25
        }
26
    },
27
    methods: {},
28
    name: "EHoldingsLocalPackageResource",
29
}
30
</script>
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalPackagesList.vue (-53 / +10 lines)
Lines 4-11 Link Here
4
        <div v-else id="packages_list">
4
        <div v-else id="packages_list">
5
            <Toolbar>
5
            <Toolbar>
6
                <ToolbarButton
6
                <ToolbarButton
7
                    :to="{ name: 'EHoldingsLocalPackagesFormAdd' }"
7
                    action="add"
8
                    icon="plus"
8
                    @go-to-add-resource="goToResourceAdd"
9
                    :title="$__('New package')"
9
                    :title="$__('New package')"
10
                />
10
                />
11
            </Toolbar>
11
            </Toolbar>
Lines 17-25 Link Here
17
                <KohaTable
17
                <KohaTable
18
                    ref="table"
18
                    ref="table"
19
                    v-bind="tableOptions"
19
                    v-bind="tableOptions"
20
                    @show="doShow"
20
                    @show="goToResourceShow"
21
                    @edit="doEdit"
21
                    @edit="goToResourceEdit"
22
                    @delete="doDelete"
22
                    @delete="doResourceDelete"
23
                ></KohaTable>
23
                ></KohaTable>
24
            </div>
24
            </div>
25
            <div v-else class="alert alert-info">
25
            <div v-else class="alert alert-info">
Lines 36-43 import { inject, ref, reactive } from "vue" Link Here
36
import { storeToRefs } from "pinia"
36
import { storeToRefs } from "pinia"
37
import { APIClient } from "../../fetch/api-client.js"
37
import { APIClient } from "../../fetch/api-client.js"
38
import KohaTable from "../KohaTable.vue"
38
import KohaTable from "../KohaTable.vue"
39
import EHoldingsLocalPackageResource from "./EHoldingsLocalPackageResource.vue"
39
40
40
export default {
41
export default {
42
    extends: EHoldingsLocalPackageResource,
41
    setup() {
43
    setup() {
42
        const vendorStore = inject("vendorStore")
44
        const vendorStore = inject("vendorStore")
43
        const { vendors } = storeToRefs(vendorStore)
45
        const { vendors } = storeToRefs(vendorStore)
Lines 45-52 export default { Link Here
45
        const AVStore = inject("AVStore")
47
        const AVStore = inject("AVStore")
46
        const { get_lib_from_av, map_av_dt_filter } = AVStore
48
        const { get_lib_from_av, map_av_dt_filter } = AVStore
47
49
48
        const { setConfirmationDialog, setMessage } = inject("mainStore")
49
50
        const table = ref()
50
        const table = ref()
51
        const filters = reactive({
51
        const filters = reactive({
52
            package_name: "",
52
            package_name: "",
Lines 54-66 export default { Link Here
54
        })
54
        })
55
55
56
        return {
56
        return {
57
            ...EHoldingsLocalPackageResource.setup(),
57
            vendors,
58
            vendors,
58
            get_lib_from_av,
59
            get_lib_from_av,
59
            map_av_dt_filter,
60
            map_av_dt_filter,
60
            table,
61
            table,
61
            filters,
62
            filters,
62
            setConfirmationDialog,
63
            setMessage,
64
            escape_str,
63
            escape_str,
65
            eholdings_packages_table_settings,
64
            eholdings_packages_table_settings,
66
        }
65
        }
Lines 76-82 export default { Link Here
76
            initialized: false,
75
            initialized: false,
77
            tableOptions: {
76
            tableOptions: {
78
                columns: this.getTableColumns(),
77
                columns: this.getTableColumns(),
79
                url: "/api/v1/erm/eholdings/local/packages",
78
                url: this.getResourceTableUrl(),
80
                options: {
79
                options: {
81
                    embed: "resources+count,vendor.name",
80
                    embed: "resources+count,vendor.name",
82
                    searchCols: [
81
                    searchCols: [
Lines 122-167 export default { Link Here
122
                error => {}
121
                error => {}
123
            )
122
            )
124
        },
123
        },
125
        doShow: function ({ package_id }, dt, event) {
126
            event.preventDefault()
127
            this.$router.push({
128
                name: "EHoldingsLocalPackagesShow",
129
                params: { package_id },
130
            })
131
        },
132
        doEdit: function ({ package_id }, dt, event) {
133
            this.$router.push({
134
                name: "EHoldingsLocalPackagesFormAddEdit",
135
                params: { package_id },
136
            })
137
        },
138
        doDelete: function (erm_package, dt, event) {
139
            this.setConfirmationDialog(
140
                {
141
                    title: this.$__(
142
                        "Are you sure you want to remove this package?"
143
                    ),
144
                    message: erm_package.name,
145
                    accept_label: this.$__("Yes, delete"),
146
                    cancel_label: this.$__("No, do not delete"),
147
                },
148
                () => {
149
                    const client = APIClient.erm
150
                    client.localPackages.delete(erm_package.package_id).then(
151
                        success => {
152
                            this.setMessage(
153
                                this.$__("Local package %s deleted").format(
154
                                    erm_package.name
155
                                ),
156
                                true
157
                            )
158
                            dt.draw()
159
                        },
160
                        error => {}
161
                    )
162
                }
163
            )
164
        },
165
        getTableColumns: function () {
124
        getTableColumns: function () {
166
            let get_lib_from_av = this.get_lib_from_av
125
            let get_lib_from_av = this.get_lib_from_av
167
            let escape_str = this.escape_str
126
            let escape_str = this.escape_str
Lines 173-181 export default { Link Here
173
                    orderable: true,
132
                    orderable: true,
174
                    render: function (data, type, row, meta) {
133
                    render: function (data, type, row, meta) {
175
                        return (
134
                        return (
176
                            '<a href="/cgi-bin/koha/erm/eholdings/local/packages/' +
135
                            '<a role="button" class="show">' +
177
                            row.package_id +
178
                            '" class="show">' +
179
                            escape_str(`${row.name} (#${row.package_id})`) +
136
                            escape_str(`${row.name} (#${row.package_id})`) +
180
                            "</a>"
137
                            "</a>"
181
                        )
138
                        )
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalPackagesShow.vue (-48 / +9 lines)
Lines 3-23 Link Here
3
    <div v-else-if="erm_package" id="packages_show">
3
    <div v-else-if="erm_package" id="packages_show">
4
        <Toolbar>
4
        <Toolbar>
5
            <ToolbarButton
5
            <ToolbarButton
6
                :to="{
6
                action="edit"
7
                    name: 'EHoldingsLocalPackagesFormAddEdit',
7
                @go-to-edit-resource="goToResourceEdit"
8
                    params: { package_id: erm_package.package_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="
16
                    delete_package(erm_package.package_id, erm_package.name)
17
                "
18
                class="btn btn-default"
19
                ><font-awesome-icon icon="trash" /> {{ $__("Delete") }}</a
20
            >
21
        </Toolbar>
13
        </Toolbar>
22
14
23
        <h2>
15
        <h2>
Lines 120-140 import EHoldingsPackageTitlesList from "./EHoldingsLocalPackageTitlesList.vue" Link Here
120
import { APIClient } from "../../fetch/api-client.js"
112
import { APIClient } from "../../fetch/api-client.js"
121
import Toolbar from "../Toolbar.vue"
113
import Toolbar from "../Toolbar.vue"
122
import ToolbarButton from "../ToolbarButton.vue"
114
import ToolbarButton from "../ToolbarButton.vue"
115
import EHoldingsLocalPackageResource from "./EHoldingsLocalPackageResource.vue"
123
116
124
export default {
117
export default {
118
    extends: EHoldingsLocalPackageResource,
125
    setup() {
119
    setup() {
126
        const format_date = $date
120
        const format_date = $date
127
121
128
        const { setConfirmationDialog, setMessage } = inject("mainStore")
129
130
        const AVStore = inject("AVStore")
122
        const AVStore = inject("AVStore")
131
        const { get_lib_from_av } = AVStore
123
        const { get_lib_from_av } = AVStore
132
124
133
        return {
125
        return {
126
            ...EHoldingsLocalPackageResource.setup(),
134
            format_date,
127
            format_date,
135
            get_lib_from_av,
128
            get_lib_from_av,
136
            setConfirmationDialog,
137
            setMessage,
138
        }
129
        }
139
    },
130
    },
140
    data() {
131
    data() {
Lines 172-206 export default { Link Here
172
                error => {}
163
                error => {}
173
            )
164
            )
174
        },
165
        },
175
        delete_package: function (package_id, package_name) {
176
            this.setConfirmationDialog(
177
                {
178
                    title: this.$__(
179
                        "Are you sure you want to remove this package?"
180
                    ),
181
                    message: package_name,
182
                    accept_label: this.$__("Yes, delete"),
183
                    cancel_label: this.$__("No, do not delete"),
184
                },
185
                () => {
186
                    const client = APIClient.erm
187
                    client.localPackages.delete(package_id).then(
188
                        success => {
189
                            this.setMessage(
190
                                this.$__("Local package %s deleted").format(
191
                                    package_name
192
                                ),
193
                                true
194
                            )
195
                            this.$router.push({
196
                                name: "EHoldingsLocalPackagesList",
197
                            })
198
                        },
199
                        error => {}
200
                    )
201
                }
202
            )
203
        },
204
    },
166
    },
205
    components: {
167
    components: {
206
        EHoldingsPackageTitlesList,
168
        EHoldingsPackageTitlesList,
207
- 

Return to bug 37301