Commit 700a6fa1ff8c60d7368fecbe8b9d087aaf17c9eb

Authored by Artem Halushko
1 parent 43367628

WIP on tooltips

... ... @@ -92,7 +92,7 @@ export default abstract class LeafletMap {
92 92 L.control['addmarker']({ position: 'topright' }).addTo(this.map);
93 93 }
94 94
95   - inited() {
  95 + inited() {///!!!!
96 96 return !!this.map;
97 97 }
98 98
... ...
... ... @@ -34,6 +34,8 @@ import { parseFunction, parseArray, parseData } from '@app/core/utils';
34 34 import { initSchema, addToSchema, mergeSchemes, addCondition, addGroupInfo } from '@app/core/schema-utils';
35 35 import { AttributeScope, EntityId } from '@app/shared/public-api';
36 36 import { forkJoin } from 'rxjs';
  37 +import { WidgetContext } from '@app/modules/home/models/widget-component.models';
  38 +import { AttributeService } from '@app/core/public-api';
37 39
38 40 export class MapWidgetController implements MapWidgetInterface {
39 41
... ... @@ -43,7 +45,7 @@ export class MapWidgetController implements MapWidgetInterface {
43 45 data;
44 46 settings;
45 47
46   - constructor(public mapProvider: MapProviders, private drawRoutes, public ctx, $element) {
  48 + constructor(public mapProvider: MapProviders, private drawRoutes, public ctx: WidgetContext, $element) {
47 49 if (this.map) {
48 50 this.map.map.remove();
49 51 delete this.map;
... ... @@ -67,6 +69,8 @@ export class MapWidgetController implements MapWidgetInterface {
67 69 }
68 70
69 71 setMarkerLocation = (e) => {
  72 + let s = this.ctx.$injector.get(AttributeService);
  73 + console.log("MapWidgetController -> setMarkerLocation -> s", s, s.saveEntityAttributes)
70 74 let attributeService = this.ctx.$scope.$injector.get(this.ctx.servicesMap.get('attributeService'));
71 75 forkJoin(
72 76 this.data.filter(data => !!e[data.dataKey.name])
... ...
... ... @@ -17,7 +17,7 @@
17 17 -->
18 18 <div class="trip-animation-widget">
19 19 <div class="trip-animation-label-container" *ngIf="settings.showLabel">
20   - {{settings.label | tbParseTemplate: activeTrip}}
  20 + {{settings.label | tbParseTemplate: activeTrip}}
21 21 </div>
22 22 <div class="trip-animation-container" layout="column">
23 23 <div class="map" #map></div>
... ... @@ -28,7 +28,7 @@
28 28 </button>
29 29 </div>
30 30 <div class="trip-animation-tooltip md-whiteframe-z4" layout="column"
31   - [ngClass]="{ 'trip-animation-tooltip-hidden':!settings.showTooltip}" [innerHTML]="mainTooltip"
  31 + [ngClass]="{'trip-animation-tooltip-hidden':!visibleTooltip}" [innerHTML]="mainTooltip"
32 32 [ngStyle]="{'background-color': settings.tooltipColor, 'opacity': settings.tooltipOpacity, 'color': settings.tooltipFontColor}">
33 33 </div>
34 34 </div>
... ...
... ... @@ -19,12 +19,14 @@ import _ from 'lodash';
19 19 import tinycolor from "tinycolor2";
20 20 import { interpolateOnPointSegment } from 'leaflet-geometryutil';
21 21
22   -import { Component, OnInit, Input, ViewChild, AfterViewInit, ChangeDetectorRef } from '@angular/core';
  22 +import { Component, OnInit, Input, ViewChild, AfterViewInit, ChangeDetectorRef, SecurityContext } from '@angular/core';
23 23 import { MapWidgetController, TbMapWidgetV2 } from '../lib/maps/map-widget2';
24 24 import { MapProviders } from '../lib/maps/map-models';
25   -import { parseArray } from '@app/core/utils';
  25 +import { parseArray, parseTemplate, safeExecute } from '@app/core/utils';
26 26 import { initSchema, addToSchema, addGroupInfo } from '@app/core/schema-utils';
27 27 import { tripAnimationSchema } from '../lib/maps/schemes';
  28 +import { DomSanitizer } from '@angular/platform-browser';
  29 +import { WidgetConfig } from '@app/shared/public-api';
28 30
29 31
30 32 @Component({
... ... @@ -34,7 +36,7 @@ import { tripAnimationSchema } from '../lib/maps/schemes';
34 36 })
35 37 export class TripAnimationComponent implements OnInit, AfterViewInit {
36 38
37   - @Input() ctx;
  39 + @Input() ctx: WidgetConfig;
38 40
39 41 @ViewChild('map') mapContainer;
40 42
... ... @@ -45,10 +47,11 @@ export class TripAnimationComponent implements OnInit, AfterViewInit {
45 47 interpolatedData = [];
46 48 widgetConfig;
47 49 settings;
48   - mainTooltip;
  50 + mainTooltip = '';
  51 + visibleTooltip = false;
49 52 activeTrip;
50 53
51   - constructor(private cd: ChangeDetectorRef) { }
  54 + constructor(private cd: ChangeDetectorRef,private sanitizer: DomSanitizer) { }
52 55
53 56 ngOnInit(): void {
54 57 this.widgetConfig = this.ctx.widgetConfig;
... ... @@ -74,6 +77,7 @@ export class TripAnimationComponent implements OnInit, AfterViewInit {
74 77 ngAfterViewInit() {
75 78 let ctxCopy = _.cloneDeep(this.ctx);
76 79 ctxCopy.settings.showLabel = false;
  80 + ctxCopy.settings.showTooltip = false;
77 81 this.mapWidget = new MapWidgetController(MapProviders.openstreet, false, ctxCopy, this.mapContainer.nativeElement);
78 82 }
79 83
... ... @@ -99,6 +103,10 @@ export class TripAnimationComponent implements OnInit, AfterViewInit {
99 103 }
100 104
101 105 showHideTooltip() {
  106 + console.log(this.activeTrip);
  107 + let tooltipText: string = this.settings.useTooltipFunction ? safeExecute(this.settings.tooolTipFunction) :
  108 + // this.mainTooltip = this.sanitizer.sanitize(SecurityContext.HTML, parseTemplate(tooltipText, this.activeTrip))
  109 + this.visibleTooltip = !this.visibleTooltip;
102 110 }
103 111
104 112 interpolateArray(originData, interpolatedIntervals) {
... ...