diff --git a/src/app/character.coffee b/src/app/character.coffee index 07b0996dcb..1c3dd6334d 100644 --- a/src/app/character.coffee +++ b/src/app/character.coffee @@ -111,6 +111,7 @@ userSchema = flags: partyEnabled: false itemsEnabled: false + tags: [] # ads: 'show' # added on registration module.exports.newUserObject = -> @@ -130,6 +131,12 @@ module.exports.newUserObject = -> {type: 'reward', text: 'Cake', notes: 'But only buy if you have enough gold - you lose HP otherwise.', value: 10 } ] + defaultTags = [ + {name: 'morning'} + {name: 'afternoon'} + {name: 'evening'} + ] + for task in defaultTasks guid = task.id = derby.uuid() newUser.tasks[guid] = task @@ -138,6 +145,11 @@ module.exports.newUserObject = -> when 'daily' then newUser.dailyIds.push guid when 'todo' then newUser.todoIds.push guid when 'reward' then newUser.rewardIds.push guid + + for tag in defaultTags + tag.id = derby.uuid() + newUser.tags.push tag + return newUser module.exports.updateUser = (model) -> diff --git a/src/app/filters.coffee b/src/app/filters.coffee new file mode 100644 index 0000000000..386bbdd63c --- /dev/null +++ b/src/app/filters.coffee @@ -0,0 +1,7 @@ +module.exports.app = (appExports, model) -> + user = model.at('_user') + + appExports.toggleFilterByTag = (e, el) -> + tagId = $(el).attr('data-tag-id') + path = '_tagFilters.' + tagId + user.set path, !(user.get path) diff --git a/src/app/index.coffee b/src/app/index.coffee index b25e52cb9d..49e18c800b 100644 --- a/src/app/index.coffee +++ b/src/app/index.coffee @@ -13,6 +13,7 @@ browser = require './browser' party = require './party' items = require './items' profile = require './profile' +filters = require './filters' helpers.viewHelpers view character.view view @@ -61,4 +62,5 @@ ready (model) -> require('../server/private').app(exports, model) require('./debug').app(exports, model) if model.get('_view.nodeEnv') != 'production' browser.app(exports, model) + filters.app(exports, model) diff --git a/src/app/tasks.coffee b/src/app/tasks.coffee index 22995d868c..c6a989a9d0 100644 --- a/src/app/tasks.coffee +++ b/src/app/tasks.coffee @@ -4,8 +4,14 @@ _ = require 'underscore' moment = require 'moment' module.exports.view = (view) -> - view.fn 'taskClasses', (type, completed, value, repeat) -> + view.fn 'taskClasses', (type, completed, value, repeat, tags = {}, filters = {}) -> #TODO figure out how to just pass in the task model, so i can access all these properties from one object + if type != 'reward' + for filter, enabled of filters + if enabled and not tags[filter] + # All the other classes don't matter + return 'filtered-out' + classes = type # show as completed if completed (naturally) or not required for today @@ -167,6 +173,13 @@ module.exports.app = (appExports, model) -> target.removeClass(oldContext) target.addClass(newContext) + appExports.addTag = (e, el) -> + tagId = $(el).attr('data-tag-id') + taskId = $(el).attr('data-task-id') + console.log taskId + path = "_user.tasks.#{taskId}.tags.#{tagId}" + model.set path, !(model.get path) + appExports.score = (e, el, next) -> direction = $(el).attr('data-direction') direction = 'up' if direction == 'true/' diff --git a/styles/app/filters.styl b/styles/app/filters.styl new file mode 100644 index 0000000000..b9dbced5b1 --- /dev/null +++ b/styles/app/filters.styl @@ -0,0 +1,15 @@ +/* Filters */ +.filters + padding-left: 19px + padding-right: 19px + +.filters .nav + margin-bottom: 0 + +.filter-description + margin-top: 7px + margin-right: 7px + +/* Filters applied to tasks */ +.task.filtered-out + display: none \ No newline at end of file diff --git a/styles/app/index.styl b/styles/app/index.styl index 406f26d74e..534dc6283e 100644 --- a/styles/app/index.styl +++ b/styles/app/index.styl @@ -7,6 +7,7 @@ @import "./customizer.styl"; @import "./items.styl"; @import "./alerts.styl"; +@import "./filters.styl"; @import "../../public/vendor/bootstrap-datepicker/css/datepicker.css"; @@ -47,7 +48,7 @@ html,body,p,h1,ul,li,table,tr,th,td .modal whitespace:normal -.dropdown-menu +.user-actions .dropdown-menu right: 0 left: auto diff --git a/styles/app/tasks.styl b/styles/app/tasks.styl index 70d54c189d..6faf19fcd5 100644 --- a/styles/app/tasks.styl +++ b/styles/app/tasks.styl @@ -39,7 +39,7 @@ label.checkbox.inline{ .context-enabled .display-context-dependant, - .task-list li + .task-list > li display: none &.context-completed diff --git a/views/app/filters.html b/views/app/filters.html new file mode 100644 index 0000000000..f87f5f52c3 --- /dev/null +++ b/views/app/filters.html @@ -0,0 +1,11 @@ + +
+
+ Filter by tag: +
+ +
\ No newline at end of file diff --git a/views/app/index.html b/views/app/index.html index 9d66e2fd2b..db5df5a5c0 100644 --- a/views/app/index.html +++ b/views/app/index.html @@ -7,6 +7,7 @@ + HabitRPG | Gamify Your Life @@ -28,6 +29,7 @@
+
diff --git a/views/app/settings.html b/views/app/settings.html index 753e3aaa6c..78d035a8f0 100644 --- a/views/app/settings.html +++ b/views/app/settings.html @@ -28,7 +28,7 @@

This is highly discouraged because you'll lose historical data, which is useful for graphing your progress over time. However, some people find it useful in the beginning after playing with the app for a while.

<@footer> - + @@ -103,7 +103,7 @@ {#unless _loggedIn} Login / Register {else} -
+ {/} + {#if not(equal(:task.type, 'reward'))} +
+
+ + +
+
+ {/}