Add fragment option to oh-repeater (#582)

Signed-off-by: Yannick Schaus <github@schaus.net>
pull/591/head
Yannick Schaus 2020-11-30 20:14:05 +01:00 committed by GitHub
parent cc4f6a6a8d
commit 38a06d2e00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 3 deletions

View File

@ -17387,6 +17387,11 @@
}
}
},
"vue-fragment": {
"version": "1.5.1",
"resolved": "https://registry.npmjs.org/vue-fragment/-/vue-fragment-1.5.1.tgz",
"integrity": "sha512-ig6eES6TcMBbANW71ylB+AJgRN+Zksb3f50AxjGpAk6hMzqmeuD80qeh4LJP0jVw2dMBMjgRUfIkrvxygoRgtQ=="
},
"vue-hot-reload-api": {
"version": "2.3.4",
"resolved": "https://registry.npmjs.org/vue-hot-reload-api/-/vue-hot-reload-api-2.3.4.tgz",

View File

@ -77,6 +77,7 @@
"vue-async-computed": "^3.9.0",
"vue-codemirror": "^4.0.6",
"vue-echarts": "^4.1.0",
"vue-fragment": "^1.5.1",
"vue-knob-control": "^1.6.0",
"vue-magic-grid": "0.0.4",
"vue2-leaflet": "^2.5.2",

View File

@ -1,4 +1,4 @@
import { pt, pb, pn } from '../helpers'
import { pt, pb, pi, pn } from '../helpers'
export default () => [
pt('for', 'Current element variable', 'Name of the variable holding the current element in the iteration, it will be propagated to the children components in the default slot. ' +
@ -14,12 +14,13 @@ export default () => [
pn('rangeStart', 'Range Start', 'Start of range (for "range" source type)'),
pn('rangeStop', 'Range Stop', 'End of range (for "range" source type)'),
pn('rangeStep', 'Range Step', 'Step of range (for "range" source type)'),
pt('groupItem', 'Group Item', 'Group item to whose members will be iterated (for "itemsInGroup" source type)'),
pi('groupItem', 'Group Item', 'Group item to whose members will be iterated (for "itemsInGroup" source type)'),
pt('itemTags', 'Item Tags', 'Iterate over items with the given tags (comma-separated, for "itemsWithTags" source type)'),
pt('fetchMetadata', 'Fetch Item Metadata Namespaces', 'Fetch the metadata from these namespaces (for "itemsInGroup" and "itemsWithTags" source types)'),
pt('filter', 'Filter expression', 'Specify an expression WITHOUT THE = PREFIX to filter the resulting array'),
pt('map', 'Map expression', 'Specify an expression WITHOUT THE = PREFIX to transform the resulting array elements'),
pb('listContainer', 'List container', 'The child components will be wrapped in a <code>ul</code> HTML elements instead of a <code>div</code>'),
pt('containerClasses', 'Classes of the container', 'Add these CSS classes to the container'),
pt('containerStyle', 'Styles of the container', 'Add these CSS styles to the container')
pt('containerStyle', 'Styles of the container', 'Add these CSS styles to the container'),
pb('fragment', 'No container (fragment)', 'Render all children directly under the repeater\'s parent, without any container')
]

View File

@ -2,6 +2,9 @@
<ul v-if="config.listContainer" :class="config.containerClasses" :style="config.containerStyle">
<generic-widget-component :context="ctx" v-for="(ctx, idx) in childrenContexts" :key="'repeater-' + idx" @command="onCommand" />
</ul>
<fragment v-else-if="config.fragment">
<generic-widget-component :context="ctx" v-for="(ctx, idx) in childrenContexts" :key="'repeater-' + idx" @command="onCommand" />
</fragment>
<div v-else :class="config.containerClasses" :style="config.containerStyle">
<generic-widget-component :context="ctx" v-for="(ctx, idx) in childrenContexts" :key="'repeater-' + idx" @command="onCommand" />
</div>
@ -11,9 +14,13 @@
import mixin from '../widget-mixin'
import { OhRepeaterDefinition } from '@/assets/definitions/widgets/system'
import { compareItems } from '@/components/widgets/widget-order'
import { Fragment } from 'vue-fragment'
export default {
mixins: [mixin],
components: {
Fragment
},
widget: OhRepeaterDefinition,
computed: {
childrenContexts () {