refactor(thermograph): empty fields handler added and correct usage of thermograph.code
This commit is contained in:
parent
909fb368ce
commit
e3942c0bb9
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue