add tag-editing context (add new, delete). still have to refresh after everything, do to the live-bound each bug
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
_ = require 'underscore'
|
||||
|
||||
module.exports.app = (appExports, model) ->
|
||||
user = model.at('_user')
|
||||
|
||||
@@ -11,3 +13,18 @@ module.exports.app = (appExports, model) ->
|
||||
id: model.id()
|
||||
name: model.get("_newTag")
|
||||
, (-> location.reload())
|
||||
|
||||
appExports.toggleEditingTags = ->
|
||||
model.set '_editingTags', !model.get('_editingTags')
|
||||
|
||||
appExports.filtersDeleteTag = (e, el) ->
|
||||
tags = user.get('tags')
|
||||
tagId = $(el).attr('data-tag-id')
|
||||
model.del "_user.filters.#{tagId}"
|
||||
#TODO remove tag from each task
|
||||
_.each tags, (tag, i) ->
|
||||
if tag.id is tagId
|
||||
tags.splice(i,1)
|
||||
model.del "_user.filters.#{tag.id}"
|
||||
model.set "_user.tags", tags, -> location.reload()
|
||||
|
||||
|
||||
+18
-5
@@ -1,16 +1,29 @@
|
||||
<filters:>
|
||||
<div class="well well-small filters">
|
||||
<div class="pull-left filter-description">
|
||||
Filter by tag:
|
||||
Filter:
|
||||
</div>
|
||||
<ul class="nav nav-pills">
|
||||
{#each _user.tags as :tag}
|
||||
<li class="{#if _user.filters[:tag.id]}active{/}"><a data-tag-id="{:tag.id}" x-bind=click:toggleFilterByTag>{:tag.name}</a></li>
|
||||
<li class="{#if _user.filters[:tag.id]}active{/}" style='position:relative;'>
|
||||
{#if _editingTags}
|
||||
<a style='float:left;' x-bind=click:filtersDeleteTag data-tag-id={:tag.id}><i class='icon-trash'></i></a> 
|
||||
<input type='text' value='{:tag.name}' />
|
||||
{else}
|
||||
<a data-tag-id="{:tag.id}" x-bind="click:toggleFilterByTag">{:tag.name}</a>
|
||||
{/}
|
||||
|
||||
</li>
|
||||
{/}
|
||||
<li>
|
||||
<form x-bind="submit:filtersNewTag">
|
||||
<input type="text" value="{_newTag}" placeholder="New Tag"/>
|
||||
</form>
|
||||
{#if _editingTags}
|
||||
<form x-bind="submit:filtersNewTag">
|
||||
<input type="text" value="{_newTag}" placeholder="New Tag"/>
|
||||
</form>
|
||||
<a x-bind=click:toggleEditingTags>[done]</a>
|
||||
{else}
|
||||
<a x-bind=click:toggleEditingTags>[edit]</a>
|
||||
{/}
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -203,7 +203,9 @@
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
{{#each _user.tags as :tag}}
|
||||
<li class="{#if :task.tags[:tag.id]}active{/}"><a data-task-id="{{:task.id}}" data-tag-id="{:tag.id}" x-bind=click:addTag>{:tag.name}</a></li>
|
||||
<li class="{#if :task.tags[:tag.id]}active{/}">
|
||||
<a data-task-id="{{:task.id}}" data-tag-id="{:tag.id}" x-bind=click:addTag>{:tag.name}</a>
|
||||
</li>
|
||||
{{/}}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user