mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-07-16 13:54:54 +00:00
(js) Fix handling of mail tags in msg viewer
This commit is contained in:
@@ -81,16 +81,18 @@
|
||||
* @param {string} search - the search string to match
|
||||
* @returns a collection of strings
|
||||
*/
|
||||
Message.filterTags = function(query) {
|
||||
Message.filterTags = function(query, excludedTags) {
|
||||
var re = new RegExp(query, 'i'),
|
||||
results = [];
|
||||
|
||||
_.forEach(_.keys(Message.$tags), function(tag) {
|
||||
var pair = Message.$tags[tag];
|
||||
if (pair[0].search(re) != -1) {
|
||||
results.push({ name: tag, description: pair[0], color: pair[1] });
|
||||
if (!_.includes(excludedTags, tag))
|
||||
results.push({ name: tag, description: pair[0], color: pair[1] });
|
||||
}
|
||||
});
|
||||
|
||||
return results;
|
||||
};
|
||||
|
||||
|
||||
@@ -64,6 +64,31 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
// Flatten new tags when coming from the predefined list of tags (Message.$tags) and
|
||||
// sync tags with server when adding or removing a tag.
|
||||
$scope.$watchCollection('viewer.message.flags', function(newTags, oldTags) {
|
||||
var tags;
|
||||
if (newTags || oldTags) {
|
||||
_.forEach(newTags, function(tag, i) {
|
||||
if (angular.isObject(tag))
|
||||
newTags[i] = tag.name;
|
||||
});
|
||||
if (newTags.length > oldTags.length) {
|
||||
tags = _.difference(newTags, oldTags);
|
||||
_.forEach(tags, function(tag) {
|
||||
vm.message.addTag(tag);
|
||||
});
|
||||
}
|
||||
else if (newTags.length < oldTags.length) {
|
||||
tags = _.difference(oldTags, newTags);
|
||||
_.forEach(tags, function(tag) {
|
||||
vm.message.removeTag(tag);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* If this is a popup window, retrieve the matching controllers (mailbox and message) of the parent window.
|
||||
|
||||
Reference in New Issue
Block a user