Skip to content

Right-positioned MultiSelectMode for sap.m.ListBase #4290

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/sap.m/src/sap/m/ListBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -1183,7 +1183,7 @@ function(
if (aSelecteds.length > 1) {
// remove selection if there are more than one item is selected
this.removeSelections(true);
} else if (sOldMode === ListMode.MultiSelect) {
} else if (sOldMode === ListMode.MultiSelect || sOldMode === ListMode.MultiSelectRight) {
// if old mode is multi select then we need to remember selected item
// in case of new item selection right after setMode call
this._oSelectedItem = aSelecteds[0];
Expand Down Expand Up @@ -1249,7 +1249,7 @@ function(
* @protected
*/
ListBase.prototype.isAllSelectableSelected = function() {
if (this.getMode() != ListMode.MultiSelect) {
if (this.getMode() != ListMode.MultiSelect && this.getMode() != ListMode.MultiSelectRight) {
return false;
}

Expand Down Expand Up @@ -1324,7 +1324,7 @@ function(
// this gets called when selected property of the ListItem is changed
ListBase.prototype.onItemSelectedChange = function(oListItem, bSelected) {

if (this.getMode() == ListMode.MultiSelect) {
if (this.getMode() == ListMode.MultiSelect || this.getMode() === ListMode.MultiSelectRight) {
this._updateSelectedPaths(oListItem, bSelected);
return;
}
Expand Down Expand Up @@ -1682,7 +1682,7 @@ function(
return;
}

if (sMode === ListMode.MultiSelect || (this._bSelectionMode && bSelected)) {
if (sMode === ListMode.MultiSelect || sMode === ListMode.MultiSelectRight || (this._bSelectionMode && bSelected)) {
this._fireSelectionChangeEvent([oListItem]);

// announce the selection state changes
Expand Down Expand Up @@ -1751,7 +1751,7 @@ function(
oEvent.altKey ||
oEvent.metaKey ||
oEvent.code == "Tab" ||
this.getMode() !== ListMode.MultiSelect ||
(this.getMode() !== ListMode.MultiSelect && this.getMode() !== ListMode.MultiSelectRight) ||
!oItem.isSelectable() ||
oEvent.key === "F6") {
if (this._mRangeSelection) {
Expand Down Expand Up @@ -2585,7 +2585,7 @@ function(
};

// Ctrl + (Shift) + A: select/deselect all
if (oEvent.code == "KeyA" && (oEvent.metaKey || oEvent.ctrlKey) && bItemEvent && this.getMode() == ListMode.MultiSelect) {
if (oEvent.code == "KeyA" && (oEvent.metaKey || oEvent.ctrlKey) && bItemEvent && (this.getMode() == ListMode.MultiSelect || this.getMode() == ListMode.MultiSelectRight)) {
var bClearAll = (this.getMultiSelectMode() == MultiSelectMode.ClearAll);
if (oEvent.shiftKey) {
if (bClearAll) {
Expand Down Expand Up @@ -3200,4 +3200,4 @@ function(

return ListBase;

});
});
1 change: 1 addition & 0 deletions src/sap.m/src/sap/m/ListBaseRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ sap.ui.define(["sap/m/library", "sap/ui/core/library", "sap/ui/Device", "sap/ui/
None : 0,
Delete : 1,
MultiSelect : -1,
MultiSelectRight: 1,
SingleSelect : 1,
SingleSelectLeft : -1,
SingleSelectMaster : 0
Expand Down
9 changes: 5 additions & 4 deletions src/sap.m/src/sap/m/ListItemBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ function(
return this.getDeleteControl(bCreateIfNotExist);
}

if (sMode == ListMode.MultiSelect) {
if (sMode == ListMode.MultiSelect || sMode == ListMode.MultiSelectRight) {
return this.getMultiSelectControl(bCreateIfNotExist);
}

Expand Down Expand Up @@ -890,7 +890,8 @@ function(
this.getListProperty("includeItemInSelection") && (
sMode == ListMode.SingleSelectLeft ||
sMode == ListMode.SingleSelect ||
sMode == ListMode.MultiSelect
sMode == ListMode.MultiSelect ||
sMode == ListMode.MultiSelectRight
)
);
};
Expand Down Expand Up @@ -987,7 +988,7 @@ function(
if (this.isIncludedIntoSelection()) {

// update selected property
if (this.getMode() == ListMode.MultiSelect) {
if (this.getMode() == ListMode.MultiSelect || ListMode.MultiSelectRight) {
this.setSelected(!this.getSelected());
this.informList("Select", this.getSelected());
} else if (!this.getSelected()) {
Expand Down Expand Up @@ -1110,7 +1111,7 @@ function(
}

// update selected property
if (this.getMode() == ListMode.MultiSelect) {
if (this.getMode() == ListMode.MultiSelect || ListMode.MultiSelectRight) {
this.setSelected(!this.getSelected());
this.informList("Select", this.getSelected());
} else if (!this.getSelected()) {
Expand Down
6 changes: 6 additions & 0 deletions src/sap.m/src/sap/m/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -3171,6 +3171,12 @@ sap.ui.define([
*/
MultiSelect : "MultiSelect",

/**
* Right-positioned multi selection mode (more than one list item can be selected).
* @public
*/
MultiSelectRight : "MultiSelectRight",

/**
* Delete mode (only one list item can be deleted via provided delete button)
* @public
Expand Down
1 change: 1 addition & 0 deletions src/sap.m/test/sap/m/Tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,7 @@ sap.ui.define([
new Item({ key: "2", text: ListMode.SingleSelectLeft }),
new Item({ key: "3", text: ListMode.SingleSelectMaster}),
new Item({ key: "4", text: ListMode.MultiSelect }),
new Item({key: "5", text: ListMode.MultiSelectRight}),
new Item({ key: "5", text: ListMode.Delete })
],
selectedItem: "0",
Expand Down