From 44bd61016ff2fb5c01b2a0acefc75ef48e4e82f0 Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Fri, 10 May 2013 18:23:05 +0100 Subject: [PATCH] tags: cleaner tag-deletion handling --- src/app/filters.coffee | 9 ++++----- views/app/filters.html | 4 ++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/app/filters.coffee b/src/app/filters.coffee index 8042e87161..15d11b09d6 100644 --- a/src/app/filters.coffee +++ b/src/app/filters.coffee @@ -24,7 +24,8 @@ module.exports.app = (appExports, model) -> appExports.filtersDeleteTag = (e, el) -> tags = user.get('tags') - tagId = $(el).attr('data-tag-id') + tag = e.at "_user.tags." + $(el).attr('data-index') + tagId = tag.get('id') #something got corrupted, let's clear the corrupt tags unless tagId @@ -33,10 +34,8 @@ module.exports.app = (appExports, model) -> return model.del "_user.filters.#{tagId}" - _.each tags, (tag, i) -> - model.remove "_user.tags", i if tag.id is tagId + tag.remove() # remove tag from all tasks - _.each user.get("tasks"), (task) -> - user.del "tasks.#{task.id}.tags.#{tagId}" + _.each user.get("tasks"), (task) -> user.del "tasks.#{task.id}.tags.#{tagId}" diff --git a/views/app/filters.html b/views/app/filters.html index 0d5ca322bf..f3479f0690 100644 --- a/views/app/filters.html +++ b/views/app/filters.html @@ -10,9 +10,9 @@ {#each _user.tags as :tag}
  • {#if _editingTags} -
    +
    - +
    {else} {:tag.name}