Skip to content

Commit

Permalink
Fix module meta admin fields breaking module in edge cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Fajfa committed Dec 11, 2024
1 parent 628d0da commit ed87cda
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
<column-picker
v-if="!options.hideConfigureFieldsButton"
:module="recordListModule"
:fields="fields"
:fields="fields.map(({ moduleField }) => moduleField)"
@updateFields="onUpdateFields"
/>
</div>
Expand Down Expand Up @@ -1310,7 +1310,7 @@ export default {
onUpdateFields (fields = []) {
this.options.fields = [...fields]
this.customConfiguredFields = fields.map((f) => f.isSystem ? f.name : f.fieldID)
this.customConfiguredFields = fields.map((f) => f.isSystem ? f.name : f.fieldID).filter(f => !!f)
this.setStorageRecordListConfiguredFields()
this.$emit('save-fields', this.options.fields)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1065,7 +1065,7 @@ export default {
onUpdateTextWrapOption (fields = []) {
if (this.options.textStyles.wrappedFields) {
this.options.textStyles.wrappedFields = fields.map(f => f.fieldID)
this.options.textStyles.wrappedFields = fields.map(f => f.fieldID && f.fieldID !== NoID ? f.fieldID : f.name).filter(f => !!f)
}
},
},
Expand Down
4 changes: 2 additions & 2 deletions client/web/compose/src/views/Admin/Modules/Records/List.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<script>
import { mapGetters, mapActions } from 'vuex'
import { compose } from '@cortezaproject/corteza-js'
import { compose, NoID } from '@cortezaproject/corteza-js'
import RecordListBase from 'corteza-webapp-compose/src/components/PageBlocks/RecordListBase'
export default {
Expand Down Expand Up @@ -190,7 +190,7 @@ export default {
}),
handleFieldsSave (fields = []) {
fields = fields.map((f) => f.fieldID)
fields = fields.map((f) => f.fieldID && f.fieldID !== NoID ? f.fieldID : f.name).filter(f => !!f)
if (!this.module.meta.ui) {
this.module.meta.ui = { admin: { fields } }
Expand Down
14 changes: 11 additions & 3 deletions lib/js/src/compose/types/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,14 @@ export class Module {
},
}

public meta: object = {};
public meta: Meta = {
ui: {
admin: {
fields: [],
},
},
};

public labels: object = {};

public createdAt?: Date = undefined;
Expand Down Expand Up @@ -227,11 +234,12 @@ export class Module {
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)
const fields = m.meta.ui.admin.fields || []
m.meta.ui.admin.fields = fields.map((f: any) => f.fieldID && f.fieldID !== NoID ? f.fieldID : f.name).filter((f: any) => !!f)
}
}

this.meta = { ...m.meta }
this.meta = merge({}, this.meta, m.meta)
}

if (IsOf(m, 'config')) {
Expand Down

0 comments on commit ed87cda

Please sign in to comment.