Add configurable column fields on public page record list
This commit is contained in:
parent
3e99588aa3
commit
acd3ec95ec
@ -846,6 +846,8 @@ export default {
|
|||||||
|
|
||||||
abortableRequests: [],
|
abortableRequests: [],
|
||||||
recordsPerPage: undefined,
|
recordsPerPage: undefined,
|
||||||
|
|
||||||
|
customConfiguredFields: [],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -965,7 +967,9 @@ export default {
|
|||||||
? []
|
? []
|
||||||
: this.options.editFields.map(({ name }) => name)
|
: this.options.editFields.map(({ name }) => name)
|
||||||
|
|
||||||
if (this.options.fields.length > 0) {
|
if (this.customConfiguredFields.length > 0) {
|
||||||
|
fields = this.recordListModule.filterFields(this.customConfiguredFields)
|
||||||
|
} else if (this.options.fields.length > 0) {
|
||||||
fields = this.recordListModule.filterFields(this.options.fields)
|
fields = this.recordListModule.filterFields(this.options.fields)
|
||||||
} else {
|
} else {
|
||||||
// Record list block does not have any configured fields
|
// Record list block does not have any configured fields
|
||||||
@ -1062,6 +1066,7 @@ export default {
|
|||||||
this.createEvents()
|
this.createEvents()
|
||||||
this.getStorageRecordListFilter()
|
this.getStorageRecordListFilter()
|
||||||
this.getStorageRecordListFilterPreset()
|
this.getStorageRecordListFilterPreset()
|
||||||
|
this.getStorageRecordListConfiguredFields()
|
||||||
this.prepRecordList()
|
this.prepRecordList()
|
||||||
this.refresh(true)
|
this.refresh(true)
|
||||||
},
|
},
|
||||||
@ -1167,9 +1172,32 @@ export default {
|
|||||||
|
|
||||||
onUpdateFields (fields = []) {
|
onUpdateFields (fields = []) {
|
||||||
this.options.fields = [...fields]
|
this.options.fields = [...fields]
|
||||||
|
this.setStorageRecordListConfiguredFields()
|
||||||
|
|
||||||
this.$emit('save-fields', this.options.fields)
|
this.$emit('save-fields', this.options.fields)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
setStorageRecordListConfiguredFields () {
|
||||||
|
try {
|
||||||
|
// Get record list configured fields from localStorage
|
||||||
|
setItem(`record-list-configured-columns-${this.uniqueID}`, this.options.fields.map((f) => f.fieldID))
|
||||||
|
} catch (e) {
|
||||||
|
console.warn(this.$t('notification:record-list.corrupted-configured-fields'))
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
getStorageRecordListConfiguredFields () {
|
||||||
|
try {
|
||||||
|
// Get record list configured fields from localStorage
|
||||||
|
this.customConfiguredFields = getItem(`record-list-configured-columns-${this.uniqueID}`)
|
||||||
|
} catch (e) {
|
||||||
|
// Land here if the configured fields is corrupted
|
||||||
|
console.warn(this.$t('notification:record-list.corrupted-configured-fields'))
|
||||||
|
// Remove filter from the local storage
|
||||||
|
removeItem(`record-list-configured-columns-${this.uniqueID}`)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
onSelectRow (selected, item) {
|
onSelectRow (selected, item) {
|
||||||
if (selected) {
|
if (selected) {
|
||||||
if (this.selected.includes(item.id)) {
|
if (this.selected.includes(item.id)) {
|
||||||
@ -1727,7 +1755,6 @@ export default {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// Get record list filters from localStorage
|
// Get record list filters from localStorage
|
||||||
currentListFilters = getItem(`record-list-filters-${this.uniqueID}`)
|
|
||||||
currentListFilters = this.recordListFilter
|
currentListFilters = this.recordListFilter
|
||||||
setItem(`record-list-filters-${this.uniqueID}`, currentListFilters)
|
setItem(`record-list-filters-${this.uniqueID}`, currentListFilters)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@ -753,6 +753,10 @@
|
|||||||
<b-form-checkbox v-model="options.hideRecordReminderButton">
|
<b-form-checkbox v-model="options.hideRecordReminderButton">
|
||||||
{{ $t('recordList.hideRecordReminderButton') }}
|
{{ $t('recordList.hideRecordReminderButton') }}
|
||||||
</b-form-checkbox>
|
</b-form-checkbox>
|
||||||
|
|
||||||
|
<b-form-checkbox v-model="options.hideConfigureFieldsButton">
|
||||||
|
{{ $t('recordList.hideConfigureFieldsButton') }}
|
||||||
|
</b-form-checkbox>
|
||||||
</b-form-group>
|
</b-form-group>
|
||||||
</b-col>
|
</b-col>
|
||||||
</b-row>
|
</b-row>
|
||||||
|
|||||||
@ -178,6 +178,8 @@ export default {
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
handleFieldsSave (fields = []) {
|
handleFieldsSave (fields = []) {
|
||||||
|
fields = fields.map((f) => f.fieldID)
|
||||||
|
|
||||||
if (!this.module.meta.ui) {
|
if (!this.module.meta.ui) {
|
||||||
this.module.meta.ui = { admin: { fields } }
|
this.module.meta.ui = { admin: { fields } }
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -230,6 +230,12 @@ export class Module {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (IsOf(m, 'meta')) {
|
if (IsOf(m, 'meta')) {
|
||||||
|
if (m.meta.ui && m.meta.ui.admin && m.meta.ui.admin.fields) {
|
||||||
|
if (!AreStrings(m.meta.ui.admin.fields)) {
|
||||||
|
m.meta.ui.admin.fields = m.meta.ui.admin.fields.map((f: any) => f.fieldID)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.meta = { ...m.meta }
|
this.meta = { ...m.meta }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -301,19 +307,19 @@ export class Module {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!AreStrings(requested)) {
|
if (!AreStrings(requested)) {
|
||||||
requested = (requested as ModuleField[]).map((f: ModuleField) => f.name)
|
requested = (requested as ModuleField[]).map((f: ModuleField) => f.name || f.fieldID)
|
||||||
}
|
}
|
||||||
|
|
||||||
const out: ModuleField[] = []
|
const out: ModuleField[] = []
|
||||||
|
|
||||||
for (const r of requested) {
|
for (const r of requested) {
|
||||||
const sf = this.systemFields().find(f => r === f.name)
|
const sf = this.systemFields().find(f => r === f.name || r === f.fieldID)
|
||||||
if (sf) {
|
if (sf) {
|
||||||
out.push(sf)
|
out.push(sf)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
const mf = this.fields.find(f => r === f.name)
|
const mf = this.fields.find(f => r === f.name || r === f.fieldID)
|
||||||
if (mf) {
|
if (mf) {
|
||||||
out.push(mf)
|
out.push(mf)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -373,6 +373,7 @@ recordList:
|
|||||||
hideRecordEditButton: Hide edit record button
|
hideRecordEditButton: Hide edit record button
|
||||||
hideRecordPermissionsButton: Hide record permissions button
|
hideRecordPermissionsButton: Hide record permissions button
|
||||||
hideRecordReminderButton: Hide record reminder button
|
hideRecordReminderButton: Hide record reminder button
|
||||||
|
hideConfigureFieldsButton: Hide configure columns
|
||||||
hideRecordViewButton: Hide view record button
|
hideRecordViewButton: Hide view record button
|
||||||
enableRecordPageNavigation: Users will be able to navigate to previous/next record
|
enableRecordPageNavigation: Users will be able to navigate to previous/next record
|
||||||
import:
|
import:
|
||||||
|
|||||||
@ -166,6 +166,7 @@ record:
|
|||||||
failed: Failed to evaluate record block field conditions
|
failed: Failed to evaluate record block field conditions
|
||||||
record-list:
|
record-list:
|
||||||
corrupted-filter: Corrupted filter
|
corrupted-filter: Corrupted filter
|
||||||
|
corrupted-configured-fields: Corrupted configured columns
|
||||||
incorrect-filter-structure: Incorrect structure of filter {{filterID}}
|
incorrect-filter-structure: Incorrect structure of filter {{filterID}}
|
||||||
report:
|
report:
|
||||||
listFetchFailed: Failed to fetch reports
|
listFetchFailed: Failed to fetch reports
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user