diff --git a/client/client/src/card/card.html b/client/client/src/card/card.html
index e324e1bd9..dd7511537 100644
--- a/client/client/src/card/card.html
+++ b/client/client/src/card/card.html
@@ -7,14 +7,8 @@
-
-
diff --git a/client/client/src/descriptor/descriptor.html b/client/client/src/descriptor/descriptor.html
index 1e61e950b..118322c2e 100644
--- a/client/client/src/descriptor/descriptor.html
+++ b/client/client/src/descriptor/descriptor.html
@@ -1,14 +1,14 @@
-
+
{{::title}}:
- {{::$ctrl.client[field] | number:2}} €
+ {{::$ctrl.client[field] | number:2}} €
{{::$ctrl.client[field]}}
diff --git a/client/client/src/descriptor/descriptor.js b/client/client/src/descriptor/descriptor.js
index 169abce0f..c1ef8f54d 100644
--- a/client/client/src/descriptor/descriptor.js
+++ b/client/client/src/descriptor/descriptor.js
@@ -2,33 +2,33 @@ import ngModule from '../module';
import './style.scss';
export default class Controller {
- constructor($scope, $http, $translate) {
- this.$http = $http;
- this.fieldsToShow = {
- id: 'id',
- name: $translate.instant('name'),
- phone: $translate.instant('phone'),
- credit: $translate.instant('credit'),
- creditInsurance: $translate.instant('creditInsurance')
- };
+ constructor($translate) {
+ this.$translate = $translate;
+ // CLient fields to display
+ this.fields = ['id', 'name', 'phone', 'credit', 'creditInsurance'];
+ this.fieldsToShow = {};
}
- set active(value) {
- if (this._active !== value && this._active !== undefined)
- this.$http.put(`/client/api/Clients/${this.client.id}/activate`);
- this._active = value;
+ // concat 2 Arrays without duplicates
+ _concatFields(a, b) {
+ return a.concat(b.filter(item => a.indexOf(item) < 0));
}
- get active() {
- return this._active;
+
+ $onInit() {
+ let fields = (this.moreFields && this.moreFields instanceof Array) ? this._concatFields(this.fields, this.moreFields) : this.fields;
+ fields.forEach(field => {
+ this.fieldsToShow[field] = this.$translate.instant(field);
+ });
}
}
-Controller.$inject = ['$scope', '$http', '$translate'];
+Controller.$inject = [
+ '$translate'];
ngModule.component('vnDescriptor', {
template: require('./descriptor.html'),
controller: Controller,
bindings: {
client: '<',
- active: '<'
+ moreFields: ''
}
});
diff --git a/client/client/src/descriptor/descriptor.spec.js b/client/client/src/descriptor/descriptor.spec.js
index d591c2300..f5d0be1d0 100644
--- a/client/client/src/descriptor/descriptor.spec.js
+++ b/client/client/src/descriptor/descriptor.spec.js
@@ -3,30 +3,32 @@ import './descriptor.js';
describe('Client', () => {
describe('Component vnDescriptor', () => {
let $componentController;
- let $scope;
+ let $translate;
let controller;
beforeEach(() => {
angular.mock.module('client');
});
- beforeEach(angular.mock.inject((_$componentController_, $rootScope) => {
+ beforeEach(angular.mock.inject((_$componentController_, _$translate_) => {
$componentController = _$componentController_;
- $scope = $rootScope.$new();
- controller = $componentController('vnDescriptor', {$scope: $scope});
+ $translate = _$translate_;
+ controller = $componentController('vnDescriptor', {$translate: $translate});
}));
- describe('set active', () => {
- it('should check if active is defined and diferent from the new value', () => {
- controller.client = {id: 1};
+ describe('onInit()', () => {
+ it('should create Object with basic fields', () => {
+ controller.client = {
+ id: 1,
+ name: "Peter Parker",
+ phone: null,
+ mobile: "666666",
+ credit: 300,
+ creditInsurance: null
+ };
+ controller.$onInit();
- expect(controller._active).toBe(undefined);
- controller.active = false;
-
- expect(controller._active).toBe(false);
- controller.active = true;
-
- expect(controller._active).toBe(true);
+ expect(controller.fieldsToShow.id).toBe('id');
});
});
});