Fix issue add/removing stock [SCI-9966] (#6909)

This commit is contained in:
wandji 2024-01-09 09:33:14 +01:00 committed by GitHub
parent fa29c99e4a
commit a201c96aef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 23 deletions

View file

@ -57,7 +57,7 @@
{{ i18n.t('repository_stock_values.manage_modal.unit') }}
</label>
<Select
:disabled="[2, 3].includes(operation)"
:disabled="['add', 'remove'].includes(operation)"
:value="unit"
:options="units"
:placeholder="i18n.t('repository_stock_values.manage_modal.unit_prompt')"
@ -180,10 +180,10 @@ export default {
const amount = new Decimal(this.amount || 0);
let value;
switch (this.operation) {
case 2:
case 'add':
value = currentAmount.plus(amount);
break;
case 3:
case 'remove':
value = currentAmount.minus(amount);
break;
default:
@ -213,7 +213,7 @@ export default {
this.amount = null;
}
this.operation = $event;
if ([2, 3].includes($event)) {
if (['add', 'remove'].includes($event)) {
this.unit = this.stockValue.unit;
}
},
@ -231,22 +231,15 @@ export default {
this.unit = result.stock_value.unit;
this.reminderEnabled = result.stock_value.reminder_enabled;
this.lowStockTreshold = result.stock_value.low_stock_treshold;
this.operation = `${I18n.t('repository_stock_values.manage_modal.values.set')}`;
this.operation = 'set';
this.stockUrl = result.stock_url;
/* eslint-disable no-undef */
this.operations = [
[
`${I18n.t('repository_stock_values.manage_modal.values.set')}`,
`${I18n.t('repository_stock_values.manage_modal.set')}`
],
[
`${I18n.t('repository_stock_values.manage_modal.values.add')}`,
`${I18n.t('repository_stock_values.manage_modal.add')}`
],
[
`${I18n.t('repository_stock_values.manage_modal.values.remove')}`,
`${I18n.t('repository_stock_values.manage_modal.remove')}`
]
['set', `${I18n.t('repository_stock_values.manage_modal.set')}`],
['add', `${I18n.t('repository_stock_values.manage_modal.add')}`],
['remove', `${I18n.t('repository_stock_values.manage_modal.remove')}`]
];
/* eslint-enable no-undef */
this.errors = {};
}
});
@ -287,8 +280,6 @@ export default {
change_amount: Math.abs(this.amount)
},
operator: this.operations.find((operation) => operation[0] == this.operation)?.[1],
change_amount: Math.abs(this.amount),
success: (result) => {
$this.stockValue = null;
$this.closeModal();

View file

@ -2361,10 +2361,6 @@ en:
add: "Add"
remove: "Remove"
set: "Set to"
values:
add: "add"
set: "set"
remove: "remove"
amount: "Amount"
amount_placeholder: "Enter amount"
amount_placeholder_new: "100, 2000, ..."