|
|
@ -14,7 +14,9 @@ module.exports = Backbone.View.extend({ |
|
|
</div> |
|
|
</div> |
|
|
</div>`), |
|
|
</div>`), |
|
|
|
|
|
|
|
|
events: {'change': 'valueUpdated'}, |
|
|
events: { |
|
|
|
|
|
'change': 'valueUpdated' |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
initialize(o) { |
|
|
initialize(o) { |
|
|
this.config = o.config || {}; |
|
|
this.config = o.config || {}; |
|
|
@ -92,8 +94,15 @@ module.exports = Backbone.View.extend({ |
|
|
* Fired when the input value is updated |
|
|
* Fired when the input value is updated |
|
|
*/ |
|
|
*/ |
|
|
valueUpdated() { |
|
|
valueUpdated() { |
|
|
if(this.$input) |
|
|
this.model.set('value', this.getInputValue()); |
|
|
this.model.set('value', this.getInputValue()); |
|
|
this.elementUpdated(); |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Fired when the element of the property is updated |
|
|
|
|
|
*/ |
|
|
|
|
|
elementUpdated() { |
|
|
|
|
|
this.model.set('status', 'updated'); |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
@ -109,41 +118,44 @@ module.exports = Backbone.View.extend({ |
|
|
let targetValue = this.getTargetValue({ignoreDefault: 1}); |
|
|
let targetValue = this.getTargetValue({ignoreDefault: 1}); |
|
|
let defaultValue = this.getDefaultValue(); |
|
|
let defaultValue = this.getDefaultValue(); |
|
|
let computedValue = this.getComputedValue(); |
|
|
let computedValue = this.getComputedValue(); |
|
|
|
|
|
const config = this.config; |
|
|
|
|
|
const em = config.em; |
|
|
|
|
|
const model = this.model; |
|
|
|
|
|
|
|
|
if (targetValue) { |
|
|
if (targetValue) { |
|
|
value = targetValue; |
|
|
value = targetValue; |
|
|
status = 'updated'; |
|
|
|
|
|
} else if (computedValue && computedValue != defaultValue) { |
|
|
if (config.highlightChanged) { |
|
|
|
|
|
status = 'updated'; |
|
|
|
|
|
} |
|
|
|
|
|
} else if (computedValue && config.showComputed && |
|
|
|
|
|
computedValue != defaultValue) { |
|
|
value = computedValue; |
|
|
value = computedValue; |
|
|
status = 'computed'; |
|
|
|
|
|
|
|
|
if (config.highlightComputed) { |
|
|
|
|
|
status = 'computed'; |
|
|
|
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
value = defaultValue; |
|
|
value = defaultValue; |
|
|
status = ''; |
|
|
status = ''; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//value = this.tryFetchFromFunction(value);
|
|
|
this.setValue(value, 1); |
|
|
this.setValue(value, 1); |
|
|
this.model.set('status', status); |
|
|
this.model.set('status', status); |
|
|
|
|
|
|
|
|
/* |
|
|
if (em) { |
|
|
get targetValue |
|
|
em.trigger('styleManager:change', this); |
|
|
if targetValue |
|
|
em.trigger(`styleManager:change:${model.get('property')}`, this); |
|
|
setValue(targetValue) |
|
|
} |
|
|
setStatus('updated'); |
|
|
|
|
|
elseif computedValue != defaultValue |
|
|
|
|
|
setValue(computedValue) |
|
|
|
|
|
setStatus('computed'); |
|
|
|
|
|
else |
|
|
|
|
|
setValue(defaultValue) |
|
|
|
|
|
setStatus(''); |
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
/* |
|
|
if(this.getTarget()) { |
|
|
if(this.getTarget()) { |
|
|
if(!this.sameValue()){ |
|
|
if(!this.sameValue()){ |
|
|
this.renderInputRequest(); |
|
|
this.renderInputRequest(); |
|
|
} |
|
|
} |
|
|
} |
|
|
}*/ |
|
|
*/ |
|
|
|
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
checkVisibility() { |
|
|
checkVisibility() { |
|
|
@ -171,11 +183,10 @@ module.exports = Backbone.View.extend({ |
|
|
* same of the value of the model |
|
|
* same of the value of the model |
|
|
* |
|
|
* |
|
|
* @return {Boolean} |
|
|
* @return {Boolean} |
|
|
* * |
|
|
* */ |
|
|
sameValue() { |
|
|
sameValue() { |
|
|
return this.getComponentValue() == this.getValueForTarget(); |
|
|
return this.getComponentValue() == this.getValueForTarget(); |
|
|
}, |
|
|
}, |
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
@ -226,6 +237,7 @@ module.exports = Backbone.View.extend({ |
|
|
var result; |
|
|
var result; |
|
|
var model = this.model; |
|
|
var model = this.model; |
|
|
var target = this.getTarget(); |
|
|
var target = this.getTarget(); |
|
|
|
|
|
var customFetchValue = this.customValue; |
|
|
|
|
|
|
|
|
if (!target) { |
|
|
if (!target) { |
|
|
return result; |
|
|
return result; |
|
|
@ -237,6 +249,15 @@ module.exports = Backbone.View.extend({ |
|
|
result = this.getDefaultValue(); |
|
|
result = this.getDefaultValue(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (typeof customFetchValue == 'function' && !opts.ignoreCustomValue) { |
|
|
|
|
|
let index = model.collection.indexOf(model); |
|
|
|
|
|
let customValue = customFetchValue(this, index); |
|
|
|
|
|
|
|
|
|
|
|
if (customValue) { |
|
|
|
|
|
result = customValue; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return result; |
|
|
return result; |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
@ -256,7 +277,9 @@ module.exports = Backbone.View.extend({ |
|
|
*/ |
|
|
*/ |
|
|
getComputedValue() { |
|
|
getComputedValue() { |
|
|
let computed = this.propTarget.computed; |
|
|
let computed = this.propTarget.computed; |
|
|
return computed && computed[this.model.get('property')]; |
|
|
const valid = this.config.validComputed; |
|
|
|
|
|
const property = this.model.get('property'); |
|
|
|
|
|
return computed && valid.indexOf(property) >= 0 && computed[property]; |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
@ -274,9 +297,10 @@ module.exports = Backbone.View.extend({ |
|
|
return value; |
|
|
return value; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var start = value.indexOf("(") + 1; |
|
|
var valueStr = value + ''; |
|
|
var end = value.lastIndexOf(")"); |
|
|
var start = valueStr.indexOf("(") + 1; |
|
|
return value.substring(start, end); |
|
|
var end = valueStr.lastIndexOf(")"); |
|
|
|
|
|
return valueStr.substring(start, end); |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
|