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

(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/LicenseResource.vue (+29 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: "license",
11
                name_attr: "name",
12
                id_attr: "license_id",
13
                show_component: "LicensesShow",
14
                list_component: "LicensesList",
15
                add_component: "LicensesFormAdd",
16
                edit_component: "LicensesFormAddEdit",
17
                api_client: APIClient.erm.licenses,
18
                resource_table_url: APIClient.erm._baseURL + "licenses",
19
                i18n: {
20
                    display_name: __("License"),
21
                },
22
            }),
23
            //LicenseResource specific setup here
24
        }
25
    },
26
    methods: {},
27
    name: "LicenseResource",
28
}
29
</script>
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/LicensesList.vue (-50 / +10 lines)
Lines 3-10 Link Here
3
    <div v-else id="licenses_list">
3
    <div v-else id="licenses_list">
4
        <Toolbar>
4
        <Toolbar>
5
            <ToolbarButton
5
            <ToolbarButton
6
                :to="{ name: 'LicensesFormAdd' }"
6
                action="add"
7
                icon="plus"
7
                @go-to-add-resource="goToResourceAdd"
8
                :title="$__('New license')"
8
                :title="$__('New license')"
9
            />
9
            />
10
        </Toolbar>
10
        </Toolbar>
Lines 14-22 Link Here
14
                v-bind="tableOptions"
14
                v-bind="tableOptions"
15
                :searchable_additional_fields="searchable_additional_fields"
15
                :searchable_additional_fields="searchable_additional_fields"
16
                :searchable_av_options="searchable_av_options"
16
                :searchable_av_options="searchable_av_options"
17
                @show="doShow"
17
                @show="goToResourceShow"
18
                @edit="doEdit"
18
                @edit="goToResourceEdit"
19
                @delete="doDelete"
19
                @delete="doResourceDelete"
20
            ></KohaTable>
20
            ></KohaTable>
21
        </div>
21
        </div>
22
        <div v-else class="alert alert-info">
22
        <div v-else class="alert alert-info">
Lines 32-39 import { inject, ref } from "vue" Link Here
32
import { storeToRefs } from "pinia"
32
import { storeToRefs } from "pinia"
33
import { APIClient } from "../../fetch/api-client.js"
33
import { APIClient } from "../../fetch/api-client.js"
34
import KohaTable from "../KohaTable.vue"
34
import KohaTable from "../KohaTable.vue"
35
import LicenseResource from "./LicenseResource.vue"
35
36
36
export default {
37
export default {
38
    extends: LicenseResource,
37
    setup() {
39
    setup() {
38
        const vendorStore = inject("vendorStore")
40
        const vendorStore = inject("vendorStore")
39
        const { vendors } = storeToRefs(vendorStore)
41
        const { vendors } = storeToRefs(vendorStore)
Lines 41-57 export default { Link Here
41
        const AVStore = inject("AVStore")
43
        const AVStore = inject("AVStore")
42
        const { get_lib_from_av, map_av_dt_filter } = AVStore
44
        const { get_lib_from_av, map_av_dt_filter } = AVStore
43
45
44
        const { setConfirmationDialog, setMessage } = inject("mainStore")
45
46
        const table = ref()
46
        const table = ref()
47
47
48
        return {
48
        return {
49
            ...LicenseResource.setup(),
49
            vendors,
50
            vendors,
50
            get_lib_from_av,
51
            get_lib_from_av,
51
            map_av_dt_filter,
52
            map_av_dt_filter,
52
            table,
53
            table,
53
            setConfirmationDialog,
54
            setMessage,
55
            license_table_settings,
54
            license_table_settings,
56
        }
55
        }
57
    },
56
    },
Lines 70-76 export default { Link Here
70
            searchable_av_options: [],
69
            searchable_av_options: [],
71
            tableOptions: {
70
            tableOptions: {
72
                columns: this.getTableColumns(),
71
                columns: this.getTableColumns(),
73
                url: "/api/v1/erm/licenses",
72
                url: this.getResourceTableUrl(),
74
                options: { embed: "vendor,extended_attributes,+strings" },
73
                options: { embed: "vendor,extended_attributes,+strings" },
75
                table_settings: this.license_table_settings,
74
                table_settings: this.license_table_settings,
76
                add_filters: true,
75
                add_filters: true,
Lines 149-191 export default { Link Here
149
                    })
148
                    })
150
                })
149
                })
151
        },
150
        },
152
        doShow: function ({ license_id }, dt, event) {
153
            event.preventDefault()
154
            this.$router.push({ name: "LicensesShow", params: { license_id } })
155
        },
156
        doEdit: function ({ license_id }, dt, event) {
157
            this.$router.push({
158
                name: "LicensesFormAddEdit",
159
                params: { license_id },
160
            })
161
        },
162
        doDelete: function (license, dt, event) {
163
            this.setConfirmationDialog(
164
                {
165
                    title: this.$__(
166
                        "Are you sure you want to remove this license?"
167
                    ),
168
                    message: license.name,
169
                    accept_label: this.$__("Yes, delete"),
170
                    cancel_label: this.$__("No, do not delete"),
171
                },
172
                () => {
173
                    const client = APIClient.erm
174
                    client.licenses.delete(license.license_id).then(
175
                        success => {
176
                            this.setMessage(
177
                                this.$__("License %s deleted").format(
178
                                    license.name
179
                                ),
180
                                true
181
                            )
182
                            dt.draw()
183
                        },
184
                        error => {}
185
                    )
186
                }
187
            )
188
        },
189
        getTableColumns: function () {
151
        getTableColumns: function () {
190
            let get_lib_from_av = this.get_lib_from_av
152
            let get_lib_from_av = this.get_lib_from_av
191
153
Lines 197-205 export default { Link Here
197
                    orderable: true,
159
                    orderable: true,
198
                    render: function (data, type, row, meta) {
160
                    render: function (data, type, row, meta) {
199
                        return (
161
                        return (
200
                            '<a href="/cgi-bin/koha/erm/licenses/' +
162
                            '<a role="button" class="show">' +
201
                            row.license_id +
202
                            '" class="show">' +
203
                            escape_str(`${row.name} (#${row.license_id})`) +
163
                            escape_str(`${row.name} (#${row.license_id})`) +
204
                            "</a>"
164
                            "</a>"
205
                        )
165
                        )
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/LicensesShow.vue (-44 / +9 lines)
Lines 3-21 Link Here
3
    <div v-else id="licenses_show">
3
    <div v-else id="licenses_show">
4
        <Toolbar>
4
        <Toolbar>
5
            <ToolbarButton
5
            <ToolbarButton
6
                :to="{
6
                action="edit"
7
                    name: 'LicensesFormAddEdit',
7
                @go-to-edit-resource="goToResourceEdit"
8
                    params: { license_id: license.license_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_license(license.license_id, license.name)"
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 160-182 import { APIClient } from "../../fetch/api-client.js" Link Here
160
import Toolbar from "../Toolbar.vue"
154
import Toolbar from "../Toolbar.vue"
161
import ToolbarButton from "../ToolbarButton.vue"
155
import ToolbarButton from "../ToolbarButton.vue"
162
import AdditionalFieldsDisplay from "../AdditionalFieldsDisplay.vue"
156
import AdditionalFieldsDisplay from "../AdditionalFieldsDisplay.vue"
157
import LicenseResource from "./LicenseResource.vue"
163
158
164
export default {
159
export default {
160
    extends: LicenseResource,
165
    setup() {
161
    setup() {
166
        const format_date = $date
162
        const format_date = $date
167
        const patron_to_html = $patron_to_html
163
        const patron_to_html = $patron_to_html
168
164
169
        const { setConfirmationDialog, setMessage } = inject("mainStore")
170
171
        const AVStore = inject("AVStore")
165
        const AVStore = inject("AVStore")
172
        const { get_lib_from_av } = AVStore
166
        const { get_lib_from_av } = AVStore
173
167
174
        return {
168
        return {
169
            ...LicenseResource.setup(),
175
            format_date,
170
            format_date,
176
            patron_to_html,
171
            patron_to_html,
177
            get_lib_from_av,
172
            get_lib_from_av,
178
            setConfirmationDialog,
179
            setMessage,
180
        }
173
        }
181
    },
174
    },
182
    data() {
175
    data() {
Lines 214-246 export default { Link Here
214
                error => {}
207
                error => {}
215
            )
208
            )
216
        },
209
        },
217
        delete_license: function (license_id, license_name) {
218
            this.setConfirmationDialog(
219
                {
220
                    title: this.$__(
221
                        "Are you sure you want to remove this license?"
222
                    ),
223
                    message: license_name,
224
                    accept_label: this.$__("Yes, delete"),
225
                    cancel_label: this.$__("No, do not delete"),
226
                },
227
                () => {
228
                    const client = APIClient.erm
229
                    client.licenses.delete(license_id).then(
230
                        success => {
231
                            this.setMessage(
232
                                this.$__("License %s deleted").format(
233
                                    license_name
234
                                ),
235
                                true
236
                            )
237
                            this.$router.push({ name: "LicensesList" })
238
                        },
239
                        error => {}
240
                    )
241
                }
242
            )
243
        },
244
    },
210
    },
245
    components: { Toolbar, ToolbarButton, AdditionalFieldsDisplay },
211
    components: { Toolbar, ToolbarButton, AdditionalFieldsDisplay },
246
    name: "LicensesShow",
212
    name: "LicensesShow",
247
- 

Return to bug 37301