Skip to content

Commit

Permalink
Merge branch 'feat/add-isfunction-prop-to-widgets' into alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
mguellsegarra committed Aug 15, 2024
2 parents 4a95095 + a7ba02c commit 5cbc403
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,15 @@ abstract class Widget {
this._parsedWidgetProps = value;
}

_isFunction: boolean | undefined;
get isFunction(): boolean | undefined {
return this._isFunction;
}

set isFunction(value: boolean | undefined) {
this._isFunction = value;
}

constructor(props?: any) {
this._colspan = Widget._defaultColspan;
this._invisible = false;
Expand Down Expand Up @@ -161,6 +170,9 @@ abstract class Widget {
if (props.key) {
this._key = props.key;
}
if (props.is_function) {
this._isFunction = props.is_function;
}
}
}

Expand Down
19 changes: 19 additions & 0 deletions src/spec/Tree.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,4 +358,23 @@ describe("A Tree", () => {
expect(tree.contextForFields.lang).toBeDefined();
expect(tree.contextForFields.lang).toEqual({ active_test: false });
});
it("Column isFunction property should be informed", () => {
const tree = new Tree({
name: {
required: true,
select: true,
size: 128,
string: "Potència contractada (kW)",
type: "char",
is_function: true,
views: {},
},
});
tree.parse(
`<tree string="Partners" colors="red:type=='updated'"><field name="name" sum="Pot&#232;ncia contractada (kW)" /></tree>`,
);

const nameWidget = tree.findById("name") as Char;
expect(nameWidget.isFunction).toBeTruthy();
});
});

0 comments on commit 5cbc403

Please sign in to comment.