Subdocs & script templates. Migrate the API from User.tasks =>

User.habits/dailys/todos/rewards. Move /#/tasks & /#/options page
loading from server-sent html to everything loaded in the page as script
templates (including necessary fixes for adsense). NOTE: this commit
won't work, it depends a bit on the *next* commit with Challenges
functionality, but I wanted to separate it out a bit for clarity
This commit is contained in:
Tyler Renelle
2013-10-26 17:23:52 -07:00
parent e81193ef28
commit e45d8307e7
18 changed files with 415 additions and 575 deletions
+80
View File
@@ -0,0 +1,80 @@
// Note here, we need this part of Habit to be a directive since we're going to be passing it variables from various
// parts of the app. The alternative would be to create new scopes for different containing sections, but that
// started to get unwieldy
script(id='templates/habitrpg-tasks.html', type="text/ng-template")
.grid
.module(ng-repeat='list in lists', ng-class='{"rewards-module": list.type==="reward"}')
.task-column(class='{{list.type}}s')
// Todos export/graph options
span.option-box.pull-right(ng-if='main && list.type=="todo"')
a.option-action(ng-show='obj.history.todos', ng-click='toggleChart("todos")', tooltip='Progress')
i.icon-signal
//-a.option-action(ng-href='/v1/users/{{user.id}}/calendar.ics?apiToken={{user.apiToken}}', tooltip='iCal')
a.option-action(ng-click='notPorted()', tooltip='iCal', ng-show='false')
i.icon-calendar
// <a href="https://www.google.com/calendar/render?cid={{encodeiCalLink(_user.id, _user.apiToken)}}" rel=tooltip title="Google Calendar"><i class=icon-calendar></i></a>
// Gold & Gems
span.option-box.pull-right.wallet(ng-if='main && list.type=="reward"')
.money
| {{gold(user.stats.gp)}}
span.shop_gold(tooltip='Gold')
.money
| {{silver(user.stats.gp)}}
span.shop_silver(tooltip='Silver')
// Header
h2.task-column_title {{list.header}}
// Todo Chart
.todos-chart(ng-if='list.type == "todo"', ng-show='charts.todos')
// Add New
form.addtask-form.form-inline.new-task-form(name='new{{list.type}}form', ng-show='editable', ng-hide='list.showCompleted && list.type=="todo"', ng-submit='addTask(list)')
span.addtask-field
input(type='text', ng-model='list.newTask', placeholder='{{list.placeHolder}}', required)
input.addtask-btn(type='submit', value='', ng-disabled='new{{list.type}}form.$invalid')
hr
// Actual List
ul(class='{{list.type}}s', ng-show='obj[list.type + "s"].length > 0', habitrpg-sortable)
include ./task
// Static Rewards
ul.items(ng-show='main && list.type=="reward" && user.flags.itemsEnabled')
li.task.reward-item(ng-hide='item.hide', ng-repeat='item in itemStore')
// right-hand side control buttons
.task-meta-controls
span.task-notes(popover-trigger='mouseenter', popover-placement='left', popover='{{item.notes}}', popover-title='{{item.text}}')
i.icon-comment
//left-hand size commands
.task-controls
a.task-action-btn.btn-reroll(ng-if='item.type=="reroll"', ng-click='modals.reroll = true')
i.icon-repeat
a.money.btn-buy.item-btn(ng-if='item.type!="reroll"', ng-click='buy(item.type)')
span.reward-cost {{item.value}}
span.shop_gold
// main content
span(ng-class='{"shop_{{item.classes}} shop-sprite item-img": true}')
p.task-text {{item.text}}
br
// Ads
div(ng-if='main && !user.purchased.ads && list.type!="reward"')
span.pull-right
a(ng-click='modals.buyGems=true', tooltip='Remove Ads')
i.icon-remove
// Habit3
ins.adsbygoogle(ng-init='initAds()', style='display: inline-block; width: 234px; height: 60px;', data-ad-client='ca-pub-3242350243827794', data-ad-slot='9529624576')
// Todo Tabs
div(ng-if='main && list.type=="todo"', ng-class='{"tabbable tabs-below": list.type=="todo"}')
button.task-action-btn.tile.spacious.bright(ng-show='list.showCompleted', ng-click='clearCompleted()') Clear Completed
// remaining/completed tabs
ul.nav.nav-tabs
li(ng-class='{active: !list.showCompleted}')
a(ng-click='list.showCompleted = false') Remaining
li(ng-class='{active: list.showCompleted}')
a(ng-click='list.showCompleted= true') Complete
+164
View File
@@ -0,0 +1,164 @@
li(ng-repeat='task in list.tasks', class='task {{taskClasses(task, user.filters, user.preferences.dayStart, user.lastCron, list.showCompleted, main)}}', data-id='{{task.id}}')
// right-hand side control buttons
.task-meta-controls
// Due Date
span.task-date(ng-if='task.type=="todo" && task.date')
| {{task.date}}
// Streak
span(ng-show='task.streak') {{task.streak}}
span(tooltip='Streak Counter')
i.icon-forward
i.icon-tags(tooltip='{{appliedTags(user.tags, task.tags)}}', ng-hide='noTags(task.tags)')
// edit
a(ng-hide='task._editing', ng-click='editTask(task)', tooltip='Edit')
i.icon-pencil(ng-hide='task._editing')
// cancel
a(ng-hide='!task._editing', ng-click='editTask(task)', tooltip='Cancel')
i.icon-remove(ng-hide='!task._editing')
//- challenges
//- {{#if :task.challenge}}
//- {{#if brokenChallengeLink(:task)}}
//- <i class='icon-bullhorn' style='background-color:red;' x-bind=click:tasks.toggleTaskEdit rel=tooltip title="Broken Challenge Link"></i>
//- {{else}}
//- <i class='icon-bullhorn' rel=tooltip title="Challenge Task"></i>
//- {{/}}
//- {{else}}
//- <!-- delete -->
//- <a x-bind="click:tasks.del" rel=tooltip title="Delete"><i class="icon-trash"></i></a>
//- {{/}}
// delete
a(ng-click='removeTask(list.tasks, $index)', tooltip='Delete')
i.icon-trash
// chart
a(ng-show='task.history', ng-click='toggleChart(task.id, task)', tooltip='Progress')
i.icon-signal
// notes
span.task-notes(ng-show='task.notes && !task._editing', popover-trigger='mouseenter', popover-placement='left', popover='{{task.notes}}', popover-title='{{task.text}}')
i.icon-comment
// left-hand side checkbox
.task-controls.task-primary
// Habits
span(ng-if='task.type=="habit"')
a.task-action-btn(ng-if='task.up', ng-click='score(task,"up")') +
a.task-action-btn(ng-if='task.down', ng-click='score(task,"down")') -
// Rewards
span(ng-show='task.type=="reward"')
a.money.btn-buy(ng-click='score(task, "down")')
span.reward-cost {{task.value}}
span.shop_gold
// Daily & Todos
span.task-checker.action-yesno(ng-if='task.type=="daily" || task.type=="todo"')
input.visuallyhidden.focusable(id='box-{{task.id}}', type='checkbox', ng-model='task.completed', ng-change='changeCheck(task)')
label(for='box-{{task.id}}')
// main content
p.task-text
// {{#if taskInChallenge(task)}}
// {{taskAttrFromChallenge(task,'text')}}
// {{else}}
| {{task.text}}
// {{/}}
// edit/options dialog
.task-options(ng-show='task._editing')
//
// {#if brokenChallengeLink(:task)}
// <div class='well'>
// {{#if groups[:task.group.id].challenges[:task.challenge]}}
// <p>Broken Challenge Link: this task was part of a challenge, but has been removed from it. What would you like to do?</p>
// <p>
// <a x-bind="click:challenges.taskUnsubscribe" data-action="keep" data-tid="{{:task.id}}">Keep It</a>&nbsp;|&nbsp;
// <a x-bind="click:challenges.taskUnsubscribe" data-action="remove" data-tid="{{:task.id}}">Remove It</a>
// </p>
// {{else}}
// <p>Broken Challenge Link: this task was part of a challenge, but the challenge (or group) has been deleted. What would you like to do with these poor lil' orphans?</p>
// <p>
// <a x-bind="click:challenges.taskUnsubscribe" data-action="keep-all" data-tid="{{:task.id}}">Keep Them</a>&nbsp;|&nbsp;
// <a x-bind="click:challenges.taskUnsubscribe" data-action="remove-all" data-tid="{{:task.id}}">Remove Them</a>
// </p>
// {{/}}
// </div>
// {/}
form(ng-submit='saveTask(task)')
// text & notes
fieldset.option-group
// {{#unless taskInChallenge(task)}}
label.option-title Text
input.option-content(type='text', ng-model='task.text', required)
// {{/}}
label.option-title Extra Notes
// {{#if taskInChallenge(task)}}
// <textarea class="option-content" rows=3 disabled>{{taskAttrFromChallenge(task,'notes')}}</textarea>
// {{else}}
textarea.option-content(rows='3', ng-model='task.notes')
// {{/}}
// if Habit, plus/minus command options
// {{#unless taskInChallenge(task)}}
fieldset.option-group(ng-if='task.type=="habit"')
legend.option-title Direction/Actions
span.task-checker.action-plusminus.select-toggle
input.visuallyhidden.focusable(id='{{task.id}}-option-plus', type='checkbox', ng-model='task.up')
label(for='{{task.id}}-option-plus')
span.task-checker.action-plusminus.select-toggle
input.visuallyhidden.focusable(id='{{task.id}}-option-minus', type='checkbox', ng-model='task.down')
label(for='{{task.id}}-option-minus')
// {{/}}
// if Daily, calendar
fieldset(ng-if='task.type=="daily"', class="option-group")
legend.option-title Repeat
.task-controls.tile-group.repeat-days
// note, does not use data-toggle="buttons-checkbox" - it would interfere with our own click binding
button.task-action-btn.tile(ng-class='{active: task.repeat.su}', type='button', data-day='su', ng-click='task.repeat.su = !task.repeat.su') Su
button.task-action-btn.tile(ng-class='{active: task.repeat.m}', type='button', data-day='m', ng-click='task.repeat.m = !task.repeat.m') M
button.task-action-btn.tile(ng-class='{active: task.repeat.t}', type='button', data-day='t', ng-click='task.repeat.t = !task.repeat.t') T
button.task-action-btn.tile(ng-class='{active: task.repeat.w}', type='button', data-day='w', ng-click='task.repeat.w = !task.repeat.w') W
button.task-action-btn.tile(ng-class='{active: task.repeat.th}', type='button', data-day='th', ng-click='task.repeat.th = !task.repeat.th') Th
button.task-action-btn.tile(ng-class='{active: task.repeat.f}', type='button', data-day='f', ng-click='task.repeat.f = !task.repeat.f') F
button.task-action-btn.tile(ng-class='{active: task.repeat.s}', type='button', data-day='s', ng-click='task.repeat.s = !task.repeat.s') S
// if Reward, pricing
fieldset.option-group.option-short(ng-if='task.type=="reward"')
legend.option-title Price
input.option-content(type='number', size='16', min='0', step="any", ng-model='task.value')
.money.input-suffix
span.shop_gold
// if Todos, the due date
fieldset.option-group(ng-if='task.type=="todo"')
legend.option-title Due Date
input.option-content.datepicker(type='text', data-date-format='mm/dd/yyyy', ng-model='task.date')
fieldset.option-group
legend.option-title Tags
label.checkbox(ng-repeat='tag in user.tags')
input(type='checkbox', ng-model='task.tags[tag.id]')
| {{tag.name}}
// Advanced Options
span(ng-if='task.type!="reward"')
p.option-title.mega(ng-click='task._advanced = !task._advanced') Advanced Options
fieldset.option-group.advanced-option(ng-class="{visuallyhidden: !task._advanced}")
legend.option-title
a.priority-multiplier-help(href='https://trello.com/card/priority-multiplier/50e5d3684fe3a7266b0036d6/17', target='_blank', popover-title='How difficult is this task?', popover-trigger='mouseenter', popover="This multiplies its point value. Use sparingly, rely instead on our organic value-adjustment algorithms. But some tasks are grossly more valuable (Write Thesis vs Floss Teeth). Click for more info.")
i.icon-question-sign
| Difficulty
// {{#if taskInChallenge(task)}}
// <button disabled type="button" class="task-action-btn tile active">
// {{taskAttrFromChallenge(task,'priority')}}
// </button>
// {{else}}
.task-controls.tile-group.priority-multiplier(data-id='{{task.id}}')
button.task-action-btn.tile(type='button', ng-class='{active: task.priority=="!" || !task.priority}', ng-click='task.priority="!"') Easy
button.task-action-btn.tile(type='button', ng-class='{active: task.priority=="!!"}', ng-click='task.priority="!!"') Medium
button.task-action-btn.tile(type='button', ng-class='{active: task.priority=="!!!"}', ng-click='task.priority="!!!"') Hard
// {{/}}
span(ng-if='task.type=="daily"')
legend.option-title Restore Streak
input.option-content(type='number', ng-model='task.streak')
button.task-action-btn.tile.spacious(type='submit') Save & Close
div(class='{{task.id}}-chart', ng-show='charts[task.id]')