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

(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalPackageTitlesList.vue (-90 / +57 lines)
Lines 1-128 Link Here
1
<template>
1
<template>
2
    <div id="title_list_result">
2
    <div id="title_list_result">
3
        <table :id="table_id"></table>
3
        <KohaTable ref="table" v-bind="tableOptions" @show="doShow"></KohaTable>
4
    </div>
4
    </div>
5
</template>
5
</template>
6
6
7
<script>
7
<script>
8
import { inject, createVNode, render } from "vue"
8
import { inject, ref } from "vue"
9
import { useDataTable } from "../../composables/datatables"
9
import { useDataTable } from "../../composables/datatables"
10
import KohaTable from "../KohaTable.vue"
10
11
11
export default {
12
export default {
12
    setup() {
13
    setup() {
13
        const AVStore = inject("AVStore")
14
        const AVStore = inject("AVStore")
14
        const { get_lib_from_av, map_av_dt_filter } = AVStore
15
        const { get_lib_from_av, map_av_dt_filter } = AVStore
15
16
16
        const table_id = "title_list"
17
        const table = ref()
17
        useDataTable(table_id)
18
19
        return {
18
        return {
20
            get_lib_from_av,
19
            get_lib_from_av,
21
            map_av_dt_filter,
20
            map_av_dt_filter,
22
            table_id,
21
            escape_str,
22
            table,
23
        }
23
        }
24
    },
24
    },
25
    data() {
25
    data() {
26
        return {}
26
        return {
27
            tableOptions: {
28
                columns: this.getTableColumns(),
29
                url:
30
                    "/api/v1/erm/eholdings/local/packages/" +
31
                    this.package_id +
32
                    "/resources",
33
                options: { embed: "title" },
34
                add_filters: true,
35
                filters_options: {
36
                    1: () =>
37
                        this.map_av_dt_filter("av_title_publication_types"),
38
                },
39
                actions: {
40
                    0: ["show"],
41
                },
42
            },
43
        }
27
    },
44
    },
28
    methods: {
45
    methods: {
29
        show_resource: function (resource_id) {
46
        doShow: function (resource, dt, event) {
47
            event.preventDefault()
30
            this.$router.push(
48
            this.$router.push(
31
                "/cgi-bin/koha/erm/eholdings/local/resources/" + resource_id
49
                "/cgi-bin/koha/erm/eholdings/local/resources/" +
50
                    resource.resource_id
32
            )
51
            )
33
        },
52
        },
34
        build_datatable: function () {
53
        getTableColumns: function () {
35
            let show_resource = this.show_resource
36
            let package_id = this.package_id
37
            let get_lib_from_av = this.get_lib_from_av
54
            let get_lib_from_av = this.get_lib_from_av
38
            let map_av_dt_filter = this.map_av_dt_filter
55
            let escape_str = this.escape_str
39
            let table_id = this.table_id
40
41
            window["av_title_publication_types"] = map_av_dt_filter(
42
                "av_title_publication_types"
43
            )
44
56
45
            $("#" + table_id).kohaTable(
57
            return [
46
                {
58
                {
47
                    ajax: {
59
                    title: __("Name"),
48
                        url:
60
                    data: "title.publication_title",
49
                            "/api/v1/erm/eholdings/local/packages/" +
61
                    searchable: true,
50
                            package_id +
62
                    orderable: true,
51
                            "/resources",
63
                    render: function (data, type, row, meta) {
52
                    },
64
                        return (
53
                    embed: ["title"],
65
                            '<a href="/cgi-bin/koha/erm/eholdings/local/resources/' +
54
                    autoWidth: false,
66
                            row.resource_id +
55
                    columns: [
67
                            '" class="show">' +
56
                        {
68
                            escape_str(row.title.publication_title) +
57
                            title: __("Name"),
69
                            "</a>"
58
                            data: "title.publication_title",
59
                            searchable: true,
60
                            orderable: true,
61
                            render: function (data, type, row, meta) {
62
                                // Rendering done in drawCallback
63
                                return ""
64
                            },
65
                        },
66
                        {
67
                            title: __("Publication type"),
68
                            data: "title.publication_type",
69
                            searchable: true,
70
                            orderable: true,
71
                            render: function (data, type, row, meta) {
72
                                return escape_str(
73
                                    get_lib_from_av(
74
                                        "av_title_publication_types",
75
                                        row.title.publication_type
76
                                    )
77
                                )
78
                            },
79
                        },
80
                    ],
81
                    drawCallback: function (settings) {
82
                        var api = new $.fn.dataTable.Api(settings)
83
84
                        $.each(
85
                            $(this).find("tbody tr td:first-child"),
86
                            function (index, e) {
87
                                let tr = $(this).parent()
88
                                let row = api.row(tr).data()
89
                                if (!row) return // Happen if the table is empty
90
                                let n = createVNode(
91
                                    "a",
92
                                    {
93
                                        role: "button",
94
                                        href:
95
                                            "/cgi-bin/koha/erm/eholdings/local/resources/" +
96
                                            row.resource_id,
97
                                        onClick: e => {
98
                                            e.preventDefault()
99
                                            show_resource(row.resource_id)
100
                                        },
101
                                    },
102
                                    `${row.title.publication_title}`
103
                                )
104
                                render(n, e)
105
                            }
106
                        )
70
                        )
107
                    },
71
                    },
108
                    preDrawCallback: function (settings) {
72
                },
109
                        $("#" + table_id)
73
                {
110
                            .find("thead th")
74
                    title: __("Publication type"),
111
                            .eq(1)
75
                    data: "title.publication_type",
112
                            .attr("data-filter", "av_title_publication_types")
76
                    searchable: true,
77
                    orderable: true,
78
                    render: function (data, type, row, meta) {
79
                        return escape_str(
80
                            get_lib_from_av(
81
                                "av_title_publication_types",
82
                                row.title.publication_type
83
                            )
84
                        )
113
                    },
85
                    },
114
                },
86
                },
115
                null,
87
            ]
116
                1
117
            )
118
        },
88
        },
119
    },
89
    },
120
    mounted() {
121
        this.build_datatable()
122
    },
123
    props: {
90
    props: {
124
        package_id: String,
91
        package_id: String,
125
    },
92
    },
93
    components: { KohaTable },
126
    name: "EHoldingsLocalPackageTitlesList",
94
    name: "EHoldingsLocalPackageTitlesList",
127
}
95
}
128
</script>
96
</script>
129
- 

Return to bug 33066