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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,3 +1,4 @@
New department: Nuevo departamento New department: Nuevo departamento
Delete department: Eliminar departamento Delete department: Eliminar departamento
Are you sure you want to delete it?: ¿Seguro que quieres eliminarlo? 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-side-menu>
<vn-dialog <vn-dialog
vn-id="addTimeDialog" vn-id="addTimeDialog"
on-response="$ctrl.addTime($response)" on-accept="$ctrl.addTime()"
message="Add time"> message="Add time">
<tpl-body> <tpl-body>
<vn-input-time <vn-input-time

View File

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

View File

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

View File

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

View File

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

View File

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