Skip to content

Commit

Permalink
Can now untag issues. Later, should add ability to remove specific ta…
Browse files Browse the repository at this point in the history
…gs only
  • Loading branch information
David Hirtle committed Jun 4, 2012
1 parent c2e0afc commit 95569d5
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/issueDao.js
Expand Up @@ -51,7 +51,18 @@ issueDao.addTag = function (id, tag, project) {
}

issue.tags.push(tag);
issues[project.slug][issue.id - 1] = issue;
this.write(project);
return issue;
};

issueDao.stripTags = function (id, project) {
var issue = issueDao.find(id, project);
if (!issue) {
return;
}

issue.tags = [];
issues[project.slug][issue.id - 1] = issue;
this.write(project);
return issue;
Expand Down
8 changes: 8 additions & 0 deletions lib/tracker.js
Expand Up @@ -78,6 +78,14 @@ function onConnect(project, socket, projectSocket) {
}
});

socket.on('untag issue', function (id) {
var untagged = issueDao.stripTags(id, project);
if (untagged) {
var event = recordEvent(ET.UntagIssue, { updater: socket.nickname, issue: untagged });
projectSocket.emit('issue untagged', event);
}
});

socket.on('close issue', function (id) {
var updated = issueDao.update(id, { closed: true, closer: socket.nickname }, project);
if (updated) {
Expand Down
9 changes: 9 additions & 0 deletions public/js/IssueManager.js
Expand Up @@ -41,6 +41,10 @@ define(['ko', 'underscore', 'jquery', 'Issue', 'error/NoSuchIssueError'], functi
var issue = that.findIssue(event.issue.id);
issue.tags(event.issue.tags);
});
this.socket.on('issue untagged', function (event) {
var issue = that.findIssue(event.issue.id);
issue.tags([]);
});
this.socket.on('issue updated', _.bind(this.refreshIssue, this));
this.socket.on('issue prioritized', _.bind(this.refreshIssue, this));
this.socket.on('issue closed', function (event) {
Expand Down Expand Up @@ -88,6 +92,11 @@ define(['ko', 'underscore', 'jquery', 'Issue', 'error/NoSuchIssueError'], functi
this.socket.emit('tag issue', id, tag);
};

IssueManager.prototype.untagIssue = function (id) {
this.findIssue(id);
this.socket.emit('untag issue', id);
};

IssueManager.prototype.closeIssue = function (id) {
var issue = this.findIssue(id);
if (issue.closed()) {
Expand Down
1 change: 1 addition & 0 deletions public/js/MessageList.js
Expand Up @@ -14,6 +14,7 @@ define(['ko', 'underscore', 'util', 'flavour'], function (ko, _, util, flavour)
socket.on('issue created', _.bind(this.append, this));
socket.on('issue assigned', _.bind(this.append, this));
socket.on('issue tagged', _.bind(this.append, this));
socket.on('issue untagged', _.bind(this.append, this));
socket.on('issue updated', _.bind(function (props, event) {
this.append(event);
}, this));
Expand Down
5 changes: 5 additions & 0 deletions public/js/ProjectView.js
Expand Up @@ -155,6 +155,11 @@ function ($, _, ko, timeago, util, Issue, Notifier, UserManager, MessageList, Is
requireArgument(id, tag);
this.issueManager.tagIssue(id, tag);
break;
case 'untag':
id = parseInt(getArgument(rest, 1), 10); // TODO: comma separated ids
requireArgument(id);
this.issueManager.untagIssue(id);
break;
case 'critical':
case 'urgent':
case '!':
Expand Down
1 change: 1 addition & 0 deletions public/js/omegaEvent.js
Expand Up @@ -38,6 +38,7 @@ var isNode = (typeof exports !== 'undefined');
NewIssue: new OmegaEventType("newIssue", "<%= issue.creator %> created <%= issue.id %>.", "New issue", "<%= issue.description %>"),
AssignIssue: new OmegaEventType("assignIssue", "<%= assigner %> assigned <%= issue.id %> to <%= issue.assignee %>."),
TagIssue: new OmegaEventType("tagIssue", "<%= updater %> tagged <%= issue.id %> with '<%= tag %>'."),
UntagIssue: new OmegaEventType("untagIssue", "<%= updater %> removed tags from <%= issue.id %>."),
UpdateIssue: new OmegaEventType("updateIssue", "<%= updater %> updated <%= issue.id %>."),
CloseIssue: new OmegaEventType("closeIssue", "<%= issue.closer %> closed <%= issue.id %>.", "Issue closed", "<%= issue.description %>"),
PrioritizeIssue: new OmegaEventType("prioritizeIssue", "<%= updater %> marked <%= issue.id %> as<% if (!issue.critical) print(' not'); %> critical.")
Expand Down

0 comments on commit 95569d5

Please sign in to comment.