mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-18 15:33:04 +00:00
62849: fixed issues with multiple selections, improved UX, updating to use new REST response
This commit is contained in:
@@ -71,10 +71,12 @@ function select(state: SelectableListState, action: SelectableListSelectAction)
|
||||
|
||||
function selectSingle(state: SelectableListState, action: SelectableListSelectSingleAction) {
|
||||
let newSelection;
|
||||
if (action.payload.multipleSelectionsAllowed && !isObjectInSelection(state.selection, action.payload.object)) {
|
||||
newSelection = [...state.selection, action.payload.object];
|
||||
} else {
|
||||
newSelection = [action.payload.object];
|
||||
if (!isObjectInSelection(state.selection, action.payload.object)) {
|
||||
if (action.payload.multipleSelectionsAllowed) {
|
||||
newSelection = [...state.selection, action.payload.object];
|
||||
} else {
|
||||
newSelection = [action.payload.object];
|
||||
}
|
||||
}
|
||||
return Object.assign({}, state, { selection: newSelection });
|
||||
}
|
||||
|
@@ -37,8 +37,9 @@ export class SelectableListService {
|
||||
* Select an object in a specific list in the store
|
||||
* @param {string} id The id of the list on which the object should be selected
|
||||
* @param {ListableObject} object The object to select
|
||||
* @param {boolean} multipleSelectionsAllowed Defines if the multiple selections are allowed for this selectable list
|
||||
*/
|
||||
selectSingle(id: string, object: ListableObject, multipleSelectionsAllowed?) {
|
||||
selectSingle(id: string, object: ListableObject, multipleSelectionsAllowed?: boolean) {
|
||||
this.store.dispatch(new SelectableListSelectSingleAction(id, object, multipleSelectionsAllowed));
|
||||
}
|
||||
|
||||
@@ -86,7 +87,7 @@ export class SelectableListService {
|
||||
isObjectSelected(id: string, object: ListableObject): Observable<boolean> {
|
||||
return this.getSelectableList(id).pipe(
|
||||
filter((state: SelectableListState) => hasValue(state)),
|
||||
map((state: SelectableListState) => isNotEmpty(state.selection) && hasValue(state.selection.find((selected) => selected === object))),
|
||||
map((state: SelectableListState) => isNotEmpty(state.selection) && hasValue(state.selection.find((selected) => selected.equals(object)))),
|
||||
startWith(false),
|
||||
distinctUntilChanged()
|
||||
);
|
||||
|
Reference in New Issue
Block a user