Add option to define custom record page layout titles with interpolation
This commit is contained in:
@@ -76,6 +76,7 @@
|
||||
tag="small"
|
||||
class="text-muted"
|
||||
>
|
||||
<code>${record.values.fieldName}</code>
|
||||
<code>${recordID}</code>
|
||||
<code>${ownerID}</code>
|
||||
<code>${userID}</code>
|
||||
|
||||
@@ -61,6 +61,7 @@
|
||||
path="kind.record.prefilterFootnote"
|
||||
tag="label"
|
||||
>
|
||||
<code>${record.values.fieldName}</code>
|
||||
<code>${recordID}</code>
|
||||
<code>${ownerID}</code>
|
||||
<code>${userID}</code>
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
path="recordList.record.prefilterFootnote"
|
||||
tag="label"
|
||||
>
|
||||
<code>${record.values.fieldName}</code>
|
||||
<code>${recordID}</code>
|
||||
<code>${ownerID}</code>
|
||||
<code>${userID}</code>
|
||||
|
||||
@@ -161,6 +161,7 @@
|
||||
path="metric.edit.filterFootnote"
|
||||
tag="label"
|
||||
>
|
||||
<code>${record.values.fieldName}</code>
|
||||
<code>${recordID}</code>
|
||||
<code>${ownerID}</code>
|
||||
<code>${userID}</code>
|
||||
|
||||
@@ -59,6 +59,7 @@
|
||||
path="metric.edit.filterFootnote"
|
||||
tag="label"
|
||||
>
|
||||
<code>${record.values.fieldName}</code>
|
||||
<code>${recordID}</code>
|
||||
<code>${ownerID}</code>
|
||||
<code>${userID}</code>
|
||||
@@ -169,6 +170,7 @@
|
||||
path="metric.edit.filterFootnote"
|
||||
tag="label"
|
||||
>
|
||||
<code>${record.values.fieldName}</code>
|
||||
<code>${recordID}</code>
|
||||
<code>${ownerID}</code>
|
||||
<code>${userID}</code>
|
||||
@@ -279,6 +281,7 @@
|
||||
path="metric.edit.filterFootnote"
|
||||
tag="label"
|
||||
>
|
||||
<code>${record.values.fieldName}</code>
|
||||
<code>${recordID}</code>
|
||||
<code>${ownerID}</code>
|
||||
<code>${userID}</code>
|
||||
|
||||
@@ -240,10 +240,9 @@
|
||||
path="recordList.record.prefilterFootnote"
|
||||
tag="label"
|
||||
>
|
||||
<code>${record.values.fieldName}</code>
|
||||
<code>${recordID}</code>
|
||||
|
||||
<code>${ownerID}</code>
|
||||
|
||||
<code>${userID}</code>
|
||||
</i18next>
|
||||
</b-form-text>
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
path="recordList.record.prefilterFootnote"
|
||||
tag="label"
|
||||
>
|
||||
<code>${record.values.fieldName}</code>
|
||||
<code>${recordID}</code>
|
||||
<code>${ownerID}</code>
|
||||
<code>${userID}</code>
|
||||
|
||||
@@ -380,6 +380,7 @@
|
||||
:title="$t('page-layout.configure', { title: ((layoutEditor.layout || {}).meta || {}).title, interpolation: { escapeValue: false } })"
|
||||
:ok-title="$t('general:label.saveAndClose')"
|
||||
ok-variant="primary"
|
||||
:ok-disabled="!layoutEditor.layout.meta.title"
|
||||
cancel-variant="link"
|
||||
size="xl"
|
||||
scrollable
|
||||
@@ -388,6 +389,79 @@
|
||||
@cancel="layoutEditor.layout = undefined"
|
||||
@hide="layoutEditor.layout = undefined"
|
||||
>
|
||||
<h5 class="mb-3">
|
||||
{{ $t('page-layout.general') }}
|
||||
</h5>
|
||||
|
||||
<b-row>
|
||||
<b-col
|
||||
cols="12"
|
||||
lg="6"
|
||||
>
|
||||
<b-form-group
|
||||
:label="$t('page-layout.title')"
|
||||
label-class="text-primary"
|
||||
>
|
||||
<b-input-group>
|
||||
<b-form-input
|
||||
v-model="layoutEditor.layout.meta.title"
|
||||
:state="layoutTitleState(layoutEditor.layout.meta.title)"
|
||||
@input="layoutEditor.layout.meta.updated = true"
|
||||
/>
|
||||
|
||||
<b-input-group-append>
|
||||
<page-layout-translator
|
||||
:page-layout="layoutEditor.layout"
|
||||
:disabled="layoutEditor.layout.pageLayoutID === '0'"
|
||||
highlight-key="meta.title"
|
||||
button-variant="light"
|
||||
/>
|
||||
</b-input-group-append>
|
||||
</b-input-group>
|
||||
</b-form-group>
|
||||
</b-col>
|
||||
|
||||
<b-col
|
||||
cols="12"
|
||||
lg="6"
|
||||
>
|
||||
<b-form-group
|
||||
:label="$t('page-layout.handle')"
|
||||
label-class="text-primary"
|
||||
>
|
||||
<b-form-input
|
||||
v-model="layoutEditor.layout.handle"
|
||||
:state="layoutHandleState(layoutEditor.layout.handle)"
|
||||
@input="layoutEditor.layout.meta.updated = true"
|
||||
/>
|
||||
</b-form-group>
|
||||
</b-col>
|
||||
</b-row>
|
||||
|
||||
<b-form-group
|
||||
v-if="isRecordPage"
|
||||
:label="$t('page-layout.useTitle')"
|
||||
label-class="text-primary ml-auto mt-2"
|
||||
>
|
||||
<c-input-checkbox
|
||||
v-model="layoutEditor.layout.config.useTitle"
|
||||
switch
|
||||
:labels="checkboxLabel"
|
||||
/>
|
||||
<i18next
|
||||
path="page-layout.tooltip.title"
|
||||
tag="small"
|
||||
class="text-muted"
|
||||
>
|
||||
<code>${record.values.fieldName}</code>
|
||||
<code>${recordID}</code>
|
||||
<code>${ownerID}</code>
|
||||
<code>${userID}</code>
|
||||
</i18next>
|
||||
</b-form-group>
|
||||
|
||||
<hr>
|
||||
|
||||
<h5 class="mb-3">
|
||||
{{ $t('page-layout.visibility') }}
|
||||
</h5>
|
||||
@@ -824,6 +898,11 @@ export default {
|
||||
processing: false,
|
||||
options: [],
|
||||
},
|
||||
|
||||
checkboxLabel: {
|
||||
on: this.$t('general:label.yes'),
|
||||
off: this.$t('general:label.no'),
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -113,6 +113,7 @@ import Grid from 'corteza-webapp-compose/src/components/Public/Page/Grid'
|
||||
import RecordToolbar from 'corteza-webapp-compose/src/components/Common/RecordToolbar'
|
||||
import record from 'corteza-webapp-compose/src/mixins/record'
|
||||
import { compose, NoID } from '@cortezaproject/corteza-js'
|
||||
import { evaluatePrefilter } from 'corteza-webapp-compose/src/lib/record-filter'
|
||||
|
||||
export default {
|
||||
i18nOptions: {
|
||||
@@ -218,7 +219,24 @@ export default {
|
||||
},
|
||||
|
||||
title () {
|
||||
if (!this.layout) {
|
||||
return ''
|
||||
}
|
||||
|
||||
const { config = {}, meta = {} } = this.layout || {}
|
||||
const { useTitle = false } = config
|
||||
|
||||
if (useTitle) {
|
||||
return evaluatePrefilter(meta.title, {
|
||||
record: this.record,
|
||||
recordID: (this.record || {}).recordID || NoID,
|
||||
ownerID: (this.record || {}).ownedBy || NoID,
|
||||
userID: (this.$auth.user || {}).userID || NoID,
|
||||
})
|
||||
}
|
||||
|
||||
const { name, handle } = this.module
|
||||
|
||||
const titlePrefix = this.inCreating ? 'create' : this.inEditing ? 'edit' : 'view'
|
||||
|
||||
return this.$t(`page:public.record.${titlePrefix}.title`, { name: name || handle, interpolation: { escapeValue: false } })
|
||||
|
||||
@@ -16,6 +16,8 @@ interface PageLayoutConfig {
|
||||
submit: Button;
|
||||
};
|
||||
actions: Action[];
|
||||
// Only used for record pages
|
||||
useTitle: Boolean;
|
||||
}
|
||||
|
||||
interface Action {
|
||||
@@ -67,6 +69,7 @@ export class PageLayout {
|
||||
submit: { enabled: true },
|
||||
},
|
||||
actions: [],
|
||||
useTitle: false,
|
||||
}
|
||||
|
||||
public meta: Meta = {
|
||||
|
||||
@@ -198,7 +198,7 @@ metric:
|
||||
dimensionFieldLabel: Field
|
||||
dimensionFieldPlaceholder: Dimension field
|
||||
dimensionLabel: Dimension
|
||||
filterFootnote: Simplified SQL condition (WHERE ...) syntax is supported. Variables like {{0}}, {{1}} and {{2}} are evaluated (when available)
|
||||
filterFootnote: Simplified SQL condition (WHERE ...) syntax is supported. Variables like {{0}}, {{1}}, {{2}} and {{3}} are evaluated (when available)
|
||||
filterLabel: Filter
|
||||
labelLabel: Label
|
||||
labelPlaceholder: Label
|
||||
@@ -302,7 +302,7 @@ recordList:
|
||||
filter:
|
||||
label: Record filter
|
||||
placeholder: field1 = 1 AND field2 = 232
|
||||
footnote: Simplified SQL condition (WHERE ...) syntax is supported. Variables like {{0}}, {{1}} and {{2}} are evaluated (when available)
|
||||
footnote: Simplified SQL condition (WHERE ...) syntax is supported. Variables like {{0}}, {{1}}, {{2}} and {{3}} are evaluated (when available)
|
||||
createdAt: Record created
|
||||
custom: Custom
|
||||
lastMonth: Last month
|
||||
@@ -450,7 +450,7 @@ recordList:
|
||||
recordsLabel: Records
|
||||
noPermission: No permission to read record
|
||||
perPage: Records per page
|
||||
prefilterFootnote: Simplified SQL condition (WHERE ...) syntax is supported. Variables like {{0}}, {{1}} and {{2}} 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
|
||||
filterHide: Users will be able to filter the list
|
||||
prefilterLabel: Filtering
|
||||
|
||||
@@ -51,7 +51,7 @@ edit:
|
||||
customize: Customize filter
|
||||
label: Filter
|
||||
preset: Preset filters
|
||||
footnote: Simplified SQL condition (WHERE ...) syntax is supported. Variables like {{0}}, {{1}} and {{2}} are evaluated (when available)
|
||||
footnote: Simplified SQL condition (WHERE ...) syntax is supported. Variables like {{0}}, {{1}}, {{2}} and {{3}} are evaluated (when available)
|
||||
placeholder: field1 = 1 AND field2 = 232
|
||||
noFilter: Select a filter or make a custom one
|
||||
recordsCreatedLastMonth: Records created last month
|
||||
|
||||
@@ -106,7 +106,7 @@ kind:
|
||||
fieldFromModuleField: Label field from related module field
|
||||
pickField: Pick field
|
||||
suggestionPlaceholder: Start typing to search for records
|
||||
prefilterFootnote: Simplified SQL condition (WHERE ...) syntax is supported. Variables like {{0}}, {{1}} and {{2}} are evaluated (when available)
|
||||
prefilterFootnote: Simplified SQL condition (WHERE ...) syntax is supported. Variables like {{0}}, {{1}}, {{2}} and {{3}} are evaluated (when available)
|
||||
prefilterLabel: Prefilter records
|
||||
prefilterPlaceholder: field1 = 1 AND field2 = 232
|
||||
select:
|
||||
|
||||
@@ -4,7 +4,10 @@ page-layout:
|
||||
add: Add layout
|
||||
configure: 'Configure layout - "{{title}}"'
|
||||
visibility: Visibility
|
||||
general: General
|
||||
useTitle: Use layout title
|
||||
tooltip:
|
||||
title: Use the layout title instead of the record page default. Variables like {{0}}, {{1}}, {{2}} and {{3}} are evaluated (when available)
|
||||
configure: Configure layout
|
||||
builder: Open layout in builder
|
||||
condition:
|
||||
@@ -96,6 +99,7 @@ notVisible: Hidden
|
||||
pageMoveFailed: Could not move this page
|
||||
reordered: Page reordered
|
||||
showSubPages: Expand sub-pages in the sidebar
|
||||
customTitle: Use custom title
|
||||
title: List of Pages
|
||||
tooltip:
|
||||
unsavedChanges: Unsaved Changes
|
||||
|
||||
@@ -84,6 +84,8 @@ type (
|
||||
|
||||
Buttons PageLayoutButtonConfig `json:"buttons"`
|
||||
Actions []PageLayoutAction `json:"actions,omitempty"`
|
||||
|
||||
UseTitle bool `json:"useTitle"`
|
||||
}
|
||||
|
||||
PageLayoutVisibility struct {
|
||||
|
||||
Reference in New Issue
Block a user