challenges: fix to not apply user's active tags to new challenge

tasks, but also not apply filters except to main user's list
This commit is contained in:
Tyler Renelle 2013-05-17 23:32:24 +01:00
parent 6507795d99
commit 9b41712ca6
3 changed files with 11 additions and 13 deletions

View file

@ -138,17 +138,19 @@ viewHelpers = (view) ->
### ###
Tasks Tasks
### ###
view.fn 'taskClasses', (task, filters, dayStart, lastCron, showCompleted=false) -> view.fn 'taskClasses', (task, filters, dayStart, lastCron, showCompleted=false, main) ->
return unless task return unless task
{type, completed, value, repeat} = task {type, completed, value, repeat} = task
# completed / remaining toggle # completed / remaining toggle
return 'hidden' if (type is 'todo') and (completed != showCompleted) return 'hidden' if (type is 'todo') and (completed != showCompleted)
for filter, enabled of filters # Filters
if enabled and not task.tags?[filter] if main # only show when on your own list
# All the other classes don't matter for filter, enabled of filters
return 'hidden' if enabled and not task.tags?[filter]
# All the other classes don't matter
return 'hidden'
classes = type classes = type

View file

@ -14,13 +14,9 @@ module.exports.app = (appExports, model) ->
# Don't add a blank task; 20/02/13 Added a check for undefined value, more at issue #463 -lancemanfv # Don't add a blank task; 20/02/13 Added a check for undefined value, more at issue #463 -lancemanfv
return if /^(\s)*$/.test(text) || text == undefined return if /^(\s)*$/.test(text) || text == undefined
activeFilters = _.reduce user.get('filters'), ((memo,v,k) -> memo[k]=v if v;memo), {} newTask = {id: model.id(), type: type, text: text, notes: '', value: 0, tags:{}}
newTask = {id: model.id(), type: type, text: text, notes: '', value: 0, tags: activeFilters}
isChallenge = e.at().path().indexOf('_challenge.new') != -1 isChallenge = e.at().path().indexOf('_challenge.new') != -1
if isChallenge newTask.tags = if isChallenge then {} else _.reduce user.get('filters'), ((memo,v,k) -> memo[k]=v if v;memo), {}
activeFilters = {}
newTask.challenge = model.get '_challenge.new.id'
switch type switch type
when 'habit' when 'habit'

View file

@ -147,7 +147,7 @@
<hr> <hr>
{{/}} {{/}}
<ul class="{{@type}}s {#unless @list}hidden{/}"> <ul class="{{@type}}s {#unless @list}hidden{/}">
{#each @list as :task}<app:tasks:task main="{@main}" />{/} {#each @list as :task}<app:tasks:task main="{{@main}}" />{/}
</ul> </ul>
{{@extra}} {{@extra}}
<br/> <br/>
@ -163,7 +163,7 @@
<!-- all the parts of a single task --> <!-- all the parts of a single task -->
<task:> <task:>
<li data-id={{:task.id}} class="task {taskClasses(:task, _user.filters, _user.preferences.dayStart, _user.lastCron, _showCompleted)}"> <li data-id={{:task.id}} class="task {taskClasses(:task, _user.filters, _user.preferences.dayStart, _user.lastCron, _showCompleted, @main)}">
<!-- right-hand side control buttons --> <!-- right-hand side control buttons -->
<div class="task-meta-controls"> <div class="task-meta-controls">