-
-
Notifications
You must be signed in to change notification settings - Fork 282
Sitemap editor: nested sitemaps #4206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| <template> | ||
| <ul class="sitemap-picker-container"> | ||
| <f7-list-item | ||
| v-if="ready" | ||
| :title="title || 'Sitemap'" | ||
| smart-select | ||
| :smart-select-params="smartSelectParams" | ||
| ref="smartSelect" | ||
| :no-chevron="disabled" | ||
| :disabled="disabled"> | ||
| <select :name="name" @change="select" :required="required"> | ||
| <option value="" /> | ||
| <option v-for="sitemap in sitemaps" :value="sitemap.name" :key="sitemap.name" :selected="value === sitemap.name ? true : null"> | ||
| {{ sitemap.label ? sitemap.label + ' (' + sitemap.name + ')' : sitemap.name }} | ||
| </option> | ||
| </select> | ||
| </f7-list-item> | ||
| <!-- for placeholder purposes before sitemaps are loaded --> | ||
| <f7-list-item v-show="!ready" link :title="title" /> | ||
| </ul> | ||
| </template> | ||
|
|
||
| <style lang="stylus"> | ||
| .sitemap-picker-container | ||
| .item-inner:after | ||
| display none | ||
| </style> | ||
|
|
||
| <script> | ||
| import { f7 } from 'framework7-vue' | ||
| import { nextTick } from 'vue' | ||
| import { showToast } from '@/js/dialog-promises' | ||
|
|
||
| import * as api from '@/api' | ||
|
|
||
| export default { | ||
| props: { | ||
| title: String, | ||
| name: String, | ||
| value: String, | ||
| required: Boolean, | ||
| filterType: Array, | ||
| openOnReady: Boolean, | ||
| disabled: Boolean | ||
| }, | ||
| emits: ['sitemapPicked', 'input'], | ||
| data() { | ||
| return { | ||
| ready: false, | ||
| sitemaps: [], | ||
| smartSelectParams: { | ||
| view: f7.view.main, | ||
| openIn: 'popup', | ||
| searchbar: true, | ||
| searchbarPlaceholder: this.$t('dialogs.search.sitemaps') | ||
| } | ||
| } | ||
| }, | ||
| created() { | ||
| this.smartSelectParams.closeOnSelect = true | ||
| api | ||
| .getSitemaps() | ||
| .then((data) => { | ||
| this.sitemaps = data | ||
| .map((sitemap) => { | ||
| return { | ||
| name: sitemap.name, | ||
| label: sitemap.label | ||
| } | ||
| }) | ||
| .sort((a, b) => { | ||
| const labelA = a.label || a.name | ||
| const labelB = b.label || b.name | ||
| return labelA.localeCompare(labelB) | ||
| }) | ||
| if (this.filterType) { | ||
| this.sitemaps = this.sitemaps.filter((i) => this.filterType.indexOf(i.type) >= 0) | ||
| if (this.sitemaps.length < 5) { | ||
| this.smartSelectParams.openIn = 'sheet' | ||
| this.smartSelectParams.searchbar = false | ||
| } | ||
| } | ||
| this.ready = true | ||
| if (this.openOnReady) { | ||
| nextTick(() => { | ||
| this.$refs.smartSelect.$el.children[0].f7SmartSelect.open() | ||
| }) | ||
| } | ||
| }) | ||
| .catch((err) => { | ||
| console.error(err) | ||
| showToast('An error occurred while loading sitemaps: ' + (err?.message || String(err))) | ||
| }) | ||
| }, | ||
| methods: { | ||
| open() { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see where 'open' is used, is it needed?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not used. |
||
| this.$refs.smartSelect.$el.children[0].f7SmartSelect.open() | ||
| }, | ||
| select(e) { | ||
| f7.input.validateInputs(this.$refs.smartSelect.$el) | ||
| this.$emit('input', e.target.value) | ||
| f7.emit('sitemapPicked', e.target.value) | ||
| } | ||
| } | ||
| } | ||
| </script> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -283,6 +283,16 @@ | |
| </option> | ||
| </select> | ||
| </f7-list-item> | ||
| <ul v-if="supports('name')" style="padding-left: 0" class="widget-nested-sitemap"> | ||
| <sitemap-picker | ||
| style="padding-left: 0" | ||
| title="Sitemap" | ||
| :value="widget.name" | ||
| :disabled="!editable" | ||
| @input="(value) => (widget.name = value)" /> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you can change the emit to be update:value instead of 'input'. That way, you can use vmodel:value="widget.name" which is shorthand for the 2 separate :value and @input lines.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK |
||
| <f7-link v-if="widget.name" @click="navigateNestedSitemap(widget.name)"> <a>Edit Sitemap</a></f7-link> | ||
| <f7-link v-else-if="!widget.item" @click="navigateNestedSitemap()"> <a>Add Sitemap</a></f7-link> | ||
| </ul> | ||
| </ul> | ||
| </f7-list> | ||
| </f7-card-content> | ||
|
|
@@ -318,6 +328,14 @@ | |
| color var(--f7-block-text-color) | ||
| .widget-persistence .item-after | ||
| color var(--f7-block-text-color) | ||
| .widget-nested-sitemap | ||
| .item-after | ||
| color var(--f7-block-text-color) | ||
| .link | ||
| display flex | ||
| flex-direction column | ||
| align-items flex-end | ||
| padding-right calc(var(--f7-list-item-padding-horizontal) + var(--f7-safe-area-right) - var(--menu-list-offset)) | ||
| #additional:before | ||
| display block !important /* need two selectors to override the important Vue card css */ | ||
|
|
||
|
|
@@ -336,21 +354,23 @@ import { Categories } from '@/assets/categories.js' | |
| import FormatEditor from '@/components/config/controls/format-editor.vue' | ||
| import ItemPicker from '@/components/config/controls/item-picker.vue' | ||
| import PersistencePicker from '@/components/config/controls/persistence-picker.vue' | ||
| import SitemapPicker from '@/components/config/controls/sitemap-picker.vue' | ||
| import SitemapMixin from '@/components/pagedesigner/sitemap/sitemap-mixin' | ||
|
|
||
| export default { | ||
| mixins: [SitemapMixin], | ||
| components: { | ||
| FormatEditor, | ||
| ItemPicker, | ||
| PersistencePicker | ||
| PersistencePicker, | ||
| SitemapPicker | ||
| }, | ||
| props: { | ||
| widget: Object, | ||
| editable: Boolean, | ||
| createMode: Boolean | ||
| }, | ||
| emits: ['sortbuttons', 'moveup', 'movedown', 'duplicate', 'remove'], | ||
| emits: ['sortbuttons', 'moveup', 'movedown', 'duplicate', 'remove', 'navigate-nested-sitemap'], | ||
| data() { | ||
| return { | ||
| iconInputId: '', | ||
|
|
@@ -413,6 +433,9 @@ export default { | |
| } | ||
| } | ||
| }, | ||
| navigateNestedSitemap(target) { | ||
| this.$emit('navigate-nested-sitemap', target) | ||
| }, | ||
| remove() { | ||
| this.$emit('remove') | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since sitempaPicked is an f7.emit, it shouldn't be listed here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i actually don't see where there is a f7.on sitemapPicked - maybe this is just here for consistency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code is copied from persistencePicker I believe, so your feedback also may also apply to that one (and some other pickers). But all you point out is correct.