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:
Vincent Vandemeulebrouck
2021-03-07 01:25:36 +01:00
parent b4c1dc1222
commit a86a786111
73 changed files with 571 additions and 638 deletions

View File

@@ -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)];
}
}