mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-16 06:06:56 +08:00
Merge pull request #7425 from G-Chubinidze/gc_SCI_10533
Enable adding negative numbers for Stock [SCI-10533]
This commit is contained in:
commit
6f66abb3e2
2 changed files with 10 additions and 2 deletions
|
@ -46,6 +46,7 @@
|
|||
:label="i18n.t('repository_stock_values.manage_modal.amount')"
|
||||
:required="true"
|
||||
:min="0"
|
||||
:negativeNumbersEnabled="this.operation == 'set'"
|
||||
:error="errors.amount"
|
||||
/>
|
||||
</div>
|
||||
|
@ -252,7 +253,6 @@ export default {
|
|||
const newErrors = {};
|
||||
if (!this.unit) { newErrors.unit = I18n.t('repository_stock_values.manage_modal.unit_error'); }
|
||||
if (!this.amount) { newErrors.amount = I18n.t('repository_stock_values.manage_modal.amount_error'); }
|
||||
if (this.amount && this.amount < 0) { newErrors.amount = I18n.t('repository_stock_values.manage_modal.negative_error'); }
|
||||
if (this.reminderEnabled && !this.lowStockTreshold) { newErrors.tresholdAmount = I18n.t('repository_stock_values.manage_modal.amount_error'); }
|
||||
if (this.comment && this.comment.length > 255) { newErrors.comment = I18n.t('repository_stock_values.manage_modal.comment_limit'); }
|
||||
this.errors = newErrors;
|
||||
|
|
|
@ -38,7 +38,8 @@ export default {
|
|||
error: { type: String, required: false },
|
||||
min: { type: [String, Number] },
|
||||
max: { type: [String, Number] },
|
||||
blockInvalidInput: { type: Boolean, default: true }
|
||||
blockInvalidInput: { type: Boolean, default: true },
|
||||
negativeNumbersEnabled: {type: Boolean, required: false }
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
@ -56,6 +57,13 @@ export default {
|
|||
},
|
||||
computed: {
|
||||
pattern() {
|
||||
if (this.negativeNumbersEnabled) {
|
||||
if (this.type === 'number' && this.decimals) {
|
||||
return `-?[0-9]+([\\.]-?[0-9]{0,${this.decimals}})?`;
|
||||
} else if (this.type === 'number') {
|
||||
return '-?[0-9]+';
|
||||
}
|
||||
}
|
||||
if (this.type === 'number' && this.decimals) {
|
||||
return `[0-9]+([\\.][0-9]{0,${this.decimals}})?`;
|
||||
} else if (this.type === 'number') {
|
||||
|
|
Loading…
Reference in a new issue