tags: cleaner tag-deletion handling
This commit is contained in:
@@ -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}"
|
||||
|
||||
|
||||
@@ -10,9 +10,9 @@
|
||||
{#each _user.tags as :tag}
|
||||
<li class="{#if _user.filters[:tag.id]}active{/}" style='position:relative;'>
|
||||
{#if _editingTags}
|
||||
<div class="input-append option-group tag-editing" >
|
||||
<div class="input-append option-group tag-editing" >
|
||||
<input class="input input-small option-content tag-editing-pill" type="text" value='{:tag.name}' />
|
||||
<span class="add-on tag-editing-pill"><a class='pull-right' x-bind=click:filtersDeleteTag data-tag-id={{:tag.id}}><i class='icon-trash'></i></a></span>
|
||||
<span class="add-on tag-editing-pill"><a class='pull-right' x-bind=click:filtersDeleteTag data-index="{$index}"><i class='icon-trash'></i></a></span>
|
||||
</div>
|
||||
{else}
|
||||
<a data-tag-id="{{:tag.id}}" x-bind="click:toggleFilterByTag">{:tag.name}</a>
|
||||
|
||||
Reference in New Issue
Block a user