summaryrefslogtreecommitdiff
path: root/web-ui/app/js/tags
diff options
context:
space:
mode:
authorDuda Dornelles <ddornell@thoughtworks.com>2014-10-16 13:53:16 +0200
committerDuda Dornelles <ddornell@thoughtworks.com>2014-10-16 13:54:03 +0200
commit0de9d8dc31298921f7272d74cdd3c5d4217b5841 (patch)
tree468ba5005379151eff72c5aaaf37db9ba29b3ef7 /web-ui/app/js/tags
parent761e85e523ec61f5629a9f1f6e4196e23ce96673 (diff)
decreasing count on tag and tag shortcut when email is read. we were
decreasing only tags that were also in the read mail, but we have also to look at the mailbox and compare that to the tags in the case of default tags #95
Diffstat (limited to 'web-ui/app/js/tags')
-rw-r--r--web-ui/app/js/tags/ui/tag.js6
-rw-r--r--web-ui/app/js/tags/ui/tag_list.js4
-rw-r--r--web-ui/app/js/tags/ui/tag_shortcut.js29
3 files changed, 26 insertions, 13 deletions
diff --git a/web-ui/app/js/tags/ui/tag.js b/web-ui/app/js/tags/ui/tag.js
index c2b7f588..2cf45764 100644
--- a/web-ui/app/js/tags/ui/tag.js
+++ b/web-ui/app/js/tags/ui/tag.js
@@ -52,9 +52,13 @@ define(
};
this.decreaseReadCountIfMatchingTag = function (ev, data) {
- if (_.contains(data.tags, this.attr.tag.name)) {
+ var mailbox_and_tags = _.flatten([data.tags, data.mailbox]);
+ if (_.contains(mailbox_and_tags, this.attr.tag.name)) {
this.attr.tag.counts.read++;
this.$node.html(this.viewFor(this.attr.tag, templates.tags.tagInner));
+ if (!_.isUndefined(this.attr.shortcut)) {
+ this.attr.shortcut.reRender();
+ }
}
};
diff --git a/web-ui/app/js/tags/ui/tag_list.js b/web-ui/app/js/tags/ui/tag_list.js
index 5bbac8ca..b5b4d555 100644
--- a/web-ui/app/js/tags/ui/tag_list.js
+++ b/web-ui/app/js/tags/ui/tag_list.js
@@ -55,7 +55,7 @@ define(
});
this.renderShortcut = function (tag, tagComponent) {
- TagShortcut.appendedTo($('#tags-shortcuts'), { linkTo: tag, trigger: tagComponent});
+ return TagShortcut.appendedTo($('#tags-shortcuts'), { linkTo: tag, trigger: tagComponent});
};
function renderTag(tag, defaultList, customList) {
@@ -63,7 +63,7 @@ define(
var tagComponent = Tag.appendedTo(list, {tag: tag});
if (_.contains(_.keys(ORDER), tag.name)) {
- this.renderShortcut(tag, tagComponent);
+ tagComponent.attr.shortcut = this.renderShortcut(tag, tagComponent);
}
}
diff --git a/web-ui/app/js/tags/ui/tag_shortcut.js b/web-ui/app/js/tags/ui/tag_shortcut.js
index 5710592e..0fe92550 100644
--- a/web-ui/app/js/tags/ui/tag_shortcut.js
+++ b/web-ui/app/js/tags/ui/tag_shortcut.js
@@ -26,7 +26,7 @@ define(
function (describeComponent, templates, events, tagBase, utils) {
- var TagShortcut = describeComponent(tagShortcut, tagBase);
+ var TagShortcut = describeComponent(tagShortcut, tagBase);
TagShortcut.appendedTo = function (parent, data) {
var res = new this();
@@ -38,9 +38,7 @@ define(
function tagShortcut() {
- this.renderAndAttach = function (parent, options) {
- var linkTo = options.linkTo;
-
+ this.renderTemplate = function (linkTo) {
var model = {
tagName: linkTo.name,
displayBadge: this.displayBadge(linkTo),
@@ -48,11 +46,16 @@ define(
count: this.badgeType(linkTo) === 'total' ? linkTo.counts.total : (linkTo.counts.total - linkTo.counts.read),
icon: iconFor[linkTo.name]
};
+ return templates.tags.shortcut(model);
+ };
- var rendered = templates.tags.shortcut(model);
- parent.append(rendered);
+ this.renderAndAttach = function (parent, options) {
+ parent.append(this.renderTemplate(options.linkTo));
+ this.initialize(parent.children().last(), options);
+ };
- this.initialize(parent.children().last(),options);
+ this.reRender = function () {
+ this.$node.html(this.renderTemplate(this.attr.linkTo));
};
var iconFor = {
@@ -64,8 +67,12 @@ define(
};
this.selectTag = function (ev, data) {
- if(data.tag === this.attr.linkTo.name) { this.doSelect(); }
- else { this.doUnselect(); }
+ if (data.tag === this.attr.linkTo.name) {
+ this.doSelect();
+ }
+ else {
+ this.doUnselect();
+ }
};
this.doUnselect = function () {
@@ -83,7 +90,9 @@ define(
};
this.after('initialize', function () {
- this.on('click', function () { this.attr.trigger.triggerSelect(); });
+ this.on('click', function () {
+ this.attr.trigger.triggerSelect();
+ });
this.on(document, events.ui.tag.select, this.selectTag);
this.on(document, events.tags.shortcuts.teardown, this.doTeardown);
});