Skip to content

Commit

Permalink
Update href trait value. Closes #2411
Browse files Browse the repository at this point in the history
  • Loading branch information
artf committed Nov 17, 2019
1 parent df6b055 commit 68f5cc6
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/i18n/locale/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export default {
// In a trait like select, these are used to translate option names
options: {
target: {
'': 'This window',
false: 'This window',
_blank: 'New window'
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/i18n/locale/it.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export default {
},
options: {
target: {
'': 'Questa finestra',
false: 'Questa finestra',
_blank: 'Nuova finestra'
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/trait_manager/config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ export default {
appendTo: '',

// Default options for the target input
optionsTarget: [{ value: '' }, { value: '_blank' }]
optionsTarget: [{ value: false }, { value: '_blank' }]
};
11 changes: 9 additions & 2 deletions src/trait_manager/model/Trait.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,19 @@ export default Backbone.Model.extend({
const target = this.target;
const name = this.get('name');
if (isUndefined(value)) return;
let valueToSet = value;

if (value === 'false') {
valueToSet = false;
} else if (value === 'true') {
valueToSet = true;
}

if (this.get('changeProp')) {
target.set(name, value, opts);
target.set(name, valueToSet, opts);
} else {
const attrs = { ...target.get('attributes') };
attrs[name] = value;
attrs[name] = valueToSet;
target.set('attributes', attrs, opts);
}
},
Expand Down
2 changes: 1 addition & 1 deletion src/trait_manager/view/TraitSelectView.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default TraitView.extend({

input += '</select>';
this.$input = $(input);
let val = model.getTargetValue() || model.get('value');
const val = model.getTargetValue();
!isUndefined(val) && this.$input.val(val);
}

Expand Down

0 comments on commit 68f5cc6

Please sign in to comment.