refactor(thermograph): empty fields handler added and correct usage of thermograph.code

This commit is contained in:
Carlos Jimenez Ruiz 2021-10-19 10:58:58 +02:00
parent 909fb368ce
commit e3942c0bb9
2 changed files with 13 additions and 3 deletions

View File

@ -2232,8 +2232,8 @@ INSERT IGNORE INTO `vn`.`greugeConfig` (`id`, `freightPickUpPrice`) VALUES ('1',
INSERT INTO `vn`.`temperature`(`code`, `name`, `description`)
VALUES
('WARM', 'Warm', 'Warm'),
('COOL', 'Cool', 'Cool');
('warm', 'Warm', 'Warm'),
('cool', 'Cool', 'Cool');
INSERT INTO `vn`.`thermograph`(`id`, `model`)
VALUES

View File

@ -1,5 +1,6 @@
import ngModule from '../../module';
import Section from 'salix/components/section';
import UserError from 'core/lib/user-error';
class Controller extends Section {
constructor($element, $) {
@ -56,7 +57,7 @@ class Controller extends Section {
}
onAddThermographClick(event) {
const defaultTemperature = 'COOL';
const defaultTemperature = 'cool';
const defaultModel = 'DISPOSABLE';
event.preventDefault();
@ -72,6 +73,15 @@ class Controller extends Section {
}
onNewThermographAccept() {
const hasMissingField =
!this.newThermograph.thermographId ||
!this.newThermograph.warehouseId ||
!this.newThermograph.temperatureFk ||
!this.newThermograph.model;
if (hasMissingField)
throw new UserError(`Some fields are invalid`);
return this.$http.post(`Thermographs/createThermograph`, this.newThermograph)
.then(res => this.dms.thermographId = res.data.id);
}