challenges: lock down editing capabilities on certain task properties,
instead showing the challenge's properties (in case they change challenge-side).This includes editing the tag name
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
+18
-1
@@ -101,4 +101,21 @@ module.exports.viewHelpers = (view) ->
|
||||
|
||||
#Tags
|
||||
view.fn 'noTags', helpers.noTags
|
||||
view.fn 'appliedTags', helpers.appliedTags
|
||||
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
|
||||
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user