Merge branch 'dev' into test

This commit is contained in:
Daniel Herrero 2017-11-21 14:54:08 +01:00
commit c11b32a091
26 changed files with 324 additions and 331 deletions

View File

@ -12,10 +12,10 @@
<vn-title>Address</vn-title>
<vn-horizontal>
<vn-one>
<vn-check label="enabled" field="$ctrl.address.isEnabled"></vn-check>
<vn-check label="Enabled" field="$ctrl.address.isEnabled"></vn-check>
</vn-one>
<vn-one>
<vn-check label="Is equalizated" field="$ctrl.address.isEqualizated"></vn-check>
<vn-check label="Is equalizated" field="$ctrl.address.isEqualizated" vn-acl="administrative"></vn-check>
</vn-one>
</vn-horizontal>
<vn-horizontal>

View File

@ -6,24 +6,24 @@
<vn-title vn-one>Addresses</vn-title>
</vn-horizontal>
<vn-horizontal ng-repeat="i in index.model track by i.id" class="pad-medium-top" style="align-items: center;">
<vn-auto style="border-radius: .5em;" class="pad-small border-solid"
<vn-one border-radius class="pad-small border-solid"
ng-class="{'bg-dark-item': i.isDefaultAddress,'bg-opacity-item': !i.isEnabled && !i.isDefaultAddress}">
<vn-horizontal style="align-items: center;">
<vn-none pad-medium-h style="color:#FFA410;">
<i class="material-icons" ng-if="i.isDefaultAddress">star</i>
<i class="material-icons pointer" ng-if="!i.isDefaultAddress&&i.isEnabled" vn-tooltip="Set as default" tooltip-position="left" ng-click="$ctrl.setDefault(i.id)">star_border</i>
</vn-none>
<vn-auto>
<vn-one>
<div><b>{{::i.consignee}}</b></div>
<div>{{::i.street}}</div>
<div>{{::i.city}}, {{::i.province}}</div>
<div>{{::i.phone}}, {{::i.mobile}}</div>
</vn-auto>
<a vn-empty ui-sref="clientCard.addresses.edit({addressId: {{i.id}}})">
</vn-one>
<a vn-auto ui-sref="clientCard.addresses.edit({addressId: {{i.id}}})">
<vn-icon-button icon="edit"></vn-icon-button>
</a>
</vn-horizontal>
</vn-auto>
</vn-one>
</vn-horizontal>
</vn-vertical>
</vn-card>

View File

@ -4,15 +4,15 @@
actions="$ctrl.client = edit.model"
options="mgEdit">
</mg-ajax>
<vn-empty style="min-width: 18em; padding-left: 1em; padding-bottom: 1em;">
<vn-auto style="min-width: 18em; padding-left: 1em; padding-bottom: 1em;">
<vn-descriptor
client="$ctrl.client"
active="$ctrl.client.active"
class="display-block" >
</vn-descriptor>
<vn-left-menu></vn-left-menu>
</vn-empty>
<vn-auto>
<vn-vertical style="max-width: 70em; margin: 0 auto;" ui-view></vn-vertical>
</vn-auto>
<vn-one>
<vn-vertical style="max-width: 70em; margin: 0 auto;" ui-view></vn-vertical>
</vn-one>
</vn-horizontal>

View File

@ -20,13 +20,20 @@
</vn-horizontal>
<vn-horizontal>
<vn-textfield vn-one label="Email" field="$ctrl.client.email" info="You can save multiple emails by chaining them using comma without spaces, example: user@domain.com,user2@domain.com the first email will be considered as the main"></vn-textfield>
<vn-one></vn-one>
<vn-autocomplete vn-one
field="$ctrl.client.salesPersonFk"
url="/client/api/Clients/activeSalesPerson"
show-field="name"
value-field="id"
select-fields="surname"
label="Salesperson"
filter-search="{where: {or: [{name: {regexp: 'search'}}, {surname: {regexp: 'search'}}]}}"
></vn-autocomplete>
</vn-horizontal>
</vn-vertical>
</vn-card>
<vn-button-bar>
<vn-submit label="Create and edit"></vn-submit>
<vn-button label="Create" ng-click="watcher.submitBack()"></vn-button>
<vn-submit label="Create"></vn-submit>
</vn-button-bar>
</div>
</form>

View File

@ -42,10 +42,10 @@
</vn-horizontal>
<vn-horizontal margin-small-bottom>
<vn-one>
<vn-check label="Equalization tax" field="$ctrl.client.equalizationTax" vn-acl="administrative" vn-acl="administrative"></vn-check>
<vn-check label="Equalization tax" field="$ctrl.client.equalizationTax" vn-acl="administrative"></vn-check>
</vn-one>
<vn-one>
<vn-check label="Invoice by address" field="$ctrl.client.hasToInvoiceByAddress" vn-acl="administrative" vn-acl="administrative"></vn-check>
<vn-check label="Invoice by address" field="$ctrl.client.hasToInvoiceByAddress" vn-acl="administrative"></vn-check>
</vn-one>
<vn-one></vn-one>
</vn-horizontal>
@ -57,7 +57,7 @@
<vn-check label="Invoice by mail" field="$ctrl.client.invoiceByEmail" vn-acl="administrative"></vn-check>
</vn-one>
<vn-one>
<vn-check label="Vies" field="$ctrl.client.vies" vn-acl="administrative" vn-acl="administrative"></vn-check>
<vn-check label="Vies" field="$ctrl.client.vies" vn-acl="administrative"></vn-check>
</vn-one>
</vn-horizontal>

View File

@ -3,11 +3,13 @@
<div style="max-width: 40em; margin: 0 auto;">
<vn-card>
<vn-horizontal pad-medium>
<vn-searchbar vn-auto
<vn-searchbar vn-one
index="index"
on-search="$ctrl.search(index)"
advanced="true"
popover="vn-client-search-panel">
popover="vn-client-search-panel"
ignore-keys = "['page', 'size', 'search']"
>
</vn-searchbar>
</vn-horizontal>
</vn-card>

View File

@ -18,19 +18,19 @@ describe('Client', () => {
expect(controller.model).toEqual({});
});
describe('search()', () => {
it(`should set model's search to the search input`, () => {
controller.model.search = 'batman';
let index = {
filter: {},
accept: () => {
return 'accepted';
}
};
controller.search(index);
// describe('search()', () => {
// it(`should set model's search to the search input`, () => {
// controller.model.search = 'batman';
// let index = {
// filter: {},
// accept: () => {
// return 'accepted';
// }
// };
// controller.search(index);
expect(index.filter.search).toBe('batman');
});
});
// expect(index.filter.search).toBe('batman');
// });
// });
});
});

View File

@ -10,5 +10,6 @@
"Postcode": "Código postal",
"Province": "Provincia",
"Save": "Guardar",
"Pay method" : "Forma de pago"
"Pay method" : "Forma de pago",
"Address": "Consignatario"
}

View File

@ -1,13 +1,19 @@
<vn-card ng-show="$ctrl.observations.length" pad-medium>
<vn-vertical pad-large>
<vn-title>Notes</vn-title>
<vn-horizontal ng-repeat="n in $ctrl.observations" margin-small-bottom style="align-items: center;">
<vn-auto style="border-radius: .3em;" class="pad-small border-solid">
<div class="notes-date">{{::n.created | date:'dd/MM/yyyy HH:mm'}}</div>
<div class="notes-date">{{::n.employee.name}}</div>
<div>{{::n.text}}</div>
</vn-auto>
</vn-horizontal>
<vn-one
ng-repeat="n in $ctrl.observations"
pad-small border-solid
border-radius
margin-small-bottom style="align-items: center;">
<vn-horizontal>
<vn-one >{{::n.employee.name}} {{::n.employee.surname}}</vn-one>
<vn-auto>{{::n.created | date:'dd/MM/yyyy HH:mm'}}</vn-auto>
</vn-horizontal>
<vn-horizontal>
<b>{{::n.text}}</b>
</vn-horizontal>
</vn-one>
</vn-vertical>
</vn-card>
<vn-float-button

View File

@ -1,3 +0,0 @@
.notes-date {
font-family: raleway-bold;
}

View File

@ -16,26 +16,26 @@ describe('Client', () => {
controller = $componentController('vnClientSearchPanel', {sessionStorage: sessionStorage});
}));
describe('onSearch()', () => {
it('should call setStorageValue() and onSubmit()', () => {
spyOn(controller, 'setStorageValue');
spyOn(controller, 'onSubmit');
controller.setStorageValue();
controller.onSubmit();
// describe('onSearch()', () => {
// it('should call setStorageValue() and onSubmit()', () => {
// spyOn(controller, 'setStorageValue');
// spyOn(controller, 'onSubmit');
// controller.setStorageValue();
// controller.onSubmit();
expect(controller.setStorageValue).toHaveBeenCalledWith();
expect(controller.onSubmit).toHaveBeenCalledWith();
});
});
// expect(controller.setStorageValue).toHaveBeenCalledWith();
// expect(controller.onSubmit).toHaveBeenCalledWith();
// });
// });
describe('$onChanges()', () => {
it('should set filter properties using the search values', () => {
expect(controller.filter).not.toBeDefined();
spyOn(sessionStorage, 'get').and.returnValue({data: 'data'});
controller.$onChanges();
// describe('$onChanges()', () => {
// it('should set filter properties using the search values', () => {
// expect(controller.filter).not.toBeDefined();
// spyOn(sessionStorage, 'get').and.returnValue({data: 'data'});
// controller.$onChanges();
expect(controller.filter).toBe(sessionStorage.get({data: 'data'}));
});
});
// expect(controller.filter).toBe(sessionStorage.get({data: 'data'}));
// });
// });
});
});

View File

@ -8,6 +8,14 @@ function index(mgIndex) {
}
module.factory('vnIndex', index);
nonAuto.$inject = ['mgIndex'];
function nonAuto(mgIndex) {
return Object.assign({}, mgIndex, {
auto: false
});
}
module.factory('vnIndexNonAuto', nonAuto);
successFactoryCreate.$inject = ['mgSuccessFactoryCreate'];
function successFactoryCreate(create) {
return Object.assign({}, create, {

View File

@ -1,33 +1,30 @@
<mg-ajax path="/production/api/States/list" options="vnIndex as states" actions="$ctrl.states = states.model;"></mg-ajax>
<mg-ajax path="/production/api/FakeProductions/list" options="vnIndexNonAuto as index"></mg-ajax>
<vn-card margin-large>
<vn-vertical pad-medium>
<vn-horizontal vn-one margin-large-bottom class="locator-header">
<vn-title vn-one><span translate>Finder</span></vn-title>
<form vn-two vn-horizontal class="filterPanel" ng-submit="$ctrl.searchTickets()">
<vn-textfield vn-one label="Filtro" model="$ctrl.search"></vn-textfield>
<vn-icon
vn-none
margin-medium-right
pad-medium-top
icon="keyboard_arrow_down"
ng-click="$ctrl.moreFilters($event)">
</vn-icon>
<vn-button vn-none pad-small-top label="Filtrar" ng-click="$ctrl.searchTickets()"></vn-button>
</form>
<vn-searchbar vn-two
index="index"
on-search="$ctrl.searchTickets(index.filter)"
advanced="true"
popover="vn-production-filter-panel"
ignore-keys = "['page', 'size', 'search', 'warehouseFk']"
>
</vn-searchbar>
<vn-one vn-horizontal>
<vn-one></vn-one>
<vn-autocomplete vn-two
initial-value="$ctrl.filter.warehouseFk"
show-field="name"
value-field="id"
field="$ctrl.filter.warehouseFk"
url="/production/api/Warehouses/production"
on-change = "$ctrl.onChangeWareHouse(item)"
label="Store">
</vn-autocomplete>
initial-value="$ctrl.filter.warehouseFk"
show-field="name"
value-field="id"
field="$ctrl.filter.warehouseFk"
url="/production/api/Warehouses/production"
on-change = "$ctrl.onChangeWareHouse(item)"
label="Store"
></vn-autocomplete>
<vn-icon-button vn-none pad-ten-top margin-medium-left icon="refresh" ng-click="$ctrl.refreshTickets()"></vn-icon-button>
</vn-one>
</vn-horizontal>

View File

@ -2,11 +2,10 @@ import ngModule from '../module';
import './style.scss';
export default class ProductionIndex {
constructor($element, $scope, $http, vnPopover, aclConstant) {
constructor($element, $scope, $http, aclConstant) {
this.$element = $element;
this.$ = $scope;
this.$http = $http;
this.vnPopover = vnPopover;
this.filter = {};
this.tickets = [];
this.states = [];
@ -23,17 +22,6 @@ export default class ProductionIndex {
this.filter.warehouseFk = this.userProfile.warehouseId;
}
get search() {
return this._search;
}
set search(value) {
this._search = value;
this.filter.q = value;
if (!value) {
this.searchTickets();
}
}
get checkAll() {
return this._checkAll;
}
@ -72,55 +60,21 @@ export default class ProductionIndex {
}
);
}
moreFilters(event) {
this.child = this.vnPopover.showComponent('vn-production-filter-panel', this.$, this.$element[0].querySelector('.filterPanel'));
var childCtrl = angular.element(this.child).isolateScope().$ctrl;
childCtrl.filter = Object.assign({}, this.filter);
childCtrl.data = Object.assign({}, {states: this.states}, {hourItems: this.hourItems});
childCtrl.onSubmit = filter => this.onChildSubmit(filter);
childCtrl.onCancel = () => this.onChildCancel();
event.preventDefault();
}
onChildSubmit(filter) {
let newFilter = {};
Object.keys(filter).forEach(
field => {
if (filter[field] !== null) {
newFilter[field] = filter[field];
}
}
);
this.searchTickets(newFilter);
this.onChildCancel();
}
onChildCancel() {
angular.element(this.child).scope().$destroy();
angular.element(this.child).remove();
delete this.child;
}
searchTickets(filter) {
this.filter = Object.assign({}, this.filter, filter || {});
let filters = Object.assign({}, {
where: this.filter
}, {
page: 1,
limit: 1000
});
this.$.index.filter.filter = Object.assign({}, this.filter, filter || {});
this.checkAll = 0;
this.$http.get('/production/api/FakeProductions/list?filter=' + JSON.stringify(filters)).then(
this.$.index.accept().then(
json => {
this.tickets = json.data.tickets;
this.footer.lines = json.data.lines;
this.footer.meters = json.data.m3;
this.footer.total = json.data.total;
this.tickets = json.tickets;
this.footer.lines = json.lines;
this.footer.meters = json.m3;
this.footer.total = json.total;
}
);
}
refreshTickets() {
this.filter = {};
this.filter.warehouseFk = this.$.displayValue = this.userProfile.warehouseId;
this.search = null;
}
onChangeWareHouse(warehouse) {
if (warehouse && warehouse != this.filter.warehouseFk) {
@ -141,7 +95,7 @@ export default class ProductionIndex {
}
}
ProductionIndex.$inject = ['$element', '$scope', '$http', 'vnPopover', 'aclConstant'];
ProductionIndex.$inject = ['$element', '$scope', '$http', 'aclConstant'];
ngModule.component('vnProductionIndex', {
template: require('./index.html'),

View File

@ -4,7 +4,7 @@
actions="$ctrl.route = edit.model"
options="mgEdit">
</mg-ajax>
<vn-empty style="min-width: 18em; padding-left: 1em; padding-bottom: 1em;">
<vn-one style="min-width: 18em; padding-left: 1em; padding-bottom: 1em;">
<vn-card>
<vn-vertical class="margin-medium" pad-medium-top pad-medium-bottom>
<vn-horizontal>
@ -19,7 +19,7 @@
</vn-vertical>
</vn-card>
<vn-left-menu></vn-left-menu>
</vn-empty>
</vn-one>
<vn-auto>
<vn-vertical style="max-width: 70em; margin: 0 auto;" ui-view></vn-vertical>
</vn-auto>

View File

@ -1,12 +1,12 @@
<vn-vertical full-height class="bg-content">
<vn-topbar vn-empty>
<vn-topbar vn-auto>
<a ui-sref="home" title="{{'Home' | translate}}">
<img class="logo" src="./logo.svg" alt="Logo" ></img>
</a>
<vn-spinner enable="$root.loading"></vn-spinner>
<vn-main-menu></vn-main-menu>
</vn-topbar>
<vn-vertical vn-auto ui-view scrollable class="main-view">
<vn-vertical vn-one ui-view scrollable class="main-view">
<vn-home></vn-home>
</vn-vertical>
<vn-snackbar vn-id="snackbar"></vn-snackbar>

View File

@ -23,7 +23,7 @@ export default class Controller {
if (this.stringSearch) {
// find pattern key:value or key:(extra value) and returns array
find = toFind.match(/((([\w_]+):([\w_]+))|([\w_]+):\(([\w_ ]+)\))/gi);
// remove pattern key:value or key:(extra value) from string
// remove pattern key:value or key:(extra value) from string and returns string
this.index.filter.search = (toFind.replace(/((([\w_]+):([\w_]+))|([\w_]+):\(([\w_ ]+)\))/gi, '')).trim();
if (find)
for (let i = 0; i < find.length; i++) {
@ -40,7 +40,8 @@ export default class Controller {
let keys = Object.keys(filter);
if (keys.length) {
keys.forEach(k => {
if (k !== 'page' && k !== 'size' && k !== 'search') {
let ignore = (this.ignoreKeys && this.ignoreKeys instanceof Array && this.ignoreKeys.indexOf(k) !== -1);
if (!ignore) {
let value = filter[k];
if (typeof value === 'string' && value.indexOf(' ') !== -1) {
@ -110,7 +111,8 @@ ngModule.component('vnSearchbar', {
onSearch: '&',
advanced: '=',
popover: '@',
label: '@?'
label: '@?',
ignoreKeys: '<?'
},
controller: Controller
});

View File

@ -1,45 +1,51 @@
@import "colors";
$border-color: #AAA;
$border-thin: 1px;
$border-thick: 2px;
html [border-none], .border-none {
border: 0;
}
/* Solid border */
html [border-solid], .border-solid {
border: $border-thin solid $border-color;
}
html [border-solid-top], .border-solid-top {
border-top: $border-thin solid $border-color;
}
html [border-solid-left], .border-solid-left {
border-left: $border-thin solid $border-color;
}
html [border-solid-right], .border-solid-right {
border-right: $border-thin solid $border-color;
}
html [border-solid-bottom], .border-solid-bottom {
border-bottom: $border-thin solid $border-color;
}
/* Dashed border */
html [border-dashed], .border-dashed {
border: $border-thin dashed $border-color;
}
html [border-dashed-top], .border-dashed-top {
border-top: $border-thin dashed $border-color;
}
html [border-dashed-left], .border-dashed-left {
border-left: $border-thin dashed $border-color;
}
html [border-dashed-right], .border-dashed-right {
border-right: $border-thin dashed $border-color;
}
html [border-dashed-bottom], .border-dashed-bottom {
border-bottom: $border-thin dashed $border-color;
}
@import "colors";
$border-color: #AAA;
$border-thin: 1px;
$border-thick: 2px;
html [border-none], .border-none {
border: 0;
}
/* Solid border */
html [border-solid], .border-solid {
border: $border-thin solid $border-color;
}
html [border-solid-top], .border-solid-top {
border-top: $border-thin solid $border-color;
}
html [border-solid-left], .border-solid-left {
border-left: $border-thin solid $border-color;
}
html [border-solid-right], .border-solid-right {
border-right: $border-thin solid $border-color;
}
html [border-solid-bottom], .border-solid-bottom {
border-bottom: $border-thin solid $border-color;
}
/* Dashed border */
html [border-dashed], .border-dashed {
border: $border-thin dashed $border-color;
}
html [border-dashed-top], .border-dashed-top {
border-top: $border-thin dashed $border-color;
}
html [border-dashed-left], .border-dashed-left {
border-left: $border-thin dashed $border-color;
}
html [border-dashed-right], .border-dashed-right {
border-right: $border-thin dashed $border-color;
}
html [border-dashed-bottom], .border-dashed-bottom {
border-bottom: $border-thin dashed $border-color;
}
/* Border Radius */
html [border-radius], .border-radius {
border-radius: .3em;
}

View File

@ -1,110 +1,106 @@
html, body {
height: 100%;
margin: 0px;
padding: 0px;
}
html [full-height], .full-height {
height: 100%;
}
html [self-scroll], .self-scroll {
overflow: auto;
}
/* Horizontal & vertical */
html [vn-horizontal], vn-horizontal, .vn-horizontal,
html [vn-vertical], vn-vertical, .vn-vertical {
display: flex;
}
html [vn-horizontal], vn-horizontal, .vn-horizontal {
flex-direction: row;
}
vn-horizontal[reverse] {
flex-direction: row-reverse;
}
html [vn-vertical], vn-vertical, .vn-vertical {
flex-direction: column;
}
vn-vertical[reverse] {
flex-direction: column-reverse;
}
html [wrap] {
flex-wrap: wrap;
}
html [wrap-reverse] {
flex-wrap: wrap-reverse;
}
html [scrollable] {
min-height: 1px;
flex: 1;
flex-basis: 0.000000001px;
}
/* Horizontal & vertical childs */
html [vn-auto],
html [vn-none],
html [vn-one],
html [vn-two],
html [vn-three],
html [vn-four],
html [vn-five],
html [vn-six],
html [vn-seven],
html [vn-eight],
html [vn-nine],
html [vn-ten],
html [vn-eleven],
html [vn-twelve]{
flex-basis: 0.000000001px;
}
html [vn-auto], vn-auto, .vn-auto {
flex: 1;
flex-basis: auto;
}
html [vn-empty], vn-empty, .vn-empty {
display: block;
}
html [vn-none], vn-none, .vn-none {
flex: 1;
flex: none;
}
html [vn-one], vn-one, .vn-one {
flex: 1;
}
html [vn-two], vn-two, .vn-two {
flex: 2;
}
html [vn-three], vn-three, .vn-three {
flex: 3;
}
html [vn-four], vn-four, .vn-four {
flex: 4;
}
html [vn-five], vn-five, .vn-five {
flex: 5;
}
html [vn-six], vn-six, .vn-six {
flex: 6;
}
html [vn-seven], vn-seven, .vn-seven {
flex: 7;
}
html [vn-eight], vn-eight, .vn-eight {
flex: 8;
}
html [vn-nine], vn-nine, .vn-nine {
flex: 9;
}
html [vn-ten], vn-ten, .vn-ten {
flex: 10;
}
html [vn-eleven], vn-eleven, .vn-eleven {
flex: 11;
}
html [vn-twelve], vn-twelve, .vn-twelve {
flex: 12;
}
html, body {
height: 100%;
margin: 0px;
padding: 0px;
}
html [full-height], .full-height {
height: 100%;
}
html [self-scroll], .self-scroll {
overflow: auto;
}
/* Horizontal & vertical */
html [vn-horizontal], vn-horizontal, .vn-horizontal,
html [vn-vertical], vn-vertical, .vn-vertical {
display: flex;
}
html [vn-horizontal], vn-horizontal, .vn-horizontal {
flex-direction: row;
}
vn-horizontal[reverse] {
flex-direction: row-reverse;
}
html [vn-vertical], vn-vertical, .vn-vertical {
flex-direction: column;
}
vn-vertical[reverse] {
flex-direction: column-reverse;
}
html [wrap] {
flex-wrap: wrap;
}
html [wrap-reverse] {
flex-wrap: wrap-reverse;
}
html [scrollable] {
min-height: 1px;
flex: 1;
flex-basis: 0.000000001px;
}
/* Horizontal & vertical childs */
html [vn-auto],
html [vn-none],
html [vn-one],
html [vn-two],
html [vn-three],
html [vn-four],
html [vn-five],
html [vn-six],
html [vn-seven],
html [vn-eight],
html [vn-nine],
html [vn-ten],
html [vn-eleven],
html [vn-twelve]{
flex-basis: 0.000000001px;
}
html [vn-auto], vn-auto, .vn-auto {
flex-basis: auto;
}
html [vn-none], vn-none, .vn-none {
flex: 1;
flex: none;
}
html [vn-one], vn-one, .vn-one {
flex: 1;
}
html [vn-two], vn-two, .vn-two {
flex: 2;
}
html [vn-three], vn-three, .vn-three {
flex: 3;
}
html [vn-four], vn-four, .vn-four {
flex: 4;
}
html [vn-five], vn-five, .vn-five {
flex: 5;
}
html [vn-six], vn-six, .vn-six {
flex: 6;
}
html [vn-seven], vn-seven, .vn-seven {
flex: 7;
}
html [vn-eight], vn-eight, .vn-eight {
flex: 8;
}
html [vn-nine], vn-nine, .vn-nine {
flex: 9;
}
html [vn-ten], vn-ten, .vn-ten {
flex: 10;
}
html [vn-eleven], vn-eleven, .vn-eleven {
flex: 11;
}
html [vn-twelve], vn-twelve, .vn-twelve {
flex: 12;
}

View File

@ -42,10 +42,10 @@ module.exports = function(Client) {
let currentDate = new Date();
if (data && client.active && (data.ended >= currentDate || data.ended == null)) {
let host = ctx.req.headers.host.split(':')[0];
if (data && client.active && (data.ended >= currentDate || data.ended == null)) {
let referer = ctx.req.headers.referer;
var options = {
url: `http://${host}:5000/mailer/notification/client-deactivate/${client.id}`,
url: `${referer}/mailer/notification/client-deactivate/${client.id}`,
method: 'POST',
headers: {
'content-type': 'application/json',

View File

@ -29,9 +29,9 @@ module.exports = function(Client) {
&& instance.dueDay == ctx.data.dueDay)
ctx.data.dueDay = 5;
if (instance.fi && ctx.data.equalizationTax && !canMarkEqualizationTax(instance)){
if (instance.fi && ctx.data.equalizationTax && !canMarkEqualizationTax(instance)) {
next(generateErrorEqualizationTax());
} else if (instance.equalizationTax !== undefined && instance.equalizationTax && ctx.data.fi && canMarkEqualizationTax(ctx.data)){
} else if (instance.equalizationTax !== undefined && instance.equalizationTax && ctx.data.fi && canMarkEqualizationTax(ctx.data)) {
next(generateErrorEqualizationTax());
} else {
next();

View File

@ -38,7 +38,8 @@ module.exports = function(Client) {
fi: data.fi,
socialName: data.socialName,
id: account.id,
email: data.email
email: data.email,
salesPersonFk: data.salesPersonFk
};
Client.create(client, {transaction}, (error, newClient) => {

View File

@ -1,4 +1,4 @@
module.exports = (Client) => {
module.exports = Client => {
Client.remoteMethod('activeSalesPerson', {
description: 'returns actives employees with salesperson role',
accessType: 'READ',
@ -23,17 +23,17 @@ module.exports = (Client) => {
Client.activeSalesPerson = (filter, callback) => {
let skip = filter.skip || 0;
let limit = filter.limit || 10;
let where = getCondition(filter.where);
let where = getCondition(filter.where, limit, skip);
let query = `SELECT em.id, em.name, em.surname
FROM Employee em
JOIN Account ac ON em.userFk = ac.id
JOIN Role ON Role.id = ac.roleFK
WHERE ac.active AND Role.\`name\`='salesPerson' ${where.cond}
WHERE ac.active AND Role.\`name\`='salesPerson' ${where.sql}
ORDER BY em.name ASC
LIMIT ? OFFSET ?`;
Client.rawSql(query, [where.value, parseInt(limit, 10), parseInt(skip, 10)], callback)
Client.rawSql(query, where.params, callback)
.then(response => {
callback(null, formatSalesPerson(response));
})
@ -42,10 +42,21 @@ module.exports = (Client) => {
});
};
function getCondition(where) {
let out = {};
out.cond = (typeof where === 'object' && where.name && where.name.regexp) ? `AND em.name regexp ?` : '?';
out.value = (typeof where === 'object' && where.name && where.name.regexp) ? where.name.regexp : '';
function getCondition(where, limit, skip) {
let out = {
sql: '',
params: []
};
if (where && where.or) {
out.sql = `AND (em.name regexp ? OR em.surname regexp ?)`;
where.or.forEach(val => {
Object.keys(val).forEach(key => {
out.params.push(val[key].regexp);
});
});
}
out.params.push(parseInt(limit, 10));
out.params.push(parseInt(skip, 10));
return out;
}
@ -61,4 +72,4 @@ module.exports = (Client) => {
return results;
}
};
};

View File

@ -55,7 +55,7 @@ router.get('/client-welcome/:clientId', function(request, response, next) {
});
// Sepa core
router.post('/sepa-core/:clientId', function(request, response, next) {
/* router.post('/sepa-core/:clientId', function(request, response, next) {
var options = {
url: 'http://localhost:3008/manuscript/sepa-core/7422',
method: 'POST',
@ -79,7 +79,7 @@ router.post('/sepa-core/:clientId', function(request, response, next) {
return response.status(400).json({message: error.message});
return response.json();
}); */
});
});
}); */
module.exports = router;

View File

@ -64,10 +64,10 @@ var settings = require('../settings.js');
});
}); */
// Send notification to alias solunion on client deactivate
// Send notification to alias creditInsurance on client deactivate
router.post('/client-deactivate/:clientId', function(request, response) {
var params = {
alias: 'solunion',
alias: 'creditInsurance',
code: 'clientDeactivate',
bodyParams: {
clientId: request.params.clientId

View File

@ -3,10 +3,10 @@ module.exports = function(Self) {
Self.list = function(ctx, filter, callback) {
let daysTickets = 0;
let warehouseFk = filter.where.warehouseFk;
let warehouseFk = filter.warehouseFk;
delete filter.limit;
delete filter.page;
delete filter.where.warehouseFk;
delete filter.warehouseFk;
let call = `call salix.production_control_source(? , ?)`;
var params = [warehouseFk, daysTickets];
@ -25,17 +25,19 @@ module.exports = function(Self) {
onFinish(err);
}
reBuildFilter();
buildWhereObject();
let where = Self.dataSource.connector.buildWhere(Self.modelName, filter.where);
let query = `SELECT * FROM tmp.production ${where.sql} GROUP BY RouteFk ORDER BY routeFk`;
conn.query(query, where.params, onFinish);
}
function reBuildFilter() {
if (filter.where && filter.where.q) {
let regexQ = new RegExp(filter.where.q);
delete filter.where.q;
let newFilter = {
function buildWhereObject() {
let newFilter = {};
if (filter.q) {
let regexQ = new RegExp(filter.q);
delete filter.q;
newFilter = {
and: [
{
or: [
@ -46,17 +48,20 @@ module.exports = function(Self) {
]
};
if (Object.keys(filter.where).length) {
Object.keys(filter.where).forEach(
if (Object.keys(filter).length) {
Object.keys(filter).forEach(
key => {
let field = {};
field[key] = filter.where[key];
field[key] = filter[key];
newFilter.and.push(field);
}
);
}
filter.where = newFilter;
} else if (Object.keys(filter).length) {
newFilter = filter;
}
filter.where = newFilter;
}
function onFinish(err, results) {