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

(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ToolbarButton.vue (-1 / +38 lines)
Lines 17-22 Link Here
17
        :class="class"
17
        :class="class"
18
        ><font-awesome-icon icon="pencil" /> {{ $__("Edit") }}</a
18
        ><font-awesome-icon icon="pencil" /> {{ $__("Edit") }}</a
19
    >
19
    >
20
    <a
21
        v-else-if="callback"
22
        @click="typeof callback === 'string' ? redirect() : callback"
23
        :class="class"
24
        style="cursor: pointer"
25
    >
26
        <font-awesome-icon v-if="icon" :icon="icon" /> {{ title }}
27
    </a>
20
    <router-link v-else-if="action === undefined && to" :to="to" :class="class"
28
    <router-link v-else-if="action === undefined && to" :to="to" :class="class"
21
        ><font-awesome-icon v-if="icon" :icon="icon" /> {{ title }}</router-link
29
        ><font-awesome-icon v-if="icon" :icon="icon" /> {{ title }}</router-link
22
    >
30
    >
Lines 43-48 export default { Link Here
43
        title: {
51
        title: {
44
            type: String,
52
            type: String,
45
        },
53
        },
54
        callback: {
55
            type: [String, Function],
56
            required: false,
57
        },
58
    },
59
    methods: {
60
        redirect() {
61
            if (typeof this.to === "string")
62
                window.location.href = this.formatUrl(this.to)
63
            if (typeof this.to === "object") {
64
                let url = this.to.path
65
                if (this.to.hasOwnProperty("query")) {
66
                    url +=
67
                        "?" +
68
                        Object.keys(this.to.query)
69
                            .map(
70
                                queryParam =>
71
                                    `${queryParam}=${this.to.query[queryParam]}`
72
                            )
73
                            .join("&")
74
                }
75
                window.open(this.formatUrl(url, this.to.internal), "_blank")
76
            }
77
        },
78
        formatUrl(url) {
79
            if (url.includes("http://") || url.includes("https://")) return url
80
            if (url.includes("cgi-bin/koha"))
81
                return `//${window.location.host}/${url}`
82
            return `//${url}`
83
        },
46
    },
84
    },
47
    emits: ["go-to-add-resource", "go-to-edit-resource", "delete-resource"],
85
    emits: ["go-to-add-resource", "go-to-edit-resource", "delete-resource"],
48
    name: "Toolbar",
86
    name: "Toolbar",
49
- 

Return to bug 38010