#738 Petición de guardado al hacer click sobre un botón + test adaptados
This commit is contained in:
parent
6773e58cad
commit
0601bb662c
|
@ -102,6 +102,6 @@
|
|||
</vn-card>
|
||||
<vn-button-bar>
|
||||
<vn-submit label="Save"></vn-submit>
|
||||
<vn-button ng-click="$ctrl.cancel($event)" label="Cancel"></vn-button>
|
||||
<vn-button ng-click="$ctrl.cancel()" label="Cancel"></vn-button>
|
||||
</vn-button-bar>
|
||||
</form>
|
||||
|
|
|
@ -12,9 +12,7 @@ export default class Controller {
|
|||
this.$.model.remove(index);
|
||||
}
|
||||
|
||||
cancel(event) {
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
cancel() {
|
||||
this.goToIndex();
|
||||
}
|
||||
|
||||
|
|
|
@ -45,19 +45,11 @@ describe('Client', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('cancel(event)', () => {
|
||||
it('should call event.preventDefault(), event.stopImmediatePropagation() and goToIndex', () => {
|
||||
let event = {
|
||||
preventDefault: () => {},
|
||||
stopImmediatePropagation: () => {}
|
||||
};
|
||||
spyOn(event, 'preventDefault');
|
||||
spyOn(event, 'stopImmediatePropagation');
|
||||
describe('cancel()', () => {
|
||||
it('should call goToIndex()', () => {
|
||||
spyOn(controller, 'goToIndex');
|
||||
controller.cancel(event);
|
||||
controller.cancel();
|
||||
|
||||
expect(event.preventDefault).toHaveBeenCalledWith();
|
||||
expect(event.stopImmediatePropagation).toHaveBeenCalledWith();
|
||||
expect(controller.goToIndex).toHaveBeenCalledWith();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
</vn-card>
|
||||
<vn-button-bar>
|
||||
<vn-submit label="Save"></vn-submit>
|
||||
<vn-button ng-click="$ctrl.cancel($event)" label="Cancel"></vn-button>
|
||||
<vn-button ng-click="$ctrl.cancel()" label="Cancel"></vn-button>
|
||||
</vn-button-bar>
|
||||
</form>
|
||||
<vn-confirm
|
||||
|
|
|
@ -17,9 +17,7 @@ class Controller {
|
|||
});
|
||||
}
|
||||
|
||||
cancel(event) {
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
cancel() {
|
||||
this.goToIndex();
|
||||
}
|
||||
|
||||
|
|
|
@ -68,19 +68,11 @@ describe('Client', () => {
|
|||
});
|
||||
|
||||
describe('cancel()', () => {
|
||||
it('should call preventDefault, stopImmediatePropagation and goToIndex', () => {
|
||||
let event = {
|
||||
preventDefault: () => {},
|
||||
stopImmediatePropagation: () => {}
|
||||
};
|
||||
spyOn(event, 'preventDefault');
|
||||
spyOn(event, 'stopImmediatePropagation');
|
||||
it('should call goToIndex()', () => {
|
||||
spyOn(controller, 'goToIndex');
|
||||
controller.cancel(event);
|
||||
controller.cancel();
|
||||
|
||||
expect(controller.goToIndex).toHaveBeenCalledWith();
|
||||
expect(event.preventDefault).toHaveBeenCalledWith();
|
||||
expect(event.stopImmediatePropagation).toHaveBeenCalledWith();
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -40,6 +40,6 @@
|
|||
</vn-card>
|
||||
<vn-button-bar>
|
||||
<vn-submit label="Save"></vn-submit>
|
||||
<vn-button ng-click="$ctrl.cancel($event)" label="Cancel"></vn-button>
|
||||
<vn-button ng-click="$ctrl.cancel()" label="Cancel"></vn-button>
|
||||
</vn-button-bar>
|
||||
</form>
|
|
@ -9,9 +9,7 @@ class Controller {
|
|||
};
|
||||
}
|
||||
|
||||
cancel(event) {
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
cancel() {
|
||||
this.goToIndex();
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,6 @@
|
|||
</vn-card>
|
||||
<vn-button-bar>
|
||||
<vn-submit label="Save"></vn-submit>
|
||||
<vn-button ng-click="$ctrl.cancel($event)" label="Cancel"></vn-button>
|
||||
<vn-button ng-click="$ctrl.cancel()" label="Cancel"></vn-button>
|
||||
</vn-button-bar>
|
||||
</form>
|
|
@ -9,9 +9,7 @@ export default class Controller {
|
|||
};
|
||||
}
|
||||
|
||||
cancel(event) {
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
cancel() {
|
||||
this.$state.go('client.card.note.index', {id: this.$state.params.id});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,6 @@
|
|||
</vn-card>
|
||||
<vn-button-bar>
|
||||
<vn-submit label="Save"></vn-submit>
|
||||
<vn-button ng-click="$ctrl.cancel($event)" label="Cancel"></vn-button>
|
||||
<vn-button ng-click="$ctrl.cancel()" label="Cancel"></vn-button>
|
||||
</vn-button-bar>
|
||||
</form>
|
||||
|
|
|
@ -9,9 +9,7 @@ class Controller {
|
|||
};
|
||||
}
|
||||
|
||||
cancel(event) {
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
cancel() {
|
||||
this.goToIndex();
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
</vn-card>
|
||||
<vn-button-bar>
|
||||
<vn-submit label="Send"></vn-submit>
|
||||
<vn-button label="Preview" ng-click="$ctrl.showPreview($event)"></vn-button>
|
||||
<vn-button label="Preview" ng-click="$ctrl.showPreview()"></vn-button>
|
||||
<vn-button ui-sref="client.card.sample.index" label="Cancel"></vn-button>
|
||||
</vn-button-bar>
|
||||
</form>
|
||||
|
|
|
@ -14,9 +14,7 @@ class Controller {
|
|||
};
|
||||
}
|
||||
|
||||
showPreview(event) {
|
||||
event.preventDefault();
|
||||
|
||||
showPreview() {
|
||||
let sampleType = this.$scope.sampleType.selection;
|
||||
let queryParams;
|
||||
|
||||
|
|
|
@ -13,6 +13,12 @@ export default class Button extends Input {
|
|||
event.stopImmediatePropagation();
|
||||
});
|
||||
}
|
||||
|
||||
$onInit() {
|
||||
if (!this.type) {
|
||||
this.type = 'button';
|
||||
}
|
||||
}
|
||||
}
|
||||
Button.$inject = ['$element'];
|
||||
|
||||
|
@ -22,7 +28,8 @@ ngModule.component('vnButton', {
|
|||
bindings: {
|
||||
label: '@?',
|
||||
disabled: '<?',
|
||||
icon: '@?'
|
||||
icon: '@?',
|
||||
type: '@?'
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue