nakedobjects.spa
Version:
Single Page Application client for a Naked Objects application.
29 lines • 1.32 kB
JavaScript
var ChoiceViewModel = (function () {
function ChoiceViewModel(wrapped, id, name, searchTerm) {
var _this = this;
this.wrapped = wrapped;
this.id = id;
this.getValue = function () { return _this.wrapped; };
this.equals = function (other) {
return other instanceof ChoiceViewModel &&
_this.id === other.id &&
_this.name === other.name &&
_this.wrapped.toValueString() === other.wrapped.toValueString();
};
this.valuesEqual = function (other) {
if (other instanceof ChoiceViewModel) {
var thisValue = _this.isEnum ? _this.wrapped.toValueString().trim() : _this.search.trim();
var otherValue = _this.isEnum ? other.wrapped.toValueString().trim() : other.search.trim();
return thisValue === otherValue;
}
return false;
};
this.toString = function () { return _this.name; };
this.name = name || wrapped.toString();
this.search = searchTerm || this.name;
this.isEnum = !wrapped.isReference() && (this.name !== this.getValue().toValueString());
}
return ChoiceViewModel;
}());
export { ChoiceViewModel };
//# sourceMappingURL=choice-view-model.js.map