-
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.
Merge pull request #74 from gisce/tag-widget
Add Tag widget
- Loading branch information
Showing
6 changed files
with
67 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
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,12 @@ | ||
import Selection from "./Selection"; | ||
|
||
/** | ||
* A Tag widget | ||
*/ | ||
class Tag extends Selection { | ||
get colors(): any | "auto" { | ||
return this._parsedWidgetProps.colors || {}; | ||
} | ||
} | ||
|
||
export default Tag; |
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,46 @@ | ||
import WidgetFactory from "../WidgetFactory"; | ||
|
||
describe("A Tag widget", () => { | ||
it("should have an id corresponding to field name", () => { | ||
const widgetFactory = new WidgetFactory(); | ||
const props = { | ||
name: "status", | ||
}; | ||
|
||
const widget = widgetFactory.createWidget("tag", props); | ||
|
||
expect(widget.id).toBe("status"); | ||
}); | ||
|
||
describe("colors property", () => { | ||
it("should have default colors to empty object", () => { | ||
const widgetFactory = new WidgetFactory(); | ||
const props = { | ||
name: "status", | ||
}; | ||
const widget = widgetFactory.createWidget("tag", props); | ||
|
||
expect(widget.colors).toStrictEqual({}); | ||
}); | ||
it("should parse colors property", () => { | ||
const widgetFactory = new WidgetFactory(); | ||
const props = { | ||
name: "status", | ||
widget_props: '{"colors": {"draft": "blue", "open": "red"}}', | ||
}; | ||
const widget = widgetFactory.createWidget("tag", props); | ||
|
||
expect(widget.colors).toStrictEqual({draft: 'blue', open: 'red'}); | ||
}); | ||
it("should parse colors property and can be an string 'auto'", () => { | ||
const widgetFactory = new WidgetFactory(); | ||
const props = { | ||
name: "status", | ||
widget_props: '{"colors": "auto"}', | ||
}; | ||
const widget = widgetFactory.createWidget("tag", props); | ||
|
||
expect(widget.colors).toStrictEqual("auto"); | ||
}); | ||
}); | ||
}); |