|
1
|
|
|
import type { PropType } from 'vue'; |
|
2
|
|
|
import type { Route } from 'vue-router'; |
|
3
|
|
|
import type { ModuleManifest } from 'src/core/factory/module.factory'; |
|
4
|
|
|
import template from './sw-meteor-page.html.twig'; |
|
5
|
|
|
import './sw-meteor-page.scss'; |
|
6
|
|
|
|
|
7
|
|
|
const { Component } = Shopware; |
|
8
|
|
|
|
|
9
|
|
|
type ComponentData = { |
|
10
|
|
|
module: ModuleManifest|null, |
|
11
|
|
|
parentRoute: string|null, |
|
12
|
|
|
} |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* @package admin |
|
16
|
|
|
* |
|
17
|
|
|
* @private |
|
18
|
|
|
*/ |
|
19
|
|
|
Component.register('sw-meteor-page', { |
|
20
|
|
|
template, |
|
21
|
|
|
|
|
22
|
|
|
props: { |
|
23
|
|
|
fullWidth: { |
|
24
|
|
|
type: Boolean, |
|
25
|
|
|
required: false, |
|
26
|
|
|
default: false, |
|
27
|
|
|
}, |
|
28
|
|
|
|
|
29
|
|
|
hideIcon: { |
|
30
|
|
|
type: Boolean, |
|
31
|
|
|
required: false, |
|
32
|
|
|
default: false, |
|
33
|
|
|
}, |
|
34
|
|
|
|
|
35
|
|
|
fromLink: { |
|
36
|
|
|
type: Object as PropType<Route|null>, |
|
37
|
|
|
required: false, |
|
38
|
|
|
default: null, |
|
39
|
|
|
}, |
|
40
|
|
|
}, |
|
41
|
|
|
|
|
42
|
|
|
data(): ComponentData { |
|
43
|
|
|
return { |
|
44
|
|
|
module: null, |
|
45
|
|
|
parentRoute: null, |
|
46
|
|
|
}; |
|
47
|
|
|
}, |
|
48
|
|
|
|
|
49
|
|
|
computed: { |
|
50
|
|
|
pageClasses(): object { |
|
51
|
|
|
return { |
|
52
|
|
|
'sw-meteor-page--full-width': this.fullWidth, |
|
53
|
|
|
}; |
|
54
|
|
|
}, |
|
55
|
|
|
|
|
56
|
|
|
hasIcon(): boolean { |
|
57
|
|
|
return typeof this.module?.icon === 'string'; |
|
58
|
|
|
}, |
|
59
|
|
|
|
|
60
|
|
|
hasIconOrIconSlot(): boolean { |
|
61
|
|
|
return this.hasIcon || |
|
62
|
|
|
typeof this.$slots['smart-bar-icon'] !== 'undefined' || |
|
63
|
|
|
typeof this.$scopedSlots['smart-bar-icon'] !== 'undefined'; |
|
64
|
|
|
}, |
|
65
|
|
|
|
|
66
|
|
|
hasTabs(): boolean { |
|
67
|
|
|
return typeof this.$slots['page-tabs'] !== 'undefined' || |
|
68
|
|
|
typeof this.$scopedSlots['page-tabs'] !== 'undefined'; |
|
69
|
|
|
}, |
|
70
|
|
|
|
|
71
|
|
|
pageColor(): string { |
|
72
|
|
|
return this.module?.color ?? '#d8dde6'; |
|
73
|
|
|
}, |
|
74
|
|
|
}, |
|
75
|
|
|
|
|
76
|
|
|
beforeDestroy(): void { |
|
77
|
|
|
void Shopware.State.dispatch('error/resetApiErrors'); |
|
78
|
|
|
}, |
|
79
|
|
|
|
|
80
|
|
|
mounted(): void { |
|
81
|
|
|
this.mountedComponent(); |
|
82
|
|
|
}, |
|
83
|
|
|
|
|
84
|
|
|
methods: { |
|
85
|
|
|
mountedComponent(): void { |
|
86
|
|
|
this.initPage(); |
|
87
|
|
|
}, |
|
88
|
|
|
|
|
89
|
|
|
emitNewTab(tabItem: string) { |
|
90
|
|
|
this.$emit('new-item-active', tabItem); |
|
91
|
|
|
}, |
|
92
|
|
|
|
|
93
|
|
|
initPage(): void { |
|
94
|
|
|
if (typeof this.$route?.meta?.$module !== 'undefined') { |
|
95
|
|
|
this.module = this.$route.meta.$module as ModuleManifest|null; |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
if (typeof this.$route?.meta?.parentPath === 'string') { |
|
99
|
|
|
this.parentRoute = this.$route.meta.parentPath; |
|
100
|
|
|
} |
|
101
|
|
|
}, |
|
102
|
|
|
}, |
|
103
|
|
|
}); |
|
104
|
|
|
|