fix(database/formula-field): when formula's field caculate result is 0 it alse will be save (#962)
This commit is contained in:
parent
8905e3c211
commit
9ff14d9d5c
@ -40,7 +40,7 @@ export class FormulaField extends Field {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
caculateField = async (instance) => {
|
caculateField = async (instance) => {
|
||||||
const { expression, name } = this.options;
|
const { expression, name } = this.options;
|
||||||
@ -50,10 +50,10 @@ export class FormulaField extends Field {
|
|||||||
result = math.evaluate(expression, scope);
|
result = math.evaluate(expression, scope);
|
||||||
result = math.round(result, 9);
|
result = math.round(result, 9);
|
||||||
} catch {}
|
} catch {}
|
||||||
if (result) {
|
if (result === 0 || result) {
|
||||||
instance.set(name, result);
|
instance.set(name, result);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
updateFieldData = async (instance, { transaction }) => {
|
updateFieldData = async (instance, { transaction }) => {
|
||||||
if (this.collection.name === instance.collectionName && instance.name === this.options.name) {
|
if (this.collection.name === instance.collectionName && instance.name === this.options.name) {
|
||||||
@ -80,7 +80,7 @@ export class FormulaField extends Field {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
bind() {
|
bind() {
|
||||||
super.bind();
|
super.bind();
|
||||||
|
Loading…
Reference in New Issue
Block a user