This commit is contained in:
Carlos Jimenez Ruiz 2019-06-20 14:41:58 +02:00
commit 7d0c42c077
14 changed files with 146 additions and 75 deletions

View File

@ -90,7 +90,7 @@ export default {
newBankEntityButton: 'vn-client-billing-data vn-icon-button[vn-tooltip="New bank entity"] > button',
newBankEntityName: 'vn-client-billing-data > vn-dialog vn-textfield[label="Name"] input',
newBankEntityBIC: 'vn-client-billing-data > vn-dialog vn-textfield[label="Swift / BIC"] input',
newBankEntityCode: 'vn-client-billing-data > vn-dialog vn-textfield[label="Code"] input',
newBankEntityCode: 'vn-client-billing-data > vn-dialog vn-textfield[label="Entity Code"] input',
acceptBankEntityButton: 'vn-client-billing-data > vn-dialog button[response="ACCEPT"]',
saveButton: `${components.vnSubmit}`
},

View File

@ -1,7 +1,9 @@
import ngModule from '../../module';
import Input from '../../lib/input';
export default class Controller {
constructor($element) {
export default class Controller extends Input {
constructor($element, $scope) {
super($element, $scope);
this.$element = $element;
this.input = $element[0].querySelector('input');
}
@ -11,7 +13,7 @@ export default class Controller {
}
}
Controller.$inject = ['$element'];
Controller.$inject = ['$element', '$scope'];
ngModule.component('vnSubmit', {
template: require('./submit.html'),

View File

@ -0,0 +1,29 @@
import ngModule from '../module';
/**
* Disables a clicked element while request is being processed
* Enables again when promise ends
*
* @param {Object} $parse
* @return {Object} The directive
*/
export function directive($parse) {
return {
restrict: 'A',
link: function($scope, $element, $attrs) {
const cb = $parse($attrs.vnHttpClick);
const element = $element[0];
$element.on('click', () => {
element.$ctrl.disabled = true;
cb($scope).finally(() => {
element.$ctrl.disabled = false;
});
});
}
};
}
directive.$inject = ['$parse'];
ngModule.directive('vnHttpClick', directive);

View File

@ -0,0 +1,37 @@
import ngModule from '../module';
/**
* Disables a submitted form while request is being processed
* Enables again when promise ends
*
* @param {Object} $parse
* @return {Object} The directive
*/
export function directive($parse) {
return {
restrict: 'A',
link: function($scope, $element, $attrs) {
const cb = $parse($attrs.vnHttpSubmit);
const element = $element[0];
$element.on('submit', () => {
const selector = 'vn-textfield, vn-autocomplete, vn-submit';
const elements = element.querySelectorAll(selector);
const fields = angular.element(elements);
angular.forEach(fields, field => {
field.$ctrl.disabled = true;
});
cb($scope).finally(() => {
angular.forEach(fields, field => {
field.$ctrl.disabled = false;
});
});
});
}
};
}
directive.$inject = ['$parse'];
ngModule.directive('vnHttpSubmit', directive);

View File

@ -13,3 +13,5 @@ import './title';
import './uvc';
import './draggable';
import './droppable';
import './http-click';
import './http-submit';

View File

@ -19,7 +19,7 @@
"name": "storage",
"connector": "loopback-component-storage",
"provider": "filesystem",
"root": "./",
"root": "./e2e/dms",
"maxFileSize": "10485760",
"allowedContentTypes": [
"application/pdf",

View File

@ -6,7 +6,7 @@
save="post">
</vn-watcher>
<div class="content-block">
<form name="form" ng-submit="$ctrl.onSubmit()" compact>
<form name="form" vn-http-submit="$ctrl.onSubmit()" compact>
<vn-card pad-large>
<vn-horizontal>
<vn-textfield vn-two vn-focus

View File

@ -13,7 +13,7 @@ export default class Controller {
}
onSubmit() {
this.$scope.watcher.submit().then(res => {
return this.$scope.watcher.submit().then(res => {
this.$state.go('zone.card.location', {id: res.data.id});
});
}

View File

@ -18,7 +18,7 @@
<vn-tool-bar margin-medium-bottom>
<vn-button
label="Import claim"
ng-click="$ctrl.importToNewRefundTicket()"
vn-http-click="$ctrl.importToNewRefundTicket()"
vn-tooltip="Imports claim details">
</vn-button>
<vn-button
@ -115,11 +115,10 @@
</vn-vertical>
</vn-card>
<vn-button-bar>
{{$ctrl.resolvedStateText}}
<vn-button
label="Regularize"
ng-click="$ctrl.regularize()"
disabled="$ctrl.claim.claimStateFk == $ctrl.resolvedState">
disabled="$ctrl.claim.claimStateFk == $ctrl.resolvedState"
vn-http-click="$ctrl.regularize()">
</vn-button>
</vn-button-bar>
<!-- WIP

View File

@ -62,7 +62,7 @@ class Controller {
importToNewRefundTicket() {
let query = `claim/api/ClaimBeginnings/${this.$stateParams.id}/importToNewRefundTicket`;
this.$http.post(query).then(() => {
return this.$http.post(query).then(() => {
this.$.model.refresh();
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
});
@ -133,7 +133,7 @@ class Controller {
regularize() {
let data = {claimFk: this.$stateParams.id};
let query = `/claim/api/Claims/regularizeClaim`;
this.$http.post(query, data).then(() => {
return this.$http.post(query, data).then(() => {
this.card.reload();
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
if (this.claim.responsibility >= Math.ceil(this.maxResponsibility) / 2)

View File

@ -39,7 +39,7 @@
<vn-vertical compact>
<vn-card pad-large>
<vn-vertical>
<form name="form" ng-submit="$ctrl.onSubmit()">
<form name="form">
<vn-horizontal ng-repeat="claimDevelopment in claimDevelopments">
<vn-autocomplete
vn-one

View File

@ -5,63 +5,65 @@
form="form"
save="patch">
</vn-watcher>
<form name="form" ng-submit="watcher.submit()" compact>
<vn-card pad-large>
<vn-horizontal>
<vn-textfield
vn-one
label="Comercial Name"
field="$ctrl.client.name" vn-focus>
</vn-textfield>
</vn-horizontal>
<vn-horizontal>
<vn-textfield
vn-one
label="Contact"
field="$ctrl.client.contact">
</vn-textfield>
<vn-textfield
vn-one
label="Email"
field="$ctrl.client.email"
info="You can save multiple emails">
</vn-textfield>
</vn-horizontal>
<vn-horizontal>
<vn-textfield
vn-one
label="Phone"
field="$ctrl.client.phone">
</vn-textfield>
<vn-textfield
vn-one
label="Mobile"
field="$ctrl.client.mobile">
</vn-textfield>
</vn-horizontal>
<vn-horizontal>
<vn-autocomplete
vn-one
disabled="false"
field="$ctrl.client.salesPersonFk"
url="/client/api/Clients/activeWorkersWithRole"
show-field="nickname"
search-function="{firstName: $search}"
value-field="id"
where="{role: 'employee'}"
label="Salesperson"
vn-acl="salesAssistant">
</vn-autocomplete>
<vn-autocomplete
vn-one
initial-data="$ctrl.client.contactChannel"
field="$ctrl.client.contactChannelFk"
url="/client/api/ContactChannels"
label="Channel">
</vn-autocomplete>
</vn-horizontal>
</vn-card>
<vn-button-bar>
<vn-submit label="Save"></vn-submit>
</vn-button-bar>
<form name="form" vn-http-submit="watcher.submit()" compact>
<fieldset>
<vn-card pad-large>
<vn-horizontal>
<vn-textfield
vn-one
label="Comercial Name"
field="$ctrl.client.name" vn-focus>
</vn-textfield>
</vn-horizontal>
<vn-horizontal>
<vn-textfield
vn-one
label="Contact"
field="$ctrl.client.contact">
</vn-textfield>
<vn-textfield
vn-one
label="Email"
field="$ctrl.client.email"
info="You can save multiple emails">
</vn-textfield>
</vn-horizontal>
<vn-horizontal>
<vn-textfield
vn-one
label="Phone"
field="$ctrl.client.phone">
</vn-textfield>
<vn-textfield
vn-one
label="Mobile"
field="$ctrl.client.mobile">
</vn-textfield>
</vn-horizontal>
<vn-horizontal>
<vn-autocomplete
vn-one
disabled="false"
field="$ctrl.client.salesPersonFk"
url="/client/api/Clients/activeWorkersWithRole"
show-field="nickname"
search-function="{firstName: $search}"
value-field="id"
where="{role: 'employee'}"
label="Salesperson"
vn-acl="salesAssistant">
</vn-autocomplete>
<vn-autocomplete
vn-one
initial-data="$ctrl.client.contactChannel"
field="$ctrl.client.contactChannelFk"
url="/client/api/ContactChannels"
label="Channel">
</vn-autocomplete>
</vn-horizontal>
</vn-card>
<vn-button-bar>
<vn-submit label="Save"></vn-submit>
</vn-button-bar>
</fieldset>
</form>

View File

@ -11,7 +11,7 @@
<vn-button
disabled="!$ctrl.isEditable"
label="Ok"
ng-click="$ctrl.onStateOkClick()"
vn-http-click="$ctrl.onStateOkClick()"
vn-tooltip="Change ticket state to 'Ok'">
</vn-button>
<vn-button-menu

View File

@ -115,7 +115,7 @@ class Controller {
onStateOkClick() {
let filter = {where: {code: 'OK'}, fields: ['id']};
let json = encodeURIComponent(JSON.stringify(filter));
this.$http.get(`/api/States?filter=${json}`).then(res => {
return this.$http.get(`/api/States?filter=${json}`).then(res => {
this.onStateChange(res.data[0].id);
});
}