diff --git a/app/javascript/vue/repository_row/manage_stock_value_modal.vue b/app/javascript/vue/repository_row/manage_stock_value_modal.vue
index 9fe4bb9fd..65c435a85 100644
--- a/app/javascript/vue/repository_row/manage_stock_value_modal.vue
+++ b/app/javascript/vue/repository_row/manage_stock_value_modal.vue
@@ -58,7 +58,7 @@
:value="unit"
:options="units"
:placeholder="i18n.t('repository_stock_values.manage_modal.unit_prompt')"
- @change="unit = $event"
+ @change="unit = $event; validateStockValue()"
:className="`${errors.unit ? 'error' : ''}`"
>
@@ -104,27 +104,27 @@
:min="0"
:error="errors.tresholdAmount"
/>
-
+
{{ unitLabel }}
-
-
- comment = event.target.value"
- type="text"
- name="comment"
- id="stock-value-comment"
- :placeholder="i18n.t('repository_stock_values.manage_modal.comment_placeholder')"
- />
-
+ comment = event.target.value"
+ :value="comment"
+ type="text"
+ name="comment"
+ id="stock-value-comment"
+ :label=" i18n.t('repository_stock_values.manage_modal.comment')"
+ :error="errors.comment"
+ :placeholder="i18n.t('repository_stock_values.manage_modal.comment_placeholder')"
+ />
@@ -244,20 +244,25 @@ export default {
},
showModal(stockValueUrl, closeCallback) {
$(this.$refs.modal).modal('show');
+ this.comment = null;
this.fetchStockValueData(stockValueUrl);
this.closeCallback = closeCallback;
},
- validateAndsaveStockValue() {
+ validateStockValue() {
const newErrors = {};
- this.errors = 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;
+ return newErrors;
+ },
- if (!$.isEmptyObject(newErrors)) return;
+ saveStockValue() {
+ this.validateStockValue();
+
+ if (!$.isEmptyObject(this.errors)) return;
this.isSaving = true;
const $this = this;
diff --git a/app/javascript/vue/shared/legacy/input.vue b/app/javascript/vue/shared/legacy/input.vue
index 70ba33a23..cec2344e4 100644
--- a/app/javascript/vue/shared/legacy/input.vue
+++ b/app/javascript/vue/shared/legacy/input.vue
@@ -36,8 +36,8 @@ export default {
required: { type: Boolean, default: false },
label: { type: String, required: false },
error: { type: String, required: false },
- min: { type: String },
- max: { type: String },
+ min: { type: [String, Number] },
+ max: { type: [String, Number] },
blockInvalidInput: { type: Boolean, default: true }
},
data() {
@@ -49,6 +49,9 @@ export default {
watch: {
value() {
this.lastValue = this.value;
+ },
+ error() {
+ this.checkInputError();
}
},
computed: {