Client refactor
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Joan Sanchez 2020-03-17 11:17:50 +01:00
parent a601a615e2
commit 381f2a08ef
64 changed files with 220 additions and 302 deletions

View File

@ -14,7 +14,7 @@ describe('Claim', () => {
$httpBackend = _$httpBackend_; $httpBackend = _$httpBackend_;
const $element = angular.element('<vn-claim-summary></vn-claim-summary>'); const $element = angular.element('<vn-claim-summary></vn-claim-summary>');
controller = $componentController('vnClaimSummary', {$element, $scope}); controller = $componentController('vnClaimSummary', {$element, $scope});
controller._claim = {id: 1}; controller.claim = {id: 1};
controller.$.model = crudModel; controller.$.model = crudModel;
})); }));

View File

@ -1,7 +1,7 @@
import ngModule from '../../module'; import ngModule from '../../module';
import Component from 'core/lib/component'; import Section from 'salix/components/section';
export default class Controller extends Component { export default class Controller extends Section {
constructor($element, $) { constructor($element, $) {
super($element, $); super($element, $);

View File

@ -1,7 +1,7 @@
import ngModule from '../../module'; import ngModule from '../../module';
import Component from 'core/lib/component'; import Section from 'salix/components/section';
export default class Controller extends Component { export default class Controller extends Section {
removeObservation(index) { removeObservation(index) {
this.$.watcher.setDirty(); this.$.watcher.setDirty();
this.$.model.remove(index); this.$.model.remove(index);

View File

@ -1,6 +1,6 @@
<vn-crud-model <vn-crud-model
vn-id="model" vn-id="model"
url="Clients/{{$ctrl.$stateParams.id}}/addresses" url="Clients/{{$ctrl.$params.id}}/addresses"
filter="$ctrl.filter" filter="$ctrl.filter"
limit="10" limit="10"
data="$ctrl.addresses" data="$ctrl.addresses"

View File

@ -1,13 +1,10 @@
import ngModule from '../../module'; import ngModule from '../../module';
import Section from 'salix/components/section';
import './style.scss'; import './style.scss';
class Controller { class Controller extends Section {
constructor($http, $scope, $stateParams, $translate, vnApp) { constructor($element, $) {
this.$http = $http; super($element, $);
this.$scope = $scope;
this.$stateParams = $stateParams;
this.$translate = $translate;
this.vnApp = vnApp;
this.filter = { this.filter = {
fields: [ fields: [
'id', 'id',
@ -47,7 +44,7 @@ class Controller {
} }
setDefault(address) { setDefault(address) {
let query = `Clients/${this.$stateParams.id}`; let query = `Clients/${this.$params.id}`;
let params = {defaultAddressFk: address.id}; let params = {defaultAddressFk: address.id};
this.$http.patch(query, params).then(res => { this.$http.patch(query, params).then(res => {
if (res.data) { if (res.data) {
@ -72,7 +69,7 @@ class Controller {
}); });
} }
} }
Controller.$inject = ['$http', '$scope', '$stateParams', '$translate', 'vnApp']; Controller.$inject = ['$element', '$scope'];
ngModule.component('vnClientAddressIndex', { ngModule.component('vnClientAddressIndex', {
template: require('./index.html'), template: require('./index.html'),

View File

@ -15,9 +15,10 @@ describe('Client', () => {
$stateParams.id = 1; $stateParams.id = 1;
$httpBackend = _$httpBackend_; $httpBackend = _$httpBackend_;
$scope = $rootScope.$new(); $scope = $rootScope.$new();
controller = $componentController('vnClientAddressIndex', {$stateParams, $scope}); const $element = angular.element('<vn-client-address-index></vn-client-address-index>');
controller = $componentController('vnClientAddressIndex', {$element, $scope});
controller.client = {id: 101, defaultAddressFk: 121}; controller.client = {id: 101, defaultAddressFk: 121};
controller.$scope.model = crudModel; controller.$.model = crudModel;
})); }));
describe('setDefault()', () => { describe('setDefault()', () => {

View File

@ -97,7 +97,7 @@
<vn-td center shrink> <vn-td center shrink>
<a ng-show="balance.hasPdf" <a ng-show="balance.hasPdf"
target="_blank" target="_blank"
href="InvoiceOuts/{{::balance.id}}/download?access_token={{::$ctrl.accessToken}}"> href="InvoiceOuts/{{::balance.id}}/download?access_token={{::$ctrl.vnToken.token}}">
<vn-icon-button <vn-icon-button
icon="cloud_download" icon="cloud_download"
title="{{'Download PDF' | translate}}"> title="{{'Download PDF' | translate}}">

View File

@ -1,14 +1,10 @@
import ngModule from '../../module'; import ngModule from '../../module';
import Section from 'salix/components/section';
import './style.scss'; import './style.scss';
class Controller { class Controller extends Section {
constructor($stateParams, $translate, $scope, vnToken, $http, vnConfig) { constructor($element, $) {
this.$http = $http; super($element, $);
this.$ = $scope;
this.$stateParams = $stateParams;
this.$translate = $translate;
this.accessToken = vnToken.token;
this.vnConfig = vnConfig;
this.filter = { this.filter = {
include: { include: {
relation: 'company', relation: 'company',
@ -46,17 +42,16 @@ class Controller {
getData() { getData() {
return this.$.model.applyFilter(null, { return this.$.model.applyFilter(null, {
clientId: this.$stateParams.id, clientId: this.$params.id,
companyId: this.companyId companyId: this.companyId
}).then(() => this.$.riskModel.applyFilter({ }).then(() => this.$.riskModel.applyFilter({
where: { where: {
clientFk: this.$stateParams.id, clientFk: this.$params.id,
companyFk: this.companyId companyFk: this.companyId
} }
})).then(() => this.getBalances()); })).then(() => this.getBalances());
} }
getCurrentBalance() { getCurrentBalance() {
const clientRisks = this.$.riskModel.data; const clientRisks = this.$.riskModel.data;
const selectedCompany = this.companyId; const selectedCompany = this.companyId;
@ -79,7 +74,6 @@ class Controller {
}); });
} }
openCreateDialog() { openCreateDialog() {
this.$.balanceCreateDialog.companyFk = this.companyId; this.$.balanceCreateDialog.companyFk = this.companyId;
this.$.balanceCreateDialog.onResponse = () => this.getData(); this.$.balanceCreateDialog.onResponse = () => this.getData();
@ -110,7 +104,7 @@ class Controller {
} }
} }
Controller.$inject = ['$stateParams', '$translate', '$scope', 'vnToken', '$http', 'vnConfig']; Controller.$inject = ['$element', '$scope'];
ngModule.component('vnClientBalanceIndex', { ngModule.component('vnClientBalanceIndex', {
template: require('./index.html'), template: require('./index.html'),

View File

@ -10,7 +10,8 @@ describe('Client', () => {
beforeEach(angular.mock.inject((_$componentController_, $rootScope) => { beforeEach(angular.mock.inject((_$componentController_, $rootScope) => {
$componentController = _$componentController_; $componentController = _$componentController_;
let $scope = $rootScope.$new(); let $scope = $rootScope.$new();
controller = $componentController('vnClientBalanceIndex', {$scope}); const $element = angular.element('<vn-client-balance-index></vn-client-balance-index>');
controller = $componentController('vnClientBalanceIndex', {$element, $scope});
controller.$.model = {applyFilter: () => {}}; controller.$.model = {applyFilter: () => {}};
controller.$.riskModel = { controller.$.riskModel = {
applyFilter: () => {}, applyFilter: () => {},
@ -30,7 +31,7 @@ describe('Client', () => {
describe('getData()', () => { describe('getData()', () => {
it('should apply the filters on he models and get the client balance', () => { it('should apply the filters on he models and get the client balance', () => {
controller._companyId = 442; controller._companyId = 442;
controller.$stateParams.id = 101; controller.$params.id = 101;
jest.spyOn(controller, 'getBalances').mockReturnThis(); jest.spyOn(controller, 'getBalances').mockReturnThis();
jest.spyOn(controller.$.model, 'applyFilter').mockReturnValue(Promise.resolve()); jest.spyOn(controller.$.model, 'applyFilter').mockReturnValue(Promise.resolve());
jest.spyOn(controller.$.riskModel, 'applyFilter').mockReturnValue(Promise.resolve()); jest.spyOn(controller.$.riskModel, 'applyFilter').mockReturnValue(Promise.resolve());

View File

@ -1,7 +1,9 @@
import ngModule from '../module'; import ngModule from '../module';
import Section from 'salix/components/section';
ngModule.component('vnClientBasicData', { ngModule.component('vnClientBasicData', {
template: require('./index.html'), template: require('./index.html'),
controller: Section,
bindings: { bindings: {
client: '<' client: '<'
} }

View File

@ -2,7 +2,7 @@
vn-id="model" vn-id="model"
url="ClientContacts" url="ClientContacts"
fields="['id', 'name', 'phone', 'clientFk']" fields="['id', 'name', 'phone', 'clientFk']"
link="{clientFk: $ctrl.$stateParams.id}" link="{clientFk: $ctrl.$params.id}"
data="contacts" data="contacts"
auto-load="true"> auto-load="true">
</vn-crud-model> </vn-crud-model>

View File

@ -1,14 +1,9 @@
import ngModule from '../module'; import ngModule from '../module';
import Section from 'salix/components/section';
class Controller { class Controller extends Section {
constructor($scope, $stateParams, $translate) {
this.$scope = $scope;
this.$stateParams = $stateParams;
this.$translate = $translate;
}
add() { add() {
this.$scope.model.insert({ this.$.model.insert({
clientFk: this.client.id, clientFk: this.client.id,
name: this.$translate.instant('Phone'), name: this.$translate.instant('Phone'),
phone: null phone: null
@ -16,16 +11,13 @@ class Controller {
} }
onSubmit() { onSubmit() {
this.$scope.watcher.check(); this.$.watcher.check();
this.$scope.model.save().then(() => { this.$.model.save().then(() =>
this.$scope.watcher.notifySaved(); this.$.watcher.notifySaved()
this.$scope.model.refresh(); );
});
} }
} }
Controller.$inject = ['$scope', '$stateParams', '$translate'];
ngModule.component('vnClientContact', { ngModule.component('vnClientContact', {
template: require('./index.html'), template: require('./index.html'),
controller: Controller, controller: Controller,

View File

@ -1,12 +1,9 @@
import ngModule from '../module'; import ngModule from '../module';
import Section from 'salix/components/section';
export default class Controller { export default class Controller extends Section {
constructor($scope, $state, $http, $translate, vnApp) { constructor($element, $) {
this.$ = $scope; super($element, $);
this.$state = $state;
this.$http = $http;
this.$translate = $translate;
this.vnApp = vnApp;
this.client = { this.client = {
active: true active: true
}; };
@ -78,7 +75,7 @@ export default class Controller {
} }
} }
Controller.$inject = ['$scope', '$state', '$http', '$translate', 'vnApp']; Controller.$inject = ['$element', '$scope'];
ngModule.component('vnClientCreate', { ngModule.component('vnClientCreate', {
template: require('./index.html'), template: require('./index.html'),

View File

@ -22,7 +22,8 @@ describe('Client', () => {
}; };
} }
}; };
controller = $componentController('vnClientCreate', {$scope: $scope}); const $element = angular.element('<vn-client-create></vn-client-create>');
controller = $componentController('vnClientCreate', {$element, $scope});
})); }));
it('should define and set scope, state and client properties', () => { it('should define and set scope, state and client properties', () => {

View File

@ -1,19 +1,16 @@
import ngModule from '../../module'; import ngModule from '../../module';
import Section from 'salix/components/section';
class Controller { class Controller extends Section {
constructor($http, $filter, $state, $scope, $translate, vnApp) { constructor($element, $) {
this.$http = $http; super($element, $);
this.$state = $state;
this.$scope = $scope;
this.$translate = $translate;
this.vnApp = vnApp;
this.creditClassification = { this.creditClassification = {
started: $filter('date')(new Date(), 'yyyy-MM-dd HH:mm') started: this.$filter('date')(new Date(), 'yyyy-MM-dd HH:mm')
}; };
} }
onSubmit() { onSubmit() {
if (this.$scope.form.$invalid) if (this.$.form.$invalid)
return this.vnApp.showError(this.$translate.instant('Some fields are invalid')); return this.vnApp.showError(this.$translate.instant('Some fields are invalid'));
let query = `creditClassifications/createWithInsurance`; let query = `creditClassifications/createWithInsurance`;
@ -29,7 +26,7 @@ class Controller {
} }
} }
Controller.$inject = ['$http', '$filter', '$state', '$scope', '$translate', 'vnApp']; Controller.$inject = ['$element', '$scope'];
ngModule.component('vnClientCreditInsuranceCreate', { ngModule.component('vnClientCreditInsuranceCreate', {
template: require('./index.html'), template: require('./index.html'),

View File

@ -14,7 +14,8 @@ describe('Client', () => {
$scope.form = { $scope.form = {
$invalid: false $invalid: false
}; };
controller = $componentController('vnClientCreditInsuranceCreate', {$scope}); const $element = angular.element('<vn-client-credit-insurance-create></vn-client-credit-insurance-create>');
controller = $componentController('vnClientCreditInsuranceCreate', {$element, $scope});
controller.client = {id: 101}; controller.client = {id: 101};
controller.card = { controller.card = {
reload: () => {} reload: () => {}

View File

@ -1,12 +1,8 @@
import ngModule from '../../module'; import ngModule from '../../module';
import Section from 'salix/components/section';
import './style.scss'; import './style.scss';
class Controller { class Controller extends Section {
constructor($http, $scope) {
this.$http = $http;
this.$scope = $scope;
}
$onChanges() { $onChanges() {
if (this.client && this.client.id) if (this.client && this.client.id)
this._getClassifications(this.client.id); this._getClassifications(this.client.id);
@ -52,7 +48,7 @@ class Controller {
closeContract(classification) { closeContract(classification) {
this.classificationId = classification.id; this.classificationId = classification.id;
this.$scope.closeContract.show(); this.$.closeContract.show();
} }
returnDialog(response) { returnDialog(response) {
@ -65,8 +61,6 @@ class Controller {
} }
} }
Controller.$inject = ['$http', '$scope'];
ngModule.component('vnClientCreditInsuranceIndex', { ngModule.component('vnClientCreditInsuranceIndex', {
template: require('./index.html'), template: require('./index.html'),
controller: Controller, controller: Controller,

View File

@ -4,12 +4,15 @@ describe('Client', () => {
describe('Component vnClientCreditInsuranceIndex', () => { describe('Component vnClientCreditInsuranceIndex', () => {
let controller; let controller;
let $httpBackend; let $httpBackend;
let $scope;
beforeEach(ngModule('client')); beforeEach(ngModule('client'));
beforeEach(angular.mock.inject(($componentController, _$httpBackend_) => { beforeEach(angular.mock.inject(($componentController, _$httpBackend_, $rootScope) => {
$httpBackend = _$httpBackend_; $httpBackend = _$httpBackend_;
controller = $componentController('vnClientCreditInsuranceIndex'); $scope = $rootScope.$new();
const $element = angular.element('<vn-client-credit-insurance-index></vn-client-credit-insurance-index>');
controller = $componentController('vnClientCreditInsuranceIndex', {$element, $scope});
controller.client = {id: 101}; controller.client = {id: 101};
})); }));
@ -59,14 +62,14 @@ describe('Client', () => {
describe('closeContract()', () => { describe('closeContract()', () => {
it('should define the classificationId property of the controller and then call the show method()', () => { it('should define the classificationId property of the controller and then call the show method()', () => {
controller.$scope.closeContract = {show: () => {}}; controller.$.closeContract = {show: () => {}};
jest.spyOn(controller.$scope.closeContract, 'show'); jest.spyOn(controller.$.closeContract, 'show');
expect(controller.classificationId).toBeFalsy(); expect(controller.classificationId).toBeFalsy();
controller.closeContract({id: 1}); controller.closeContract({id: 1});
expect(controller.classificationId).toEqual(1); expect(controller.classificationId).toEqual(1);
expect(controller.$scope.closeContract.show).toHaveBeenCalledWith(); expect(controller.$.closeContract.show).toHaveBeenCalledWith();
}); });
}); });

View File

@ -1,25 +1,25 @@
import ngModule from '../../../module'; import ngModule from '../../../module';
import Section from 'salix/components/section';
class Controller { class Controller extends Section {
constructor($scope, $state, $filter) { constructor($element, $) {
this.$scope = $scope; super($element, $);
this.$state = $state;
this.insurance = { this.insurance = {
created: $filter('date')(new Date(), 'yyyy-MM-dd HH:mm:ss') created: this.$filter('date')(new Date(), 'yyyy-MM-dd HH:mm:ss')
}; };
} }
onSubmit() { onSubmit() {
let params = {classificationId: this.$state.params.classificationId}; let params = {classificationId: this.$params.classificationId};
let state = 'client.card.creditInsurance.insurance.index'; let state = 'client.card.creditInsurance.insurance.index';
this.$scope.watcher.submitGo(state, params).then(() => { this.$.watcher.submitGo(state, params).then(() => {
this.card.reload(); this.card.reload();
}); });
} }
} }
Controller.$inject = ['$scope', '$state', '$filter']; Controller.$inject = ['$element', '$scope'];
ngModule.component('vnClientCreditInsuranceInsuranceCreate', { ngModule.component('vnClientCreditInsuranceInsuranceCreate', {
template: require('./index.html'), template: require('./index.html'),

View File

@ -1,7 +1,7 @@
<vn-crud-model <vn-crud-model
vn-id="model" vn-id="model"
url="CreditInsurances" url="CreditInsurances"
link="{creditClassification: $ctrl.$stateParams.classificationId}" link="{creditClassification: $ctrl.$params.classificationId}"
limit="20" limit="20"
data="insurances" data="insurances"
auto-load="true"> auto-load="true">
@ -30,7 +30,7 @@
</div> </div>
<a <a
ng-if="!$ctrl.isClosed" ng-if="!$ctrl.isClosed"
ui-sref="client.card.creditInsurance.insurance.create({classificationId: {{$ctrl.$stateParams.classificationId}}})" ui-sref="client.card.creditInsurance.insurance.create({classificationId: {{$ctrl.$params.classificationId}}})"
fixed-bottom-right fixed-bottom-right
vn-tooltip="New credit" vn-tooltip="New credit"
vn-bind="+"> vn-bind="+">

View File

@ -1,9 +1,9 @@
import ngModule from '../../../module'; import ngModule from '../../../module';
import Section from 'salix/components/section';
class Controller { class Controller extends Section {
constructor($stateParams, $http) { constructor($element, $) {
this.$stateParams = $stateParams; super($element, $);
this.$http = $http;
this.isClosed = true; this.isClosed = true;
this.filter = { this.filter = {
include: [ include: [
@ -15,7 +15,7 @@ class Controller {
$onInit() { $onInit() {
let filter = { let filter = {
fields: ['finished'], fields: ['finished'],
where: {id: this.$stateParams.classificationId} where: {id: this.$params.classificationId}
}; };
filter = encodeURIComponent(JSON.stringify(filter)); filter = encodeURIComponent(JSON.stringify(filter));
@ -27,7 +27,7 @@ class Controller {
} }
} }
Controller.$inject = ['$stateParams', '$http']; Controller.$inject = ['$element', '$scope'];
ngModule.component('vnClientCreditInsuranceInsuranceIndex', { ngModule.component('vnClientCreditInsuranceInsuranceIndex', {
template: require('./index.html'), template: require('./index.html'),

View File

@ -4,13 +4,16 @@ describe('Client', () => {
describe('Component vnClientCreditInsuranceInsuranceIndex', () => { describe('Component vnClientCreditInsuranceInsuranceIndex', () => {
let controller; let controller;
let $httpBackend; let $httpBackend;
let $scope;
beforeEach(ngModule('client')); beforeEach(ngModule('client'));
beforeEach(angular.mock.inject(($componentController, _$httpBackend_) => { beforeEach(angular.mock.inject(($componentController, _$httpBackend_, $rootScope) => {
let $stateParams = {classificationId: 1}; $scope = $rootScope.$new();
$httpBackend = _$httpBackend_; $httpBackend = _$httpBackend_;
controller = $componentController('vnClientCreditInsuranceInsuranceIndex', {$stateParams}); const $element = angular.element('<vn-client-credit-insurance-insurance-index></vn-client-credit-insurance-insurance-index>');
controller = $componentController('vnClientCreditInsuranceInsuranceIndex', {$element, $scope});
controller.$params = {classificationId: 1};
})); }));
describe('$onInit()', () => { describe('$onInit()', () => {

View File

@ -1,17 +1,12 @@
import ngModule from '../../module'; import ngModule from '../../module';
import Section from 'salix/components/section';
class Controller { class Controller extends Section {
constructor($http, $scope, $state) {
this.$http = $http;
this.$scope = $scope;
this.$state = $state;
}
onSubmit() { onSubmit() {
this.$http.get(`Recoveries/${this.$state.params.id}/hasActiveRecovery`).then(res => { this.$http.get(`Recoveries/${this.$params.id}/hasActiveRecovery`).then(res => {
let activeRecovery = res.data; let activeRecovery = res.data;
if (activeRecovery) if (activeRecovery)
this.$scope.confirmation.show(); this.$.confirmation.show();
else else
this.addCredit(); this.addCredit();
}); });
@ -31,7 +26,7 @@ class Controller {
} }
addCredit() { addCredit() {
this.$scope.watcher.submit().then( this.$.watcher.submit().then(
() => { () => {
this.goToIndex(); this.goToIndex();
} }
@ -39,8 +34,6 @@ class Controller {
} }
} }
Controller.$inject = ['$http', '$scope', '$state'];
ngModule.component('vnClientCreditCreate', { ngModule.component('vnClientCreditCreate', {
template: require('./index.html'), template: require('./index.html'),
controller: Controller, controller: Controller,

View File

@ -30,7 +30,8 @@ describe('Client', () => {
$state = _$state_; $state = _$state_;
$state.params.id = 101; $state.params.id = 101;
$httpBackend = _$httpBackend_; $httpBackend = _$httpBackend_;
controller = $componentController('vnClientCreditCreate', {$scope, $state}); const $element = angular.element('<vn-client-credit-create></vn-client-credit-create>');
controller = $componentController('vnClientCreditCreate', {$element, $scope});
})); }));
describe('onSubmit()', () => { describe('onSubmit()', () => {
@ -42,13 +43,13 @@ describe('Client', () => {
}); });
it('should call show() method when the client have a recovery', () => { it('should call show() method when the client have a recovery', () => {
jest.spyOn(controller.$scope.confirmation, 'show'); jest.spyOn(controller.$.confirmation, 'show');
$httpBackend.whenGET(`Recoveries/101/hasActiveRecovery`).respond(true); $httpBackend.whenGET(`Recoveries/101/hasActiveRecovery`).respond(true);
$httpBackend.expectGET(`Recoveries/101/hasActiveRecovery`); $httpBackend.expectGET(`Recoveries/101/hasActiveRecovery`);
controller.onSubmit(); controller.onSubmit();
$httpBackend.flush(); $httpBackend.flush();
expect(controller.$scope.confirmation.show).toHaveBeenCalledWith(); expect(controller.$.confirmation.show).toHaveBeenCalledWith();
}); });
it('should call addCredit() method when the client doesnt have a recovery', () => { it('should call addCredit() method when the client doesnt have a recovery', () => {

View File

@ -2,7 +2,7 @@
vn-id="model" vn-id="model"
url="ClientCredits" url="ClientCredits"
filter="::$ctrl.filter" filter="::$ctrl.filter"
link="{clientFk: $ctrl.$stateParams.id}" link="{clientFk: $ctrl.$params.id}"
limit="20" limit="20"
data="credits" data="credits"
order="created DESC" order="created DESC"

View File

@ -1,8 +1,9 @@
import ngModule from '../../module'; import ngModule from '../../module';
import Section from 'salix/components/section';
class Controller { class Controller extends Section {
constructor($stateParams) { constructor($element, $) {
this.$stateParams = $stateParams; super($element, $);
this.filter = { this.filter = {
include: [ include: [
{ {
@ -22,7 +23,7 @@ class Controller {
} }
} }
Controller.$inject = ['$stateParams']; Controller.$inject = ['$element', '$scope'];
ngModule.component('vnClientCreditIndex', { ngModule.component('vnClientCreditIndex', {
template: require('./index.html'), template: require('./index.html'),

View File

@ -1,14 +1,10 @@
import ngModule from '../../module'; import ngModule from '../../module';
import Section from 'salix/components/section';
import './style.scss'; import './style.scss';
class Controller { class Controller extends Section {
constructor($scope, $http, $state, $translate, vnApp, vnConfig) { constructor($element, $) {
this.$ = $scope; super($element, $);
this.$http = $http;
this.$state = $state;
this.$translate = $translate;
this.vnApp = vnApp;
this.vnConfig = vnConfig;
this.dms = { this.dms = {
files: [], files: [],
hasFile: false, hasFile: false,
@ -106,7 +102,7 @@ class Controller {
} }
} }
Controller.$inject = ['$scope', '$http', '$state', '$translate', 'vnApp', 'vnConfig']; Controller.$inject = ['$element', '$scope'];
ngModule.component('vnClientDmsCreate', { ngModule.component('vnClientDmsCreate', {
template: require('./index.html'), template: require('./index.html'),

View File

@ -13,7 +13,8 @@ describe('Client', () => {
$scope = $rootScope.$new(); $scope = $rootScope.$new();
$httpBackend = _$httpBackend_; $httpBackend = _$httpBackend_;
$httpParamSerializer = _$httpParamSerializer_; $httpParamSerializer = _$httpParamSerializer_;
controller = $componentController('vnClientDmsCreate', {$scope}); const $element = angular.element('<vn-client-create></vn-client-create>');
controller = $componentController('vnClientDmsCreate', {$element, $scope});
controller._client = {id: 101, name: 'Bruce wayne'}; controller._client = {id: 101, name: 'Bruce wayne'};
})); }));

View File

@ -1,16 +1,8 @@
import ngModule from '../../module'; import ngModule from '../../module';
import Section from 'salix/components/section';
import './style.scss'; import './style.scss';
class Controller { class Controller extends Section {
constructor($scope, $http, $state, $translate, vnApp) {
this.$ = $scope;
this.$http = $http;
this.$state = $state;
this.$stateParams = $state.params;
this.$translate = $translate;
this.vnApp = vnApp;
}
get client() { get client() {
return this._client; return this._client;
} }
@ -38,7 +30,7 @@ class Controller {
} }
setDefaultParams() { setDefaultParams() {
const path = `Dms/${this.$stateParams.dmsId}`; const path = `Dms/${this.$params.dmsId}`;
this.$http.get(path).then(res => { this.$http.get(path).then(res => {
const dms = res.data && res.data; const dms = res.data && res.data;
this.dms = { this.dms = {
@ -55,7 +47,7 @@ class Controller {
} }
onSubmit() { onSubmit() {
const query = `dms/${this.$stateParams.dmsId}/updateFile`; const query = `dms/${this.$params.dmsId}/updateFile`;
const options = { const options = {
method: 'POST', method: 'POST',
url: query, url: query,
@ -93,8 +85,6 @@ class Controller {
} }
} }
Controller.$inject = ['$scope', '$http', '$state', '$translate', 'vnApp'];
ngModule.component('vnClientDmsEdit', { ngModule.component('vnClientDmsEdit', {
template: require('./index.html'), template: require('./index.html'),
controller: Controller, controller: Controller,

View File

@ -5,16 +5,16 @@ describe('Client', () => {
let controller; let controller;
let $scope; let $scope;
let $httpBackend; let $httpBackend;
let $state;
beforeEach(ngModule('client')); beforeEach(ngModule('client'));
beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_) => { beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_) => {
$scope = $rootScope.$new(); $scope = $rootScope.$new();
$httpBackend = _$httpBackend_; $httpBackend = _$httpBackend_;
$state = {params: {dmsId: 1}}; const $element = angular.element('<vn-client-dms-edit></vn-client-dms-edit>');
controller = $componentController('vnClientDmsEdit', {$scope, $state}); controller = $componentController('vnClientDmsEdit', {$element, $scope});
controller._client = {id: 1}; controller._client = {id: 1};
controller.$params = {dmsId: 1};
})); }));
describe('client() setter', () => { describe('client() setter', () => {

View File

@ -1,7 +1,7 @@
<vn-crud-model <vn-crud-model
vn-id="model" vn-id="model"
url="ClientDms" url="ClientDms"
link="{clientFk: $ctrl.$stateParams.id}" link="{clientFk: $ctrl.$params.id}"
filter="::$ctrl.filter" filter="::$ctrl.filter"
limit="20" limit="20"
data="$ctrl.clientDms" data="$ctrl.clientDms"
@ -56,7 +56,7 @@
<vn-td shrink> <vn-td shrink>
<a target="_blank" <a target="_blank"
title="{{'Download file' | translate}}" title="{{'Download file' | translate}}"
href="api/dms/{{::document.dmsFk}}/downloadFile?access_token={{::$ctrl.accessToken}}"> href="api/dms/{{::document.dmsFk}}/downloadFile?access_token={{::$ctrl.vnToken.token}}">
{{::document.dms.file}} {{::document.dms.file}}
</a> </a>
</vn-td> </vn-td>
@ -70,7 +70,7 @@
</vn-td> </vn-td>
<vn-td shrink> <vn-td shrink>
<a target="_blank" <a target="_blank"
href="api/dms/{{::document.dmsFk}}/downloadFile?access_token={{::$ctrl.accessToken}}"> href="api/dms/{{::document.dmsFk}}/downloadFile?access_token={{::$ctrl.vnToken.token}}">
<vn-icon-button <vn-icon-button
icon="cloud_download" icon="cloud_download"
title="{{'Download file' | translate}}"> title="{{'Download file' | translate}}">

View File

@ -1,14 +1,10 @@
import ngModule from '../../module'; import ngModule from '../../module';
import Section from 'salix/components/section';
import './style.scss'; import './style.scss';
class Controller { class Controller extends Section {
constructor($stateParams, $scope, vnToken, $http, vnApp, $translate) { constructor($element, $) {
this.$stateParams = $stateParams; super($element, $);
this.$ = $scope;
this.accessToken = vnToken.token;
this.$http = $http;
this.vnApp = vnApp;
this.$translate = $translate;
this.filter = { this.filter = {
include: { include: {
relation: 'dms', relation: 'dms',
@ -71,7 +67,7 @@ class Controller {
} }
} }
Controller.$inject = ['$stateParams', '$scope', 'vnToken', '$http', 'vnApp', '$translate']; Controller.$inject = ['$element', '$scope'];
ngModule.component('vnClientDmsIndex', { ngModule.component('vnClientDmsIndex', {
template: require('./index.html'), template: require('./index.html'),

View File

@ -14,7 +14,8 @@ describe('Client', () => {
$componentController = _$componentController_; $componentController = _$componentController_;
$httpBackend = _$httpBackend_; $httpBackend = _$httpBackend_;
$scope = $rootScope.$new(); $scope = $rootScope.$new();
controller = $componentController('vnClientDmsIndex', {$: $scope}); const $element = angular.element('<vn-client-dms-index></vn-client-dms-index>');
controller = $componentController('vnClientDmsIndex', {$element, $scope});
controller.$.model = crudModel; controller.$.model = crudModel;
})); }));

View File

@ -1,7 +1,7 @@
import ngModule from '../module'; import ngModule from '../module';
import Component from 'core/lib/component'; import Section from 'salix/components/section';
export default class Controller extends Component { export default class Controller extends Section {
onSubmit() { onSubmit() {
const orgData = this.$.watcher.orgData; const orgData = this.$.watcher.orgData;
delete this.client.despiteOfClient; delete this.client.despiteOfClient;

View File

@ -1,12 +1,12 @@
import ngModule from '../../module'; import ngModule from '../../module';
import Section from 'salix/components/section';
class Controller { class Controller extends Section {
constructor($scope, $state, $filter) { constructor($element, $) {
this.$ = $scope; super($element, $);
this.$state = $state;
this.greuge = { this.greuge = {
shipped: new Date(), shipped: new Date(),
clientFk: $state.params.id clientFk: this.$params.id
}; };
} }
@ -26,7 +26,7 @@ class Controller {
); );
} }
} }
Controller.$inject = ['$scope', '$state', '$filter']; Controller.$inject = ['$element', '$scope'];
ngModule.component('vnClientGreugeCreate', { ngModule.component('vnClientGreugeCreate', {
template: require('./index.html'), template: require('./index.html'),

View File

@ -22,7 +22,8 @@ describe('Client', () => {
}; };
} }
}; };
controller = $componentController('vnClientGreugeCreate', {$scope: $scope}); const $element = angular.element('<vn-client-greuge-create></vn-client-greuge-create>');
controller = $componentController('vnClientGreugeCreate', {$element, $scope});
})); }));
describe('onSubmit()', () => { describe('onSubmit()', () => {

View File

@ -2,13 +2,13 @@
vn-id="model" vn-id="model"
url="greuges" url="greuges"
filter="::$ctrl.filter" filter="::$ctrl.filter"
link="{clientFk: $ctrl.$stateParams.id}" link="{clientFk: $ctrl.$params.id}"
limit="20" limit="20"
data="greuges" data="greuges"
auto-load="true"> auto-load="true">
</vn-crud-model> </vn-crud-model>
<mg-ajax <mg-ajax
path="greuges/{{$ctrl.$stateParams.id}}/sumAmount" path="greuges/{{$ctrl.$params.id}}/sumAmount"
options="mgEdit"> options="mgEdit">
</mg-ajax> </mg-ajax>
<vn-data-viewer <vn-data-viewer

View File

@ -1,8 +1,9 @@
import ngModule from '../../module'; import ngModule from '../../module';
import Section from 'salix/components/section';
class Controller { class Controller extends Section {
constructor($stateParams) { constructor($element, $) {
this.$stateParams = $stateParams; super($element, $);
this.filter = { this.filter = {
include: [ include: [
{ {
@ -17,7 +18,7 @@ class Controller {
} }
} }
Controller.$inject = ['$stateParams']; Controller.$inject = ['$element', '$scope'];
ngModule.component('vnClientGreugeIndex', { ngModule.component('vnClientGreugeIndex', {
template: require('./index.html'), template: require('./index.html'),

View File

@ -1,12 +1,7 @@
import ngModule from '../module'; import ngModule from '../module';
import Section from 'salix/components/section';
export default class Controller { export default class Controller extends Section {
constructor($scope, $state) {
this.$ = $scope;
this.$state = $state;
this.clientSelected = null;
}
exprBuilder(param, value) { exprBuilder(param, value) {
switch (param) { switch (param) {
case 'search': case 'search':
@ -52,7 +47,6 @@ export default class Controller {
{q: JSON.stringify({clientFk: client.id})}); {q: JSON.stringify({clientFk: client.id})});
} }
} }
Controller.$inject = ['$scope', '$state'];
ngModule.component('vnClientIndex', { ngModule.component('vnClientIndex', {
template: require('./index.html'), template: require('./index.html'),

View File

@ -2,13 +2,16 @@ import './index';
describe('Client index', () => { describe('Client index', () => {
let $state; let $state;
let $scope;
let controller; let controller;
beforeEach(ngModule('client')); beforeEach(ngModule('client'));
beforeEach(angular.mock.inject(($componentController, _$state_) => { beforeEach(angular.mock.inject(($componentController, _$state_, $rootScope) => {
$state = _$state_; $state = _$state_;
controller = $componentController('vnClientIndex'); $scope = $rootScope.$new();
const $element = angular.element('<vn-client-index></vn-client-index>');
controller = $componentController('vnClientIndex', {$element, $scope});
})); }));
describe('filterTickets()', () => { describe('filterTickets()', () => {

View File

@ -1 +1 @@
<vn-log url="ClientLogs" origin-id="$ctrl.$stateParams.id"></vn-log> <vn-log url="ClientLogs" origin-id="$ctrl.$params.id"></vn-log>

View File

@ -1,15 +1,7 @@
import ngModule from '../module'; import ngModule from '../module';
import Section from 'salix/components/section';
class Controller {
constructor($scope, $stateParams) {
this.$scope = $scope;
this.$stateParams = $stateParams;
}
}
Controller.$inject = ['$scope', '$stateParams'];
ngModule.component('vnClientLog', { ngModule.component('vnClientLog', {
template: require('./index.html'), template: require('./index.html'),
controller: Controller, controller: Section,
}); });

View File

@ -2,7 +2,7 @@
vn-id="model" vn-id="model"
url="Mandates" url="Mandates"
filter="::$ctrl.filter" filter="::$ctrl.filter"
link="{clientFk: $ctrl.$stateParams.id}" link="{clientFk: $ctrl.$params.id}"
limit="20" limit="20"
data="mandates" data="mandates"
order="created DESC" order="created DESC"

View File

@ -1,8 +1,9 @@
import ngModule from '../module'; import ngModule from '../module';
import Section from 'salix/components/section';
class Controller { class Controller extends Section {
constructor($stateParams) { constructor($element, $) {
this.$stateParams = $stateParams; super($element, $);
this.filter = { this.filter = {
include: [ include: [
{ {
@ -21,7 +22,7 @@ class Controller {
} }
} }
Controller.$inject = ['$stateParams']; Controller.$inject = ['$element', '$scope'];
ngModule.component('vnClientMandate', { ngModule.component('vnClientMandate', {
template: require('./index.html'), template: require('./index.html'),

View File

@ -2,7 +2,7 @@
vn-id="model" vn-id="model"
url="clientObservations" url="clientObservations"
filter="$ctrl.filter" filter="$ctrl.filter"
link="{clientFk: $ctrl.$stateParams.id}" link="{clientFk: $ctrl.$params.id}"
data="notes" data="notes"
auto-load="true"> auto-load="true">
</vn-crud-model> </vn-crud-model>
@ -24,7 +24,7 @@
</vn-card> </vn-card>
</vn-data-viewer> </vn-data-viewer>
<a vn-tooltip="New note" <a vn-tooltip="New note"
ui-sref="client.card.note.create({id: $ctrl.$stateParams.id})" ui-sref="client.card.note.create({id: $ctrl.$params.id})"
vn-bind="+" vn-bind="+"
fixed-bottom-right> fixed-bottom-right>
<vn-float-button icon="add"></vn-float-button> <vn-float-button icon="add"></vn-float-button>

View File

@ -1,16 +1,17 @@
import ngModule from '../../module'; import ngModule from '../../module';
import Section from 'salix/components/section';
import './style.scss'; import './style.scss';
export default class Controller { export default class Controller extends Section {
constructor($stateParams) { constructor($element, $) {
this.$stateParams = $stateParams; super($element, $);
this.filter = { this.filter = {
order: 'created DESC', order: 'created DESC',
}; };
} }
} }
Controller.$inject = ['$stateParams']; Controller.$inject = ['$element', '$scope'];
ngModule.component('vnClientNote', { ngModule.component('vnClientNote', {
template: require('./index.html'), template: require('./index.html'),

View File

@ -3,14 +3,6 @@ import Component from 'core/lib/component';
import './style.scss'; import './style.scss';
class Controller extends Component { class Controller extends Component {
constructor($element, $scope, $http, $translate, vnApp) {
super($element, $scope);
this.$ = $scope;
this.$http = $http;
this.$translate = $translate;
this.vnApp = vnApp;
}
get townSelection() { get townSelection() {
return this._townSelection; return this._townSelection;
} }
@ -54,8 +46,6 @@ class Controller extends Component {
} }
} }
Controller.$inject = ['$element', '$scope', '$http', '$translate', 'vnApp'];
ngModule.component('vnClientPostcode', { ngModule.component('vnClientPostcode', {
template: require('./index.html'), template: require('./index.html'),
controller: Controller, controller: Controller,

View File

@ -4,14 +4,15 @@ describe('Client', () => {
describe('Component vnClientPostcode', () => { describe('Component vnClientPostcode', () => {
let controller; let controller;
let $httpBackend; let $httpBackend;
let $element; let $scope;
beforeEach(ngModule('client')); beforeEach(ngModule('client'));
beforeEach(angular.mock.inject(($componentController, _$httpBackend_) => { beforeEach(angular.mock.inject(($componentController, _$httpBackend_, $rootScope) => {
$httpBackend = _$httpBackend_; $httpBackend = _$httpBackend_;
$element = angular.element('<vn-dialog></vn-dialog>'); $scope = $rootScope.$new();
controller = $componentController('vnClientPostcode', {$element}); const $element = angular.element('<vn-dialog></vn-dialog>');
controller = $componentController('vnClientPostcode', {$element, $scope});
controller.client = {id: 101}; controller.client = {id: 101};
})); }));

View File

@ -1,9 +1,9 @@
import ngModule from '../../module'; import ngModule from '../../module';
import Section from 'salix/components/section';
class Controller { class Controller extends Section {
constructor($scope, $state, $filter) { constructor($element, $) {
this.$ = $scope; super($element, $);
this.$state = $state;
this.recovery = { this.recovery = {
started: new Date() started: new Date()
}; };
@ -18,7 +18,7 @@ class Controller {
} }
onSubmit() { onSubmit() {
this.recovery.clientFk = this.$state.params.id; this.recovery.clientFk = this.$params.id;
this.$.watcher.submit().then( this.$.watcher.submit().then(
() => { () => {
this.goToIndex(); this.goToIndex();
@ -26,7 +26,7 @@ class Controller {
); );
} }
} }
Controller.$inject = ['$scope', '$state', '$filter']; Controller.$inject = ['$element', '$scope'];
ngModule.component('vnClientRecoveryCreate', { ngModule.component('vnClientRecoveryCreate', {
template: require('./index.html'), template: require('./index.html'),

View File

@ -22,7 +22,8 @@ describe('Client', () => {
}; };
} }
}; };
controller = $componentController('vnClientRecoveryCreate', {$scope: $scope}); const $element = angular.element('<vn-client-recovery-create></vn-client-recovery-create>');
controller = $componentController('vnClientRecoveryCreate', {$element, $scope});
})); }));
describe('onSubmit()', () => { describe('onSubmit()', () => {

View File

@ -1,7 +1,7 @@
<vn-crud-model <vn-crud-model
vn-id="model" vn-id="model"
url="Recoveries" url="Recoveries"
link="{clientFk: $ctrl.$stateParams.id}" link="{clientFk: $ctrl.$params.id}"
limit="20" limit="20"
data="recoveries" data="recoveries"
order="started DESC" order="started DESC"

View File

@ -1,24 +1,17 @@
import ngModule from '../../module'; import ngModule from '../../module';
import Section from 'salix/components/section';
class Controller { class Controller extends Section {
constructor($stateParams, $scope, $http) {
this.$stateParams = $stateParams;
this.$scope = $scope;
this.$http = $http;
}
setFinished(recovery) { setFinished(recovery) {
if (!recovery.finished) { if (!recovery.finished) {
let params = {finished: Date.now()}; let params = {finished: Date.now()};
this.$http.patch(`Recoveries/${recovery.id}`, params).then( this.$http.patch(`Recoveries/${recovery.id}`, params).then(
() => this.$scope.model.refresh() () => this.$.model.refresh()
); );
} }
} }
} }
Controller.$inject = ['$stateParams', '$scope', '$http'];
ngModule.component('vnClientRecoveryIndex', { ngModule.component('vnClientRecoveryIndex', {
template: require('./index.html'), template: require('./index.html'),
controller: Controller controller: Controller

View File

@ -1,16 +1,13 @@
import ngModule from '../../module'; import ngModule from '../../module';
import Component from 'core/lib/component'; import Section from 'salix/components/section';
import './style.scss'; import './style.scss';
class Controller extends Component { class Controller extends Section {
constructor($element, $, vnApp, $httpParamSerializer, vnConfig) { constructor($element, $) {
super($element, $); super($element, $);
this.vnApp = vnApp;
this.$httpParamSerializer = $httpParamSerializer;
this.vnConfig = vnConfig;
this.clientSample = { this.clientSample = {
clientFk: this.$params.id, clientFk: this.$params.id,
companyId: vnConfig.companyFk companyId: this.vnConfig.companyFk
}; };
} }
@ -82,12 +79,11 @@ class Controller extends Component {
if (isPreview) params.isPreview = true; if (isPreview) params.isPreview = true;
const serializedParams = this.$httpParamSerializer(params); const query = `email/${sampleType.code}`;
const query = `email/${sampleType.code}?${serializedParams}`; this.$http.get(query, {params}).then(cb);
this.$http.get(query).then(cb);
} }
} }
Controller.$inject = ['$element', '$scope', 'vnApp', '$httpParamSerializer', 'vnConfig']; Controller.$inject = ['$element', '$scope'];
ngModule.component('vnClientSampleCreate', { ngModule.component('vnClientSampleCreate', {
template: require('./index.html'), template: require('./index.html'),

View File

@ -2,7 +2,7 @@
vn-id="model" vn-id="model"
url="ClientSamples" url="ClientSamples"
filter="::$ctrl.filter" filter="::$ctrl.filter"
link="{clientFk: $ctrl.$stateParams.id}" link="{clientFk: $ctrl.$params.id}"
limit="20" limit="20"
data="samples" data="samples"
order="created DESC" order="created DESC"

View File

@ -1,9 +1,9 @@
import ngModule from '../../module'; import ngModule from '../../module';
import Section from 'salix/components/section';
class Controller { class Controller extends Section {
constructor($scope, $stateParams) { constructor($element, $) {
this.$ = $scope; super($element, $);
this.$stateParams = $stateParams;
this.filter = { this.filter = {
include: [ include: [
{ {
@ -45,7 +45,7 @@ class Controller {
} }
} }
Controller.$inject = ['$scope', '$stateParams']; Controller.$inject = ['$element', '$scope'];
ngModule.component('vnClientSampleIndex', { ngModule.component('vnClientSampleIndex', {
template: require('./index.html'), template: require('./index.html'),

View File

@ -1,23 +1,14 @@
import ngModule from '../module'; import ngModule from '../module';
import Component from 'core/lib/component'; import Section from 'salix/components/section';
import './style.scss'; import './style.scss';
class Controller extends Component { class Controller extends Section {
constructor($element, $scope, $http, $translate, vnApp) {
super($element, $scope);
this.$scope = $scope;
this.$http = $http;
this.$translate = $translate;
this.vnApp = vnApp;
}
open() { open() {
this.$scope.SMSDialog.show(); this.$.SMSDialog.show();
} }
charactersRemaining() { charactersRemaining() {
const element = this.$scope.message; const element = this.$.message;
const value = element.input.value; const value = element.input.value;
const maxLength = 160; const maxLength = 160;

View File

@ -15,7 +15,7 @@ describe('Client', () => {
controller = $componentController('vnClientSms', {$element, $scope}); controller = $componentController('vnClientSms', {$element, $scope});
controller.client = {id: 101}; controller.client = {id: 101};
controller.$params = {id: 101}; controller.$params = {id: 101};
controller.$scope.message = { controller.$.message = {
input: { input: {
value: 'My SMS' value: 'My SMS'
} }
@ -59,7 +59,7 @@ describe('Client', () => {
describe('charactersRemaining()', () => { describe('charactersRemaining()', () => {
it('should return the characters remaining in a element', () => { it('should return the characters remaining in a element', () => {
controller.$scope.message = { controller.$.message = {
input: { input: {
value: 'My message 0€' value: 'My message 0€'
} }

View File

@ -1,11 +1,8 @@
import ngModule from '../module'; import ngModule from '../module';
import Section from 'salix/components/section';
import './style.scss'; import './style.scss';
class Controller { class Controller extends Section {
constructor($http) {
this.$http = $http;
}
$onChanges() { $onChanges() {
if (!this.client) if (!this.client)
return; return;
@ -41,8 +38,6 @@ class Controller {
} }
} }
Controller.$inject = ['$http'];
ngModule.component('vnClientSummary', { ngModule.component('vnClientSummary', {
template: require('./index.html'), template: require('./index.html'),
controller: Controller, controller: Controller,

View File

@ -4,12 +4,15 @@ describe('Client', () => {
describe('Component vnClientSummary', () => { describe('Component vnClientSummary', () => {
let controller; let controller;
let $httpBackend; let $httpBackend;
let $scope;
beforeEach(ngModule('client')); beforeEach(ngModule('client'));
beforeEach(angular.mock.inject(($componentController, _$httpBackend_) => { beforeEach(angular.mock.inject(($componentController, _$httpBackend_, $rootScope) => {
$httpBackend = _$httpBackend_; $httpBackend = _$httpBackend_;
controller = $componentController('vnClientSummary'); $scope = $rootScope.$new();
const $element = angular.element('<vn-client-summary></vn-client-summary>');
controller = $componentController('vnClientSummary', {$element, $scope});
controller.client = {id: 101}; controller.client = {id: 101};
})); }));

View File

@ -1,11 +1,9 @@
import ngModule from '../module'; import ngModule from '../module';
import Section from 'salix/components/section';
export default class Controller { export default class Controller extends Section {
constructor($scope, $http, vnApp, $translate) { constructor($element, $) {
this.$ = $scope; super($element, $);
this.$http = $http;
this.vnApp = vnApp;
this.$translate = $translate;
this.canChangePassword = false; this.canChangePassword = false;
this.canEnableCheckBox = true; this.canEnableCheckBox = true;
} }
@ -64,7 +62,7 @@ export default class Controller {
return true; return true;
} }
} }
Controller.$inject = ['$scope', '$http', 'vnApp', '$translate']; Controller.$inject = ['$element', '$scope'];
ngModule.component('vnClientWebAccess', { ngModule.component('vnClientWebAccess', {
template: require('./index.html'), template: require('./index.html'),

View File

@ -13,7 +13,8 @@ describe('Component VnClientWebAccess', () => {
$httpBackend = _$httpBackend_; $httpBackend = _$httpBackend_;
vnApp = _vnApp_; vnApp = _vnApp_;
jest.spyOn(vnApp, 'showError'); jest.spyOn(vnApp, 'showError');
controller = $componentController('vnClientWebAccess', {$scope}); const $element = angular.element('<vn-client-web-access></vn-client-web-access>');
controller = $componentController('vnClientWebAccess', {$element, $scope});
})); }));
describe('$onChanges()', () => { describe('$onChanges()', () => {

View File

@ -1,7 +1,7 @@
<vn-crud-model <vn-crud-model
vn-id="model" vn-id="model"
url="clients/getTransactions" url="clients/getTransactions"
link="{clientFk: $ctrl.$stateParams.id}" link="{clientFk: $ctrl.$params.id}"
limit="20" limit="20"
data="transactions" data="transactions"
order="created DESC" order="created DESC"

View File

@ -1,18 +1,13 @@
import ngModule from '../module'; import ngModule from '../module';
import Section from 'salix/components/section';
import './style.scss'; import './style.scss';
class Controller { class Controller extends Section {
constructor($scope, $http, $stateParams) {
this.$scope = $scope;
this.$http = $http;
this.$stateParams = $stateParams;
}
confirm(transaction) { confirm(transaction) {
const path = 'Clients/confirmTransaction'; const path = 'Clients/confirmTransaction';
let data = {id: transaction.id}; let data = {id: transaction.id};
this.$http.post(path, data).then(res => { this.$http.post(path, data).then(res => {
this.$scope.model.refresh(); this.$.model.refresh();
}); });
} }
@ -26,8 +21,6 @@ class Controller {
} }
} }
Controller.$inject = ['$scope', '$http', '$stateParams'];
ngModule.component('vnClientWebPayment', { ngModule.component('vnClientWebPayment', {
template: require('./index.html'), template: require('./index.html'),
controller: Controller controller: Controller

View File

@ -15,7 +15,8 @@ describe('Component vnClientWebPayment', () => {
$httpBackend = _$httpBackend_; $httpBackend = _$httpBackend_;
vnApp = _vnApp_; vnApp = _vnApp_;
jest.spyOn(vnApp, 'showError'); jest.spyOn(vnApp, 'showError');
controller = $componentController('vnClientWebPayment', {$scope: $scope}); const $element = angular.element('<vn-client-web-payment></vn-client-web-payment>');
controller = $componentController('vnClientWebPayment', {$element, $scope});
})); }));
describe('confirm()', () => { describe('confirm()', () => {