mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
challenges: shortcode for tag names & task tooltips
This commit is contained in:
@@ -19,19 +19,20 @@ var api = module.exports;
|
|||||||
*/
|
*/
|
||||||
var syncChalToUser = function(chal, user) {
|
var syncChalToUser = function(chal, user) {
|
||||||
if (!chal || !user) return;
|
if (!chal || !user) return;
|
||||||
|
chal.shortName = chal.shortName || chal.name;
|
||||||
|
|
||||||
// Sync tags
|
// Sync tags
|
||||||
var tags = user.tags || [];
|
var tags = user.tags || [];
|
||||||
var i = _.findIndex(tags, {id: chal._id})
|
var i = _.findIndex(tags, {id: chal._id})
|
||||||
if (~i) {
|
if (~i) {
|
||||||
if (tags[i].name !== chal.name) {
|
if (tags[i].name !== chal.shortName) {
|
||||||
// update the name - it's been changed since
|
// update the name - it's been changed since
|
||||||
user.tags[i].name = chal.name;
|
user.tags[i].name = chal.shortName;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
user.tags.push({
|
user.tags.push({
|
||||||
id: chal._id,
|
id: chal._id,
|
||||||
name: chal.name,
|
name: chal.shortName,
|
||||||
challenge: true
|
challenge: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ var Group = require('./group').model;
|
|||||||
var ChallengeSchema = new Schema({
|
var ChallengeSchema = new Schema({
|
||||||
_id: {type: String, 'default': helpers.uuid},
|
_id: {type: String, 'default': helpers.uuid},
|
||||||
name: String,
|
name: String,
|
||||||
|
shortName: String,
|
||||||
description: String,
|
description: String,
|
||||||
habits: [TaskSchema],
|
habits: [TaskSchema],
|
||||||
dailys: [TaskSchema],
|
dailys: [TaskSchema],
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ script(type='text/ng-template', id='partials/options.social.challenges.detail.ht
|
|||||||
div(ng-show='challenge._locked==false')
|
div(ng-show='challenge._locked==false')
|
||||||
.-options
|
.-options
|
||||||
input.option-content(type='text', ng-model='challenge.name')
|
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')
|
textarea.option-content(cols='3', placeholder='Description', ng-model='challenge.description')
|
||||||
hr
|
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')
|
select(ng-model='newChallenge.group', ng-required='required', name='Group', ng-options='g._id as g.name for g in groups')
|
||||||
.challenge-options
|
.challenge-options
|
||||||
input.option-content(type='text', ng-model='newChallenge.name', placeholder='Challenge Title', required='required')
|
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')
|
textarea.option-content(cols='3', placeholder='Description', ng-model='newChallenge.description')
|
||||||
|
|
||||||
.challenge-options
|
//- what's going on here?
|
||||||
.option-group.option-medium
|
br
|
||||||
|
br
|
||||||
|
|
||||||
|
.option-medium
|
||||||
input.option-content(type='number', min="0", max="{{maxPrize}}", ng-model='newChallenge.prize', placeholder='Prize')
|
input.option-content(type='number', min="0", max="{{maxPrize}}", ng-model='newChallenge.prize', placeholder='Prize')
|
||||||
span.input-suffix.Pet_Currency_Gem1x.inline-gems
|
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')
|
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')
|
||||||
|
|||||||
Reference in New Issue
Block a user