Nombreux fixes
* Utilisation de EmbeddedDocuments * utiliser data seulement dans le chemin d'update * utiliser class au lieu de id dans le html * si possible, update de la valuer au lieu d'un duplicate du noeud
This commit is contained in:
@@ -6,26 +6,24 @@
|
||||
export class Misc {
|
||||
static isFunction(v) {
|
||||
return v && {}.toString.call(v) === '[object Function]';
|
||||
}
|
||||
}
|
||||
|
||||
static upperFirst(text) {
|
||||
return text.charAt(0).toUpperCase() + text.slice(1);
|
||||
}
|
||||
|
||||
static toSignedString(number){
|
||||
static toSignedString(number) {
|
||||
const value = parseInt(number)
|
||||
const isPositiveNumber = value != NaN && value > 0;
|
||||
return isPositiveNumber ? "+"+number : number
|
||||
return isPositiveNumber ? "+" + number : number
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the value to an integer, or to 0 if undefined/null/not representing integer
|
||||
* @param {*} value value to convert to an integer using parseInt
|
||||
*/
|
||||
static toInt(value)
|
||||
{
|
||||
if (value == undefined)
|
||||
{
|
||||
static toInt(value) {
|
||||
if (value == undefined) {
|
||||
return 0;
|
||||
}
|
||||
const parsed = parseInt(value);
|
||||
@@ -41,13 +39,13 @@ export class Misc {
|
||||
}
|
||||
}
|
||||
|
||||
static classify(items, classifier = it => it.type, transform = it => it) {
|
||||
static classify(items, classifier = item => item.type, transform = it => it) {
|
||||
let itemsBy = {};
|
||||
Misc.classifyInto(itemsBy, items, classifier, transform);
|
||||
return itemsBy;
|
||||
}
|
||||
|
||||
static classifyInto(itemsBy, items, classifier = it => it.type, transform = it => it) {
|
||||
static classifyInto(itemsBy, items, classifier = item => item.type, transform = it => it) {
|
||||
for (const item of items) {
|
||||
const classification = classifier(item);
|
||||
let list = itemsBy[classification];
|
||||
@@ -66,5 +64,4 @@ export class Misc {
|
||||
static distinct(array) {
|
||||
return [...new Set(array)];
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user