-
Notifications
You must be signed in to change notification settings - Fork 2
plugin label update #341
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
roguisharcanetrickster
wants to merge
2
commits into
master
Choose a base branch
from
rat/plugin_label
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
plugin label update #341
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,206 @@ | ||
| // FNViewLabel Properties | ||
| // A properties side import for an ABView. | ||
| // | ||
| export default function FNViewLabelProperties({ | ||
| AB, | ||
| ABViewPropertiesPlugin, | ||
| }) { | ||
| return class ABViewLabelProperties extends ABViewPropertiesPlugin { | ||
| constructor() { | ||
| super(ABViewLabelProperties.getPluginKey(), { | ||
| text: "", | ||
| format: "", | ||
| alignment: "", | ||
| }); | ||
| this.AB = AB; | ||
| } | ||
|
|
||
|
|
||
| static getPluginKey() { | ||
| return "label"; | ||
| } | ||
|
|
||
| static getPluginType() { | ||
| return "properties-view"; | ||
| // properties-view : will display in the properties panel of the ABDesigner | ||
| } | ||
|
|
||
| defaultValues() { | ||
| let values = { | ||
| format: 0, | ||
| alignment: "left" | ||
| }; | ||
| return values; | ||
| } | ||
|
|
||
| ui() { | ||
| const ids = this.ids; | ||
| let L = this.AB.Label(); | ||
| const defaultValues = this.defaultValues(); | ||
| let initial_text = this.view?.settings?.text || ""; | ||
| return super.ui([ | ||
| // .text : The Text displayed for this label | ||
| { | ||
| id: ids.text, | ||
| view: "text", | ||
| name: initial_text || "text", | ||
| label: L("Text"), | ||
| placeholder: L("Text Placeholder"), | ||
| on: { | ||
| onChange: (newValue, oldValue) => { | ||
| if (newValue !== oldValue) { | ||
| const baseView = this.CurrentView; | ||
|
|
||
| baseView.text = newValue; | ||
|
|
||
| baseView.save(); | ||
| this.onChange(); | ||
| } | ||
| }, | ||
| }, | ||
| }, | ||
| { | ||
| view: "fieldset", | ||
| label: L("Format Options:"), | ||
| body: { | ||
| type: "clean", | ||
| padding: 10, | ||
| rows: [ | ||
| { | ||
| id: ids.format, | ||
| view: "radio", | ||
| name: "format", | ||
| vertical: true, | ||
| value: defaultValues.format, | ||
| options: [ | ||
| { | ||
| id: 0, | ||
| value: L("normal"), | ||
| }, | ||
| { | ||
| id: 1, | ||
| value: L("title"), | ||
| }, | ||
| { | ||
| id: 2, | ||
| value: L("description"), | ||
| }, | ||
| ], | ||
| on: { | ||
| onChange: () => { | ||
| this.onChange(); | ||
| }, | ||
| }, | ||
| }, | ||
| ], | ||
| }, | ||
| }, | ||
| { | ||
| view: "fieldset", | ||
| label: L("Alignment:"), | ||
| body: { | ||
| type: "clean", | ||
| padding: 10, | ||
| rows: [ | ||
| { | ||
| id: ids.alignment, | ||
| view: "radio", | ||
| name: "alignment", | ||
| vertical: true, | ||
| value: defaultValues.alignment, | ||
| options: [ | ||
| { | ||
| id: "left", | ||
| value: L("Left"), | ||
| }, | ||
| { | ||
| id: "center", | ||
| value: L("Center"), | ||
| }, | ||
| { | ||
| id: "right", | ||
| value: L("Right"), | ||
| }, | ||
| ], | ||
| on: { | ||
| onChange: () => { | ||
| this.onChange(); | ||
| }, | ||
| }, | ||
| }, | ||
| ], | ||
| }, | ||
| }, | ||
| {}, | ||
| ]); | ||
| } | ||
|
|
||
| async init(AB) { | ||
| this.AB = AB; | ||
| await super.init(AB); | ||
| } | ||
|
|
||
| /** | ||
| * @method populate | ||
| * populate the properties with the values from the view. | ||
| * @param {obj} view | ||
| */ | ||
| populate(view) { | ||
| super.populate(view); | ||
| const ids = this.ids; | ||
|
|
||
| $$(ids.text).setValue(view.text); | ||
| $$(ids.format).setValue(view.settings.format); | ||
| $$(ids.alignment).setValue(view.settings.alignment); | ||
| } | ||
|
|
||
| /** | ||
| * @method values | ||
| * return the values from the property editor | ||
| * @return {obj} | ||
| */ | ||
| values() { | ||
| const values = super.values(); | ||
|
|
||
| const ids = this.ids; | ||
| const $component = $$(ids.component); | ||
| values.settings = $component.getValues(); | ||
| values.text = values.settings.text; | ||
|
|
||
| return values; | ||
| } | ||
|
|
||
| /** | ||
| * @method fromValues() | ||
| * | ||
| * initialze this object with the given set of values. | ||
| * @param {obj} values | ||
| */ | ||
| fromValues(values) { | ||
| super.fromValues(values); | ||
|
|
||
| this.settings = this.settings || {}; | ||
|
|
||
| // convert from "0" => 0 | ||
| this.settings.height = parseInt( | ||
| this.settings.height || ABViewTextPropertyComponentDefaults.height | ||
| ); | ||
|
|
||
| // if this is being instantiated on a read from the Property UI, | ||
| this.text = values.text || ABViewTextPropertyComponentDefaults.text; | ||
|
|
||
| // NOTE: ABView auto translates/untranslates "label" | ||
| // add in any additional fields here: | ||
| this.translate(this, this, ["text"]); | ||
| } | ||
| /** | ||
| * @method FieldClass() | ||
| * A method to return the proper ABViewXXX Definition. | ||
| * NOTE: Must be overwritten by the Child Class | ||
| */ | ||
| ViewClass() { | ||
| return super._ViewClass("label"); | ||
| } | ||
| }; | ||
| } | ||
|
|
This file contains hidden or 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,100 @@ | ||
| // FNViewLabel Editor | ||
| // An Editor wrapper for the ABView Component. | ||
| // The Editor is displayed in the ABDesigner as a view is worked on. | ||
| // The Editor allows a widget to be moved and placed on the canvas. | ||
| // | ||
| export default function FNViewLabelEditor({ AB, ABViewEditorPlugin }) { | ||
| const BASE_ID = "interface_editor_viewlabel"; | ||
|
|
||
| return class ABViewLabelEditor extends ABViewEditorPlugin { | ||
| constructor(view, base = BASE_ID, ids = {}) { | ||
| // view: {ABView} The ABView instance this editor is for | ||
| // BASE_ID: {string} unique base id reference | ||
| // ids: {hash} { key => '' } | ||
| // this is provided by the Sub Class and has the keys | ||
| // unique to the Sub Class' interface elements. | ||
|
|
||
| super(view, base, ids); | ||
| } | ||
|
|
||
| /** | ||
| * @method getPluginKey | ||
| * return the plugin key for this editor. | ||
| * @return {string} plugin key | ||
| */ | ||
| static getPluginKey() { | ||
| return "label"; | ||
| } | ||
|
|
||
| /** | ||
| * @method getPluginType | ||
| * return the plugin type for this editor. | ||
| * plugin types are how our ClassManager knows how to store | ||
| * the plugin. | ||
| * @return {string} plugin type | ||
| */ | ||
| static getPluginType() { | ||
| return "editor-view"; | ||
| // editor-view : will display in the editor panel of the ABDesigner | ||
| } | ||
|
|
||
| /** | ||
| * @method ui() | ||
| * Return the Webix UI definition for this editor. | ||
| * @return {object} Webix UI definition | ||
| */ | ||
| ui() { | ||
| // Default implementation uses the component's UI | ||
| // Sub classes can override this to provide custom editor UI | ||
| return super.ui(); | ||
| } | ||
|
|
||
| /** | ||
| * @method init() | ||
| * Initialize the editor with the ABFactory instance. | ||
| * @param {ABFactory} AB | ||
| */ | ||
| async init(AB) { | ||
| await super.init(AB); | ||
|
|
||
| // | ||
| // Add any custom initialization here | ||
| // | ||
| } | ||
|
|
||
| /** | ||
| * @method onShow() | ||
| * Called when the editor is shown. | ||
| */ | ||
| onShow() { | ||
| super.onShow(); | ||
| // | ||
| // Add any custom onShow logic here | ||
| // | ||
| } | ||
|
|
||
| /** | ||
| * @method onHide() | ||
| * Called when the editor is hidden. | ||
| */ | ||
| onHide() { | ||
| super.onHide(); | ||
|
|
||
| // | ||
| // Add any custom onHide logic here | ||
| // | ||
| } | ||
|
|
||
| /** | ||
| * @method detatch() | ||
| * Detach the editor component. | ||
| */ | ||
| detatch() { | ||
| super.detatch(); | ||
|
|
||
| // | ||
| // Add any custom cleanup logic here | ||
| // | ||
| } | ||
| }; | ||
| } |
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.