Skip to content

Commit

Permalink
fix: revert changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mguellsegarra committed Oct 28, 2024
1 parent 628bb82 commit 08ad4b8
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 37 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gisce/ooui",
"version": "2.14.0-alpha.2",
"version": "2.13.2",
"engines": {
"node": "20.5.0"
},
Expand Down
8 changes: 2 additions & 6 deletions src/WidgetFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Many2one from "./Many2one";
import Markdown from "./Markdown";
import Boolean from "./Boolean";
import Integer from "./Integer";
import Widget from "./Widget";
import Float from "./Float";
import FloatTime from "./FloatTime";
import HTMLPreview from "./HTMLPreview";
Expand All @@ -37,7 +38,6 @@ import Avatar from "./Avatar";
import Time from "./Time";
import Alert from "./Alert";
import Comments from "./Comments";
import Field from "./Field";

class WidgetFactory {
/**
Expand Down Expand Up @@ -179,8 +179,6 @@ class WidgetFactory {
}

createWidget(type: string, props: any) {
this._widgetClass = undefined;

let finalType = type;

this.setWidgetClass(type);
Expand All @@ -192,9 +190,7 @@ class WidgetFactory {
}

if (this._widgetClass === undefined) {
// Last fallback, with Field widget and original type from xml
finalType = type;
this._widgetClass = Field;
this._widgetClass = Widget;
}

// TODO: Widget Class constructors should use only the props needed, not all props.
Expand Down
28 changes: 0 additions & 28 deletions src/spec/Form.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5975,32 +5975,4 @@ describe("A Form", () => {
const field_char = form.findById("field_char");
expect(field_char!.domain!).toBe("[('value', '=', 'form')]");
});
it.only("a field with no supported type should fallback to field generic widget", () => {
const fields = {
field_char: {
digits: [16, 2],
is_function: true,
readonly: 1,
string: "Etapa",
type: "json",
views: {},
widget: "arrow_steps",
},
};
const xmlViewForm = `<?xml version="1.0"?>
<form string="Form1">
<field name="field_char" widget="arrow_steps" colspan="4" nolabel="1"/>
</form>`;
const form = new Form(fields);
form.parse(xmlViewForm, {
values: {
field_char: "test",
},
});

const field_char = form.findById("field_char") as Field;
expect(field_char).toBeDefined();
expect(field_char?.type).toBe("arrow_steps");
expect(field_char?.id).toBe("field_char");
});
});

0 comments on commit 08ad4b8

Please sign in to comment.