Merge branch 'dev' of https://git.verdnatura.es/salix into dev

This commit is contained in:
gerard 2018-07-16 09:19:44 +02:00
commit 4cf5777b4e
26 changed files with 398 additions and 315 deletions

View File

@ -1,8 +1,15 @@
<mg-ajax path="/client/api/Clients/{{index.params.id}}/listAddresses" options="mgIndex"></mg-ajax>
<vn-crud-model
vn-id="model"
url="/client/api/Addresses"
filter="::$ctrl.filter"
link="{clientFk: $ctrl.$stateParams.id}"
data="addresses">
</vn-crud-model>
<vn-vertical>
<vn-card pad-large>
<vn-title vn-one>Addresses</vn-title>
<vn-horizontal ng-repeat="address in index.model.items track by address.id" class="pad-medium-top" style="align-items: center;">
<vn-horizontal ng-repeat="address in addresses" class="pad-medium-top" style="align-items: center;">
<vn-one border-radius class="pad-small border-solid"
ng-class="{'bg-main': address.isDefaultAddress,'bg-opacity-item': !address.isActive && !address.isDefaultAddress}">
<vn-horizontal style="align-items: center;">
@ -56,7 +63,6 @@
</vn-one>
</vn-horizontal>
</vn-card>
<vn-paging index="index" total="index.model.total"></vn-paging>
<vn-float-button
vn-bind="+"
fixed-bottom-right

View File

@ -1,20 +1,28 @@
import ngModule from '../../module';
class Controller {
constructor($http, $scope) {
constructor($http, $scope, $stateParams) {
this.$http = $http;
this.$scope = $scope;
this.$stateParams = $stateParams;
this.filter = {
include: {
observations: 'observationType'
},
order: ['isDefaultAddress DESC', 'isActive DESC', 'nickname ASC']
};
}
setDefault(address) {
if (address.isActive) {
let params = {isDefaultAddress: true};
this.$http.patch(`/client/api/Addresses/${address.id}`, params).then(
() => this.$scope.index.accept()
() => this.$scope.model.refresh()
);
}
}
}
Controller.$inject = ['$http', '$scope'];
Controller.$inject = ['$http', '$scope', '$stateParams'];
ngModule.component('vnClientAddressIndex', {
template: require('./index.html'),

View File

@ -19,7 +19,7 @@ describe('Client', () => {
$httpBackend.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({});
$scope = $rootScope.$new();
$scope.form = {$invalid: false};
$scope.index = {accept: () => {}};
$scope.model = {refresh: () => {}};
controller = $componentController('vnClientContactIndex', {$scope: $scope}, {$state: $state});
controller.client = {
id: 101
@ -70,11 +70,11 @@ describe('Client', () => {
describe('submit()', () => {
it("should perfom a query to delete contacts", () => {
controller._oldContacts = [];
controller._oldContacts[1] = {id: 1, clientFk: 101, name: 'My contact 1', phone: '123456789'};
controller._oldContacts[2] = {id: 2, clientFk: 101, name: 'My contact 2', phone: '123456789'};
controller.oldContacts = [];
controller.oldContacts[1] = {id: 1, clientFk: 101, name: 'My contact 1', phone: '123456789'};
controller.oldContacts[2] = {id: 2, clientFk: 101, name: 'My contact 2', phone: '123456789'};
controller._contacts = [
controller.contacts = [
{id: 2, name: 'My contact 2', phone: '123456789'}
];
controller.removedContacts = [1];
@ -93,11 +93,11 @@ describe('Client', () => {
});
it("should perfom a query to update contacts", () => {
controller._oldContacts = [];
controller._oldContacts[1] = {id: 1, clientFk: 101, name: 'My contact 1', phone: '123456789'};
controller._oldContacts[2] = {id: 2, clientFk: 101, name: 'My contact 2', phone: '123456789'};
controller.oldContacts = [];
controller.oldContacts[1] = {id: 1, clientFk: 101, name: 'My contact 1', phone: '123456789'};
controller.oldContacts[2] = {id: 2, clientFk: 101, name: 'My contact 2', phone: '123456789'};
controller._contacts = [
controller.contacts = [
{id: 1, clientFk: 101, name: 'My contact 1', phone: '123456789'},
{id: 2, clientFk: 101, name: 'My contact 2', phone: '111111111'}
];
@ -119,11 +119,11 @@ describe('Client', () => {
});
it("should perfom a query to create new contact", () => {
controller._oldContacts = [];
controller._oldContacts[1] = {id: 1, name: 'My contact 1', phone: '123456789'};
controller._oldContacts[2] = {id: 2, name: 'My contact 2', phone: '123456789'};
controller.oldContacts = [];
controller.oldContacts[1] = {id: 1, name: 'My contact 1', phone: '123456789'};
controller.oldContacts[2] = {id: 2, name: 'My contact 2', phone: '123456789'};
controller._contacts = [
controller.contacts = [
{id: 1, name: 'My contact 1', phone: '123456789'},
{id: 2, name: 'My contact 2', phone: '123456789'},
{name: 'My contact 3', phone: '123456789'}

View File

@ -1,12 +1,14 @@
<mg-ajax
path="/client/api/Clients/{{index.params.id}}/contacts"
options="mgIndex"
actions="$ctrl.contacts = index.model">
</mg-ajax>
<vn-crud-model
vn-id="model"
url="/client/api/ClientContacts"
link="{clientFk: $ctrl.$stateParams.id}"
data="contacts" on-data-change="$ctrl.onDataChange()">
</vn-crud-model>
<form name="form" ng-submit="$ctrl.submit()">
<vn-card pad-large>
<vn-title>Contacts</vn-title>
<vn-horizontal ng-repeat="contact in index.model track by $index">
<vn-horizontal ng-repeat="contact in contacts">
<vn-textfield
vn-one
label="Name"

View File

@ -1,25 +1,18 @@
import ngModule from '../module';
class Controller {
constructor($http, $scope, $translate, vnApp) {
constructor($http, $scope, $stateParams, $translate, vnApp) {
this.$http = $http;
this.$scope = $scope;
this.$stateParams = $stateParams;
this.$translate = $translate;
this.vnApp = vnApp;
this.removedContacts = [];
}
/**
* Setter for contacts and original contacts
* @param {Object} value - Contacts object
*/
set contacts(value) {
this._contacts = value;
this.oldContacts = value;
}
get contacts() {
return this._contacts;
onDataChange() {
this.contacts = this.$scope.model.data;
this.oldContacts = this.$scope.model.data;
}
/**
@ -64,7 +57,7 @@ class Controller {
this.$http.post(query, data).then(() => {
this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
this.$scope.index.accept();
this.$scope.model.refresh();
});
}
@ -85,7 +78,7 @@ class Controller {
add() {
let data = {
clientFk: this.client.id,
name: 'Teléfono',
name: this.$translate.instant('Phone'),
phone: null
};
this.contacts.push(data);
@ -115,7 +108,7 @@ class Controller {
}
}
Controller.$inject = ['$http', '$scope', '$translate', 'vnApp'];
Controller.$inject = ['$http', '$scope', '$stateParams', '$translate', 'vnApp'];
ngModule.component('vnClientContactIndex', {
template: require('./index.html'),

View File

@ -12,10 +12,10 @@ describe('Client', () => {
beforeEach(angular.mock.inject((_$componentController_, _$httpBackend_) => {
$componentController = _$componentController_;
let $state = {params: {classificationId: 1}};
let $stateParams = {classificationId: 1};
$httpBackend = _$httpBackend_;
$httpBackend.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({});
controller = $componentController('vnClientCreditInsuranceInsuranceIndex', {$state: $state});
controller = $componentController('vnClientCreditInsuranceInsuranceIndex', {$stateParams: $stateParams});
}));
it('should perform a query to GET credit the credit classification', () => {

View File

@ -1,28 +1,39 @@
<mg-ajax path="/client/api/CreditClassifications/{{index.params.classificationId}}/insurances" options="vnIndex"></mg-ajax>
<vn-crud-model
vn-id="model"
url="/client/api/CreditInsurances"
link="{creditClassification: $ctrl.$stateParams.classificationId}"
limit="20"
data="insurances">
</vn-crud-model>
<vn-vertical>
<vn-card pad-large>
<vn-vertical>
<vn-title>Requested credits</vn-title>
<table class="vn-grid">
<thead>
<tr>
<th number translate>Credit</th>
<th number translate>Grade</th>
<th translate>Created</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="insurance in index.model track by insurance.id" class="list list-element">
<td number>{{::insurance.credit | currency: '€': 2}}</td>
<td number>{{::insurance.grade}}</td>
<td>{{::insurance.created | date: 'dd/MM/yyyy'}}</td>
</tr>
<tr ng-if="index.model.count === 0" class="list list-element">
<td colspan="6" style="text-align: center" translate>No results</td>
</tr>
</tbody>
</table>
<vn-table model="model">
<vn-thead>
<vn-tr>
<vn-th number>Credit</vn-th>
<vn-th number>Grade</vn-th>
<vn-th>Created</vn-th>
</vn-tr>
</vn-thead>
<vn-tbody>
<vn-tr ng-repeat="insurance in insurances">
<vn-td number>{{::insurance.credit | currency: ' €': 2}}</vn-td>
<vn-td number>{{::insurance.grade}}</vn-td>
<vn-td>{{::insurance.created | date: 'dd/MM/yyyy'}}</vn-td>
</vn-tr>
</vn-tbody>
<vn-empty-rows ng-if="model.data.length === 0" translate>
No results
</vn-empty-rows>
</vn-table>
</vn-vertical>
<vn-pagination
model="model"
scroll-selector="ui-view">
</vn-pagination>
</vn-card>
<vn-button-bar>
<button
@ -30,9 +41,8 @@
translate
ui-sref="client.card.creditInsurance.index">Back</button>
</vn-button-bar>
<vn-paging vn-one margin-large-top index="index" total="index.model.count"></vn-paging>
</vn-vertical>
<a ui-sref="client.card.creditInsurance.insurance.create({classificationId: {{index.params.classificationId}}})"
<a ui-sref="client.card.creditInsurance.insurance.create({classificationId: {{$ctrl.$stateParams.classificationId}}})"
fixed-bottom-right vn-tooltip="New credit" vn-bind="+" ng-if="!$ctrl.isClosed">
<vn-float-button icon="add"></vn-float-button>
</a>

View File

@ -1,19 +1,21 @@
import ngModule from '../../../module';
import FilterList from 'core/src/lib/filter-list';
class Controller extends FilterList {
constructor($scope, $timeout, $state, $http) {
super($scope, $timeout, $state);
this.modelName = 'creditClassificationFk';
this.modelId = $state.params.classificationId;
this.isClosed = true;
class Controller {
constructor($stateParams, $http) {
this.$stateParams = $stateParams;
this.$http = $http;
this.isClosed = true;
this.filter = {
include: [
{relation: 'classification'}
]
};
}
$onInit() {
let filter = {
fields: ['finished'],
where: {id: this.modelId}
where: {id: this.$stateParams.classificationId}
};
filter = encodeURIComponent(JSON.stringify(filter));
@ -25,7 +27,7 @@ class Controller extends FilterList {
}
}
Controller.$inject = ['$scope', '$timeout', '$state', '$http'];
Controller.$inject = ['$stateParams', '$http'];
ngModule.component('vnClientCreditInsuranceInsuranceIndex', {
template: require('./index.html'),

View File

@ -1,28 +1,41 @@
<mg-ajax path="/client/api/ClientCredits/filter" options="vnIndexNonAuto"></mg-ajax>
<vn-crud-model
vn-id="model"
url="/client/api/ClientCredits"
filter="::$ctrl.filter"
link="{clientFk: $ctrl.$stateParams.id}"
limit="20"
data="credits">
</vn-crud-model>
<vn-vertical>
<vn-card pad-large>
<vn-vertical>
<vn-title>Credit</vn-title>
<vn-grid-header on-order="$ctrl.onOrder(field, order)">
<vn-column-header vn-one pad-medium-h field="amount" text="Credit"></vn-column-header>
<vn-column-header vn-two pad-medium-h field="created" text="Since" default-order="ASC"></vn-column-header>
<vn-column-header vn-two pad-medium-h field="worker.firstName" text="Employee" order-locked></vn-column-header>
</vn-grid-header>
<vn-one class="list list-content">
<vn-horizontal
vn-one class="list list-element text-center"
pad-small-bottom
ng-repeat="credit in index.model.instances track by credit.id">
<vn-one pad-medium-h>{{::credit.amount | number:2}} €</vn-one>
<vn-two pad-medium-h>{{::credit.created | date:'dd/MM/yyyy HH:mm'}}</vn-two>
<vn-two pad-medium-h>{{::credit.worker.firstName}} {{::credit.worker.name}}</vn-two>
</vn-horizontal>
</vn-one>
<vn-one class="text-center pad-small-v" ng-if="index.model.count === 0" translate>No results</vn-one>
<vn-horizontal vn-one class="list list-footer"></vn-horizontal>
<vn-table model="model">
<vn-thead>
<vn-tr>
<vn-th field="amount">Credit</vn-th>
<vn-th field="created" default-order="DESC">Since</vn-th>
<vn-th>Employee</vn-th>
</vn-tr>
</vn-thead>
<vn-tbody>
<vn-tr ng-repeat="credit in credits track by credit.id">
<vn-td>{{::credit.amount | number:2}} €</vn-td>
<vn-td>{{::credit.created | date:'dd/MM/yyyy HH:mm'}}</vn-td>
<vn-td>{{::credit.worker.firstName}} {{::credit.worker.name}}</vn-td>
</vn-tr>
</vn-tbody>
<vn-empty-rows ng-if="model.data.length === 0" translate>
No results
</vn-empty-rows>
</vn-table>
</vn-vertical>
<vn-pagination
model="model"
scroll-selector="ui-view">
</vn-pagination>
</vn-card>
<vn-paging vn-one margin-large-top index="index" total="index.model.count"></vn-paging>
</vn-vertical>
<a ui-sref="client.card.credit.create" vn-bind="+" fixed-bottom-right>
<vn-float-button icon="add"></vn-float-button>

View File

@ -1,7 +1,24 @@
import ngModule from '../../module';
import FilterClientList from '../../filter-client-list';
class Controller {
constructor($stateParams) {
this.$stateParams = $stateParams;
this.filter = {
include: [
{
relation: 'worker',
scope: {
fields: ['firstName', 'name']
}
}
]
};
}
}
Controller.$inject = ['$stateParams'];
ngModule.component('vnClientCreditIndex', {
template: require('./index.html'),
controller: FilterClientList
controller: Controller
});

View File

@ -1,36 +1,58 @@
<mg-ajax path="/client/api/greuges/filter" options="vnIndexNonAuto"></mg-ajax>
<mg-ajax path="/client/api/greuges/{{edit.params.id}}/sumAmount" options="mgEdit"></mg-ajax>
<vn-crud-model
vn-id="model"
url="/client/api/greuges"
filter="::$ctrl.filter"
link="{clientFk: $ctrl.$stateParams.id}"
limit="20"
data="greuges">
</vn-crud-model>
<mg-ajax
path="/client/api/greuges/{{$ctrl.$stateParams.id}}/sumAmount"
options="mgEdit">
</mg-ajax>
<vn-vertical>
<vn-card pad-large>
<vn-vertical>
<vn-title>Greuge</vn-title>
<vn-grid-header on-order="$ctrl.onOrder(field, order)">
<vn-column-header vn-one pad-medium-h field="shipped" text="Date" default-order="ASC"></vn-column-header>
<vn-column-header vn-two pad-medium-h field="description" text="Comment"></vn-column-header>
<vn-column-header vn-one pad-medium-h field="amount" text="Amount"></vn-column-header>
<vn-column-header vn-one pad-medium-h field="greugeTypeFk" text="Type"></vn-column-header>
</vn-grid-header>
<vn-one class="list list-content">
<vn-horizontal
class="list list-element text-center"
pad-small-bottom
ng-repeat="greuge in index.model.instances track by greuge.id">
<vn-one pad-medium-h>{{::greuge.shipped | date:'dd/MM/yyyy HH:mm' }}</vn-one>
<vn-two pad-medium-h>{{::greuge.description}}</vn-two>
<vn-one pad-medium-h>{{::greuge.amount | number:2}} €</vn-one>
<vn-one pad-medium-h>{{::greuge.greugeType.name}}</vn-one>
</vn-horizontal>
</vn-one>
<vn-one class="text-center pad-small-v" ng-if="index.model.count === 0" translate>No results</vn-one>
<vn-horizontal vn-one class="list list-footer text-center">
<vn-one pad-medium-h></vn-one>
<vn-two pad-medium-h></vn-two>
<vn-one pad-medium-h ng-if="index.model.count > 0">{{edit.model.sumAmount | number:2}} €</vn-one>
<vn-one pad-medium-h></vn-one>
</vn-horizontal>
<vn-table model="model">
<vn-thead>
<vn-tr>
<vn-th field="shipped" default-order="DESC">Date</vn-th>
<vn-th field="description">Comment</vn-th>
<vn-th field="amount">Amount</vn-th>
<vn-th field="greugeTypeFk">Type</vn-th>
</vn-tr>
</vn-thead>
<vn-tbody>
<vn-tr ng-repeat="greuge in greuges">
<vn-td>{{::greuge.shipped | date:'dd/MM/yyyy HH:mm' }}</vn-td>
<vn-td>{{::greuge.description}}</vn-td>
<vn-td>{{::greuge.amount | currency: ' €': 2}}</vn-td>
<vn-td>{{::greuge.greugeType.name}}</vn-td>
</vn-tr>
</vn-tbody>
<vn-empty-rows ng-if="model.data.length === 0" translate>
No results
</vn-empty-rows>
<vn-tfoot ng-if="model.data.length > 0">
<vn-tr>
<vn-td></vn-td>
<vn-td></vn-td>
<vn-td>
<strong>{{edit.model.sumAmount | currency: ' €': 2}}</strong>
</vn-td>
<vn-td></vn-td>
</vn-tr>
</vn-tfoot>
</vn-table>
</vn-vertical>
<vn-pagination
model="model"
scroll-selector="ui-view">
</vn-pagination>
</vn-card>
<vn-paging margin-large-top vn-one index="index" total="index.model.count"></vn-paging>
</vn-vertical>
<a ui-sref="client.card.greuge.create" vn-bind="+" fixed-bottom-right>
<vn-float-button icon="add"></vn-float-button>

View File

@ -1,7 +1,24 @@
import ngModule from '../../module';
import FilterClientList from '../../filter-client-list';
class Controller {
constructor($stateParams) {
this.$stateParams = $stateParams;
this.filter = {
include: [
{
relation: "greugeType",
scope: {
fields: ["id", "name"]
}
}
]
};
}
}
Controller.$inject = ['$stateParams'];
ngModule.component('vnClientGreugeIndex', {
template: require('./index.html'),
controller: FilterClientList
controller: Controller
});

View File

@ -1,34 +1,42 @@
<mg-ajax path="/client/api/InvoiceOuts/filter" options="vnIndexNonAuto"></mg-ajax>
<vn-crud-model
vn-id="model"
url="/client/api/InvoiceOuts"
filter="{}"
link="{clientFk: $ctrl.$stateParams.id}"
limit="20"
data="invoices">
</vn-crud-model>
<vn-vertical>
<vn-card pad-large>
<vn-vertical>
<vn-title>Invoices</vn-title>
<vn-vertical style="text-align: center;">
<vn-grid-header on-order="$ctrl.onOrder(field, order)">
<vn-column-header vn-one field="ref" text="Reference" default-order="ASC"></vn-column-header>
<vn-column-header vn-one field="issued" text="Issue date"></vn-column-header>
<vn-column-header vn-one field="dued" text="Due date"></vn-column-header>
<vn-column-header vn-one field="amount" text="Amount"></vn-column-header>
</vn-grid-header>
<vn-vertical>
<vn-one
ng-if="index.model.count > 0"
class="list list-content">
<vn-horizontal
class="list list-element"
pad-small-bottom
ng-repeat="invoice in index.model.instances track by invoice.id">
<vn-one>{{::invoice.ref}}</vn-one>
<vn-one>{{::invoice.issued | date:'dd/MM/yyyy' }}</vn-one>
<vn-one>{{::invoice.dued | date:'dd/MM/yyyy' }}</vn-one>
<vn-one>{{::invoice.amount | currency:'€':2}}</vn-one>
</vn-horizontal>
</vn-one>
<vn-one class="text-center pad-small-v" ng-if="index.model.count === 0" translate>No results</vn-one>
</vn-vertical>
<vn-horizontal vn-one class="list list-footer"></vn-horizontal>
</vn-vertical>
<vn-table model="model">
<vn-thead>
<vn-tr>
<vn-th field="ref" default-order="DESC">Reference</vn-th>
<vn-th field="issued">Issue date</vn-th>
<vn-th field="dued">Due date</vn-th>
<vn-th field="amount">Amount</vn-th>
</vn-tr>
</vn-thead>
<vn-tbody>
<vn-tr ng-repeat="invoice in invoices">
<vn-td>{{::invoice.ref}}</vn-td>
<vn-td>{{::invoice.issued | date:'dd/MM/yyyy' }}</vn-td>
<vn-td>{{::invoice.dued | date:'dd/MM/yyyy' }}</vn-td>
<vn-td>{{::invoice.amount | currency:' €': 2}}</vn-td>
</vn-tr>
</vn-tbody>
<vn-empty-rows ng-if="model.data.length === 0" translate>
No results
</vn-empty-rows>
</vn-table>
</vn-vertical>
<vn-pagination
model="model"
scroll-selector="ui-view">
</vn-pagination>
</vn-card>
<vn-paging margin-large-top vn-one index="index" total="index.model.count"></vn-paging>
</vn-vertical>

View File

@ -1,13 +1,12 @@
import ngModule from '../module';
import FilterClientList from '../filter-client-list';
class Controller extends FilterClientList {
constructor($scope, $timeout, $state, $stateParams) {
super($scope, $timeout, $state);
$scope.$stateParams = $stateParams;
class Controller {
constructor($stateParams) {
this.$stateParams = $stateParams;
}
}
Controller.$inject = ['$scope', '$timeout', '$state', '$stateParams'];
Controller.$inject = ['$stateParams'];
ngModule.component('vnClientInvoice', {
template: require('./index.html'),

View File

@ -1,30 +1,43 @@
<mg-ajax path="/client/api/Mandates/filter" options="vnIndexNonAuto"></mg-ajax>
<vn-crud-model
vn-id="model"
url="/client/api/Mandates"
filter="::$ctrl.filter"
link="{clientFk: $ctrl.$stateParams.id}"
limit="20"
data="mandates">
</vn-crud-model>
<vn-vertical>
<vn-card pad-large>
<vn-vertical>
<vn-title>Mandate</vn-title>
<vn-grid-header on-order="$ctrl.onOrder(field, order)">
<vn-column-header vn-one pad-medium-h field="id" text="Id"></vn-column-header>
<vn-column-header vn-one pad-medium-h field="companyFk" text="Company"></vn-column-header>
<vn-column-header vn-one pad-medium-h field="mandateTypeFk" text="Type"></vn-column-header>
<vn-column-header vn-one pad-medium-h field="created" text="Register date" default-order="ASC"></vn-column-header>
<vn-column-header vn-one pad-medium-h field="finished" text="End date"></vn-column-header>
</vn-grid-header>
<vn-one class="list list-content">
<vn-horizontal
vn-one class="list list-element text-center"
pad-small-bottom
ng-repeat="mandate in index.model.instances track by mandate.id">
<vn-one pad-medium-h>{{::mandate.id}}</vn-one>
<vn-one pad-medium-h>{{::mandate.company.code}}</vn-one>
<vn-one pad-medium-h>{{::mandate.mandateType.name}}</vn-one>
<vn-one pad-medium-h>{{::mandate.created | date:'dd/MM/yyyy HH:mm' }}</vn-one>
<vn-one pad-medium-h>{{::mandate.finished | date:'dd/MM/yyyy HH:mm' || '-'}}</vn-one>
</vn-horizontal>
</vn-one>
<vn-one class="text-center pad-small-v" ng-if="index.model.count === 0" translate>No results</vn-one>
<vn-horizontal vn-one class="list list-footer"></vn-horizontal>
<vn-table model="model">
<vn-thead>
<vn-tr>
<vn-th field="id">Id</vn-th>
<vn-th field="companyFk">Company</vn-th>
<vn-th field="mandateTypeFk">Type</vn-th>
<vn-th field="created" default-order="DESC">Register date</vn-th>
<vn-th field="finished">End date</vn-th>
</vn-tr>
</vn-thead>
<vn-tbody>
<vn-tr ng-repeat="mandate in mandates">
<vn-td>{{::mandate.id}}</vn-td>
<vn-td>{{::mandate.company.code}}</vn-td>
<vn-td>{{::mandate.mandateType.name}}</vn-td>
<vn-td>{{::mandate.created | date:'dd/MM/yyyy HH:mm' }}</vn-td>
<vn-td>{{::mandate.finished | date:'dd/MM/yyyy HH:mm' || '-'}}</vn-td>
</vn-tr>
</vn-tbody>
<vn-empty-rows ng-if="model.data.length === 0" translate>
No results
</vn-empty-rows>
</vn-table>
</vn-vertical>
<vn-pagination
model="model"
scroll-selector="ui-view">
</vn-pagination>
</vn-card>
<vn-paging vn-one margin-large-top index="index" total="index.model.count"></vn-paging>
</vn-vertical>

View File

@ -1,7 +1,30 @@
import ngModule from '../module';
import FilterClientList from '../filter-client-list';
class Controller {
constructor($stateParams) {
this.$stateParams = $stateParams;
this.filter = {
include: [
{
relation: "mandateType",
scope: {
fields: ["id", "name"]
}
},
{
relation: "company",
scope: {
fields: ["id", "code"]
}
}
]
};
}
}
Controller.$inject = ['$stateParams'];
ngModule.component('vnClientMandate', {
template: require('./index.html'),
controller: FilterClientList
controller: Controller
});

View File

@ -1,25 +1,31 @@
<vn-crud-model
vn-id="model"
url="/client/api/clientObservations"
filter="{order: 'created DESC'}"
link="{clientFk: $ctrl.$stateParams.id}"
data="notes">
</vn-crud-model>
<vn-vertical>
<vn-card ng-show="$ctrl.observations.length" pad-large>
<vn-card pad-large>
<vn-title>Notes</vn-title>
<vn-vertical
ng-repeat="n in $ctrl.observations"
ng-repeat="note in notes"
pad-small
border-solid
border-radius
margin-small-bottom>
<vn-horizontal margin-small-bottom style="color: #666">
<vn-one>{{::n.worker.firstName}} {{::n.worker.name}}</vn-one>
<vn-auto>{{::n.created | date:'dd/MM/yyyy HH:mm'}}</vn-auto>
<vn-one>{{::note.worker.firstName}} {{::note.worker.name}}</vn-one>
<vn-auto>{{::note.created | date:'dd/MM/yyyy HH:mm'}}</vn-auto>
</vn-horizontal>
<vn-horizontal class="text">
{{::n.text}}
{{::note.text}}
</vn-horizontal>
</vn-vertical>
</vn-card>
</vn-vertical>
<vn-float-button
fixed-bottom-right
ng-click="$ctrl.newObservation()"
vn-bind="+"
icon="add">
</vn-float-button>
<a ui-sref="client.card.note.create({id: $ctrl.$stateParams.id})" vn-bind="+" fixed-bottom-right>
<vn-float-button icon="add"></vn-float-button>
</a>

View File

@ -1,31 +1,12 @@
import ngModule from '../../module';
export default class Controller {
constructor($http, $state) {
this.$http = $http;
this.$state = $state;
}
$onChanges() {
if (this.client) {
this.getObservation(this.client.id);
}
}
getObservation(clientId) {
let json = JSON.stringify({where: {clientFk: this.client.id}, order: 'created DESC'});
this.$http.get(`/client/api/clientObservations?filter=${json}`).then(
json => {
this.observations = json.data;
}
);
}
newObservation() {
this.$state.go("client.card.note.create", {id: this.client.id});
constructor($stateParams) {
this.$stateParams = $stateParams;
}
}
Controller.$inject = ['$http', '$state'];
Controller.$inject = ['$stateParams'];
ngModule.component('vnClientNote', {
template: require('./index.html'),

View File

@ -1,58 +0,0 @@
import './index';
describe('Client', () => {
describe('Component vnClientNote', () => {
let $componentController;
let $state;
let $httpBackend;
let controller;
beforeEach(() => {
angular.mock.module('client');
});
beforeEach(angular.mock.inject((_$componentController_, _$state_, _$httpBackend_) => {
$componentController = _$componentController_;
$state = _$state_;
$httpBackend = _$httpBackend_;
$httpBackend.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({});
controller = $componentController('vnClientNote', {$state: $state});
}));
describe('$onChanges()', () => {
it(`should call getObservation() with the client id`, () => {
controller.client = {
id: 1234
};
spyOn(controller, 'getObservation').and.returnValue();
controller.$onChanges();
expect(controller.getObservation).toHaveBeenCalledWith(1234);
});
});
describe('$getObservation()', () => {
it(`should request to GET the client notes`, () => {
controller.client = {id: '1234'};
let jsonString = JSON.stringify({where: {clientFk: '1234'}, order: 'created DESC'});
let json = {data: 'some data'};
$httpBackend.when('GET', `/client/api/clientObservations?filter=${jsonString}`).respond(json);
$httpBackend.expectGET(`/client/api/clientObservations?filter=${jsonString}`, {Accept: 'application/json, text/plain, */*'});
controller.getObservation();
$httpBackend.flush();
expect(controller.observations).toEqual(json);
});
});
describe('$newObservation()', () => {
it(`should redirect the user to the newObservation view`, () => {
controller.client = {id: '1234'};
spyOn(controller.$state, 'go');
controller.newObservation();
expect(controller.$state.go).toHaveBeenCalledWith('client.card.note.create', Object({id: '1234'}));
});
});
});
});

View File

@ -1,36 +1,53 @@
<mg-ajax path="/client/api/Recoveries/filter" options="vnIndexNonAuto"></mg-ajax>
<vn-crud-model
vn-id="model"
url="/client/api/Recoveries"
filter="{}"
link="{clientFk: $ctrl.$stateParams.id}"
limit="20"
data="recoveries">
</vn-crud-model>
<vn-vertical>
<vn-card pad-large>
<vn-vertical>
<vn-title>Recovery</vn-title>
<vn-grid-header on-order="$ctrl.onOrder(field, order)">
<vn-column-header vn-one pad-medium-h field="started" text="Since" default-order="ASC"></vn-column-header>
<vn-column-header vn-one pad-medium-h field="finished" text="To"></vn-column-header>
<vn-column-header vn-one pad-medium-h field="amount" text="Amount"></vn-column-header>
<vn-column-header vn-one pad-medium-h field="period" text="Period"></vn-column-header>
</vn-grid-header>
<vn-one class="list list-content">
<vn-horizontal
vn-one class="list list-element text-center"
pad-small-bottom
ng-repeat="recovery in index.model.instances track by $index">
<vn-none pad-medium-h orange>
<i class="material-icons pointer"
vn-tooltip="Finish that recovery period"
ng-if="!recovery.finished"
ng-click="$ctrl.setFinished(recovery)">lock</i>
</vn-none>
<vn-one pad-medium-h>{{::recovery.started | date:'dd/MM/yyyy' }}</vn-one>
<vn-one pad-medium-h>{{recovery.finished | date:'dd/MM/yyyy' }}</vn-one>
<vn-one pad-medium-h>{{::recovery.amount | currency:'€':0}}</vn-one>
<vn-one pad-medium-h>{{::recovery.period}}</vn-one>
</vn-horizontal>
</vn-one>
<vn-one class="text-center pad-small-v" ng-if="index.model.count === 0" translate>No results</vn-one>
<vn-horizontal vn-one class="list list-footer"></vn-horizontal>
<vn-table model="model">
<vn-thead>
<vn-tr>
<vn-th></vn-th>
<vn-th field="started" default-order="DESC">Since</vn-th>
<vn-th field="finished">To</vn-th>
<vn-th field="amount">Amount</vn-th>
<vn-th field="period">Period</vn-th>
</vn-tr>
</vn-thead>
<vn-tbody>
<vn-tr ng-repeat="recovery in recoveries">
<vn-td>
<vn-icon
class="bright pointer"
icon="lock"
vn-tooltip="Finish that recovery period"
ng-if="!recovery.finished"
ng-click="$ctrl.setFinished(recovery)">
</vn-icon>
</vn-td>
<vn-td>{{::recovery.started | date:'dd/MM/yyyy' }}</vn-td>
<vn-td>{{recovery.finished | date:'dd/MM/yyyy' }}</vn-td>
<vn-td>{{::recovery.amount | currency:' €': 0}}</vn-td>
<vn-td>{{::recovery.period}}</vn-td>
</vn-tr>
</vn-tbody>
<vn-empty-rows ng-if="model.data.length === 0" translate>
No results
</vn-empty-rows>
</vn-table>
</vn-vertical>
<vn-pagination
model="model"
scroll-selector="ui-view">
</vn-pagination>
</vn-card>
<vn-paging vn-one margin-large-top index="index" total="index.model.count"></vn-paging>
</vn-vertical>
<a ui-sref="client.card.recovery.create" vn-bind="+" fixed-bottom-right>
<vn-float-button icon="add"></vn-float-button>

View File

@ -1,22 +1,23 @@
import ngModule from '../../module';
import FilterClientList from '../../filter-client-list';
class Controller extends FilterClientList {
constructor($scope, $timeout, $state, $http) {
super($scope, $timeout, $state);
class Controller {
constructor($stateParams, $scope, $http) {
this.$stateParams = $stateParams;
this.$scope = $scope;
this.$http = $http;
}
setFinished(recovery) {
if (!recovery.finished) {
let params = {finished: Date.now()};
this.$http.patch(`/client/api/Recoveries/${recovery.id}`, params).then(
() => this.$.index.accept()
() => this.$scope.model.refresh()
);
}
}
}
Controller.$inject = ['$scope', '$timeout', '$state', '$http'];
Controller.$inject = ['$stateParams', '$scope', '$http'];
ngModule.component('vnClientRecoveryIndex', {
template: require('./index.html'),

View File

@ -18,15 +18,17 @@ export default class Table {
this.order = order;
}
applyFilter(field = this.field, order = this.order) {
this.model.filter.order = `${field} ${order}`;
applyOrder(field = this.field, order = this.order) {
if (!field) return;
this.model.order = `${field} ${order}`;
this.model.refresh();
this.setActiveArrow();
}
$onChanges() {
if (this.model && this.model.filter)
this.applyFilter();
this.applyOrder();
}
setActiveArrow() {

View File

@ -78,6 +78,7 @@ vn-table {
}
vn-td, vn-th {
vertical-align: middle;
display: table-cell;
text-align: left;
padding: 10px;

View File

@ -57,7 +57,7 @@ export default class Th {
this.updateArrow();
this.table.applyFilter(this.field, this.order);
this.table.applyOrder(this.field, this.order);
}
/**

View File

@ -132,7 +132,7 @@ export default {
addCreditFloatButton: `${components.vnFloatButton}`,
creditInput: `${components.vnTextfield}[name="credit"]`,
saveButton: `${components.vnSubmit}`,
firstCreditText: 'vn-client-credit-index .list-element'
firstCreditText: 'vn-client-credit-index vn-card > div vn-table vn-tbody > vn-tr'
},
clientGreuge: {
greugeButton: `vn-menu-item a[ui-sref="client.card.greuge.index"]`,
@ -142,15 +142,15 @@ export default {
typeInput: `vn-autocomplete[field="$ctrl.greuge.greugeTypeFk"] input`,
typeSecondOption: `vn-autocomplete[field="$ctrl.greuge.greugeTypeFk"] vn-drop-down ul > li`,
saveButton: `${components.vnSubmit}`,
firstGreugeText: 'vn-client-greuge-index .list-element'
firstGreugeText: 'vn-client-greuge-index vn-card > div vn-table vn-tbody > vn-tr'
},
clientMandate: {
mandateButton: `vn-menu-item a[ui-sref="client.card.mandate"]`,
firstMandateText: 'vn-client-mandate .list-element'
firstMandateText: 'vn-client-mandate vn-card > div vn-table vn-tbody > vn-tr'
},
clientInvoices: {
invoicesButton: `vn-menu-item a[ui-sref="client.card.invoice"]`,
firstInvoiceText: 'vn-client-invoice .list-element'
firstInvoiceText: 'vn-client-invoice vn-card > div vn-table vn-tbody > vn-tr'
},
itemsIndex: {
createItemButton: `${components.vnFloatButton}`,

View File

@ -3,7 +3,7 @@
"title": "Changement des C.G.V",
"dear": "Chèr client,",
"bodyDescription": "Nous vous informons que les conditions de paiement ont changé. Voici les nouvelles conditions:",
"paymentMethod": "Méthod de paiement:",
"paymentMethod": "Méthode de paiement:",
"paymentDay": "Date paiement:",
"everyMonth": "de chaque mois",
"cardPaymentAdvice": "Su modo de pago actual implica que deberá abonar el importe de los pedidos realizados en el mismo día para que se puedan enviar.",