challenges: shortcode for tag names & task tooltips

This commit is contained in:
Tyler Renelle
2013-10-31 18:18:34 -07:00
parent 0ce76ee689
commit 58fa97fb19
3 changed files with 17 additions and 6 deletions

View File

@@ -19,19 +19,20 @@ var api = module.exports;
*/
var syncChalToUser = function(chal, user) {
if (!chal || !user) return;
chal.shortName = chal.shortName || chal.name;
// Sync tags
var tags = user.tags || [];
var i = _.findIndex(tags, {id: chal._id})
if (~i) {
if (tags[i].name !== chal.name) {
if (tags[i].name !== chal.shortName) {
// update the name - it's been changed since
user.tags[i].name = chal.name;
user.tags[i].name = chal.shortName;
}
} else {
user.tags.push({
id: chal._id,
name: chal.name,
name: chal.shortName,
challenge: true
});
}

View File

@@ -8,6 +8,7 @@ var Group = require('./group').model;
var ChallengeSchema = new Schema({
_id: {type: String, 'default': helpers.uuid},
name: String,
shortName: String,
description: String,
habits: [TaskSchema],
dailys: [TaskSchema],

View File

@@ -20,6 +20,8 @@ script(type='text/ng-template', id='partials/options.social.challenges.detail.ht
div(ng-show='challenge._locked==false')
.-options
input.option-content(type='text', ng-model='challenge.name')
.option-medium
input.option-content(type='text', minlength="3", maxlength="16", ng-model='challenge.shortName', placeholder='Tag Name', required)
textarea.option-content(cols='3', placeholder='Description', ng-model='challenge.description')
hr
@@ -64,11 +66,18 @@ script(type='text/ng-template', id='partials/options.social.challenges.html')
select(ng-model='newChallenge.group', ng-required='required', name='Group', ng-options='g._id as g.name for g in groups')
.challenge-options
input.option-content(type='text', ng-model='newChallenge.name', placeholder='Challenge Title', required='required')
.challenge-options
.option-medium
input.option-content(type='text', minlength="3", maxlength="16", ng-model='newChallenge.shortName', placeholder='Tag Name', required)
i.icon-question-sign(popover="Challenges appear on tag-lists & task-tooltips. So while you'll want a descriptive title above, you'll also need a 'short name'. Eg, 'Lose 10 pounds in 3 months' might become '-10lb'", popover-trigger='mouseenter', popover-placement='right')
textarea.option-content(cols='3', placeholder='Description', ng-model='newChallenge.description')
.challenge-options
.option-group.option-medium
//- what's going on here?
br
br
.option-medium
input.option-content(type='number', min="0", max="{{maxPrize}}", ng-model='newChallenge.prize', placeholder='Prize')
span.input-suffix.Pet_Currency_Gem1x.inline-gems
i.icon-question-sign(popover="If someone can 'win' your challenge, you can optionally award that winner a Gem prize. Max = #gems you own (+ guild.gems, if you created this challenge's guild). Note: This prize can't be changed later.", popover-trigger='mouseenter', popover-placement='right')