-
Notifications
You must be signed in to change notification settings - Fork 325
/
ComposePage.vue
134 lines (122 loc) · 3.08 KB
/
ComposePage.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<template>
<tr>
<td />
<td>
<b-form-group :label="$t('navigation.fieldLabel')">
<b-form-input
v-model="options.item.label"
type="text"
/>
</b-form-group>
</td>
<td style="min-width: 200px;">
<b-form-group :label="$t('navigation.composePage')">
<vue-select
key="pageID"
v-model="options.item.pageID"
:placeholder="$t('navigation.none')"
:options="pageList"
append-to-body
:get-option-key="getOptionKey"
label="title"
:calculate-position="calculateDropdownPosition"
:reduce="f => f.pageID"
option-value="pageID"
option-text="title"
class="bg-white"
@input="updateLabelValue"
/>
</b-form-group>
</td>
<td>
<b-form-group :label="$t('navigation.openIn')">
<b-form-select
v-model="options.item.target"
:options="targetOptions"
/>
</b-form-group>
</td>
<td
v-if="selectedPageChildren(options.item.pageID).length > 0"
cols="12"
sm="6"
class="align-middle text-center"
>
<b-form-group
:label="$t('navigation.displaySubPages')"
label-class="text-nowrap"
class="d-flex align-items-center justify-content-center mb-0"
>
<c-input-checkbox
v-model="options.item.displaySubPages"
switch
size="sm"
/>
</b-form-group>
</td>
<td />
</tr>
</template>
<script>
import base from './base'
import { VueSelect } from 'vue-select'
import { NoID, compose } from '@cortezaproject/corteza-js'
export default {
components: {
VueSelect,
},
extends: base,
props: {
namespace: {
type: compose.Namespace,
required: true,
},
},
data () {
return {
pageList: [],
checkboxLabel: {
on: this.$t('general:label.yes'),
off: this.$t('general:label.no'),
},
targetOptions: [
{ value: 'sameTab', text: this.$t('navigation.sameTab') },
{ value: 'newTab', text: this.$t('navigation.newTab') },
],
}
},
created () {
this.loadPages()
},
methods: {
selectedPageChildren (pageID) {
return this.pageList.filter(value => value.selfID === pageID && value.moduleID === NoID) || []
},
loadPages () {
const { namespaceID } = this.namespace
this.$ComposeAPI
.pageList({ namespaceID, sort: 'title' })
.then(({ set: pages }) => {
this.pageList = pages.map(p => new compose.Page(p)).filter(p => p.moduleID === NoID)
})
.catch(this.toastErrorHandler(this.$t('notification:page.loadFailed')))
},
updateLabelValue (pageID) {
if (!this.options.item.label) {
const composePage = this.pageList.find(t => t.pageID === pageID)
this.options.item.label = composePage ? composePage.title : ''
}
},
getOptionKey ({ pageID }) {
return pageID
},
},
}
</script>
<style lang="scss" scoped>
th,
td {
padding-left: 15px;
padding-right: 15px;
}
</style>