entry templates fields

This commit is contained in:
antelle 2017-05-03 21:21:29 +02:00
parent 6930b23ad9
commit 3662a67de3
3 changed files with 8 additions and 3 deletions

View File

@ -388,9 +388,9 @@ const EntryModel = Backbone.Model.extend({
this._fillByEntry();
},
setField: function(field, val) {
setField: function(field, val, allowEmpty) {
const hasValue = val && (typeof val === 'string' || val.isProtected && val.byteLength);
if (hasValue || this.builtInFields.indexOf(field) >= 0) {
if (hasValue || allowEmpty || this.builtInFields.indexOf(field) >= 0) {
this._entryModified();
this.entry.fields[field] = val;
} else if (this.entry.fields.hasOwnProperty(field)) {

View File

@ -248,6 +248,10 @@ const GroupModel = MenuItemModel.extend({
return this.parentGroup ? this.parentGroup.getEffectiveAutoTypeSeq() : DefaultAutoTypeSequence;
},
isEntryTemplatesGroup: function() {
return this.group.uuid.equals(this.file.db.meta.entryTemplatesGroup);
},
moveToTrash: function() {
this.file.setModified();
this.file.db.remove(this.group);

View File

@ -479,7 +479,8 @@ const DetailsView = Backbone.View.extend({
i++;
fieldName = e.newField + i;
}
this.model.setField(fieldName, e.val);
const allowEmpty = this.model.group.isEntryTemplatesGroup();
this.model.setField(fieldName, e.val, allowEmpty);
this.entryUpdated();
return;
} else if (fieldName === 'File') {