Skip to content

Commit

Permalink
Enable to use useExistVar in JS assistant
Browse files Browse the repository at this point in the history
[Issue]: #184
[Problem] User can't select "use Exist Var" checkbox and use a variable to add events.
[Solution] Add function to display select list of variables and change key in weakmap from jquery object to DOM element.

Signed-off-by: Wojciech Szczepanski <w.szczepansk@samsung.com>
  • Loading branch information
wszczepanski97 committed Aug 12, 2019
1 parent 8e72bd8 commit 93ab71a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
17 changes: 16 additions & 1 deletion design-editor/src/panel/assistant/assistant-wizard.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ class AssistantWizard extends DressElement {
*/
_bindEvent() {
this._$useCustomEventCheckbox.on('click', this._onClickCustom.bind(this));
this._$actionPresetGroup.on('click', this._onClickPreset.bind(this));
this._$actionPresetGroup.on('click', this._onClickPreset.bind(this));
this._$usingExistInstanceCheckbox.on('click', this._onClickUseExistVar.bind(this));
}

/**
Expand Down Expand Up @@ -166,6 +167,20 @@ class AssistantWizard extends DressElement {
this._showPresetOptions(presetName);
}

/**
* On click useExistVar checkbox callback
* @param {Event} event
* @private
*/
_onClickUseExistVar(event){
const isCheckboxChecked = event.target.checked;
if (!isCheckboxChecked) {
this._$instanceList[0].style = 'display:none;';
} else {
this._$instanceList[0].style = 'display:flex;';
}
}

/**
* Show preset
* @param {string} presetName
Expand Down
12 changes: 6 additions & 6 deletions design-editor/src/system/assistant/assistant-code-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,11 @@ class AssistantCodeGenerator {
* @private
*/
_setValueToMap(map, key, value) {
const stored = this._getValueFromMap(map, key);
const stored = this._getValueFromMap(map, key[0]);

stored.push(value);
map.set(key, stored);
}
stored.push(value);
map.set(key[0], stored);
}

/**
* Get value form map
Expand All @@ -265,8 +265,8 @@ class AssistantCodeGenerator {
* @returns {*}
* @private
*/
_getValueFromMap(map, key) {
return map.get(key) || [];
_getValueFromMap(map, key) {
return map.get(key[0]) || [];
}
}

Expand Down

0 comments on commit 93ab71a

Please sign in to comment.