shared-code-tags-gold-silver (#7056)
This commit is contained in:
committed by
Matteo Pagliazzi
parent
a29dd1a1c7
commit
2f1329254e
@@ -1,21 +1,14 @@
|
||||
import _ from 'lodash';
|
||||
|
||||
/*
|
||||
Are there tags applied?
|
||||
*/
|
||||
|
||||
// TODO move to client
|
||||
|
||||
module.exports = function(userTags, taskTags) {
|
||||
var arr;
|
||||
arr = [];
|
||||
_.each(userTags, function(t) {
|
||||
if (t == null) {
|
||||
return;
|
||||
}
|
||||
if (taskTags != null ? taskTags[t.id] : void 0) {
|
||||
return arr.push(t.name);
|
||||
}
|
||||
module.exports = function appliedTags (userTags, taskTags = {}) {
|
||||
let arr = userTags.filter(tag => {
|
||||
return taskTags[tag.id];
|
||||
}).map(tag => {
|
||||
return tag.name;
|
||||
});
|
||||
return arr.join(', ');
|
||||
};
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// TODO move to client
|
||||
|
||||
module.exports = function(num) {
|
||||
module.exports = function gold (num) {
|
||||
if (num) {
|
||||
return Math.floor(num);
|
||||
} else {
|
||||
return "0";
|
||||
return '0';
|
||||
}
|
||||
};
|
||||
|
||||
@@ -6,8 +6,8 @@ are any tags active?
|
||||
|
||||
// TODO move to client
|
||||
|
||||
module.exports = function(tags) {
|
||||
return _.isEmpty(tags) || _.isEmpty(_.filter(tags, function(t) {
|
||||
module.exports = function noTags (tags) {
|
||||
return _.isEmpty(tags) || _.isEmpty(_.filter(tags, (t) => {
|
||||
return t;
|
||||
}));
|
||||
};
|
||||
|
||||
@@ -4,10 +4,11 @@ Silver amount from their money
|
||||
|
||||
// TODO move to client
|
||||
|
||||
module.exports = function(num) {
|
||||
module.exports = function silver (num) {
|
||||
if (num) {
|
||||
return ("0" + Math.floor((num - Math.floor(num)) * 100)).slice(-2);
|
||||
let centCount = Math.floor((num - Math.floor(num)) * 100);
|
||||
return `0${centCount}`.slice(-2);
|
||||
} else {
|
||||
return "00";
|
||||
return '00';
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user