Fix a couple of issues with the unique-collection control:
- Pass the data to evaluation functions like canEdit, canAdd - Properly honour the canAdd option.pull/3/head
parent
d21e60cc60
commit
2f334673a3
|
@ -528,6 +528,7 @@
|
||||||
checkVars.push('role');
|
checkVars.push('role');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (self.control_data.canAdd) {
|
||||||
self.collection.each(function(m) {
|
self.collection.each(function(m) {
|
||||||
if (!inSelected) {
|
if (!inSelected) {
|
||||||
var has = true;
|
var has = true;
|
||||||
|
@ -543,6 +544,10 @@
|
||||||
inSelected = has;
|
inSelected = has;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
inSelected = true;
|
||||||
|
}
|
||||||
|
|
||||||
self.$header.find('button.add').prop('disabled', inSelected);
|
self.$header.find('button.add').prop('disabled', inSelected);
|
||||||
},
|
},
|
||||||
|
|
|
@ -872,22 +872,22 @@
|
||||||
attributes: attributes,
|
attributes: attributes,
|
||||||
formatter: this.formatter
|
formatter: this.formatter
|
||||||
}),
|
}),
|
||||||
evalF = function(f, m) {
|
evalF = function(f, d, m) {
|
||||||
return (_.isFunction(f) ? !!f(m) : !!f);
|
return (_.isFunction(f) ? !!f.apply(d, [m]) : !!f);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Evaluate the disabled, visible, required, canAdd, & canDelete option
|
// Evaluate the disabled, visible, required, canAdd, & canDelete option
|
||||||
_.extend(data, {
|
_.extend(data, {
|
||||||
disabled: (field.version_compatible &&
|
disabled: (field.version_compatible &&
|
||||||
evalF.apply(this.field, [data.disabled, this.model])
|
evalF.apply(this.field, [data.disabled, data, this.model])
|
||||||
),
|
),
|
||||||
visible: evalF.apply(this.field, [data.visible, this.model]),
|
visible: evalF.apply(this.field, [data.visible, data, this.model]),
|
||||||
required: evalF.apply(this.field, [data.required, this.model]),
|
required: evalF.apply(this.field, [data.required, data, this.model]),
|
||||||
canAdd: (field.version_compatible &&
|
canAdd: (field.version_compatible &&
|
||||||
evalF.apply(this.field, [data.canAdd, this.model])
|
evalF.apply(this.field, [data.canAdd, data, this.model])
|
||||||
),
|
),
|
||||||
canDelete: evalF.apply(this.field, [data.canDelete, this.model]),
|
canDelete: evalF.apply(this.field, [data.canDelete, data, this.model]),
|
||||||
canEdit: evalF.apply(this.field, [data.canEdit, this.model])
|
canEdit: evalF.apply(this.field, [data.canEdit, data, this.model])
|
||||||
});
|
});
|
||||||
_.extend(data, {add_label: "ADD"});
|
_.extend(data, {add_label: "ADD"});
|
||||||
|
|
||||||
|
@ -896,6 +896,8 @@
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.control_data = _.clone(data);
|
||||||
|
|
||||||
// Show Backgrid Control
|
// Show Backgrid Control
|
||||||
grid = this.showGridControl(data);
|
grid = this.showGridControl(data);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue