Skip to content

Commit 512ecce

Browse files
authored
Page: Add ability to edit current tab of tabbed page (#2953)
Closes #2899. Signed-off-by: Florian Hotze <[email protected]>
1 parent 1f4673f commit 512ecce

File tree

1 file changed

+47
-17
lines changed

1 file changed

+47
-17
lines changed

bundles/org.openhab.ui/web/src/pages/page/page-view.vue

+47-17
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</f7-nav-left>
77
<f7-nav-title>{{ (page) ? page.config.label : '' }}</f7-nav-title>
88
<f7-nav-right>
9-
<f7-link v-if="isAdmin" icon-md="material:edit" :href="'/settings/pages/' + pageType + '/' + uid">
9+
<f7-link v-if="isAdmin" icon-md="material:edit" @click="editPage" class="edit-page-button">
1010
{{ $theme.md ? '' : $t('page.navbar.edit') }}
1111
</f7-link>
1212
<f7-link v-if="fullscreenIcon" class="fullscreen-icon-navbar" :icon-f7="fullscreenIcon" @click="toggleFullscreen" />
@@ -95,22 +95,7 @@ export default {
9595
return this.$store.getters.page(this.uid)
9696
},
9797
pageType () {
98-
if (!this.page) return null
99-
switch (this.page.component) {
100-
case 'oh-layout-page':
101-
return 'layout'
102-
case 'oh-map-page':
103-
return 'map'
104-
case 'oh-tabs-page':
105-
return 'tabs'
106-
case 'oh-plan-page':
107-
return 'plan'
108-
case 'oh-chart-page':
109-
return 'chart'
110-
default:
111-
console.warn('Unknown page type!')
112-
return 'unknown'
113-
}
98+
return this.getPageType(this.page)
11499
},
115100
isAdmin () {
116101
return this.page && this.$store.getters.isAdmin
@@ -149,6 +134,24 @@ export default {
149134
onCommand (itemName, command) {
150135
this.$store.dispatch('sendCommand', { itemName, command })
151136
},
137+
getPageType (page) {
138+
if (!page) return null
139+
switch (page.component) {
140+
case 'oh-layout-page':
141+
return 'layout'
142+
case 'oh-map-page':
143+
return 'map'
144+
case 'oh-tabs-page':
145+
return 'tabs'
146+
case 'oh-plan-page':
147+
return 'plan'
148+
case 'oh-chart-page':
149+
return 'chart'
150+
default:
151+
console.warn('Unknown page type!')
152+
return 'unknown'
153+
}
154+
},
152155
tabContext (tab) {
153156
const page = tab.config.page ? this.$store.getters.page(tab.config.page.replace('page:', '')) : tab.component
154157
const context = {
@@ -180,6 +183,33 @@ export default {
180183
const ctx = this.tabContext(tab)
181184
return this.evaluateExpression('tab-' + idx + '-' + key, tab.config[key], ctx, ctx.props)
182185
},
186+
editPage () {
187+
if (this.pageType === 'tabs') {
188+
const action = this.$f7.actions.create({
189+
buttons: [
190+
{
191+
text: 'Edit Tabbed Page',
192+
onClick: () => {
193+
this.$f7router.navigate('/settings/pages/' + this.pageType + '/' + this.uid)
194+
}
195+
},
196+
{
197+
text: 'Edit Current Tab',
198+
onClick: () => {
199+
const tabPageUid = this.page.slots.default[this.currentTab].config.page.replace('page:', '')
200+
const tabPage = this.$store.getters.page(tabPageUid)
201+
const tabPageType = this.getPageType(tabPage)
202+
this.$f7router.navigate('/settings/pages/' + tabPageType + '/' + tabPageUid)
203+
}
204+
}
205+
],
206+
targetEl: this.$el.querySelector('.edit-page-button')
207+
})
208+
action.open()
209+
} else {
210+
this.$f7router.navigate('/settings/pages/' + this.pageType + '/' + this.uid)
211+
}
212+
},
183213
toggleFullscreen () {
184214
this.$fullscreen.toggle(document.body, {
185215
wrap: false,

0 commit comments

Comments
 (0)