#1716 ticket.summary añadir link a la Ruta
gitea/salix/dev This commit looks good Details

This commit is contained in:
Carlos Jimenez Ruiz 2019-09-26 09:05:54 +02:00
parent 65981099b6
commit 156c9ec3ab
4 changed files with 74 additions and 9 deletions

View File

@ -1,6 +1,12 @@
<section class="ellipsize">
<vn-label></vn-label>
<span></span>
<vn-label></vn-label>
<a
ng-show="$ctrl.state"
ui-sref="{{$ctrl.state}}($ctrl.stateParams)">
</a>
<span
ng-show="!$ctrl.state">
</span>
<vn-icon
ng-if="$ctrl.hasInfo"
vn-tooltip="{{$ctrl.info}}"

View File

@ -19,17 +19,24 @@ export default class Controller {
return this._label;
}
set value(value) {
let span = this.element.querySelector('span');
span.title = value;
span.textContent = value ? value : '-';
this._value = value;
get state() {
return this._state;
}
set state(value) {
this._state = value;
this.applyTextContent();
}
get value() {
return this._value;
}
set value(value) {
this._value = value;
this.applyTextContent();
}
get title() {
return this._title;
}
@ -39,6 +46,14 @@ export default class Controller {
span.title = value;
this._title = value;
}
applyTextContent() {
const targetElement = this.state ? 'a' : 'span';
const element = this.element.querySelector(targetElement);
const hasValue = this.value && this.value != '';
element.title = this.value;
element.textContent = hasValue ? this.value : '-';
}
}
Controller.$inject = ['$element', '$translate', '$attrs'];
@ -48,6 +63,8 @@ ngModule.component('vnLabelValue', {
bindings: {
title: '@?',
label: '@',
value: '@'
value: '@',
state: '@?',
stateParams: '<?'
}
});

View File

@ -0,0 +1,40 @@
import './label-value.js';
import template from './label-value.html';
describe('Component vnInputTime', () => {
let $element;
let controller;
beforeEach(angular.mock.module('vnCore', $translateProvider => {
$translateProvider.translations('en', {});
}));
beforeEach(angular.mock.inject($componentController => {
const $attrs = {};
$element = angular.element(`${template}`);
controller = $componentController('vnLabelValue', {$element, $attrs});
}));
describe('applyTextContent()', () => {
it(`should set the value on the span element as there's no navigation setted`, () => {
const value = 'I am the value';
controller.value = value;
controller.title = value;
controller.applyTextContent();
expect(controller.element.querySelector('span').textContent).toEqual(value);
expect(controller.element.querySelector('span').title).toEqual(value);
});
it(`should set the value on the anchor element as there's a navigation setted`, () => {
const value = 'I am the value';
controller.value = value;
controller.title = value;
controller.state = 'some.state.to.go';
controller.applyTextContent();
expect(controller.element.querySelector('a').textContent).toEqual(value);
expect(controller.element.querySelector('a').title).toEqual(value);
});
});
});

View File

@ -36,7 +36,9 @@
value="{{$ctrl.summary.landed | dateTime: 'dd/MM/yyyy'}}">
</vn-label-value>
<vn-label-value label="Route"
value="{{$ctrl.summary.routeFk}}">
value="{{$ctrl.summary.routeFk}}"
state="route.card.summary"
state-params="{id: $ctrl.summary.routeFk}">
</vn-label-value>
<vn-label-value label="Address"
value="{{$ctrl.formattedAddress}}">