Skip to content

Commit a46efe4

Browse files
authored
Merge pull request #350 from algenty:20220603_fix_mapping_edit_mode
ShapeMap
2 parents ab51675 + 2d43d58 commit a46efe4

File tree

5 files changed

+59
-40
lines changed

5 files changed

+59
-40
lines changed

Diff for: src/globals_class.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ export class $GF {
927927
* @param {*} value
928928
* @memberof $GF
929929
*/
930-
static GetT4V(list: gf.TSelectAny[], value: any): string {
930+
GetT4V(list: gf.TSelectAny[], value: any): string {
931931
if (list) {
932932
for (let i = 0; i < list.length; i++) {
933933
const element = list[i];

Diff for: src/mapping_class.ts

+38-18
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import { XCell } from 'cell_class';
32
import { GFEvents } from 'flowcharting_base';
43
import { $GF, GFCONSTANT, GFPlugin, GFVariables } from 'globals_class';
@@ -106,16 +105,16 @@ abstract class GFMap<MapData extends gf.TDefObjMapData> {
106105
return this.data.pattern;
107106
}
108107
set pattern(v: string) {
109-
if(!v || v.length === 0 || v === this.data.pattern) {
108+
if (!v || v.length === 0 || v === this.data.pattern) {
110109
return;
111110
}
112111
this.data.pattern = v;
113-
this.change()
112+
this.change();
114113
}
115114

116115
//HIDDEN
117116
set hidden(v: boolean) {
118-
if(!v || v === this.data.hidden) {
117+
if (!v || v === this.data.hidden) {
119118
return;
120119
}
121120
this.data.hidden = v;
@@ -125,7 +124,6 @@ abstract class GFMap<MapData extends gf.TDefObjMapData> {
125124
return this.data.hidden;
126125
}
127126

128-
129127
//############################################################################
130128
//### LOGICS
131129
//############################################################################
@@ -152,8 +150,6 @@ abstract class GFMap<MapData extends gf.TDefObjMapData> {
152150
return this.options;
153151
}
154152

155-
156-
157153
/**
158154
* Get default stored data
159155
*
@@ -319,7 +315,34 @@ export class ShapeMap extends GFMap<gf.TShapeMapData> {
319315
protected _setType() {
320316
this.type = 'shape';
321317
}
318+
//############################################################################
319+
//### ACCESSORS
320+
//############################################################################
321+
set condition(v: gf.TColorOnKeys) {
322+
if(!v || v.length === 0 || v === this.data.colorOn) {
323+
return;
324+
}
325+
this.data.colorOn = v
326+
this.change();
327+
}
328+
get condition(): gf.TColorOnKeys {
329+
return this.data.colorOn;
330+
}
322331

332+
set style(v: gf.TStyleColorKeys) {
333+
if(!v || v.length === 0 || v === this.data.style) {
334+
return
335+
}
336+
this.data.style = v
337+
this.change();
338+
}
339+
get style(): gf.TStyleColorKeys {
340+
return this.data.style;
341+
}
342+
343+
//############################################################################
344+
//### LOGIC
345+
//############################################################################
323346
/**
324347
* Return default data
325348
*
@@ -736,14 +759,13 @@ class VMAP<VMAPType extends gf.TDefMapData> {
736759
events: GFEvents<MappingSignals> = GFEvents.create(mappingSignalsArray);
737760
constructor(data: VMAPType) {
738761
this.data = data;
739-
this.init()
762+
this.init();
740763
}
741764

742765
//############################################################################
743766
//### INIT/UPDATE/CHANGE/FREE
744767
//############################################################################
745-
init(): void {
746-
}
768+
init(): void {}
747769

748770
change(): void {
749771
this.events.emit('mapping_changed', this);
@@ -757,17 +779,17 @@ class VMAP<VMAPType extends gf.TDefMapData> {
757779
//### ACCESSORS GETTERS/SETTERS
758780
//############################################################################
759781
set hidden(v: boolean) {
760-
if( v !== this.data.hidden) {
782+
if (v !== this.data.hidden) {
761783
this.data.hidden = v;
762784
this.change();
763785
}
764786
}
765787
get hidden(): boolean {
766-
return this.data.hidden
788+
return this.data.hidden;
767789
}
768790

769791
set text(v: string) {
770-
if( v !== this.data.text) {
792+
if (v !== this.data.text) {
771793
this.data.text = v.trim();
772794
this.change();
773795
}
@@ -837,15 +859,14 @@ export class ValueMap extends VMAP<gf.TValueMapData> {
837859
//### INIT/UPDATE/CHANGE/FREE
838860
//############################################################################
839861

840-
841862
//############################################################################
842863
//### ACCESSORS
843864
//############################################################################
844865
get value(): string {
845866
return this.data.value ?? '';
846867
}
847868
set value(v: string) {
848-
if( v !== this.data.value) {
869+
if (v !== this.data.value) {
849870
this.data.value = v;
850871
this.change();
851872
}
@@ -941,15 +962,14 @@ export class RangeMap extends VMAP<gf.TRangeMapData> {
941962
//### INIT/UPDATE/CHANGE/FREE
942963
//############################################################################
943964

944-
945965
//############################################################################
946966
//### ACCESSORS
947967
//############################################################################
948968
get to(): string {
949969
return this.data.to ?? '';
950970
}
951971
set to(v: string) {
952-
if( v !== this.data.to) {
972+
if (v !== this.data.to) {
953973
this.data.to = v;
954974
this.change();
955975
}
@@ -958,7 +978,7 @@ export class RangeMap extends VMAP<gf.TRangeMapData> {
958978
return this.data.from ?? '';
959979
}
960980
set from(v: string) {
961-
if( v !== this.data.from) {
981+
if (v !== this.data.from) {
962982
this.data.from = v;
963983
this.change();
964984
}

Diff for: src/partials/rules/shapes/shapesTable.html

+18-20
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,10 @@
110110
<div role="cell" class="gf-table-cells gf-table-cells-resizable" id="what"
111111
ng-mouseleave="shape.displayWhatEdit = false;" ng-mouseover="shape.displayWhatEdit = true;"
112112
ng-style="{'width' : editor.shapesTable.getWidth('what')}"
113-
ng-attr-title="{{shape.getData().pattern}}">
113+
ng-attr-title="{{shape.pattern}}">
114114
<div class="gf-table-content" ng-show="shape.whatEdit !== true"
115115
ng-dblclick="shape.whatEdit = true;">
116-
{{shape.getData().pattern}}
116+
{{shape.pattern}}
117117
</div>
118118
<div ng-show="shape.displayWhatEdit === true && shape.whatEdit !== true"
119119
ng-click="shape.whatEdit = true;$GF.setFocus(shape.uid + '-what');"
@@ -126,48 +126,46 @@
126126
title="Select a shape in diagram">
127127
</div>
128128
<input type="text" ng-show="shape.whatEdit === true" class="gf-form-input"
129-
ng-model="shape.getData().pattern" style="margin-right: 2px;width : 100%"
129+
ng-model="shape.pattern" style="margin-right: 2px;width : 100%"
130130
ng-attr-id="{{shape.uid + '-what'}}" ng-model-onblur
131-
ng-blur="editor.onRulesChange();shape.whatEdit = false;"
131+
ng-blur="shape.whatEdit = false;"
132132
bs-typeahead="rule.getShapeMapOptions().identByProp !== 'metadata' ? editor.getCellNamesTypeHead : editor.getCellNamesMD"
133133
data-min-length="0" data-items="100" data-placement="right" />
134134
</div>
135135
<!-- WHEN -->
136136
<div role="cell" class="gf-table-cells gf-table-cells-resizable" id="when"
137137
ng-mouseleave="shape.displayWhenEdit = false;" ng-mouseover="shape.displayWhenEdit = true;"
138138
ng-style="{'width' : editor.shapesTable.getWidth('when')}"
139-
ng-attr-title="{{$GF.GetT4V( editor.colorOn, shape.getData().colorOn)}}">
139+
ng-attr-title="{{$GF.GetT4V( editor.colorOn, shape.condition)}}">
140140
<div class="gf-table-content" style="text-align: left;" ng-show="shape.whenEdit !== true">
141-
{{$GF.GetT4V( editor.colorOn, shape.getData().colorOn)}}
141+
{{$GF.GetT4V( editor.colorOn, shape.condition)}}
142142
</div>
143143
<div ng-show="shape.displayWhenEdit === true && shape.whenEdit !== true"
144144
ng-click="shape.whenEdit = true;$GF.setFocus( shape.uid + '-when' )"
145145
class="gf-icon-action gf-icon-edit gf-icon-withcontent" title="Edit condition">
146146
</div>
147-
<select class="gf-form-input" ng-model="shape.getData().colorOn" style="width:100%;"
147+
<select class="gf-form-input" ng-model="shape.condition" style="width:100%;"
148148
ng-attr-id="{{shape.uid + '-when'}}"
149-
ng-blur="editor.onRulesChange();shape.whenEdit = false;"
150-
ng-show="shape.whenEdit === true" ng-options="c.value as c.text for c in editor.colorOn"
151-
ng-change="editor.onRulesChange()">
149+
ng-blur="shape.whenEdit = false;"
150+
ng-show="shape.whenEdit === true" ng-options="c.value as c.text for c in editor.colorOn">
152151
</select>
153152
</div>
154153
<!-- HOW -->
155154
<div role="cell" class="gf-table-cells gf-table-cells-resizable" id="how"
156155
ng-mouseleave="shape.displayHowEdit = false;" ng-mouseover="shape.displayHowEdit = true;"
157156
ng-style="{'width' : editor.shapesTable.getWidth('how')}"
158-
ng-attr-title="{{$GF.GetT4V(editor.style, shape.getData().style)}}">
159-
<!-- {{shape.getData().style}} -->
157+
ng-attr-title="{{$GF.GetT4V(editor.style, shape.style)}}">
160158
<div class="gf-table-content" style="text-align: left;" ng-show="shape.howEdit !== true">
161-
{{$GF.GetT4V(editor.style, shape.getData().style)}}
159+
{{$GF.GetT4V(editor.style, shape.style)}}
162160
</div>
163161
<div ng-show="shape.displayHowEdit === true && shape.howEdit !== true"
164162
ng-click="shape.howEdit = true;$GF.setFocus( shape.uid + '-how' );"
165163
class="gf-icon-action gf-icon-edit gf-icon-withcontent" title="Edit method">
166164
</div>
167-
<select class="gf-form-input" ng-model="shape.getData().style" style="width:100%;"
165+
<select class="gf-form-input" ng-model="shape.style" style="width:100%;"
168166
ng-attr-id="{{shape.uid + '-how'}}"
169-
ng-blur="editor.onRulesChange();shape.howEdit = false;" ng-show="shape.howEdit === true"
170-
ng-options="c.value as c.text for c in editor.style" ng-change="editor.onRulesChange()">
167+
ng-blur="shape.howEdit = false;" ng-show="shape.howEdit === true"
168+
ng-options="c.value as c.text for c in editor.style">
171169
</select>
172170
<!-- <div style="display:inline-block;">
173171
<div class="gf-icon-fill gf-icon-action" * ng-click="selectStyle = true;"
@@ -186,19 +184,19 @@
186184
ng-style="{'width' : editor.shapesTable.getWidth('actions')}">
187185
<div class="gf-table-content gf-unselectable"
188186
style="text-align: left;justify-content: center;">
189-
<div ng-click="editor.removeShapeMap(rule,$index);editor.onRulesChange()"
187+
<div ng-click="ruleremoveShapeMap(shape)"
190188
title="Delete this mapping object" class="gf-icon-action gf-icon-remove">
191189
</div>
192190
<div title="Duplicate this mapping"
193-
ng-click="shape.isHidden() ? shape.show(): shape.hide();editor.onRulesChange()"
191+
ng-click="shape.hidden=!shape.hidden"
194192
title="Enable/Disable this mapping" class="gf-icon-action"
195-
ng-class="{'gf-icon-show': !shape.isHidden(), 'gf-icon-hide': shape.isHidden()}">
193+
ng-class="{'gf-icon-show': !shape.hidden, 'gf-icon-hide': shape.hidden}">
196194
</div>
197195
<div ng-click="editor.flowchartHandler.setMap(shape, rule.getShapeMapOptions())"
198196
title="Select a shape in diagram" class="gf-icon-action"
199197
ng-class="{'gf-icon-target': !editor.flowchartHandler.isMapping(shape), 'gf-icon-empty': editor.flowchartHandler.isMapping(shape)}">
200198
</div>
201-
<div ng-click="rule.cloneShapeMap(shape);editor.onRulesChange();"
199+
<div ng-click="rule.cloneShapeMap(shape)"
202200
title="Duplicate this mapping" class="gf-icon-action gf-icon-clone">
203201
</div>
204202
</div>

Diff for: src/rule_class.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1768,6 +1768,7 @@ export class Rule {
17681768
maps.splice(index, 1);
17691769
datas.splice(index, 1);
17701770
}
1771+
this.change();
17711772
}
17721773

17731774
//

Diff for: src/rules_options.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ export class RulesOptionsCtrl {
826826
const value = m.getValue(rule.aggregation, columnName);
827827
if (!DateTH.isValidDate(value)) {
828828
this.$gf.notify(
829-
`The value for the metric ${m.getName()} and the aggregation ${$GF.GetT4V(
829+
`The value for the metric ${m.getName()} and the aggregation ${this.$gf.GetT4V(
830830
this.aggregationTypes,
831831
rule.aggregation
832832
)} is not a valid date : ${value}`

0 commit comments

Comments
 (0)