diff --git a/src/app/tasks.coffee b/src/app/tasks.coffee
index afcc5f5896..ff2feedf84 100644
--- a/src/app/tasks.coffee
+++ b/src/app/tasks.coffee
@@ -11,6 +11,8 @@ module.exports.view = (view) ->
# show as completed if completed (naturally) or not required for today
if completed or (repeat and repeat[helpers.dayMapping[moment().day()]]==false)
classes += " completed"
+ else
+ classes += " uncompleted"
switch
when value<-8 then classes += ' color-worst'
@@ -65,15 +67,8 @@ module.exports.app = (appExports, model) ->
appExports.del = (e, el) ->
# Derby extends model.at to support creation from DOM nodes
- #task = model.at(e.target)
- # FIXME normally that would work, and we'd later simply call `user.del task` (instead of that 4-liner down there)
- # however, see https://github.com/lefnire/habitrpg/pull/226#discussion_r2810391
-
- id = $(e.target).parents('li.task').attr('data-id')
- return unless id?
-
- task = user.at "tasks.#{id}"
- type = task.get('type')
+ task = model.at(e.target)
+ id = task.get('id')
history = task.get('history')
if history and history.length>2
@@ -95,10 +90,8 @@ module.exports.app = (appExports, model) ->
# fix when query subscriptions implemented properly
$('[rel=tooltip]').tooltip('hide')
- ids = user.get("#{type}Ids")
- ids.splice(ids.indexOf(id),1)
user.del('tasks.'+id)
- user.set("#{type}Ids", ids)
+ task.remove()
appExports.clearCompleted = (e, el) ->
@@ -148,6 +141,29 @@ module.exports.app = (appExports, model) ->
chart = new google.visualization.LineChart(document.getElementById( chartSelector ))
chart.draw(data, options)
+ appExports.changeContext = (e, el) ->
+ # Get the data from the element
+ targetSelector = $(el).attr('data-target')
+ newContext = $(el).attr('data-context')
+ newActiveNav = $(el).parent('li')
+
+ # If the clicked nav is already active, do nothing
+ if newActiveNav.hasClass('active')
+ return
+
+ # Find the old active nav and context
+ oldActiveNav = $(el).closest('ul').find('> .active')
+ oldContext = oldActiveNav.find('a').attr('data-context')
+
+ # Set the new active nav
+ oldActiveNav.removeClass('active')
+ newActiveNav.addClass('active')
+
+ # Set the new context on the target
+ target = $(targetSelector)
+ target.removeClass(oldContext)
+ target.addClass(newContext)
+
appExports.score = (e, el, next) ->
direction = $(el).attr('data-direction')
direction = 'up' if direction == 'true/'
diff --git a/styles/app/tasks.styl b/styles/app/tasks.styl
index f54b431de8..70d54c189d 100644
--- a/styles/app/tasks.styl
+++ b/styles/app/tasks.styl
@@ -37,6 +37,19 @@ label.checkbox.inline{
background-image: linear-gradient(to bottom, #eee, #aaa);
background-repeat: repeat-x;
+.context-enabled
+ .display-context-dependant,
+ .task-list li
+ display: none
+
+ &.context-completed
+ .show-for-completed, .completed
+ display: block
+
+ &.context-uncompleted
+ .show-for-uncompleted, .uncompleted
+ display: block
+
.help-icon
float:right;
diff --git a/views/app/index.html b/views/app/index.html
index b27b2ec5f8..c33e65bbf2 100644
--- a/views/app/index.html
+++ b/views/app/index.html
@@ -295,37 +295,22 @@