mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ACS-6489] Add resizable option for column data model (#9220)
* [ACS-6489] Add resizable option for column data model * [ACS-6489] CR fixes
This commit is contained in:
@@ -48,6 +48,7 @@ Defines column properties for DataTable, Tasklist, Document List and other compo
|
|||||||
| cssClass | `string` | | Additional CSS class to be applied to column (header and cells). |
|
| cssClass | `string` | | Additional CSS class to be applied to column (header and cells). |
|
||||||
| customData | `any` | | You can specify any custom data which can be used by any specific feature |
|
| customData | `any` | | You can specify any custom data which can be used by any specific feature |
|
||||||
| draggable | `boolean` | false | Enable drag and drop for header column |
|
| draggable | `boolean` | false | Enable drag and drop for header column |
|
||||||
|
| resizable | `boolean` | true | Enable column resizing |
|
||||||
| editable | `boolean` | false | Toggles the editing support of the column data. |
|
| editable | `boolean` | false | Toggles the editing support of the column data. |
|
||||||
| focus | `boolean` | true | Enable or disable cell focus |
|
| focus | `boolean` | true | Enable or disable cell focus |
|
||||||
| format | `string` | | Value format (if supported by the parent component), for example format of the date. |
|
| format | `string` | | Value format (if supported by the parent component), for example format of the date. |
|
||||||
|
@@ -96,7 +96,7 @@
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
*ngIf="isResizingEnabled"
|
*ngIf="isResizingEnabled && col.resizable"
|
||||||
adf-resize-handle
|
adf-resize-handle
|
||||||
class="adf-datatable__resize-handle"
|
class="adf-datatable__resize-handle"
|
||||||
[resizableContainer]="resizableElement">
|
[resizableContainer]="resizableElement">
|
||||||
|
@@ -1694,6 +1694,10 @@ describe('Column Resizing', () => {
|
|||||||
|
|
||||||
const getResizeHandler = (): HTMLDivElement => fixture.debugElement.nativeElement.querySelector('.adf-datatable__resize-handle');
|
const getResizeHandler = (): HTMLDivElement => fixture.debugElement.nativeElement.querySelector('.adf-datatable__resize-handle');
|
||||||
|
|
||||||
|
const getResizeHandlersCount = (): number => {
|
||||||
|
const resizeHandlers = fixture.debugElement.nativeElement.querySelectorAll('.adf-datatable__resize-handle');
|
||||||
|
return resizeHandlers.length;
|
||||||
|
};
|
||||||
|
|
||||||
const testClassesAfterResizing = (headerColumnsSelector = '.adf-datatable-cell-header', excludedClass = 'adf-datatable__cursor--pointer') => {
|
const testClassesAfterResizing = (headerColumnsSelector = '.adf-datatable-cell-header', excludedClass = 'adf-datatable__cursor--pointer') => {
|
||||||
dataTable.isResizingEnabled = true;
|
dataTable.isResizingEnabled = true;
|
||||||
@@ -1744,6 +1748,22 @@ describe('Column Resizing', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should display resize handle for each column by default', () => {
|
||||||
|
dataTable.isResizingEnabled = true;
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
expect(getResizeHandlersCount()).toBe(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should NOT display resize handle for the column when the column has resizable param set to false', () => {
|
||||||
|
dataTable.isResizingEnabled = true;
|
||||||
|
dataTableSchema[0].resizable = false;
|
||||||
|
dataTable.data = new ObjectDataTableAdapter([...data], [...dataTableSchema]);
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
expect(getResizeHandlersCount()).toBe(1);
|
||||||
|
});
|
||||||
|
|
||||||
it('should display resize handle when the feature is Enabled [isResizingEnabled=true]', () => {
|
it('should display resize handle when the feature is Enabled [isResizingEnabled=true]', () => {
|
||||||
dataTable.isResizingEnabled = true;
|
dataTable.isResizingEnabled = true;
|
||||||
|
|
||||||
|
@@ -85,6 +85,20 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
resizable: {
|
||||||
|
description: 'Toggles resize for column.',
|
||||||
|
control: { type: 'boolean' },
|
||||||
|
defaultValue: true,
|
||||||
|
table: {
|
||||||
|
category: 'Component Inputs',
|
||||||
|
type: {
|
||||||
|
summary: 'boolean'
|
||||||
|
},
|
||||||
|
defaultValue: {
|
||||||
|
summary: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
editable: {
|
editable: {
|
||||||
description: 'Toggles the editing support of the column data.',
|
description: 'Toggles the editing support of the column data.',
|
||||||
control: { type: 'boolean', disable: true },
|
control: { type: 'boolean', disable: true },
|
||||||
|
@@ -61,6 +61,10 @@ export class DataColumnComponent implements OnInit {
|
|||||||
@Input()
|
@Input()
|
||||||
draggable: boolean = false;
|
draggable: boolean = false;
|
||||||
|
|
||||||
|
/** Enable resize for column */
|
||||||
|
@Input()
|
||||||
|
resizable = true;
|
||||||
|
|
||||||
/** Hide column */
|
/** Hide column */
|
||||||
@Input()
|
@Input()
|
||||||
isHidden: boolean = false;
|
isHidden: boolean = false;
|
||||||
|
@@ -37,6 +37,7 @@ export interface DataColumn<T = unknown> {
|
|||||||
sortingKey?: string;
|
sortingKey?: string;
|
||||||
header?: TemplateRef<any>;
|
header?: TemplateRef<any>;
|
||||||
draggable?: boolean;
|
draggable?: boolean;
|
||||||
|
resizable?: boolean;
|
||||||
isHidden?: boolean;
|
isHidden?: boolean;
|
||||||
width?: number;
|
width?: number;
|
||||||
customData?: T;
|
customData?: T;
|
||||||
|
@@ -35,6 +35,7 @@ export class ObjectDataColumn<T = unknown> implements DataColumn<T> {
|
|||||||
sortingKey?: string;
|
sortingKey?: string;
|
||||||
header?: TemplateRef<any>;
|
header?: TemplateRef<any>;
|
||||||
draggable: boolean;
|
draggable: boolean;
|
||||||
|
resizable: boolean;
|
||||||
isHidden: boolean;
|
isHidden: boolean;
|
||||||
customData?: T;
|
customData?: T;
|
||||||
width?: number;
|
width?: number;
|
||||||
@@ -58,6 +59,7 @@ export class ObjectDataColumn<T = unknown> implements DataColumn<T> {
|
|||||||
this.sortingKey = input.sortingKey;
|
this.sortingKey = input.sortingKey;
|
||||||
this.header = input.header;
|
this.header = input.header;
|
||||||
this.draggable = input.draggable ?? false;
|
this.draggable = input.draggable ?? false;
|
||||||
|
this.resizable = input.resizable ?? true;
|
||||||
this.isHidden = input.isHidden ?? false;
|
this.isHidden = input.isHidden ?? false;
|
||||||
this.customData = input.customData;
|
this.customData = input.customData;
|
||||||
this.width = input.width;
|
this.width = input.width;
|
||||||
|
@@ -36,6 +36,7 @@ export const getDataColumnMock = <T = unknown>(
|
|||||||
sortingKey: 'sortingKey',
|
sortingKey: 'sortingKey',
|
||||||
header: undefined,
|
header: undefined,
|
||||||
draggable: false,
|
draggable: false,
|
||||||
|
resizable: true,
|
||||||
isHidden: false,
|
isHidden: false,
|
||||||
customData: undefined,
|
customData: undefined,
|
||||||
...column
|
...column
|
||||||
|
@@ -50,4 +50,5 @@ export interface DocumentListPresetRef extends ExtensionElement {
|
|||||||
visible?: string;
|
visible?: string;
|
||||||
};
|
};
|
||||||
draggable?: boolean;
|
draggable?: boolean;
|
||||||
|
resizable?: boolean;
|
||||||
}
|
}
|
||||||
|
@@ -565,6 +565,10 @@
|
|||||||
"desktopOnly": {
|
"desktopOnly": {
|
||||||
"description": "Display column only for large screens",
|
"description": "Display column only for large screens",
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"resizable": {
|
||||||
|
"description": "Toggles resizable state of the column",
|
||||||
|
"type": "boolean"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user