Permalink
Browse files

feat: adapter层setValue增加beforeSetValue调用,方便组件个性化设置

  • Loading branch information...
LiuYueKai committed Feb 14, 2017
1 parent 15ebc69 commit 44706dfe15ff2b28cfd2093a5e4d5d20cd8eecdd
Showing with 11 additions and 24 deletions.
  1. +0 −1 dist/js/1.1.min.js
  2. +2 −12 js/component/keroa-ckeditor.js
  3. +2 −8 js/component/keroa-datetimepicker.js
  4. +7 −3 js/component/keroa-multilang.js
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -25,7 +25,7 @@ var CkEditorAdapter = BaseAdapter.extend({
this.tmpeditor.on('blur',function(){
self.setValue(tmpeditor.getData())
});
-
+
this.tmpeditor.on('focus',function(){
self.setShowValue(self.getValue())
});
@@ -39,23 +39,13 @@ var CkEditorAdapter = BaseAdapter.extend({
this.setShowValue(this.showValue)
},
- setValue: function(value) {
- this.trueValue = value
- this.showValue = value
- this.setShowValue(this.showValue)
- this.slice = true
- this.dataModel.setValue(this.field, this.trueValue);
- this.slice = false
- //this.trigger(Editor.EVENT_VALUE_CHANGE, this.trueValue)
- },
-
getValue : function() {
return this.trueValue
},
setShowValue : function(showValue) {
var self = this;
- this.showValue = showValue
+ this.showValue = showValue
this.element.value = showValue
this.tmpeditor.setData(showValue);
@@ -304,7 +304,7 @@ var DateTimeAdapter = BaseAdapter.extend({
// this.formater = new $.DateFormater(this.maskerMeta.format);
// this.masker = new DateTimeMasker(this.maskerMeta);
},
- setValue: function (value) {
+ beforeSetValue: function (value) {
if(this.dataModel){
var valueObj = date.getDateObj(value);
if(valueObj){
@@ -332,13 +332,7 @@ var DateTimeAdapter = BaseAdapter.extend({
}
}
value = date.format(value,this.options.format);
- ValueMixin.methods.setValue.call(this,value);
- // this.trueValue = this.formater ? this.formater.format(value) : value;
- // this.showValue = this.masker ? this.masker.format(this.trueValue).value : this.trueValue;
- // this.setShowValue(this.showValue);
- // this.slice = true;
- // this.dataModel.setValue(this.field, this.trueValue);
- // this.slice = false;
+ return value;
},
setEnable: function(enable){
if (enable === true || enable === 'true') {
@@ -39,7 +39,7 @@ var MultilangAdapter = BaseAdapter.extend({
var childObj = ValueMixin.methods.getChildVariable.call(this);
var lastRow = childObj.lastRow;
var lastField = childObj.lastField;
- this.field = lastField;
+ this.field = lastField;
}
}
@@ -185,7 +185,7 @@ var MultilangAdapter = BaseAdapter.extend({
// if (rowObj) {
// this.modelValueChange(rowObj.getValue(this.field));
// }
-
+
// UI传值到datatable
this.comp.on('change.u.multilang', function(object){
self.slice = true;
@@ -198,13 +198,17 @@ var MultilangAdapter = BaseAdapter.extend({
modelValueChange: function(field,value) {
this.comp.setDataValue(field,value);
},
+ /**
+ * [setValue 由于多语组件对应多个field,因此setValue需要额外传入field字段]
+ * @param {[type]} field [发生改变的字段]
+ * @param {[type]} value [发生改变的值]
+ */
setValue: function(field,value){
this.slice = true;
if(parseInt(this.options.rowIndex) > -1){
if((this.options.rowIndex + '').indexOf('.') > 0){
var childObj = ValueMixin.methods.getChildVariable.call(this);
var lastRow = childObj.lastRow;
- var lastField = childObj.lastField;
if(lastRow)
lastRow.setValue(field, value);
}else{

0 comments on commit 44706df

Please sign in to comment.