@sapui5/sap.ui.vbm 1.131.0 → 1.133.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,13 +12,14 @@ sap.ui.define([
12
12
  *
13
13
  * @private
14
14
  * @author SAP SE
15
- * @version 1.131.0
15
+ * @version 1.133.0
16
16
  * @alias sap.ui.vbm.vector.PayloadGenerator
17
17
  */
18
+ var adapter = {};
18
19
  const PayloadGenerator = BaseObject.extend("sap.ui.vbm.vector.PayloadGenerator", /** @lends sap.ui.vbm.vector.PayloadGenerator.prototype */ {
19
- constructor: function (adapter) {
20
+ constructor: function (_adapter) {
20
21
  BaseObject.call(this);
21
- this._adapter = adapter;
22
+ adapter = _adapter;
22
23
  }
23
24
  });
24
25
 
@@ -33,17 +34,34 @@ sap.ui.define([
33
34
  }
34
35
  return false;
35
36
  };
36
-
37
+ PayloadGenerator.fcodeSelect = function (action_name, action_id,action_obj,action_ins) {
38
+ const payload = {
39
+ version: "2.0",
40
+ "xmlns:VB": "VB",
41
+ Action: {
42
+ "name": action_name,
43
+ "object": action_obj,
44
+ "id": action_id,
45
+ "instance": action_ins
46
+ }
47
+ }
48
+ // Fire the submit event with the generated payload
49
+ adapter.fireSubmit({
50
+ data: JSON.stringify(payload)
51
+ });
52
+ };
37
53
  // Method to insert unique key-value pairs and update "VB:s" flags
38
- PayloadGenerator.insertUniqueKey = function (name, key, mergeArray) {
54
+ PayloadGenerator.insertUniqueKey = function (name, event, key, mergeArray) {
39
55
  // Update all existing entries' "VB:s" flag to false
40
- mergeArray.forEach(item => {
41
- if (item.name === name) {
42
- item.E.forEach(entry => {
43
- entry["VB:s"] = "false"; // Set all existing ones to false
44
- });
45
- }
46
- });
56
+ if (event === "CLICK") {
57
+ mergeArray.forEach(item => {
58
+ if (item.name === name) {
59
+ item.E.forEach(entry => {
60
+ entry["VB:s"] = "false"; // Set all existing ones to false
61
+ });
62
+ }
63
+ });
64
+ }
47
65
 
48
66
  let nameObject = mergeArray.find(item => item.name === name);
49
67
 
@@ -77,14 +95,14 @@ sap.ui.define([
77
95
 
78
96
  // Initialize objects for this specific call
79
97
  const keysObjects = {};
80
- const mergeArray = this.mergeArray; // This array persists across multiple clicks
98
+ const mergeArray = this.mergeArray; // This array persists across multiple clicks/selects
81
99
 
82
100
  keysObjects["K"] = object.properties.Key;
83
101
 
84
102
  // Insert only if the key is unique for "objectType"
85
- PayloadGenerator.insertUniqueKey(objectType, keysObjects["K"], mergeArray);
103
+ PayloadGenerator.insertUniqueKey(objectType, "CLICK", keysObjects["K"], mergeArray);
86
104
 
87
- var payload = {
105
+ const payload = {
88
106
  version: "2.0",
89
107
  "xmlns:VB": "VB",
90
108
  Action: {
@@ -121,10 +139,152 @@ sap.ui.define([
121
139
  };
122
140
 
123
141
  // Fire the submit event with the generated payload
124
- this._adapter.fireSubmit({
142
+ adapter.fireSubmit({
125
143
  data: JSON.stringify(payload)
126
144
  });
127
145
  };
146
+
147
+ PayloadGenerator.KeyboardHandler = (event, name) => {
148
+ const modifiers = {
149
+ code: event.keyCode,
150
+ shift: event.shiftKey,
151
+ ctrl: event.ctrlKey,
152
+ alt: event.altKey,
153
+ meta: event.metaKey
154
+ };
155
+
156
+ var data = {
157
+ "version": "2.0",
158
+ "xmlns:VB": "VB",
159
+ "Action": {
160
+ "name": name,
161
+ "Params": {
162
+ "Param": Object.entries(modifiers).map(([name, value]) => ({
163
+ "name": name,
164
+ "#": value
165
+ }))
166
+ }
167
+ }
168
+ };
169
+
170
+ this._adapter.fireSubmit({ data: JSON.stringify(data) });
171
+ };
172
+
173
+ PayloadGenerator.selectObjects = (objects) => {
174
+ // Initialize objects for this specific call
175
+ const keysObjects = {};
176
+ const mergeArray = this.mergeArray; // This array persists across multiple clicks/selects
177
+
178
+ // Set VB:s to false for all existing entries
179
+ mergeArray.forEach(item => {
180
+ item.E.forEach(entry => {
181
+ entry["VB:s"] = "false";
182
+ });
183
+ });
184
+ this.mergeArray = mergeArray; //Update it back
185
+
186
+ objects.forEach(object => {
187
+ switch (object.layer.type) {
188
+ case 'circle': // Spot
189
+ keysObjects["K"] = object.properties.Key;
190
+ // Insert only if the key is unique for "objectType"
191
+ PayloadGenerator.insertUniqueKey("Spot", "SELECT", keysObjects["K"], mergeArray);
192
+ break;
193
+ case 'line': // Link
194
+ keysObjects["K"] = object.properties.Key;
195
+ // Insert only if the key is unique for "objectType"
196
+ PayloadGenerator.insertUniqueKey("Link", "SELECT", keysObjects["K"], mergeArray);
197
+ break;
198
+ default:
199
+ break;
200
+ }
201
+ });
202
+
203
+ const payload = {
204
+ version: "2.0",
205
+ "xmlns:VB": "VB",
206
+ Action: {
207
+ name: "SELECT",
208
+ object: "General",
209
+ id: "GenSelect"
210
+ },
211
+ Data: {
212
+ Merge: {
213
+ N: mergeArray
214
+ }
215
+ }
216
+ }
217
+ // Fire the submit event with the generated payload
218
+ adapter.fireSubmit({
219
+ data: JSON.stringify(payload)
220
+ });
221
+ }
222
+
223
+
224
+ PayloadGenerator.onMapContextMenu = (coords, zoom, center, screenX, screenY) => {
225
+
226
+ const payload = {
227
+ version: "2.0",
228
+ "xmlns:VB": "VB",
229
+ Action: {
230
+ name: "CONTEXT_MENU_REQUEST",
231
+ object: "Map",
232
+ id: "7",
233
+ Params: {
234
+ Param: [
235
+ {
236
+ name: "x",
237
+ "#": screenX
238
+ },
239
+ {
240
+ name: "y",
241
+ "#": screenY
242
+ },
243
+ {
244
+ name: "scene",
245
+ "#": "MainScene"
246
+ }
247
+ ]
248
+ },
249
+ AddActionProperties: {
250
+ AddActionProperty: [
251
+ {
252
+ name: "pos",
253
+ "#": coords
254
+ },
255
+ {
256
+ name: "zoom",
257
+ "#": zoom
258
+ },
259
+ {
260
+ name: "centerpoint",
261
+ "#": center
262
+ },
263
+ {
264
+ name: "pitch",
265
+ "#": "0.0"
266
+ },
267
+ {
268
+ name: "yaw",
269
+ "#": "0.0"
270
+ }
271
+ ]
272
+ }
273
+ }
274
+ }
275
+
276
+ if (this.mergeArray.length > 0) {
277
+ // Ensure `payload`, `Data`, `Merge`, and `N` nodes exist and set `N` to this.mergeArray
278
+ payload.Data = payload.Data || {}; // Ensure `Data` exists
279
+ payload.Data.Merge = payload.Data.Merge || {}; // Ensure `Merge` exists under `Data`
280
+ payload.Data.Merge.N = this.mergeArray; // Set `N` to this.mergeArray
281
+ }
282
+
283
+ // Fire the submit event with the generated payload
284
+ adapter.fireSubmit({
285
+ data: JSON.stringify(payload)
286
+ });
287
+ }
128
288
 
129
289
  return PayloadGenerator;
130
- });
290
+ });
@@ -0,0 +1,119 @@
1
+ sap.ui.define([
2
+ "sap/ui/base/Object",
3
+ "./PayloadGenerator"
4
+ ], function (BaseObject, PayloadGenerator) {
5
+ 'use strict';
6
+
7
+ /**
8
+ * Constructor for a new RectangularSelection.
9
+ *
10
+ * @class
11
+ * Provides a class for doing Rectangular Selection on map.
12
+ *
13
+ * @private
14
+ * @author SAP SE
15
+ * @version 1.133.0
16
+ * @alias sap.ui.vbm.vector.RectangularSelection
17
+ */
18
+
19
+ // Variable to hold the starting xy coordinates
20
+ // when `mousedown` occured.
21
+ let start;
22
+
23
+ // Variable to hold the current xy coordinates
24
+ // when `mousemove` or `mouseup` occurs.
25
+ let current;
26
+
27
+ // Variable for the draw box element.
28
+ let box;
29
+ const RectangularSelection = BaseObject.extend("sap.ui.vbm.vector.RectangularSelection", /** @lends sap.ui.vbm.vector.RectangularSelection.prototype */ {
30
+ constructor: function (map) {
31
+ BaseObject.call(this);
32
+ this._map = map;
33
+ },
34
+
35
+ mouseDown(e, rPressed) {
36
+ var map = this._map;
37
+ const canvas = map.getCanvasContainer();
38
+ // Continue the rest of the function if the R Key is pressed.
39
+ if (!((rPressed) && (e.button === 0))) return;
40
+ // Disable default drag zooming when the R key is pressed.
41
+ map.dragPan.disable();
42
+
43
+ // Call functions for the following events
44
+ document.addEventListener('mousemove', onMouseMove);
45
+ document.addEventListener('mouseup', onMouseUp);
46
+ document.addEventListener('keydown', onKeyDown);
47
+
48
+ // Capture the first xy coordinates
49
+ start = mousePos(e);
50
+
51
+ function mousePos(e) {
52
+ const rect = canvas.getBoundingClientRect();
53
+ return new maplibregl.Point(
54
+ e.clientX - rect.left - canvas.clientLeft,
55
+ e.clientY - rect.top - canvas.clientTop
56
+ );
57
+ }
58
+ function onMouseMove(e) {
59
+ // Capture the ongoing xy coordinates
60
+ current = mousePos(e);
61
+
62
+ // Append the box element if it doesnt exist
63
+ if (!box) {
64
+ box = document.createElement('div');
65
+ box.classList.add('boxdraw');
66
+ canvas.appendChild(box);
67
+ }
68
+
69
+ const minX = Math.min(start.x, current.x),
70
+ maxX = Math.max(start.x, current.x),
71
+ minY = Math.min(start.y, current.y),
72
+ maxY = Math.max(start.y, current.y);
73
+
74
+ // Adjust width and xy position of the box element ongoing
75
+ const pos = `translate(${minX}px, ${minY}px)`;
76
+ box.style.transform = pos;
77
+ box.style.width = maxX - minX + 'px';
78
+ box.style.height = maxY - minY + 'px';
79
+ }
80
+ function onMouseUp(e) {
81
+ // Capture xy coordinates
82
+ finish([start, mousePos(e)]);
83
+ }
84
+
85
+ function onKeyDown(e) {
86
+ // If the ESC key is pressed
87
+ if (e.keyCode === 27) finish();
88
+ }
89
+ function finish(bbox) {
90
+ // Remove these events now that finish has been called.
91
+ document.removeEventListener('mousemove', onMouseMove);
92
+ document.removeEventListener('keydown', onKeyDown);
93
+ document.removeEventListener('mouseup', onMouseUp);
94
+
95
+ if (box) {
96
+ box.parentNode.removeChild(box);
97
+ box = null;
98
+ }
99
+
100
+ // If bbox exists. use this value as the argument for `queryRenderedFeatures`
101
+ if (bbox) {
102
+ const features = map.queryRenderedFeatures(bbox, {
103
+ layers: ['geojson-source-route', 'geojson-source-point']
104
+ });
105
+ //Only trigger payload if something is selected
106
+ if (features && features.length > 0) {
107
+ // Trigger a payload for the selected features
108
+ PayloadGenerator.selectObjects(features);
109
+ }
110
+ }
111
+
112
+ map.dragPan.enable();
113
+
114
+ }
115
+ }
116
+ });
117
+
118
+ return RectangularSelection;
119
+ });