Skip to content

Commit e7d24bb

Browse files
olemartinorgOle Martin Handeland
andauthored
Schema for removeWhenHidden property (#3615)
Co-authored-by: Ole Martin Handeland <[email protected]>
1 parent d20bfc9 commit e7d24bb

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/codegen/ComponentConfig.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { GenerateImportedSymbol } from 'src/codegen/dataTypes/GenerateImportedSy
55
import { GenerateObject } from 'src/codegen/dataTypes/GenerateObject';
66
import { GenerateRaw } from 'src/codegen/dataTypes/GenerateRaw';
77
import { GenerateUnion } from 'src/codegen/dataTypes/GenerateUnion';
8+
import { ExprVal } from 'src/features/expressions/types';
89
import { ValidationPlugin } from 'src/features/validation/ValidationPlugin';
910
import { CompCategory } from 'src/layout/common';
1011
import { isNodeDefChildrenPlugin, NodeDefPlugin } from 'src/utils/layout/plugins/NodeDefPlugin';
@@ -157,6 +158,24 @@ export class ComponentConfig {
157158

158159
const name = 'dataModelBindings';
159160
const existing = this.inner.getProperty(name)?.type;
161+
162+
if (!existing || existing instanceof GenerateRaw) {
163+
// For all components with dataModelBindings, the backend wants this property defined so that app-developers can
164+
// escape from hidden-data-deletion per-component.
165+
this.inner.addProperty(
166+
new CG.prop(
167+
'removeWhenHidden',
168+
new CG.expr(ExprVal.Boolean)
169+
.setTitle('Remove fields from component dataModelBindings when hidden expression is true')
170+
.setDescription(
171+
'Override the logic cleaning data for hidden components at task end, if you want to keep data ' +
172+
'referenced in hidden components. Currently only has effect if AppSettings.RemoveHiddenData is enabled.',
173+
)
174+
.optional(),
175+
),
176+
);
177+
}
178+
160179
if (existing && existing instanceof GenerateUnion) {
161180
existing.addType(type);
162181
} else if (existing && !(existing instanceof GenerateRaw)) {

0 commit comments

Comments
 (0)