Bug #124 address observations validations
This commit is contained in:
parent
0bf4e292a1
commit
78f893b811
|
@ -61,29 +61,36 @@
|
||||||
<tpl-item>{{$parent.$parent.item.description}}</tpl-item>
|
<tpl-item>{{$parent.$parent.item.description}}</tpl-item>
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
<vn-textfield
|
<vn-textfield
|
||||||
vn-auto
|
vn-two
|
||||||
|
margin-large-right
|
||||||
label="Description"
|
label="Description"
|
||||||
model="observation.description"
|
model="observation.description"
|
||||||
rule="addressObservation.description">
|
rule="addressObservation.description">
|
||||||
</vn-textfield>
|
</vn-textfield>
|
||||||
<vn-one pad-medium-top>
|
<vn-auto pad-medium-top>
|
||||||
<vn-icon
|
<vn-icon
|
||||||
pointer
|
pointer
|
||||||
medium-grey
|
medium-grey
|
||||||
|
vn-tooltip="Remove note"
|
||||||
|
tooltip-position = "left"
|
||||||
icon="remove_circle_outline"
|
icon="remove_circle_outline"
|
||||||
ng-click="$ctrl.removeObservation($index)">
|
ng-click="$ctrl.removeObservation($index)">
|
||||||
</vn-icon>
|
</vn-icon>
|
||||||
<vn-icon
|
|
||||||
pointer
|
|
||||||
margin-medium-left
|
|
||||||
orange
|
|
||||||
icon="add_circle"
|
|
||||||
ng-if="observation.showAddIcon && observationsTypes.model.length > $ctrl.observations.length"
|
|
||||||
ng-click="$ctrl.addObservation()">
|
|
||||||
</vn-icon>
|
|
||||||
</vn-one>
|
</vn-one>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
</vn-one>
|
</vn-one>
|
||||||
|
<vn-one>
|
||||||
|
<vn-icon
|
||||||
|
pointer
|
||||||
|
margin-medium-left
|
||||||
|
vn-tooltip="Add note"
|
||||||
|
tooltip-position = "right"
|
||||||
|
orange
|
||||||
|
icon="add_circle"
|
||||||
|
ng-if="observationsTypes.model.length > $ctrl.observations.length"
|
||||||
|
ng-click="$ctrl.addObservation()">
|
||||||
|
</vn-icon>
|
||||||
|
</vn-one>
|
||||||
</vn-card>
|
</vn-card>
|
||||||
<vn-button-bar>
|
<vn-button-bar>
|
||||||
<vn-submit label="Save"></vn-submit>
|
<vn-submit label="Save"></vn-submit>
|
||||||
|
|
|
@ -17,18 +17,6 @@ export default class Controller {
|
||||||
this.observationsRemoved = [];
|
this.observationsRemoved = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
_setIconAdd() {
|
|
||||||
if (this.observations.length) {
|
|
||||||
this.observations.map(element => {
|
|
||||||
element.showAddIcon = false;
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
this.observations[this.observations.length - 1].showAddIcon = true;
|
|
||||||
} else {
|
|
||||||
this.addObservation();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_setDirtyForm() {
|
_setDirtyForm() {
|
||||||
if (this.$scope.form) {
|
if (this.$scope.form) {
|
||||||
this.$scope.form.$setDirty();
|
this.$scope.form.$setDirty();
|
||||||
|
@ -41,15 +29,13 @@ export default class Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
addObservation() {
|
addObservation() {
|
||||||
this.observations.push({observationTypeFk: null, addressFk: this.address.id, description: null, showAddIcon: true});
|
this.observations.push({observationTypeFk: null, addressFk: this.address.id, description: null});
|
||||||
this._setIconAdd();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
removeObservation(index) {
|
removeObservation(index) {
|
||||||
let item = this.observations[index];
|
let item = this.observations[index];
|
||||||
if (item) {
|
if (item) {
|
||||||
this.observations.splice(index, 1);
|
this.observations.splice(index, 1);
|
||||||
this._setIconAdd();
|
|
||||||
if (item.id) {
|
if (item.id) {
|
||||||
this.observationsRemoved.push(item.id);
|
this.observationsRemoved.push(item.id);
|
||||||
this._setDirtyForm();
|
this._setDirtyForm();
|
||||||
|
@ -65,7 +51,10 @@ export default class Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
submit() {
|
submit() {
|
||||||
this._unsetDirtyForm();
|
if (this.$scope.form.$invalid) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
let canWatcherSubmit = this.$scope.watcher.dataChanged();
|
let canWatcherSubmit = this.$scope.watcher.dataChanged();
|
||||||
let canObservationsSubmit;
|
let canObservationsSubmit;
|
||||||
let repeatedTypes = false;
|
let repeatedTypes = false;
|
||||||
|
@ -118,6 +107,7 @@ export default class Controller {
|
||||||
this.$translate.instant('No changes to save')
|
this.$translate.instant('No changes to save')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
this._unsetDirtyForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
$onInit() {
|
$onInit() {
|
||||||
|
|
|
@ -3,3 +3,5 @@ Is equalizated: Recargo de equivalencia
|
||||||
Observation type: Tipo de observación
|
Observation type: Tipo de observación
|
||||||
Description: Descripción
|
Description: Descripción
|
||||||
The observation type must be unique: El tipo de observación ha de ser único
|
The observation type must be unique: El tipo de observación ha de ser único
|
||||||
|
Add note: Añadir nota
|
||||||
|
Remove note: Quitar nota
|
Loading…
Reference in New Issue