-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: sync changes from v2 to v2-develop
- Loading branch information
1 parent
50b5e6e
commit 474a353
Showing
6 changed files
with
114 additions
and
3 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@gisce/ooui", | ||
"version": "2.24.0", | ||
"version": "2.25.0", | ||
"engines": { | ||
"node": "20.5.0" | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import ContainerWidget from "./ContainerWidget"; | ||
import Group from "./Group"; | ||
import { parseBoolAttribute } from "./helpers/nodeParser"; | ||
|
||
class Carousel extends ContainerWidget { | ||
_autoPlay = true; | ||
|
||
get autoPlay(): boolean { | ||
return this._autoPlay; | ||
} | ||
|
||
set autoPlay(value: boolean) { | ||
this._autoPlay = value; | ||
} | ||
|
||
get items(): Group[] { | ||
return this._container.rows.flat().filter((g) => !g.invisible) as Group[]; | ||
} | ||
|
||
constructor(props?: any) { | ||
super(props); | ||
if (props) { | ||
if ("auto_play" in props) { | ||
this._autoPlay = parseBoolAttribute(props.auto_play); | ||
} | ||
} | ||
} | ||
} | ||
|
||
export default Carousel; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import WidgetFactory from "../WidgetFactory"; | ||
import Form from "../Form"; | ||
import Carousel from "../Carousel"; | ||
import { it, expect, describe } from "vitest"; | ||
|
||
describe("A Carousel", () => { | ||
it("should have an id corresponding to field name", () => { | ||
const widgetFactory = new WidgetFactory(); | ||
const props = { | ||
name: "carousel", | ||
}; | ||
|
||
const widget = widgetFactory.createWidget("carousel", props); | ||
expect(widget).toBeInstanceOf(Carousel); | ||
}); | ||
it("should have autoPlay as true by default", () => { | ||
const widgetFactory = new WidgetFactory(); | ||
const props = { | ||
name: "carousel", | ||
}; | ||
const widget = widgetFactory.createWidget("carousel", props); | ||
expect(widget.autoPlay).toBe(true); | ||
}); | ||
it("should allow autoPlay to be set", () => { | ||
const widgetFactory = new WidgetFactory(); | ||
const props = { | ||
name: "carousel", | ||
auto_play: false, | ||
}; | ||
const widget = widgetFactory.createWidget("carousel", props); | ||
expect(widget.autoPlay).toBe(false); | ||
}); | ||
it("should have items with the first childs group items", () => { | ||
const xml = ` | ||
<form> | ||
<carousel name="carousel"> | ||
<group string="Group 1"> | ||
<field name="field1" string="Field 1" /> | ||
</group> | ||
<group string="Group 2"> | ||
<field name="field2" string="Field 2" /> | ||
<group string="Group 3"> | ||
<field name="field3" string="Field 3" /> | ||
</group> | ||
</group> | ||
</carousel> | ||
</form> | ||
`; | ||
const fields = { | ||
field1: { | ||
string: "Field 1", | ||
type: "char", | ||
size: 10, | ||
}, | ||
field2: { | ||
string: "Field 2", | ||
type: "char", | ||
size: 10, | ||
}, | ||
field3: { | ||
string: "Field 3", | ||
type: "char", | ||
size: 10, | ||
}, | ||
}; | ||
|
||
const form = new Form(fields); | ||
form.parse(xml); | ||
const carousel = form.findById("carousel") as Carousel; | ||
expect(carousel).toBeInstanceOf(Carousel); | ||
expect(carousel.items.length).toBe(2); | ||
expect(carousel.items[0].label).toBe("Group 1"); | ||
expect(carousel.items[1].label).toBe("Group 2"); | ||
}); | ||
}); |