3
0

Update some block configurators UX with columns and c-input-selects

This commit is contained in:
Jože Fortun 2024-10-07 15:04:28 +02:00
parent 799c067526
commit ff07c40dbb
5 changed files with 269 additions and 247 deletions

View File

@ -6,9 +6,11 @@
> >
<c-input-select <c-input-select
v-model="options.moduleID" v-model="options.moduleID"
:options="moduleOptions" :options="filterModulesByRecord"
label="name" label="name"
:reduce="module => module.moduleID" :reduce="m => m.moduleID"
:placeholder="$t('comment.module.placeholder')"
default-value="0"
required required
/> />
</b-form-group> </b-form-group>
@ -60,91 +62,96 @@
</i18next> </i18next>
</b-form-group> </b-form-group>
<b-row>
<b-col
cols="12"
lg="6"
>
<b-form-group <b-form-group
:label="$t('comment.titleField.label')" :label="$t('comment.titleField.label')"
label-class="text-primary" label-class="text-primary"
> >
<b-form-select v-model="options.titleField"> <c-input-select
<option value=""> v-model="options.titleField"
{{ $t('general.label.none') }} :options="selectedModuleFieldsByType('String')"
</option> :get-option-label="f => `${f.label || f.name} (${f.kind})`"
:reduce="f => f.name"
<option :placeholder="$t('general.label.none')"
v-for="(field, index) in selectedModuleFieldsByType('String')" />
:key="index" <b-form-text>
:value="field.name" {{ $t('comment.titleField.footnote') }}
> </b-form-text>
{{ field.label || field.name }} ({{ field.kind }})
</option>
</b-form-select>
<b-form-text>{{ $t('comment.titleField.footnote') }}</b-form-text>
</b-form-group> </b-form-group>
</b-col>
<b-col
cols="12"
lg="6"
>
<b-form-group <b-form-group
:label="$t('comment.contentField.label')" :label="$t('comment.contentField.label')"
label-class="text-primary" label-class="text-primary"
> >
<b-form-select v-model="options.contentField"> <c-input-select
<option value=""> v-model="options.contentField"
{{ $t('general.label.none') }} :options="selectedModuleFieldsByType('String')"
</option> :get-option-label="f => `${f.label || f.name} (${f.kind})`"
<option :reduce="f => f.name"
v-for="(field, index) in selectedModuleFieldsByType('String')" :placeholder="$t('general.label.none')"
:key="index" />
:value="field.name" <b-form-text>
>
{{ field.label || field.name }} ({{ field.kind }})
</option>
</b-form-select>
<b-form-text class="text-secondary small">
{{ $t('comment.contentField.footnote') }} {{ $t('comment.contentField.footnote') }}
</b-form-text> </b-form-text>
</b-form-group> </b-form-group>
</b-col>
<b-col
cols="12"
lg="6"
>
<b-form-group <b-form-group
:label="$t('comment.referenceField.label')" :label="$t('comment.referenceField.label')"
label-class="text-primary" label-class="text-primary"
> >
<b-form-select v-model="options.referenceField"> <c-input-select
<option value=""> v-model="options.referenceField"
{{ $t('general.label.none') }} :options="selectedModuleFieldsByType('Record')"
</option> :get-option-label="f => `${f.label || f.name} (${f.kind})`"
<option :reduce="f => f.name"
v-for="(field, index) in selectedModuleFieldsByType('Record')" :placeholder="$t('general.label.none')"
:key="index" />
:value="field.name" <b-form-text>
>
{{ field.label || field.name }} ({{ field.kind }})
</option>
</b-form-select>
<b-form-text class="text-secondary small">
{{ $t('comment.referenceField.footnote') }} {{ $t('comment.referenceField.footnote') }}
</b-form-text> </b-form-text>
</b-form-group> </b-form-group>
</b-col>
<b-col
cols="12"
lg="6"
>
<b-form-group <b-form-group
:label="$t('comment.sortDirection.label')" :label="$t('comment.sortDirection.label')"
label-class="text-primary" label-class="text-primary"
> >
<b-form-select v-model="options.sortDirection"> <c-input-select
<option v-model="options.sortDirection"
v-for="(item, index) in sortDirections" :options="sortDirections"
:key="index" label="label"
:value="item.value" :clearable="false"
> :reduce="o => o.value"
{{ item.label }} />
</option> <b-form-text>
</b-form-select>
<b-form-text class="text-secondary small">
{{ $t('comment.sortDirection.footnote') }} {{ $t('comment.sortDirection.footnote') }}
</b-form-text> </b-form-text>
</b-form-group> </b-form-group>
</b-col>
</b-row>
</div> </div>
</b-tab> </b-tab>
</template> </template>
<script> <script>
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
import { NoID } from '@cortezaproject/corteza-js'
import base from './base' import base from './base'
export default { export default {
@ -157,8 +164,15 @@ export default {
extends: base, extends: base,
data () { data () {
return { return {
referenceList: [{ label: 'Record ID (recordID)', value: 'recordID' }, { label: 'Page ID (pageID)', value: 'pageID' }], referenceList: [
sortDirections: [{ label: this.$t('comment.sortDirection.asc'), value: 'asc' }, { label: this.$t('comment.sortDirection.desc'), value: 'desc' }], { label: 'Record ID (recordID)', value: 'recordID' },
{ label: 'Page ID (pageID)', value: 'pageID' },
],
sortDirections: [
{ label: this.$t('comment.sortDirection.asc'), value: 'asc' },
{ label: this.$t('comment.sortDirection.desc'), value: 'desc' },
],
} }
}, },
@ -167,13 +181,6 @@ export default {
modules: 'module/set', modules: 'module/set',
}), }),
moduleOptions () {
return [
{ moduleID: NoID, name: this.$t('general.label.none') },
...this.filterModulesByRecord,
]
},
filterModulesByRecord () { filterModulesByRecord () {
if (this.record) { if (this.record) {
return this.modules.filter(module => { return this.modules.filter(module => {

View File

@ -15,7 +15,7 @@
<b-row> <b-row>
<b-col <b-col
cols="12" cols="12"
lg="6" :lg="isInlineEditorAllowed ? 6 : 12"
> >
<b-form-group <b-form-group
:label="$t('general.module')" :label="$t('general.module')"
@ -24,16 +24,18 @@
> >
<c-input-select <c-input-select
v-model="options.moduleID" v-model="options.moduleID"
:options="moduleOptions" :options="modules"
label="name" label="name"
:reduce="o => o.moduleID" :reduce="o => o.moduleID"
:placeholder="$t('recordList.modulePlaceholder')"
default-value="0"
required required
/> />
</b-form-group> </b-form-group>
</b-col> </b-col>
<b-col <b-col
v-if="recordListModule && (onRecordPage || options.editable)" v-if="isInlineEditorAllowed"
cols="12" cols="12"
lg="6" lg="6"
> >
@ -84,7 +86,7 @@
:module="recordListModule" :module="recordListModule"
:fields.sync="options.fields" :fields.sync="options.fields"
class="mb-3" class="mb-3"
style="height: 40vh;" style="height: 50vh;"
/> />
</b-col> </b-col>
@ -150,7 +152,7 @@
:fields.sync="options.editFields" :fields.sync="options.editFields"
:field-subset="options.fields" :field-subset="options.fields"
disable-system-fields disable-system-fields
style="height: 40vh;" style="height: 50vh;"
/> />
</b-form-group> </b-form-group>
@ -471,6 +473,30 @@
</b-form-group> </b-form-group>
</b-col> </b-col>
<b-col
cols="12"
lg="6"
>
<b-form-group
label-class="d-flex align-items-center text-primary p-0"
>
<template #label>
{{ $t('recordList.record.fullPageNavigation') }}
<c-hint
:tooltip="$t('recordList.tooltip.performance.impact')"
icon-class="text-warning"
/>
</template>
<c-input-checkbox
v-model="options.fullPageNavigation"
switch
:labels="checkboxLabel"
data-test-id="hide-page-navigation"
/>
</b-form-group>
</b-col>
<b-col <b-col
cols="12" cols="12"
lg="6" lg="6"
@ -478,7 +504,7 @@
<b-form-group <b-form-group
horizontal horizontal
breakpoint="md" breakpoint="md"
label-class="d-flex align-items-center text-primary p-0" label-class="d-flex align-items-center text-primary"
> >
<template #label> <template #label>
{{ $t('recordList.record.perPage') }} {{ $t('recordList.record.perPage') }}
@ -496,25 +522,6 @@
/> />
</b-form-group> </b-form-group>
</b-col> </b-col>
</b-row>
<b-row>
<b-col
cols="12"
lg="6"
>
<b-form-group
:label="$t('recordList.record.showTotalCount')"
label-class="text-primary"
>
<c-input-checkbox
v-model="options.showTotalCount"
data-test-id="show-total-record-count"
switch
:labels="checkboxLabel"
/>
</b-form-group>
</b-col>
<b-col <b-col
cols="12" cols="12"
@ -531,29 +538,20 @@
/> />
</b-form-group> </b-form-group>
</b-col> </b-col>
</b-row>
<b-row>
<b-col <b-col
cols="12" cols="12"
lg="6" lg="6"
> >
<b-form-group <b-form-group
label-class="d-flex align-items-center text-primary p-0" :label="$t('recordList.record.showTotalCount')"
label-class="text-primary"
> >
<template #label>
{{ $t('recordList.record.fullPageNavigation') }}
<c-hint
:tooltip="$t('recordList.tooltip.performance.impact')"
icon-class="text-warning"
/>
</template>
<c-input-checkbox <c-input-checkbox
v-model="options.fullPageNavigation" v-model="options.showTotalCount"
data-test-id="show-total-record-count"
switch switch
:labels="checkboxLabel" :labels="checkboxLabel"
data-test-id="hide-page-navigation"
/> />
</b-form-group> </b-form-group>
</b-col> </b-col>
@ -841,13 +839,6 @@ export default {
] ]
}, },
moduleOptions () {
return [
{ moduleID: NoID, name: this.$t('general.label.none') },
...this.modules,
]
},
recordListModule () { recordListModule () {
if (this.options.moduleID !== NoID) { if (this.options.moduleID !== NoID) {
return this.getModuleByID(this.options.moduleID) return this.getModuleByID(this.options.moduleID)
@ -903,22 +894,8 @@ export default {
return [] return []
}, },
/* isInlineEditorAllowed () {
Inline record editor is disabled if: return this.recordListModule && (this.onRecordPage || this.options.editable)
- An inline record editor for the same module already exists
- Record list module doesn't have record page (inline record autoselected and disabled)
*/
disableInlineEditor () {
const thisModuleID = this.options.moduleID
// Finds another inline editor block with the same recordListModule as this one
const otherInlineWithSameModule = this.blocks.some(({ kind, options }, index) => {
if (this.blockIndex !== index) {
return kind === 'RecordList' && options.editable && options.moduleID === thisModuleID
}
})
return otherInlineWithSameModule || !this.recordListModuleRecordPage
}, },
}, },
@ -974,10 +951,10 @@ export default {
}, },
methods: { methods: {
async fetchRoles () { fetchRoles () {
if (this.options.filterPresets.length) {
this.fetchingRoles = true this.fetchingRoles = true
if (this.options.filterPresets.length) {
const rolesToResolve = this.options.filterPresets.reduce((acc, { roles }) => { const rolesToResolve = this.options.filterPresets.reduce((acc, { roles }) => {
return acc.concat(roles) return acc.concat(roles)
}, []) }, [])

View File

@ -2,12 +2,15 @@
<b-tab :title="$t('recordOrganizer.label')"> <b-tab :title="$t('recordOrganizer.label')">
<b-form-group <b-form-group
:label="$t('general.module')" :label="$t('general.module')"
label-class="text-primary"
> >
<c-input-select <c-input-select
v-model="options.moduleID" v-model="options.moduleID"
:options="moduleOptions" :options="modules"
label="name" label="name"
:reduce="m => m.moduleID" :reduce="m => m.moduleID"
:placeholder="$t('recordOrganizer.module.placeholder')"
default-value="0"
required required
/> />
</b-form-group> </b-form-group>
@ -59,6 +62,11 @@
</i18next> </i18next>
</b-form-group> </b-form-group>
<b-row>
<b-col
cols="12"
lg="6"
>
<b-form-group <b-form-group
:label="$t('recordOrganizer.labelField.label')" :label="$t('recordOrganizer.labelField.label')"
label-class="text-primary" label-class="text-primary"
@ -72,7 +80,12 @@
/> />
<b-form-text>{{ $t('recordOrganizer.labelField.footnote') }}</b-form-text> <b-form-text>{{ $t('recordOrganizer.labelField.footnote') }}</b-form-text>
</b-form-group> </b-form-group>
</b-col>
<b-col
cols="12"
lg="6"
>
<b-form-group <b-form-group
:label="$t('recordOrganizer.descriptionField.label')" :label="$t('recordOrganizer.descriptionField.label')"
label-class="text-primary" label-class="text-primary"
@ -89,23 +102,12 @@
{{ $t('recordOrganizer.descriptionField.footnote') }} {{ $t('recordOrganizer.descriptionField.footnote') }}
</b-form-text> </b-form-text>
</b-form-group> </b-form-group>
</b-col>
<b-form-group <b-col
:label="$t('recordOrganizer.positionField.label')" cols="12"
label-class="text-primary" lg="6"
> >
<c-input-select
v-model="options.positionField"
:placeholder="$t('recordOrganizer.positionField.placeholder')"
:reduce="f => f.name"
label="label"
/>
<b-form-text class="text-secondary small">
{{ $t('recordOrganizer.positionField.footnote') }}
</b-form-text>
</b-form-group>
<b-form-group <b-form-group
:label="$t('recordOrganizer.groupField.label')" :label="$t('recordOrganizer.groupField.label')"
label-class="text-primary" label-class="text-primary"
@ -122,24 +124,60 @@
{{ $t('recordOrganizer.groupField.footnote') }} {{ $t('recordOrganizer.groupField.footnote') }}
</b-form-text> </b-form-text>
</b-form-group> </b-form-group>
</b-col>
<b-col
cols="12"
lg="6"
>
<b-form-group <b-form-group
v-if="options.groupField"
:label="$t('recordOrganizer.group.label')" :label="$t('recordOrganizer.group.label')"
label-class="text-primary" label-class="text-primary"
> >
<field-editor <field-editor
class="mb-0" v-if="options.groupField"
value-only
v-bind="mock" v-bind="mock"
value-only
class="mb-0"
/> />
<b-form-input
v-else
disabled
/>
<b-form-text class="text-secondary small"> <b-form-text class="text-secondary small">
{{ $t('recordOrganizer.group.footnote') }} {{ $t('recordOrganizer.group.footnote') }}
</b-form-text> </b-form-text>
</b-form-group> </b-form-group>
</b-col>
<b-col
cols="12"
lg="6"
>
<b-form-group
:label="$t('recordOrganizer.positionField.label')"
label-class="text-primary"
>
<c-input-select
v-model="options.positionField"
:placeholder="$t('recordOrganizer.positionField.placeholder')"
:reduce="f => f.name"
label="label"
/>
<b-form-text class="text-secondary small">
{{ $t('recordOrganizer.positionField.footnote') }}
</b-form-text>
</b-form-group>
</b-col>
<b-col
cols="12"
lg="6"
>
<b-form-group <b-form-group
v-if="options.groupField"
:label="$t('recordOrganizer.onRecordClick')" :label="$t('recordOrganizer.onRecordClick')"
label-class="text-primary" label-class="text-primary"
class="mb-0" class="mb-0"
@ -149,13 +187,15 @@
:options="displayOptions" :options="displayOptions"
/> />
</b-form-group> </b-form-group>
</b-col>
</b-row>
</div> </div>
</b-tab> </b-tab>
</template> </template>
<script> <script>
import FieldEditor from '../ModuleFields/Editor' import FieldEditor from '../ModuleFields/Editor'
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
import { compose, validator, NoID } from '@cortezaproject/corteza-js' import { compose, validator } from '@cortezaproject/corteza-js'
import base from './base' import base from './base'
export default { export default {
@ -192,13 +232,6 @@ export default {
modules: 'module/set', modules: 'module/set',
}), }),
moduleOptions () {
return [
{ moduleID: NoID, name: this.$t('general.label.none') },
...this.modules,
]
},
selectedModule () { selectedModule () {
return this.modules.find(m => m.moduleID === this.options.moduleID) return this.modules.find(m => m.moduleID === this.options.moduleID)
}, },

View File

@ -426,6 +426,7 @@ recordList:
title: Record import error report title: Record import error report
totalRecords: Total records totalRecords: Total records
label: Record list label: Record list
modulePlaceholder: Select a module
moduleFootnote: Modules without a {{0}} can only be used in a record list as an inline editor moduleFootnote: Modules without a {{0}} can only be used in a record list as an inline editor
moduleFieldsFootnote : If no fields are selected, the default fields will be shown moduleFieldsFootnote : If no fields are selected, the default fields will be shown
noRecords: There are no records matching your request noRecords: There are no records matching your request
@ -468,12 +469,12 @@ recordList:
pagingLabel: Paging pagingLabel: Paging
pagingOptions: Paging Options pagingOptions: Paging Options
moreOptions: More Options moreOptions: More Options
hidePaging: User will be able to use Paging hidePaging: User will be able to navigate through pages
inlineEditor: Inline Options inlineEditor: Inline Options
inlineEditorAllow: Inline record editor inlineEditorAllow: Inline record editor
recordsLabel: Records recordsLabel: Records
noPermission: No permission to read record noPermission: No permission to read record
perPage: Per Page perPage: Records per page
prefilterFootnote: Simplified SQL condition (WHERE ...) syntax is supported. Variables like {{0}}, {{1}}, {{2}} and {{3}} are evaluated (when available) prefilterFootnote: Simplified SQL condition (WHERE ...) syntax is supported. Variables like {{0}}, {{1}}, {{2}} and {{3}} are evaluated (when available)
prefilterHideSearch: Users will be able to search the record list prefilterHideSearch: Users will be able to search the record list
filterHide: Users will be able to filter the list filterHide: Users will be able to filter the list
@ -488,7 +489,7 @@ recordList:
presortInputLabel: Presort presortInputLabel: Presort
presortPlaceholder: field1 DESC, field2 ASC presortPlaceholder: field1 DESC, field2 ASC
showTotalCount: Show total record count showTotalCount: Show total record count
showRecordPerPageOption: Allow users to select records per page showRecordPerPageOption: User will be able to select records per page
showDeletedRecordsOption: Show option to see deleted records showDeletedRecordsOption: Show option to see deleted records
setCustomFilterPresets: User will be able to set custom filter presets setCustomFilterPresets: User will be able to set custom filter presets
openInSameTab: Open record in the same tab openInSameTab: Open record in the same tab
@ -525,6 +526,8 @@ recordOrganizer:
openInSameTab: Open in the same tab openInSameTab: Open in the same tab
openInNewTab: Open in a new tab openInNewTab: Open in a new tab
openInModal: Open in a modal openInModal: Open in a modal
module:
placeholder: Select a module
descriptionField: descriptionField:
footnote: Field value will be used as record description footnote: Field value will be used as record description
label: Description field label: Description field
@ -617,6 +620,8 @@ field:
title: Update record values title: Update record values
comment: comment:
label: Comments label: Comments
module:
placeholder: Select a module
titleField: titleField:
label: Title field label: Title field
footnote: Field value will be used as record title footnote: Field value will be used as record title
@ -628,12 +633,12 @@ comment:
submit: Submit submit: Submit
sortDirection: sortDirection:
label: Sort direction label: Sort direction
footnote: Field value will be used as sorting direction reference footnote: Sort comments by when they were created
asc: ASC asc: Ascending
desc: DESC desc: Descending
referenceField: referenceField:
label: Reference field label: Reference field
footnote: Field value will be used as reference footnote: Field that links comments with the parent record
navigation: navigation:
chart: Charts chart: Charts
colorPicker: Choose a color colorPicker: Choose a color

View File

@ -116,7 +116,7 @@ kind:
currentUnnamedModule: (Current unnamed module) currentUnnamedModule: (Current unnamed module)
label: Record label: Record
moduleLabel: Module moduleLabel: Module
modulePlaceholder: Pick module modulePlaceholder: Select a module
queryFieldsLabel: Query fields on search queryFieldsLabel: Query fields on search
moduleField: Label field moduleField: Label field
variantField: Variant field variantField: Variant field