removed on response if just accept
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Carlos Jimenez Ruiz 2020-07-29 10:47:48 +02:00
parent e126350079
commit e2481366a2
25 changed files with 121 additions and 140 deletions

View File

@ -60,7 +60,7 @@
</vn-float-button>
<vn-confirm
vn-id="close-contract"
on-response="$ctrl.returnDialog($response)"
on-accept="$ctrl.returnDialog()"
question="Close contract"
message="Are you sure you want to close this contract?">
</vn-confirm>

View File

@ -51,14 +51,12 @@ class Controller extends Section {
this.$.closeContract.show();
}
returnDialog(response) {
if (response === 'accept') {
returnDialog() {
let params = {finished: Date.now()};
this.$http.patch(`CreditClassifications/${this.classificationId}`, params).then(() => {
this._getClassifications(this.client.id);
});
}
}
}
ngModule.vnComponent('vnClientCreditInsuranceIndex', {

View File

@ -78,7 +78,7 @@ describe('Client', () => {
jest.spyOn(controller, '_getClassifications').mockReturnThis();
controller.classificationId = 1;
$httpBackend.expect('PATCH', `CreditClassifications/1`).respond(200);
controller.returnDialog('accept');
controller.returnDialog();
$httpBackend.flush();
expect(controller._getClassifications).toHaveBeenCalledWith(101);

View File

@ -1,6 +1,6 @@
<vn-dialog
vn-id="SMSDialog"
on-response="$ctrl.onResponse($response)">
on-accept="$ctrl.onResponse()">
<tpl-body>
<section class="SMSDialog">
<h5 class="vn-py-sm" translate>Send SMS</h5>

View File

@ -16,8 +16,7 @@ class Controller extends Section {
return maxLength - textAreaLength;
}
onResponse(response) {
if (response === 'accept') {
onResponse() {
try {
if (!this.sms.destination)
throw new Error(`The destination can't be empty`);
@ -35,7 +34,6 @@ class Controller extends Section {
this.vnApp.showError(this.$t(e.message));
return false;
}
}
return true;
}
}

View File

@ -30,7 +30,7 @@ describe('Client', () => {
jest.spyOn(controller.vnApp, 'showMessage');
$httpBackend.expect('POST', `Clients/101/sendSms`, params).respond(200, params);
controller.onResponse('accept');
controller.onResponse();
$httpBackend.flush();
expect(controller.vnApp.showMessage).toHaveBeenCalledWith('SMS sent!');

View File

@ -34,7 +34,7 @@
<vn-dialog
vn-id="change-pass"
on-open="$ctrl.onPassOpen()"
on-response="$ctrl.onPassChange($response)">
on-accept="$ctrl.onPassChange()">
<tpl-body>
<vn-textfield
type="password"

View File

@ -38,8 +38,7 @@ export default class Controller extends Section {
this.$.$apply();
}
onPassChange(response) {
if (response == 'accept') {
onPassChange() {
try {
if (!this.newPassword)
throw new Error(`You must enter a new password`);
@ -57,7 +56,6 @@ export default class Controller extends Section {
return false;
}
}
return true;
}

View File

@ -83,7 +83,7 @@ describe('Component VnClientWebAccess', () => {
controller.repeatPassword = 'm24x8';
controller.canChangePassword = true;
$httpBackend.expectPATCH('Accounts/1234', {password: 'm24x8'}).respond('done');
controller.onPassChange('accept');
controller.onPassChange();
$httpBackend.flush();
});
@ -92,7 +92,7 @@ describe('Component VnClientWebAccess', () => {
controller.client = {id: '1234'};
controller.newPassword = '';
controller.canChangePassword = true;
controller.onPassChange('accept');
controller.onPassChange();
expect(vnApp.showError).toHaveBeenCalledWith(`You must enter a new password`);
});
@ -104,7 +104,7 @@ describe('Component VnClientWebAccess', () => {
controller.newPassword = 'm24x8';
controller.canChangePassword = true;
controller.repeatPassword = 'notMatchingPassword';
controller.onPassChange('accept');
controller.onPassChange();
expect(vnApp.showError).toHaveBeenCalledWith(`Passwords don't match`);
});

View File

@ -108,7 +108,7 @@
<vn-confirm
vn-id="confirm"
question="Delete ticket from route?"
on-response="$ctrl.removeTicketFromRoute($response)">
on-accept="$ctrl.removeTicketFromRoute()">
</vn-confirm>
<vn-crud-model
vn-id="possibleTicketsModel"
@ -118,7 +118,7 @@
</vn-crud-model>
<vn-dialog
vn-id="possibleTicketsDialog"
on-response="$ctrl.setTicketsRoute($response)"
on-accept="$ctrl.setTicketsRoute()"
message="Tickets to add">
<tpl-body>
<vn-data-viewer class="vn-pa-md" model="possibleTicketsModel">

View File

@ -101,8 +101,7 @@ class Controller extends Section {
this.$.confirm.show();
}
removeTicketFromRoute(response) {
if (response === 'accept') {
removeTicketFromRoute() {
let params = {routeFk: null};
let query = `Tickets/${this.selectedTicket}/`;
this.$http.patch(query, params).then(() => {
@ -110,7 +109,6 @@ class Controller extends Section {
this.updateVolume();
});
}
}
updateVolume() {
let url = `Routes/${this.$params.id}/updateVolume`;
@ -133,10 +131,9 @@ class Controller extends Section {
this.$.possibleTicketsDialog.show();
}
setTicketsRoute(response) {
if (response === 'accept') {
setTicketsRoute() {
let tickets = this.getSelectedItems(this.possibleTickets);
if (tickets.length === 0) return;
for (let i = 0; i < tickets.length; i++) {
delete tickets[i].checked;
tickets[i].routeFk = this.route.id;
@ -146,8 +143,6 @@ class Controller extends Section {
this.$.model.data = this.$.model.data.concat(tickets);
});
}
return Promise.resolve();
}
onDrop($event) {
const ticketId = $event.dataTransfer.getData('Text');

View File

@ -170,7 +170,7 @@ describe('Route', () => {
controller.selectedTicket = ticketId;
$httpBackend.expectPATCH(`Tickets/${ticketId}/`).respond('ok');
controller.removeTicketFromRoute('accept');
controller.removeTicketFromRoute();
$httpBackend.flush();
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Ticket removed from route');
@ -250,15 +250,11 @@ describe('Route', () => {
{id: 5, routeFk: 111}
];
controller.setTicketsRoute('accept').then(() => {
controller.setTicketsRoute().then(() => {
expect(controller.$.model.data).toEqual(expectedResult);
done();
}).catch(done.fail);
});
it('should just return a promise', () => {
expect(controller.setTicketsRoute('cancel')).toEqual(jasmine.any(Promise));
});
});
describe('onDrop()', () => {

View File

@ -384,14 +384,14 @@
vn-id="delete-lines"
question="You are going to delete lines of the ticket"
message="Continue anyway?"
on-response="$ctrl.removeSales()">
on-accept="$ctrl.removeSales()">
</vn-confirm>
<vn-confirm
vn-id="delete-ticket"
question="Do you want to delete it?"
message="This ticket is now empty"
on-response="$ctrl.transferSales($ctrl.transfer.ticketId, $response)">
on-accept="$ctrl.transferSales($ctrl.transfer.ticketId)">
</vn-confirm>
<vn-menu vn-id="moreOptions">

View File

@ -1,6 +1,6 @@
<vn-dialog
vn-id="SMSDialog"
on-response="$ctrl.onResponse($response)"
on-accept="$ctrl.onResponse()"
message="Send SMS">
<tpl-body>
<section class="SMSDialog">

View File

@ -16,8 +16,7 @@ class Controller extends Component {
return maxLength - textAreaLength;
}
onResponse(response) {
if (response === 'accept') {
onResponse() {
try {
if (!this.sms.destination)
throw new Error(`The destination can't be empty`);
@ -35,7 +34,6 @@ class Controller extends Component {
this.vnApp.showError(this.$t(e.message));
return false;
}
}
return true;
}
}

View File

@ -28,7 +28,7 @@ describe('Ticket', () => {
jest.spyOn(controller.vnApp, 'showMessage');
$httpBackend.expect('POST', `Tickets/11/sendSms`, params).respond(200, params);
controller.onResponse('accept');
controller.onResponse();
$httpBackend.flush();
expect(controller.vnApp.showMessage).toHaveBeenCalledWith('SMS sent!');
@ -39,7 +39,7 @@ describe('Ticket', () => {
jest.spyOn(controller.vnApp, 'showError');
controller.onResponse('accept');
controller.onResponse();
expect(controller.vnApp.showError).toHaveBeenCalledWith(`The destination can't be empty`);
});
@ -49,7 +49,7 @@ describe('Ticket', () => {
jest.spyOn(controller.vnApp, 'showError');
controller.onResponse('accept');
controller.onResponse();
expect(controller.vnApp.showError).toHaveBeenCalledWith(`The message can't be empty`);
});

View File

@ -19,7 +19,7 @@
</form>
<vn-confirm
vn-id="deleteNode"
on-response="$ctrl.onRemoveResponse($response)"
on-accept="$ctrl.onRemoveResponse()"
question="Delete department"
message="Are you sure you want to delete it?">
</vn-confirm>
@ -27,7 +27,7 @@
<vn-dialog
vn-id="createNode"
on-open="$ctrl.onCreateDialogOpen()"
on-response="$ctrl.onCreateResponse($response)"
on-accept="$ctrl.onCreateResponse()"
message="New department">
<tpl-body>
<vn-textfield

View File

@ -38,8 +38,7 @@ class Controller extends Section {
this.newChild.name = '';
}
onCreateResponse(response) {
if (response == 'accept') {
onCreateResponse() {
try {
if (!this.newChild.name)
throw new Error(`Name can't be empty`);
@ -61,7 +60,6 @@ class Controller extends Section {
this.vnApp.showError(this.$t(e.message));
return false;
}
}
return true;
}
@ -70,15 +68,13 @@ class Controller extends Section {
this.$.deleteNode.show();
}
onRemoveResponse(response) {
if (response === 'accept') {
onRemoveResponse() {
const childId = this.removedChild.id;
const path = `departments/${childId}/removeChild`;
this.$http.post(path).then(() => {
this.$.treeview.remove(this.removedChild);
});
}
}
}
ngModule.vnComponent('vnWorkerDepartment', {

View File

@ -1,3 +1,4 @@
New department: Nuevo departamento
Delete department: Eliminar departamento
Are you sure you want to delete it?: ¿Seguro que quieres eliminarlo?
Name can't be empty: El nombre esta vacio

View File

@ -92,7 +92,7 @@
</vn-side-menu>
<vn-dialog
vn-id="addTimeDialog"
on-response="$ctrl.addTime($response)"
on-accept="$ctrl.addTime()"
message="Add time">
<tpl-body>
<vn-input-time

View File

@ -233,8 +233,7 @@ class Controller extends Section {
this.$.addTimeDialog.show();
}
addTime(response) {
if (response !== 'accept') return;
addTime() {
let data = {
workerFk: this.$params.id,
timed: this.newTime

View File

@ -10,6 +10,10 @@
"id": {
"id": true,
"type": "Number"
},
"warehouseFk": {
"type": "Number",
"required": true
}
},
"relations": {

View File

@ -28,7 +28,7 @@
</vn-float-button>
<vn-dialog
vn-id="dialog"
on-response="$ctrl.onSave($response)">
on-accept="$ctrl.onSave()">
<tpl-body>
<vn-autocomplete
ng-model="$ctrl.selected.warehouseFk"

View File

@ -21,9 +21,7 @@ class Controller extends Section {
this.$.dialog.show();
}
onSave(response) {
if (response != 'accept') return;
onSave() {
this.$http.post(this.path, this.selected)
.then(() => {
this.selected = null;

View File

@ -36,7 +36,7 @@ describe('Zone warehouses', () => {
jest.spyOn(controller, 'refresh').mockReturnThis();
$httpBackend.expect('POST', `Zones/1/warehouses`).respond(200);
controller.onSave('accept');
controller.onSave();
$httpBackend.flush();
expect(controller.selected).toBeNull();