fixes: display preferences for components

This commit is contained in:
arpitnath 2023-10-01 19:58:31 +05:30
parent 529d5dc666
commit a587b9bead
5 changed files with 26 additions and 2 deletions

View file

@ -1695,6 +1695,10 @@ export const buildComponentMetaDefinition = (components = {}) => {
...componentMeta.definition.validations,
...currentComponentData?.component.definition.validations,
},
others: {
...componentMeta.definition.others,
...currentComponentData?.component.definition.others,
},
};
const mergedComponent = {

View file

@ -32,6 +32,10 @@ const defaultComponent = {
styles: {},
validation: {},
type: '',
others: {
showOnDesktop: { value: '{{true}}' },
showOnMobile: { value: '{{false}}' },
},
};
const updateType = Object.freeze({
@ -224,6 +228,13 @@ const computeComponentDiff = (appDiff, currentPageId, opts) => {
});
}
const currentDisplayPreference = _.keys(appDiff.pages[currentPageId].components[id].layouts)[0];
if (currentDisplayPreference === 'mobile') {
result[id].others.showOnMobile = { value: '{{true}}' };
result[id].others.showOnDesktop = { value: '{{false}}' };
}
if (result[id]?.definition) {
delete result[id].definition;
}

View file

@ -47,6 +47,11 @@ export class CreateComponentTable1691006952074 implements MigrationInterface {
type: 'json',
isNullable: true,
},
{
name: 'display_preferences',
type: 'json',
isNullable: true,
},
{
name: 'validations',
type: 'json',

View file

@ -39,6 +39,9 @@ export class Component {
@Column('simple-json', { name: 'general_styles', nullable: true })
generalStyles: any;
@Column('simple-json', { name: 'display_preferences', nullable: true })
displayPreferences: any;
@Column('simple-json')
validations: any;

View file

@ -195,6 +195,7 @@ export class ComponentsService {
transformedComponent.properties = componentData.properties || {};
transformedComponent.styles = componentData.styles || {};
transformedComponent.validations = componentData.validation || {};
transformedComponent.displayPreferences = componentData.others || null;
transformedComponents.push(transformedComponent);
}
@ -203,9 +204,8 @@ export class ComponentsService {
}
createComponentWithLayout(componentData, layoutData) {
const { id, name, properties, styles, generalStyles, validations, parent } = componentData;
const { id, name, properties, styles, generalStyles, validations, parent, displayPreferences } = componentData;
const { type, top, left, width, height } = layoutData;
const componentWithLayout = {
[id]: {
component: {
@ -216,6 +216,7 @@ export class ComponentsService {
styles,
generalStyles,
validations,
others: displayPreferences,
},
parent,
},