@openui5/sap.ui.table 1.123.0 → 1.124.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.
- package/.eslintrc.json +9 -1
- package/package.json +3 -3
- package/src/sap/ui/table/.library +1 -1
- package/src/sap/ui/table/AnalyticalColumn.js +40 -40
- package/src/sap/ui/table/AnalyticalColumnMenu.js +11 -11
- package/src/sap/ui/table/AnalyticalTable.js +107 -107
- package/src/sap/ui/table/Column.js +83 -83
- package/src/sap/ui/table/ColumnMenu.js +54 -54
- package/src/sap/ui/table/CreationRow.js +29 -29
- package/src/sap/ui/table/CreationRowRenderer.js +21 -21
- package/src/sap/ui/table/Row.js +55 -56
- package/src/sap/ui/table/RowAction.js +27 -27
- package/src/sap/ui/table/RowActionItem.js +7 -7
- package/src/sap/ui/table/RowActionRenderer.js +3 -3
- package/src/sap/ui/table/RowSettings.js +28 -37
- package/src/sap/ui/table/Table.js +263 -266
- package/src/sap/ui/table/TablePersoController.js +46 -46
- package/src/sap/ui/table/TableRenderer.js +112 -113
- package/src/sap/ui/table/TreeTable.js +16 -16
- package/src/sap/ui/table/designtime/Table.designtime.js +2 -2
- package/src/sap/ui/table/extensions/Accessibility.js +185 -181
- package/src/sap/ui/table/extensions/AccessibilityRender.js +15 -15
- package/src/sap/ui/table/extensions/DragAndDrop.js +47 -47
- package/src/sap/ui/table/extensions/ExtensionBase.js +9 -9
- package/src/sap/ui/table/extensions/Keyboard.js +40 -40
- package/src/sap/ui/table/extensions/KeyboardDelegate.js +257 -264
- package/src/sap/ui/table/extensions/Pointer.js +108 -109
- package/src/sap/ui/table/extensions/Scrolling.js +289 -285
- package/src/sap/ui/table/extensions/ScrollingIOS.js +50 -50
- package/src/sap/ui/table/extensions/Synchronization.js +32 -32
- package/src/sap/ui/table/library.js +12 -12
- package/src/sap/ui/table/menus/ColumnHeaderMenuAdapter.js +9 -9
- package/src/sap/ui/table/menus/LegacyColumnMenuAdapter.js +35 -37
- package/src/sap/ui/table/menus/MobileColumnHeaderMenuAdapter.js +23 -23
- package/src/sap/ui/table/messagebundle_sh.properties +9 -9
- package/src/sap/ui/table/plugins/BindingSelection.js +26 -25
- package/src/sap/ui/table/plugins/MultiSelectionPlugin.js +77 -32
- package/src/sap/ui/table/plugins/ODataV4Selection.js +81 -35
- package/src/sap/ui/table/plugins/PluginBase.js +12 -12
- package/src/sap/ui/table/plugins/SelectionModelSelection.js +13 -12
- package/src/sap/ui/table/plugins/SelectionPlugin.js +3 -3
- package/src/sap/ui/table/plugins/V4Aggregation.js +38 -38
- package/src/sap/ui/table/rowmodes/Auto.js +59 -61
- package/src/sap/ui/table/rowmodes/Fixed.js +18 -18
- package/src/sap/ui/table/rowmodes/Interactive.js +42 -44
- package/src/sap/ui/table/rowmodes/RowMode.js +64 -63
- package/src/sap/ui/table/rowmodes/Type.js +1 -1
- package/src/sap/ui/table/rowmodes/Variable.js +4 -4
- package/src/sap/ui/table/rules/Accessibility.support.js +15 -16
- package/src/sap/ui/table/rules/Binding.support.js +11 -11
- package/src/sap/ui/table/rules/ColumnTemplate.support.js +10 -10
- package/src/sap/ui/table/rules/Plugins.support.js +7 -7
- package/src/sap/ui/table/rules/Rows.support.js +29 -29
- package/src/sap/ui/table/rules/TableHelper.support.js +10 -10
- package/src/sap/ui/table/themes/base/library.source.less +2 -0
- package/src/sap/ui/table/utils/TableUtils.js +130 -128
- package/src/sap/ui/table/utils/_BindingUtils.js +7 -7
- package/src/sap/ui/table/utils/_ColumnUtils.js +98 -97
- package/src/sap/ui/table/utils/_GroupingUtils.js +56 -56
- package/src/sap/ui/table/utils/_HookUtils.js +26 -26
- package/src/sap/ui/table/utils/_MenuUtils.js +19 -19
|
@@ -23,7 +23,7 @@ sap.ui.define([
|
|
|
23
23
|
|
|
24
24
|
"use strict";
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
const SelectionMode = library.SelectionMode;
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* Constructs an instance of sap.ui.table.plugins.MultiSelectionPlugin
|
|
@@ -51,7 +51,7 @@ sap.ui.define([
|
|
|
51
51
|
* @alias sap.ui.table.plugins.MultiSelectionPlugin
|
|
52
52
|
* @borrows sap.ui.table.plugins.PluginBase.findOn as findOn
|
|
53
53
|
*/
|
|
54
|
-
|
|
54
|
+
const MultiSelectionPlugin = SelectionPlugin.extend("sap.ui.table.plugins.MultiSelectionPlugin", {metadata: {
|
|
55
55
|
library: "sap.ui.table",
|
|
56
56
|
properties: {
|
|
57
57
|
/**
|
|
@@ -120,10 +120,6 @@ sap.ui.define([
|
|
|
120
120
|
MultiSelectionPlugin.prototype.init = function() {
|
|
121
121
|
SelectionPlugin.prototype.init.apply(this, arguments);
|
|
122
122
|
|
|
123
|
-
var oIcon = new Icon({src: IconPool.getIconURI(TableUtils.ThemeParameters.clearSelectionIcon), useIconTooltip: false});
|
|
124
|
-
oIcon.addStyleClass("sapUiTableSelectClear");
|
|
125
|
-
this.setAggregation("icon", oIcon, true);
|
|
126
|
-
|
|
127
123
|
this._bLimitReached = false;
|
|
128
124
|
this._bLimitDisabled = this.getLimit() === 0;
|
|
129
125
|
this.oInnerSelectionPlugin = null;
|
|
@@ -138,6 +134,7 @@ sap.ui.define([
|
|
|
138
134
|
this.oInnerSelectionPlugin.attachSelectionChange(this._onSelectionChange, this);
|
|
139
135
|
oTable.addAggregation("_hiddenDependents", this.oInnerSelectionPlugin);
|
|
140
136
|
oTable.setProperty("selectionMode", this.getSelectionMode());
|
|
137
|
+
updateHeaderSelectorIcon(this);
|
|
141
138
|
};
|
|
142
139
|
|
|
143
140
|
/**
|
|
@@ -159,7 +156,7 @@ sap.ui.define([
|
|
|
159
156
|
}
|
|
160
157
|
|
|
161
158
|
if (mConfig && mConfig.range) {
|
|
162
|
-
|
|
159
|
+
const iLastSelectedIndex = this.getSelectedIndex();
|
|
163
160
|
|
|
164
161
|
if (iLastSelectedIndex >= 0) {
|
|
165
162
|
this.addSelectionInterval(iLastSelectedIndex, oRow.getIndex());
|
|
@@ -182,17 +179,18 @@ sap.ui.define([
|
|
|
182
179
|
|
|
183
180
|
return {
|
|
184
181
|
headerSelector: {
|
|
185
|
-
type: this._bLimitDisabled ? "toggle" : "
|
|
182
|
+
type: this._bLimitDisabled ? "toggle" : "custom",
|
|
186
183
|
icon: this.getAggregation("icon"),
|
|
187
184
|
visible: this.getSelectionMode() === SelectionMode.MultiToggle && this.getShowHeaderSelector(),
|
|
188
|
-
enabled: this.
|
|
189
|
-
selected: this.getSelectableCount() > 0 && this.getSelectableCount() === this.getSelectedCount()
|
|
185
|
+
enabled: this.getSelectableCount() > 0,
|
|
186
|
+
selected: this.getSelectableCount() > 0 && this.getSelectableCount() === this.getSelectedCount(),
|
|
187
|
+
tooltip: this.getSelectedCount() === 0 ? TableUtils.getResourceText("TBL_SELECT_ALL") : TableUtils.getResourceText("TBL_DESELECT_ALL")
|
|
190
188
|
}
|
|
191
189
|
};
|
|
192
190
|
};
|
|
193
191
|
|
|
194
192
|
MultiSelectionPlugin.prototype.onHeaderSelectorPress = function() {
|
|
195
|
-
|
|
193
|
+
const mRenderConfig = this.getRenderConfig();
|
|
196
194
|
|
|
197
195
|
if (!mRenderConfig.headerSelector.visible || !mRenderConfig.headerSelector.enabled) {
|
|
198
196
|
return;
|
|
@@ -200,17 +198,28 @@ sap.ui.define([
|
|
|
200
198
|
|
|
201
199
|
if (mRenderConfig.headerSelector.type === "toggle") {
|
|
202
200
|
toggleSelection(this);
|
|
203
|
-
} else if (mRenderConfig.headerSelector.type === "
|
|
204
|
-
|
|
201
|
+
} else if (mRenderConfig.headerSelector.type === "custom") {
|
|
202
|
+
if (this.getSelectedCount() > 0) {
|
|
203
|
+
this.clearSelection();
|
|
204
|
+
} else {
|
|
205
|
+
this.addSelectionInterval(0, this._getHighestSelectableIndex());
|
|
206
|
+
}
|
|
205
207
|
}
|
|
206
208
|
};
|
|
207
209
|
|
|
208
210
|
MultiSelectionPlugin.prototype.onKeyboardShortcut = function(sType, oEvent) {
|
|
209
|
-
if (sType === "toggle") {
|
|
210
|
-
if (this._bLimitDisabled
|
|
211
|
-
|
|
211
|
+
if (sType === "toggle") { // ctrl + a
|
|
212
|
+
if (this._bLimitDisabled) {
|
|
213
|
+
if (!toggleSelection(this)) {
|
|
214
|
+
oEvent?.setMarked("sapUiTableClearAll");
|
|
215
|
+
}
|
|
216
|
+
} else {
|
|
217
|
+
const sSelectionMode = this.getSelectionMode();
|
|
218
|
+
if (sSelectionMode === SelectionMode.MultiToggle) {
|
|
219
|
+
this.addSelectionInterval(0, this._getHighestSelectableIndex());
|
|
220
|
+
}
|
|
212
221
|
}
|
|
213
|
-
} else if (sType === "clear") {
|
|
222
|
+
} else if (sType === "clear") { // ctrl + shift + a
|
|
214
223
|
this.clearSelection();
|
|
215
224
|
oEvent?.setMarked("sapUiTableClearAll");
|
|
216
225
|
}
|
|
@@ -233,7 +242,7 @@ sap.ui.define([
|
|
|
233
242
|
}
|
|
234
243
|
|
|
235
244
|
MultiSelectionPlugin.prototype.setSelectionMode = function(sSelectionMode) {
|
|
236
|
-
|
|
245
|
+
const oTable = this.getParent();
|
|
237
246
|
|
|
238
247
|
if (oTable) {
|
|
239
248
|
oTable.setProperty("selectionMode", sSelectionMode, true);
|
|
@@ -245,6 +254,8 @@ sap.ui.define([
|
|
|
245
254
|
|
|
246
255
|
this.setProperty("selectionMode", sSelectionMode);
|
|
247
256
|
|
|
257
|
+
updateHeaderSelectorIcon(this);
|
|
258
|
+
|
|
248
259
|
return this;
|
|
249
260
|
};
|
|
250
261
|
|
|
@@ -257,6 +268,9 @@ sap.ui.define([
|
|
|
257
268
|
// invalidate only when the limit changes from 0 to a positive value or vice versa
|
|
258
269
|
this.setProperty("limit", iLimit, !!this.getLimit() === !!iLimit);
|
|
259
270
|
this._bLimitDisabled = iLimit === 0;
|
|
271
|
+
|
|
272
|
+
updateHeaderSelectorIcon(this);
|
|
273
|
+
|
|
260
274
|
return this;
|
|
261
275
|
};
|
|
262
276
|
|
|
@@ -296,7 +310,7 @@ sap.ui.define([
|
|
|
296
310
|
return Promise.reject(new Error("Not possible if the limit is enabled"));
|
|
297
311
|
}
|
|
298
312
|
|
|
299
|
-
|
|
313
|
+
const iSelectableCount = this.getSelectableCount();
|
|
300
314
|
|
|
301
315
|
if (iSelectableCount === 0) {
|
|
302
316
|
return Promise.reject(new Error("Nothing to select"));
|
|
@@ -316,7 +330,7 @@ sap.ui.define([
|
|
|
316
330
|
* loaded. The Promise is rejected if the index is out of range.
|
|
317
331
|
*/
|
|
318
332
|
function prepareSelection(oPlugin, iIndexFrom, iIndexTo, bAddSelection) {
|
|
319
|
-
|
|
333
|
+
const iHighestSelectableIndex = oPlugin._getHighestSelectableIndex();
|
|
320
334
|
|
|
321
335
|
if (iIndexFrom < 0 && iIndexTo < 0 || iIndexFrom > iHighestSelectableIndex && iIndexTo > iHighestSelectableIndex) {
|
|
322
336
|
// Selection is not possible if the index range it completely out of the selectable range.
|
|
@@ -327,10 +341,10 @@ sap.ui.define([
|
|
|
327
341
|
iIndexFrom = Math.min(Math.max(0, iIndexFrom), iHighestSelectableIndex);
|
|
328
342
|
iIndexTo = Math.min(Math.max(0, iIndexTo), iHighestSelectableIndex);
|
|
329
343
|
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
344
|
+
const iLimit = oPlugin.getLimit();
|
|
345
|
+
const bReverse = iIndexTo < iIndexFrom; // Indicates whether the selection is made from bottom to top.
|
|
346
|
+
let iGetContextsStartIndex = bReverse ? iIndexTo : iIndexFrom;
|
|
347
|
+
let iGetContextsLength;
|
|
334
348
|
|
|
335
349
|
// If the start index is already selected, the range starts from the next index.
|
|
336
350
|
if (bAddSelection && oPlugin.isIndexSelected(iIndexFrom)) {
|
|
@@ -382,8 +396,8 @@ sap.ui.define([
|
|
|
382
396
|
* @public
|
|
383
397
|
*/
|
|
384
398
|
MultiSelectionPlugin.prototype.setSelectionInterval = function(iIndexFrom, iIndexTo, oEventPayload) {
|
|
385
|
-
|
|
386
|
-
|
|
399
|
+
const oTable = this.getTable();
|
|
400
|
+
const sSelectionMode = this.getSelectionMode();
|
|
387
401
|
|
|
388
402
|
if (sSelectionMode === SelectionMode.None) {
|
|
389
403
|
return Promise.reject(new Error("SelectionMode is '" + SelectionMode.None + "'"));
|
|
@@ -441,8 +455,8 @@ sap.ui.define([
|
|
|
441
455
|
* @public
|
|
442
456
|
*/
|
|
443
457
|
MultiSelectionPlugin.prototype.addSelectionInterval = function(iIndexFrom, iIndexTo, oEventPayload) {
|
|
444
|
-
|
|
445
|
-
|
|
458
|
+
const oTable = this.getTable();
|
|
459
|
+
const sSelectionMode = this.getSelectionMode();
|
|
446
460
|
|
|
447
461
|
if (sSelectionMode === SelectionMode.None) {
|
|
448
462
|
return Promise.reject(new Error("SelectionMode is '" + SelectionMode.None + "'"));
|
|
@@ -514,8 +528,9 @@ sap.ui.define([
|
|
|
514
528
|
};
|
|
515
529
|
|
|
516
530
|
/**
|
|
517
|
-
*
|
|
518
|
-
*
|
|
531
|
+
* Returns the number of selectable rows.
|
|
532
|
+
*
|
|
533
|
+
* @returns {int} The number of selectable rows.
|
|
519
534
|
*/
|
|
520
535
|
MultiSelectionPlugin.prototype.getSelectableCount = function() {
|
|
521
536
|
if (this.oInnerSelectionPlugin) {
|
|
@@ -578,6 +593,34 @@ sap.ui.define([
|
|
|
578
593
|
}
|
|
579
594
|
};
|
|
580
595
|
|
|
596
|
+
/**
|
|
597
|
+
* Changes the current icon and tooltip text of the header selection icon in the given plugin object based on the selection.
|
|
598
|
+
*
|
|
599
|
+
* @param {sap.ui.table.plugins.MultiSelectionPlugin} oPlugin The plugin to toggle the selection on.
|
|
600
|
+
*/
|
|
601
|
+
function updateHeaderSelectorIcon(oPlugin) {
|
|
602
|
+
if (oPlugin.getSelectionMode() === SelectionMode.MultiToggle && !oPlugin._bLimitDisabled) {
|
|
603
|
+
if (!oPlugin.getAggregation("icon")) {
|
|
604
|
+
const oIcon = new Icon({useIconTooltip: false});
|
|
605
|
+
oIcon.addStyleClass("sapUiTableSelectClear");
|
|
606
|
+
oPlugin.setAggregation("icon", oIcon, true);
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
const oIcon = oPlugin.getAggregation("icon");
|
|
610
|
+
const iSelectedCount = oPlugin.getSelectedCount();
|
|
611
|
+
|
|
612
|
+
if (oPlugin.getSelectableCount() === iSelectedCount) {
|
|
613
|
+
oIcon.setSrc(IconPool.getIconURI(TableUtils.ThemeParameters.allSelectedIcon));
|
|
614
|
+
} else if (iSelectedCount !== 0) {
|
|
615
|
+
oIcon.setSrc(IconPool.getIconURI(TableUtils.ThemeParameters.clearSelectionIcon));
|
|
616
|
+
} else {
|
|
617
|
+
oIcon.setSrc(IconPool.getIconURI(TableUtils.ThemeParameters.checkboxIcon));
|
|
618
|
+
}
|
|
619
|
+
} else {
|
|
620
|
+
oPlugin.destroyAggregation("icon");
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
|
|
581
624
|
/**
|
|
582
625
|
* Fires the _onSelectionChange event.
|
|
583
626
|
*
|
|
@@ -585,7 +628,9 @@ sap.ui.define([
|
|
|
585
628
|
* @private
|
|
586
629
|
*/
|
|
587
630
|
MultiSelectionPlugin.prototype._onSelectionChange = function(oEvent) {
|
|
588
|
-
|
|
631
|
+
const aRowIndices = oEvent.getParameter("rowIndices");
|
|
632
|
+
|
|
633
|
+
updateHeaderSelectorIcon(this);
|
|
589
634
|
|
|
590
635
|
this.fireSelectionChange({
|
|
591
636
|
rowIndices: aRowIndices,
|
|
@@ -610,7 +655,7 @@ sap.ui.define([
|
|
|
610
655
|
};
|
|
611
656
|
|
|
612
657
|
MultiSelectionPlugin.prototype.onThemeChanged = function() {
|
|
613
|
-
this
|
|
658
|
+
updateHeaderSelectorIcon(this);
|
|
614
659
|
};
|
|
615
660
|
|
|
616
661
|
return MultiSelectionPlugin;
|
|
@@ -20,8 +20,8 @@ sap.ui.define([
|
|
|
20
20
|
) {
|
|
21
21
|
"use strict";
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
const SelectionMode = library.plugins.SelectionMode;
|
|
24
|
+
const TableSelectionMode = library.SelectionMode;
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* Constructs an instance of sap.ui.table.plugins.ODataV4Selection.
|
|
@@ -36,7 +36,7 @@ sap.ui.define([
|
|
|
36
36
|
* @private
|
|
37
37
|
* @borrows sap.ui.table.plugins.PluginBase.findOn as findOn
|
|
38
38
|
*/
|
|
39
|
-
|
|
39
|
+
const ODataV4Selection = SelectionPlugin.extend("sap.ui.table.plugins.ODataV4Selection", {
|
|
40
40
|
metadata: {
|
|
41
41
|
library: "sap.ui.table",
|
|
42
42
|
properties: {
|
|
@@ -90,8 +90,7 @@ sap.ui.define([
|
|
|
90
90
|
|
|
91
91
|
ODataV4Selection.prototype.init = function() {
|
|
92
92
|
SelectionPlugin.prototype.init.apply(this, arguments);
|
|
93
|
-
|
|
94
|
-
var oIcon = new Icon({src: IconPool.getIconURI(TableUtils.ThemeParameters.clearSelectionIcon), useIconTooltip: false});
|
|
93
|
+
const oIcon = new Icon({src: IconPool.getIconURI(TableUtils.ThemeParameters.checkboxIcon), useIconTooltip: false});
|
|
95
94
|
oIcon.addStyleClass("sapUiTableSelectClear");
|
|
96
95
|
this.setAggregation("icon", oIcon, true);
|
|
97
96
|
|
|
@@ -111,7 +110,7 @@ sap.ui.define([
|
|
|
111
110
|
};
|
|
112
111
|
|
|
113
112
|
ODataV4Selection.prototype.setSelected = function(oRow, bSelected, mConfig) {
|
|
114
|
-
|
|
113
|
+
const oContext = oRow.getRowBindingContext();
|
|
115
114
|
|
|
116
115
|
if (!oContext || !isContextSelectable(oContext)) {
|
|
117
116
|
return;
|
|
@@ -141,9 +140,9 @@ sap.ui.define([
|
|
|
141
140
|
return;
|
|
142
141
|
}
|
|
143
142
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
143
|
+
let iIndexFrom = oPlugin._oRangeSelectionStartContext.getIndex();
|
|
144
|
+
const oContext = oRow.getRowBindingContext();
|
|
145
|
+
const iIndexTo = oContext ? oContext.getIndex() : -1;
|
|
147
146
|
|
|
148
147
|
// The start index is already selected in case of range selection, so the range needs to start from the next index.
|
|
149
148
|
if (iIndexFrom !== iIndexTo) {
|
|
@@ -154,7 +153,7 @@ sap.ui.define([
|
|
|
154
153
|
}
|
|
155
154
|
|
|
156
155
|
ODataV4Selection.prototype.isSelected = function(oRow) {
|
|
157
|
-
|
|
156
|
+
const oContext = oRow.getRowBindingContext();
|
|
158
157
|
return oContext ? oContext.isSelected() : false;
|
|
159
158
|
};
|
|
160
159
|
|
|
@@ -162,18 +161,51 @@ sap.ui.define([
|
|
|
162
161
|
return this.getSelectedContexts().length;
|
|
163
162
|
};
|
|
164
163
|
|
|
164
|
+
/**
|
|
165
|
+
* Returns the number of selectable rows.
|
|
166
|
+
*
|
|
167
|
+
* @param {sap.ui.table.plugins.ODataV4Selection} oPlugin The plugin to getthe number of selectable rows from.
|
|
168
|
+
* @returns {int} The number of selectable rows.
|
|
169
|
+
*/
|
|
170
|
+
function getSelectableCount(oPlugin) {
|
|
171
|
+
return oPlugin.getTableBinding()?.getLength() ?? 0;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Changes the current icon and tooltip text of the header selection icon in the given plugin object based on the selection.
|
|
176
|
+
*
|
|
177
|
+
* @param {sap.ui.table.plugins.ODataV4Selection} oPlugin The plugin to change the header selection icon on.
|
|
178
|
+
*/
|
|
179
|
+
function updateHeaderSelectorIcon(oPlugin) {
|
|
180
|
+
if (!oPlugin._isLimitDisabled()) {
|
|
181
|
+
const oIcon = oPlugin.getAggregation("icon");
|
|
182
|
+
const iSelectedCount = oPlugin.getSelectedCount();
|
|
183
|
+
|
|
184
|
+
if (getSelectableCount(oPlugin) === iSelectedCount) {
|
|
185
|
+
oIcon.setSrc(IconPool.getIconURI(TableUtils.ThemeParameters.allSelectedIcon));
|
|
186
|
+
} else if (iSelectedCount !== 0) {
|
|
187
|
+
oIcon.setSrc(IconPool.getIconURI(TableUtils.ThemeParameters.clearSelectionIcon));
|
|
188
|
+
} else {
|
|
189
|
+
oIcon.setSrc(IconPool.getIconURI(TableUtils.ThemeParameters.checkboxIcon));
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
165
194
|
ODataV4Selection.prototype.getRenderConfig = function() {
|
|
166
195
|
if (!this.isActive()) {
|
|
167
196
|
return SelectionPlugin.prototype.getRenderConfig.apply(this, arguments);
|
|
168
197
|
}
|
|
169
198
|
|
|
199
|
+
updateHeaderSelectorIcon(this);
|
|
200
|
+
|
|
170
201
|
return {
|
|
171
202
|
headerSelector: {
|
|
172
|
-
type: this._isLimitDisabled() ? "toggle" : "
|
|
203
|
+
type: this._isLimitDisabled() ? "toggle" : "custom",
|
|
173
204
|
icon: this.getAggregation("icon"),
|
|
174
205
|
visible: this.getSelectionMode() === SelectionMode.MultiToggle && !this.getHideHeaderSelector(),
|
|
175
|
-
enabled:
|
|
176
|
-
selected: areAllRowsSelected(this)
|
|
206
|
+
enabled: getSelectableCount(this) > 0,
|
|
207
|
+
selected: areAllRowsSelected(this),
|
|
208
|
+
tooltip: this.getSelectedCount() === 0 ? TableUtils.getResourceText("TBL_SELECT_ALL") : TableUtils.getResourceText("TBL_DESELECT_ALL")
|
|
177
209
|
}
|
|
178
210
|
};
|
|
179
211
|
};
|
|
@@ -189,7 +221,7 @@ sap.ui.define([
|
|
|
189
221
|
oPlugin.clearSelection();
|
|
190
222
|
return false;
|
|
191
223
|
} else if (oPlugin._isLimitDisabled()) {
|
|
192
|
-
|
|
224
|
+
const oBinding = oPlugin.getTableBinding();
|
|
193
225
|
if (oBinding && oBinding.getLength()) {
|
|
194
226
|
select(oPlugin, 0, oBinding.getLength() - 1);
|
|
195
227
|
return true;
|
|
@@ -205,7 +237,7 @@ sap.ui.define([
|
|
|
205
237
|
* @returns {boolean} Whether all rows are selected.
|
|
206
238
|
*/
|
|
207
239
|
function areAllRowsSelected(oPlugin) {
|
|
208
|
-
|
|
240
|
+
const oBinding = oPlugin.getTableBinding();
|
|
209
241
|
|
|
210
242
|
// isLengthFinal is checked in case the count is not requested. Even though it is documented that the count is required if the limit is
|
|
211
243
|
// disabled (SelectAll enabled), it could still happen.
|
|
@@ -213,10 +245,10 @@ sap.ui.define([
|
|
|
213
245
|
return false;
|
|
214
246
|
}
|
|
215
247
|
|
|
216
|
-
|
|
248
|
+
const iNumberOfSelectableContexts = oBinding.getAllCurrentContexts().filter(function(oContext) {
|
|
217
249
|
return isContextSelectable(oContext);
|
|
218
250
|
}).length;
|
|
219
|
-
|
|
251
|
+
const iNumberOfSelectedContexts = oPlugin.getSelectedContexts().filter(function(oContext) {
|
|
220
252
|
return isContextSelectable(oContext);
|
|
221
253
|
}).length;
|
|
222
254
|
|
|
@@ -224,7 +256,7 @@ sap.ui.define([
|
|
|
224
256
|
}
|
|
225
257
|
|
|
226
258
|
ODataV4Selection.prototype.onHeaderSelectorPress = function() {
|
|
227
|
-
|
|
259
|
+
const mRenderConfig = this.getRenderConfig();
|
|
228
260
|
|
|
229
261
|
if (!mRenderConfig.headerSelector.visible || !mRenderConfig.headerSelector.enabled) {
|
|
230
262
|
return;
|
|
@@ -232,24 +264,38 @@ sap.ui.define([
|
|
|
232
264
|
|
|
233
265
|
if (mRenderConfig.headerSelector.type === "toggle") {
|
|
234
266
|
toggleSelectAll(this);
|
|
235
|
-
} else if (mRenderConfig.headerSelector.type === "
|
|
236
|
-
this.
|
|
267
|
+
} else if (mRenderConfig.headerSelector.type === "custom") {
|
|
268
|
+
if (this.getSelectedCount() > 0) {
|
|
269
|
+
this.clearSelection();
|
|
270
|
+
} else {
|
|
271
|
+
const oBinding = this.getTableBinding();
|
|
272
|
+
if (oBinding && oBinding.getLength() > 0) {
|
|
273
|
+
select(this, 0, oBinding.getLength() - 1);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
237
276
|
}
|
|
238
277
|
};
|
|
239
278
|
|
|
240
279
|
ODataV4Selection.prototype.onKeyboardShortcut = function(sType, oEvent) {
|
|
241
|
-
if (sType === "toggle") {
|
|
242
|
-
if (this._isLimitDisabled()
|
|
243
|
-
|
|
280
|
+
if (sType === "toggle") { // ctrl + a
|
|
281
|
+
if (this._isLimitDisabled()) {
|
|
282
|
+
if (toggleSelectAll(this) === false) {
|
|
283
|
+
oEvent?.setMarked("sapUiTableClearAll");
|
|
284
|
+
}
|
|
285
|
+
} else {
|
|
286
|
+
const oBinding = this.getTableBinding();
|
|
287
|
+
if (oBinding && oBinding.getLength() > 0) {
|
|
288
|
+
select(this, 0, oBinding.getLength() - 1);
|
|
289
|
+
}
|
|
244
290
|
}
|
|
245
|
-
} else if (sType === "clear") {
|
|
291
|
+
} else if (sType === "clear") { // ctrl + shift + a
|
|
246
292
|
this.clearSelection();
|
|
247
293
|
oEvent?.setMarked("sapUiTableClearAll");
|
|
248
294
|
}
|
|
249
295
|
};
|
|
250
296
|
|
|
251
297
|
ODataV4Selection.prototype.setSelectionMode = function(sSelectionMode) {
|
|
252
|
-
|
|
298
|
+
const oTable = this.getTable();
|
|
253
299
|
|
|
254
300
|
this.setProperty("selectionMode", sSelectionMode, true);
|
|
255
301
|
this._oRangeSelectionStartContext = null;
|
|
@@ -296,11 +342,11 @@ sap.ui.define([
|
|
|
296
342
|
* @param {int} iIndexTo The end index of the range selection.
|
|
297
343
|
*/
|
|
298
344
|
function select(oPlugin, iIndexFrom, iIndexTo) {
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
345
|
+
const oTable = oPlugin.getTable();
|
|
346
|
+
const iLimit = oPlugin.getLimit();
|
|
347
|
+
const bUpwardSelection = iIndexTo < iIndexFrom; // Indicates whether the selection is made from bottom to top.
|
|
348
|
+
let iGetContextsStartIndex = bUpwardSelection ? iIndexTo : iIndexFrom;
|
|
349
|
+
let iGetContextsLength = Math.abs(iIndexTo - iIndexFrom) + 1;
|
|
304
350
|
|
|
305
351
|
if (!oPlugin._isLimitDisabled()) {
|
|
306
352
|
oPlugin._bLimitReached = iGetContextsLength > iLimit;
|
|
@@ -319,7 +365,7 @@ sap.ui.define([
|
|
|
319
365
|
}
|
|
320
366
|
}
|
|
321
367
|
|
|
322
|
-
|
|
368
|
+
let bSelectionChange = false;
|
|
323
369
|
TableUtils.loadContexts(oPlugin.getTableBinding(), iGetContextsStartIndex, iGetContextsLength).then(function(aContexts) {
|
|
324
370
|
aContexts.forEach(function(oContext) {
|
|
325
371
|
if (!isContextSelectable(oContext) || oContext.isSelected()) {
|
|
@@ -349,12 +395,12 @@ sap.ui.define([
|
|
|
349
395
|
}
|
|
350
396
|
|
|
351
397
|
function isContextSelectable(oContext) {
|
|
352
|
-
|
|
398
|
+
const bIsTree = "hierarchyQualifier" in (oContext.getBinding().getAggregation() || {});
|
|
353
399
|
return bIsTree || (oContext.getProperty("@$ui5.node.isExpanded") === undefined && !oContext.getProperty("@$ui5.node.isTotal"));
|
|
354
400
|
}
|
|
355
401
|
|
|
356
402
|
ODataV4Selection.prototype.clearSelection = function() {
|
|
357
|
-
|
|
403
|
+
let bContextDeselected = false;
|
|
358
404
|
|
|
359
405
|
this.getSelectedContexts().forEach(function(oContext) {
|
|
360
406
|
if (!bContextDeselected && oContext.isSelected()) {
|
|
@@ -370,7 +416,7 @@ sap.ui.define([
|
|
|
370
416
|
};
|
|
371
417
|
|
|
372
418
|
ODataV4Selection.prototype.getSelectedContexts = function() {
|
|
373
|
-
|
|
419
|
+
const oBinding = this.getTableBinding();
|
|
374
420
|
|
|
375
421
|
return oBinding ? oBinding.getAllCurrentContexts().filter(function(oContext) {
|
|
376
422
|
return oContext.isSelected();
|
|
@@ -378,7 +424,7 @@ sap.ui.define([
|
|
|
378
424
|
};
|
|
379
425
|
|
|
380
426
|
ODataV4Selection.prototype.onThemeChanged = function() {
|
|
381
|
-
this
|
|
427
|
+
updateHeaderSelectorIcon(this);
|
|
382
428
|
};
|
|
383
429
|
|
|
384
430
|
return ODataV4Selection;
|
|
@@ -12,9 +12,9 @@ sap.ui.define([
|
|
|
12
12
|
) {
|
|
13
13
|
"use strict";
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
const Hook = TableUtils.Hook.Keys;
|
|
16
|
+
const oHookInstallation = {};
|
|
17
|
+
const _private = TableUtils.createWeakMapFacade();
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* Constructor for a new table plugin.
|
|
@@ -28,14 +28,14 @@ sap.ui.define([
|
|
|
28
28
|
* @extends sap.ui.core.Element
|
|
29
29
|
*
|
|
30
30
|
* @author SAP SE
|
|
31
|
-
* @version 1.
|
|
31
|
+
* @version 1.124.0
|
|
32
32
|
*
|
|
33
33
|
* @private
|
|
34
34
|
* @experimental Since 1.75
|
|
35
35
|
* @since 1.75
|
|
36
36
|
* @alias sap.ui.table.plugins.PluginBase
|
|
37
37
|
*/
|
|
38
|
-
|
|
38
|
+
const PluginBase = Element.extend("sap.ui.table.plugins.PluginBase", /** @lends sap.ui.table.plugins.PluginBase.prototype */ {
|
|
39
39
|
metadata: {
|
|
40
40
|
"abstract": true,
|
|
41
41
|
library: "sap.ui.table"
|
|
@@ -204,7 +204,7 @@ sap.ui.define([
|
|
|
204
204
|
* @protected
|
|
205
205
|
*/
|
|
206
206
|
PluginBase.prototype.getTable = function() {
|
|
207
|
-
|
|
207
|
+
const oParent = this.getParent();
|
|
208
208
|
return TableUtils.isA(oParent, "sap.ui.table.Table") ? oParent : null;
|
|
209
209
|
};
|
|
210
210
|
|
|
@@ -215,8 +215,8 @@ sap.ui.define([
|
|
|
215
215
|
* @protected
|
|
216
216
|
*/
|
|
217
217
|
PluginBase.prototype.getTableBinding = function() {
|
|
218
|
-
|
|
219
|
-
|
|
218
|
+
const oTable = this.getTable();
|
|
219
|
+
const oBinding = oTable ? oTable.getBinding() : null;
|
|
220
220
|
return oBinding ? oBinding : null;
|
|
221
221
|
};
|
|
222
222
|
|
|
@@ -242,7 +242,7 @@ sap.ui.define([
|
|
|
242
242
|
PluginBase.prototype.setRowCountConstraints = function(mConstraints) {
|
|
243
243
|
// TODO: Add a type definition for a protected type "rowCountConstraints" in the library file to document the parameter
|
|
244
244
|
// RowMode#getRowCountConstraints + PluginBase#setRowCountConstraints
|
|
245
|
-
|
|
245
|
+
const oTable = this.getTable();
|
|
246
246
|
|
|
247
247
|
if (oTable) {
|
|
248
248
|
oTable._setRowCountConstraints(mConstraints);
|
|
@@ -255,7 +255,7 @@ sap.ui.define([
|
|
|
255
255
|
* @protected
|
|
256
256
|
*/
|
|
257
257
|
PluginBase.prototype.activate = function() {
|
|
258
|
-
|
|
258
|
+
const oTable = this.getTable();
|
|
259
259
|
|
|
260
260
|
if (!oTable || this.isActive()) {
|
|
261
261
|
return;
|
|
@@ -264,7 +264,7 @@ sap.ui.define([
|
|
|
264
264
|
TableUtils.Hook.install(oTable, oHookInstallation, this);
|
|
265
265
|
this.onActivate(oTable);
|
|
266
266
|
|
|
267
|
-
|
|
267
|
+
const oTableBinding = this.getTableBinding();
|
|
268
268
|
if (oTableBinding) {
|
|
269
269
|
this.onTableRowsBound(oTableBinding);
|
|
270
270
|
}
|
|
@@ -278,7 +278,7 @@ sap.ui.define([
|
|
|
278
278
|
* @protected
|
|
279
279
|
*/
|
|
280
280
|
PluginBase.prototype.deactivate = function() {
|
|
281
|
-
|
|
281
|
+
const oTable = this.getTable();
|
|
282
282
|
|
|
283
283
|
if (!this.isActive()) {
|
|
284
284
|
return;
|
|
@@ -16,19 +16,19 @@ sap.ui.define([
|
|
|
16
16
|
) {
|
|
17
17
|
"use strict";
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
const SelectionMode = library.SelectionMode;
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* Constructs an instance of sap.ui.table.plugins.SelectionModelSelection
|
|
23
23
|
*
|
|
24
24
|
* @class Implements the selection methods for a Table
|
|
25
25
|
* @extends sap.ui.table.plugins.SelectionPlugin
|
|
26
|
-
* @version 1.
|
|
26
|
+
* @version 1.124.0
|
|
27
27
|
* @constructor
|
|
28
28
|
* @private
|
|
29
29
|
* @alias sap.ui.table.plugins.SelectionModelSelection
|
|
30
30
|
*/
|
|
31
|
-
|
|
31
|
+
const SelectionModelSelection = SelectionPlugin.extend("sap.ui.table.plugins.SelectionModelSelection", {
|
|
32
32
|
metadata: {
|
|
33
33
|
library: "sap.ui.table",
|
|
34
34
|
properties: {
|
|
@@ -102,7 +102,7 @@ sap.ui.define([
|
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
if (mConfig && mConfig.range) {
|
|
105
|
-
|
|
105
|
+
const iLastSelectedIndex = this.getSelectedIndex();
|
|
106
106
|
|
|
107
107
|
if (iLastSelectedIndex >= 0) {
|
|
108
108
|
this.addSelectionInterval(iLastSelectedIndex, oRow.getIndex());
|
|
@@ -132,7 +132,8 @@ sap.ui.define([
|
|
|
132
132
|
};
|
|
133
133
|
|
|
134
134
|
function toggleSelectAll(oPlugin) {
|
|
135
|
-
|
|
135
|
+
const oTable = oPlugin.getTable();
|
|
136
|
+
let bSelectAll;
|
|
136
137
|
|
|
137
138
|
// in order to fire the rowSelectionChanged event, the SourceRowIndex mus be set to -1
|
|
138
139
|
// to indicate that the selection was changed by user interaction
|
|
@@ -225,7 +226,7 @@ sap.ui.define([
|
|
|
225
226
|
* @inheritDoc
|
|
226
227
|
*/
|
|
227
228
|
SelectionModelSelection.prototype.getSelectableCount = function() {
|
|
228
|
-
|
|
229
|
+
const oBinding = this.getTableBinding();
|
|
229
230
|
return oBinding ? oBinding.getLength() : 0;
|
|
230
231
|
};
|
|
231
232
|
|
|
@@ -309,7 +310,7 @@ sap.ui.define([
|
|
|
309
310
|
* @public
|
|
310
311
|
*/
|
|
311
312
|
SelectionModelSelection.prototype.setSelectionMode = function(sSelectionMode) {
|
|
312
|
-
|
|
313
|
+
const sOldSelectionMode = this.getSelectionMode();
|
|
313
314
|
|
|
314
315
|
this.setProperty("selectionMode", sSelectionMode);
|
|
315
316
|
|
|
@@ -335,7 +336,7 @@ sap.ui.define([
|
|
|
335
336
|
* @private
|
|
336
337
|
*/
|
|
337
338
|
SelectionModelSelection.prototype._getHighestSelectableIndex = function() {
|
|
338
|
-
|
|
339
|
+
const oBinding = this.getTableBinding();
|
|
339
340
|
return oBinding ? oBinding.getLength() - 1 : -1;
|
|
340
341
|
};
|
|
341
342
|
|
|
@@ -358,8 +359,8 @@ sap.ui.define([
|
|
|
358
359
|
};
|
|
359
360
|
|
|
360
361
|
function onSelectionChange(oEvent) {
|
|
361
|
-
|
|
362
|
-
|
|
362
|
+
const aRowIndices = oEvent.getParameter("rowIndices");
|
|
363
|
+
const bSelectAll = oEvent.getParameter("selectAll");
|
|
363
364
|
|
|
364
365
|
if (!this._bSuppressSelectionChangeEvent) {
|
|
365
366
|
this.fireSelectionChange({
|
|
@@ -383,7 +384,7 @@ sap.ui.define([
|
|
|
383
384
|
}
|
|
384
385
|
|
|
385
386
|
function onBindingChange(oEvent) {
|
|
386
|
-
|
|
387
|
+
const sReason = typeof (oEvent) === "object" ? oEvent.getParameter("reason") : oEvent;
|
|
387
388
|
|
|
388
389
|
if (sReason === "sort" || sReason === "filter") {
|
|
389
390
|
this.clearSelection();
|
|
@@ -391,7 +392,7 @@ sap.ui.define([
|
|
|
391
392
|
}
|
|
392
393
|
|
|
393
394
|
function onTotalRowCountChanged() {
|
|
394
|
-
|
|
395
|
+
const iTotalRowCount = this.getTable()._getTotalRowCount();
|
|
395
396
|
|
|
396
397
|
// If rows are added or removed, the index-based selection of the SelectionModel is invalid and needs to be cleared.
|
|
397
398
|
// Changes from 0 are ignored for compatibility, so it is possible to select something before the initial rows update is done.
|