mirror of
https://github.com/keeweb/keeweb.git
synced 2024-06-26 07:39:04 +02:00
29 lines
814 B
JavaScript
29 lines
814 B
JavaScript
'use strict';
|
|
|
|
var FieldViewText = require('./field-view-text');
|
|
|
|
var FieldViewTags = FieldViewText.extend({
|
|
renderValue: function(value) {
|
|
return value ? _.escape(value.join(', ')) : '';
|
|
},
|
|
|
|
getEditValue: function(value) {
|
|
return value ? value.join(', ') : '';
|
|
},
|
|
|
|
endEdit: function(newVal, extra) {
|
|
if (newVal !== undefined) {
|
|
var allTags = {};
|
|
this.model.tags.forEach(function(tag) {
|
|
allTags[tag.toLowerCase()] = tag;
|
|
});
|
|
newVal = _.unique(newVal.split(/\s*[;,:]\s*/).filter(_.identity).map(function (tag) {
|
|
return allTags[tag.toLowerCase()] || tag;
|
|
}));
|
|
}
|
|
FieldViewText.prototype.endEdit.call(this, newVal, extra);
|
|
}
|
|
});
|
|
|
|
module.exports = FieldViewTags;
|