mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ACS-5738] unable to unselect libraries (#8825)
* [ACS-5738] - Make libraries in datatable to be possible to unselect
This commit is contained in:
@@ -15,8 +15,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { SimpleChange, NO_ERRORS_SCHEMA, QueryList, Component, TemplateRef, ViewChild } from '@angular/core';
|
||||
import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing';
|
||||
import { Component, NO_ERRORS_SCHEMA, QueryList, SimpleChange, TemplateRef, ViewChild } from '@angular/core';
|
||||
import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
|
||||
import { MatCheckboxChange } from '@angular/material/checkbox';
|
||||
import { DataColumn } from '../../data/data-column.model';
|
||||
import { DataRow } from '../../data/data-row.model';
|
||||
@@ -563,11 +563,11 @@ describe('DataTable', () => {
|
||||
expect(rows[1].isSelected).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should NOT unselect the row with [single] selection mode', (done) => {
|
||||
it('should unselect the row with [single] selection mode', (done) => {
|
||||
dataTable.selectionMode = 'single';
|
||||
dataTable.data = new ObjectDataTableAdapter(
|
||||
[
|
||||
{ name: '1', isSelected: true },
|
||||
{name: '1'},
|
||||
{ name: '2' }
|
||||
],
|
||||
[new ObjectDataColumn({ key: 'name' })]
|
||||
@@ -575,13 +575,17 @@ describe('DataTable', () => {
|
||||
const rows = dataTable.data.getRows();
|
||||
dataTable.ngOnChanges({});
|
||||
fixture.detectChanges();
|
||||
|
||||
dataTable.rowClick.subscribe(() => {
|
||||
expect(rows[0].isSelected).toBeTruthy();
|
||||
expect(rows[1].isSelected).toBeFalsy();
|
||||
done();
|
||||
});
|
||||
dataTable.onRowClick(rows[0], new MouseEvent('click'));
|
||||
dataTable.rowClick.pipe(take(1)).subscribe(() => {
|
||||
expect(rows[0].isSelected).toBeTrue();
|
||||
expect(rows[1].isSelected).toBeFalse();
|
||||
dataTable.onRowClick(rows[0], new MouseEvent('click'));
|
||||
dataTable.rowClick.pipe(take(1)).subscribe(() => {
|
||||
expect(rows[0].isSelected).toBeFalse();
|
||||
expect(rows[1].isSelected).toBeFalse();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should unselect the row with [multiple] selection mode and modifier key', (done) => {
|
||||
|
@@ -18,14 +18,31 @@
|
||||
/* eslint-disable @angular-eslint/no-conflicting-lifecycle */
|
||||
|
||||
import {
|
||||
ViewChildren, QueryList, HostListener,
|
||||
AfterContentInit, Component, ContentChild, DoCheck, ElementRef, EventEmitter, Input,
|
||||
IterableDiffers, OnChanges, Output, SimpleChange, SimpleChanges, TemplateRef, ViewEncapsulation, OnDestroy, AfterViewInit, OnInit
|
||||
AfterContentInit,
|
||||
AfterViewInit,
|
||||
Component,
|
||||
ContentChild,
|
||||
DoCheck,
|
||||
ElementRef,
|
||||
EventEmitter,
|
||||
HostListener,
|
||||
Input,
|
||||
IterableDiffers,
|
||||
OnChanges,
|
||||
OnDestroy,
|
||||
OnInit,
|
||||
Output,
|
||||
QueryList,
|
||||
SimpleChange,
|
||||
SimpleChanges,
|
||||
TemplateRef,
|
||||
ViewChildren,
|
||||
ViewEncapsulation
|
||||
} from '@angular/core';
|
||||
import { FocusKeyManager } from '@angular/cdk/a11y';
|
||||
import { MatCheckboxChange } from '@angular/material/checkbox';
|
||||
import { MatMenuTrigger } from '@angular/material/menu';
|
||||
import { Subscription, Observable, Observer } from 'rxjs';
|
||||
import { Observable, Observer, Subscription } from 'rxjs';
|
||||
import { DataColumnListComponent } from '../../data-column/data-column-list.component';
|
||||
import { DataColumn } from '../../data/data-column.model';
|
||||
import { DataRowEvent } from '../../data/data-row-event.model';
|
||||
@@ -39,7 +56,7 @@ import { ObjectDataColumn } from '../../data/object-datacolumn.model';
|
||||
import { ObjectDataTableAdapter } from '../../data/object-datatable-adapter';
|
||||
import { DataCellEvent } from '../data-cell.event';
|
||||
import { DataRowActionEvent } from '../data-row-action.event';
|
||||
import { share, buffer, map, filter, debounceTime } from 'rxjs/operators';
|
||||
import { buffer, debounceTime, filter, map, share } from 'rxjs/operators';
|
||||
import { CdkDragDrop, moveItemInArray } from '@angular/cdk/drag-drop';
|
||||
import { MatIconRegistry } from '@angular/material/icon';
|
||||
import { DomSanitizer } from '@angular/platform-browser';
|
||||
@@ -527,9 +544,14 @@ export class DataTableComponent implements OnInit, AfterContentInit, OnChanges,
|
||||
private handleRowSelection(row: DataRow, e: KeyboardEvent | MouseEvent) {
|
||||
if (this.data) {
|
||||
if (this.isSingleSelectionMode()) {
|
||||
this.resetSelection();
|
||||
this.selectRow(row, true);
|
||||
this.emitRowSelectionEvent('row-select', row);
|
||||
if (row.isSelected) {
|
||||
this.resetSelection();
|
||||
this.emitRowSelectionEvent('row-unselect', null);
|
||||
} else {
|
||||
this.resetSelection();
|
||||
this.selectRow(row, true);
|
||||
this.emitRowSelectionEvent('row-select', row);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.isMultiSelectionMode()) {
|
||||
|
Reference in New Issue
Block a user