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

(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Link.vue (+71 lines)
Line 0 Link Here
1
<template>
2
    <a
3
        v-if="callback"
4
        @click="typeof callback === 'string' ? redirect() : callback(this)"
5
        :class="cssClass"
6
        style="cursor: pointer"
7
    >
8
        <font-awesome-icon v-if="icon" :icon="icon" /> {{ title }}
9
    </a>
10
    <router-link v-else :to="to" :class="cssClass"
11
        ><font-awesome-icon v-if="icon" :icon="icon" /> {{ title }}</router-link
12
    >
13
</template>
14
15
<script>
16
export default {
17
    props: {
18
        to: {
19
            type: [String, Object],
20
        },
21
        icon: {
22
            type: String,
23
            required: false,
24
        },
25
        title: {
26
            type: String,
27
        },
28
        callback: {
29
            type: [String, Function],
30
            required: false,
31
        },
32
        cssClass: {
33
            type: String,
34
            default: "btn btn-default",
35
            required: false,
36
        },
37
    },
38
    methods: {
39
        redirect(url) {
40
            const redirectParams = url ? url : this.to;
41
            if (typeof redirectParams === "string")
42
                window.location.href = this.formatUrl(redirectParams);
43
            if (typeof redirectParams === "object") {
44
                const url = this.handleQuery(redirectParams);
45
                window.open(this.formatUrl(url), "_blank");
46
            }
47
        },
48
        formatUrl(url) {
49
            if (url.includes("http://") || url.includes("https://")) return url;
50
            if (url.includes("cgi-bin/koha"))
51
                return `//${window.location.host}/${url}`;
52
            return `//${url}`;
53
        },
54
        handleQuery(query) {
55
            let url = this.to.path;
56
            if (this.to.hasOwnProperty("query")) {
57
                url +=
58
                    "?" +
59
                    Object.keys(this.to.query)
60
                        .map(
61
                            queryParam =>
62
                                `${queryParam}=${this.to.query[queryParam]}`
63
                        )
64
                        .join("&");
65
            }
66
            return url;
67
        },
68
    },
69
    name: "Link",
70
};
71
</script>
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ToolbarButton.vue (-42 / +3 lines)
Lines 1-19 Link Here
1
<template>
1
<template>
2
    <a
2
    <Link v-bind="$props" />
3
        v-if="callback"
4
        @click="typeof callback === 'string' ? redirect() : callback(this)"
5
        :class="cssClass"
6
        style="cursor: pointer"
7
    >
8
        <font-awesome-icon v-if="icon" :icon="icon" /> {{ title }}
9
    </a>
10
    <router-link v-else :to="to" :class="cssClass"
11
        ><font-awesome-icon v-if="icon" :icon="icon" /> {{ title }}</router-link
12
    >
13
</template>
3
</template>
14
4
15
<script>
5
<script>
6
import Link from "./Link.vue";
16
export default {
7
export default {
8
    components: { Link },
17
    props: {
9
    props: {
18
        to: {
10
        to: {
19
            type: [String, Object],
11
            type: [String, Object],
Lines 35-71 export default { Link Here
35
            required: false,
27
            required: false,
36
        },
28
        },
37
    },
29
    },
38
    methods: {
39
        redirect(url) {
40
            const redirectParams = url ? url : this.to;
41
            if (typeof redirectParams === "string")
42
                window.location.href = this.formatUrl(redirectParams);
43
            if (typeof redirectParams === "object") {
44
                const url = this.handleQuery(redirectParams);
45
                window.open(this.formatUrl(url), "_blank");
46
            }
47
        },
48
        formatUrl(url) {
49
            if (url.includes("http://") || url.includes("https://")) return url;
50
            if (url.includes("cgi-bin/koha"))
51
                return `//${window.location.host}/${url}`;
52
            return `//${url}`;
53
        },
54
        handleQuery(query) {
55
            let url = this.to.path;
56
            if (this.to.hasOwnProperty("query")) {
57
                url +=
58
                    "?" +
59
                    Object.keys(this.to.query)
60
                        .map(
61
                            queryParam =>
62
                                `${queryParam}=${this.to.query[queryParam]}`
63
                        )
64
                        .join("&");
65
            }
66
            return url;
67
        },
68
    },
69
    name: "ToolbarButton",
30
    name: "ToolbarButton",
70
};
31
};
71
</script>
32
</script>
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorDetails.vue (-3 / +3 lines)
Lines 45-51 Link Here
45
            </li>
45
            </li>
46
            <li v-if="vendor.url" id="vendorWebsite">
46
            <li v-if="vendor.url" id="vendorWebsite">
47
                <label>{{ $__("Website") }}:</label>
47
                <label>{{ $__("Website") }}:</label>
48
                <ToolbarButton
48
                <Link
49
                    :to="{
49
                    :to="{
50
                        path: vendor.url,
50
                        path: vendor.url,
51
                    }"
51
                    }"
Lines 174-180 Link Here
174
174
175
<script>
175
<script>
176
import { inject } from "vue";
176
import { inject } from "vue";
177
import ToolbarButton from "../ToolbarButton.vue";
177
import Link from "../Link.vue";
178
178
179
export default {
179
export default {
180
    props: {
180
    props: {
Lines 211-217 export default { Link Here
211
        },
211
        },
212
    },
212
    },
213
    components: {
213
    components: {
214
        ToolbarButton,
214
        Link,
215
    },
215
    },
216
};
216
};
217
</script>
217
</script>
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorInterfaces.vue (-4 / +3 lines)
Lines 13-19 Link Here
13
            </li>
13
            </li>
14
            <li v-if="vi.uri">
14
            <li v-if="vi.uri">
15
                <label>{{ $__("URI") }}:</label>
15
                <label>{{ $__("URI") }}:</label>
16
                <ToolbarButton
16
                <Link
17
                    :to="{
17
                    :to="{
18
                        path: vi.uri,
18
                        path: vi.uri,
19
                    }"
19
                    }"
Lines 159-165 Link Here
159
159
160
<script>
160
<script>
161
import { inject } from "vue";
161
import { inject } from "vue";
162
import ToolbarButton from "../ToolbarButton.vue";
162
import Link from "../Link.vue";
163
163
164
export default {
164
export default {
165
    props: {
165
    props: {
Lines 196-202 export default { Link Here
196
        },
196
        },
197
    },
197
    },
198
    components: {
198
    components: {
199
        ToolbarButton,
199
        Link,
200
    },
200
    },
201
};
201
};
202
</script>
202
</script>
203
- 

Return to bug 38010