Lines 1-5
Link Here
|
1 |
<template> |
1 |
<template> |
2 |
<router-link :to="to" class="btn btn-default" |
2 |
<a |
|
|
3 |
v-if="callback" |
4 |
@click="typeof callback === 'string' ? redirect() : callback" |
5 |
class="btn btn-default" |
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="class" |
3 |
><font-awesome-icon v-if="icon" :icon="icon" /> {{ title }}</router-link |
11 |
><font-awesome-icon v-if="icon" :icon="icon" /> {{ title }}</router-link |
4 |
> |
12 |
> |
5 |
</template> |
13 |
</template> |
Lines 17-23
export default {
Link Here
|
17 |
title: { |
25 |
title: { |
18 |
type: String, |
26 |
type: String, |
19 |
}, |
27 |
}, |
|
|
28 |
callback: { |
29 |
type: [String, Function], |
30 |
required: false, |
31 |
}, |
32 |
}, |
33 |
methods: { |
34 |
redirect() { |
35 |
if (typeof this.to === "string") |
36 |
window.location.href = this.formatUrl(this.to); |
37 |
if (typeof this.to === "object") { |
38 |
let url = this.to.path; |
39 |
if (this.to.hasOwnProperty("query")) { |
40 |
url += |
41 |
"?" + |
42 |
Object.keys(this.to.query) |
43 |
.map( |
44 |
queryParam => |
45 |
`${queryParam}=${this.to.query[queryParam]}` |
46 |
) |
47 |
.join("&"); |
48 |
} |
49 |
window.open(this.formatUrl(url, this.to.internal), "_blank"); |
50 |
} |
51 |
}, |
52 |
formatUrl(url) { |
53 |
if (url.includes("http://") || url.includes("https://")) return url; |
54 |
if (url.includes("cgi-bin/koha")) |
55 |
return `//${window.location.host}/${url}`; |
56 |
return `//${url}`; |
57 |
}, |
20 |
}, |
58 |
}, |
21 |
name: "Toolbar", |
59 |
name: "ToolbarButton", |
22 |
}; |
60 |
}; |
23 |
</script> |
61 |
</script> |
24 |
- |
|
|