diff --git a/src/app/challenges.coffee b/src/app/challenges.coffee index 73927ccef7..3ef9b3e910 100644 --- a/src/app/challenges.coffee +++ b/src/app/challenges.coffee @@ -40,7 +40,7 @@ module.exports.app = (appExports, model) -> # Add challenge name as a tag for user tags = user.get('tags') unless tags and _.find(tags,{id: chal.id}) - model.push('_user.tags', {id: chal.id, name: chal.name}) + model.push '_user.tags', {id: chal.id, name: chal.name, challenge: true} tags = {}; tags[chal.id] = true # Add all challenge's tasks to user's tasks @@ -50,6 +50,7 @@ module.exports.app = (appExports, model) -> _.each chal["#{type}s"], (task) -> task.tags = tags task.challenge = chal.id + task.group = {id: chal.group.id, type: chal.group.type} model.push("_#{type}List", task) true diff --git a/src/app/misc.coffee b/src/app/misc.coffee index 735addb804..30a4246368 100644 --- a/src/app/misc.coffee +++ b/src/app/misc.coffee @@ -101,4 +101,21 @@ module.exports.viewHelpers = (view) -> #Tags view.fn 'noTags', helpers.noTags - view.fn 'appliedTags', helpers.appliedTags \ No newline at end of file + view.fn 'appliedTags', helpers.appliedTags + + #Challenges + view.fn 'taskAttrFromChallenge', (task, attr) -> + [tid, gid, cid, tType, gType] = [task.id, task.group.id, task.challenge, task.type, task.group.type] + findAttr = (challenges) -> + challenge = _.find(challenges,{id:cid}) + val = _.find(challenge["#{tType}s"],{id:tid})[attr] + if attr is 'priority' + val = switch val + when '!!!' then 'Hard' + when '!!' then 'Medium' + else 'Easy' + return val + if gType is 'party' + findAttr @model.get("_party.challenges") + else if gType is 'guild' + findAttr _.find(@model.get("_guilds"),{id:gid}).challenges \ No newline at end of file diff --git a/src/app/tasks.coffee b/src/app/tasks.coffee index 8fa4ebe27d..8023bdc636 100644 --- a/src/app/tasks.coffee +++ b/src/app/tasks.coffee @@ -19,9 +19,8 @@ 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 return if /^(\s)*$/.test(text) || text == undefined - newTask = {id: model.id(), type: type, text: text, notes: '', value: 0, tags:{}} - isChallenge = e.at().path().indexOf('_challenge.new') != -1 - newTask.tags = if isChallenge then {} else _.reduce user.get('filters'), ((memo,v,k) -> memo[k]=v if v;memo), {} + newTask = {id: model.id(), type, text, notes: '', value: 0} + newTask.tags = _.reduce user.get('filters'), ((memo,v,k) -> memo[k]=v if v; memo), {} switch type when 'habit' diff --git a/views/app/filters.html b/views/app/filters.html index 1a04d02a3a..b2e58dc26e 100644 --- a/views/app/filters.html +++ b/views/app/filters.html @@ -9,7 +9,7 @@ {#each _user.tags as :tag}
  • - {#if _editingTags} + {#if and(_editingTags,not(:tag.challenge))}
    diff --git a/views/app/tasks.html b/views/app/tasks.html index 656a3fb6d2..bb361ce32f 100644 --- a/views/app/tasks.html +++ b/views/app/tasks.html @@ -175,11 +175,13 @@ - {{#if :task.challenge}}{{/}} - - + {{#if :task.challenge}} + + {{else}} + + + {{/}} - {#if :task.history} {/} @@ -231,7 +233,11 @@

    - {:task.text} + {{#if :task.challenge}} + {{taskAttrFromChallenge(:task,'text')}} + {{else}} + {:task.text} + {{/}}

    @@ -244,12 +250,19 @@
    - - + {{#unless :task.challenge}} + + {{/}} + + {{#if :task.challenge}} + + {{else}} + + {{/}}
    - {#if equal(:task.type, 'habit')} + {#if and(equal(:task.type, 'habit'),not(:task.challenge))}
    Direction/Actions @@ -304,11 +317,18 @@

    Advanced Options

    Difficulty -
    - - - -
    + + {{#if :task.challenge}} + + {{else}} +
    + + + +
    + {{/}} {{#if equal(:task.type,'daily')}} Restore Streak