From 95569d5d8c970f20f0bc452c2adf52a2c797b16c Mon Sep 17 00:00:00 2001 From: David Hirtle Date: Sun, 3 Jun 2012 22:41:32 -0700 Subject: [PATCH] Can now untag issues. Later, should add ability to remove specific tags only --- lib/issueDao.js | 11 +++++++++++ lib/tracker.js | 8 ++++++++ public/js/IssueManager.js | 9 +++++++++ public/js/MessageList.js | 1 + public/js/ProjectView.js | 5 +++++ public/js/omegaEvent.js | 1 + 6 files changed, 35 insertions(+) diff --git a/lib/issueDao.js b/lib/issueDao.js index 6cb1646..7ded324 100644 --- a/lib/issueDao.js +++ b/lib/issueDao.js @@ -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; diff --git a/lib/tracker.js b/lib/tracker.js index dd5ca9b..887f325 100644 --- a/lib/tracker.js +++ b/lib/tracker.js @@ -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) { diff --git a/public/js/IssueManager.js b/public/js/IssueManager.js index b49c350..3b6980f 100644 --- a/public/js/IssueManager.js +++ b/public/js/IssueManager.js @@ -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) { @@ -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()) { diff --git a/public/js/MessageList.js b/public/js/MessageList.js index 463cf13..001555a 100644 --- a/public/js/MessageList.js +++ b/public/js/MessageList.js @@ -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)); diff --git a/public/js/ProjectView.js b/public/js/ProjectView.js index 2fd5e78..149c118 100644 --- a/public/js/ProjectView.js +++ b/public/js/ProjectView.js @@ -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 '!': diff --git a/public/js/omegaEvent.js b/public/js/omegaEvent.js index 9016a5d..fda3eff 100644 --- a/public/js/omegaEvent.js +++ b/public/js/omegaEvent.js @@ -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.")