Skip to content

Commit

Permalink
feat(plugins): move external Draggable Grouping into Slickgrid-Universal
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiscoding committed Sep 25, 2021
1 parent 2ae3855 commit 8e6eb48
Show file tree
Hide file tree
Showing 33 changed files with 1,156 additions and 326 deletions.
2 changes: 2 additions & 0 deletions examples/webpack-demo-vanilla-bundle/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"COMMANDS": "Commands",
"CONTAINS": "Contains",
"COPY": "Copy",
"DROP_COLUMN_HEADER_TO_GROUP_BY": "Drop a column header here to group by the column",
"EMPTY_DATA_WARNING_MESSAGE": "No data to display.",
"ENDS_WITH": "Ends With",
"EQUALS": "Equals",
Expand Down Expand Up @@ -57,6 +58,7 @@
"SORT_DESCENDING": "Sort Descending",
"STARTS_WITH": "Starts With",
"SYNCHRONOUS_RESIZE": "Synchronous resize",
"TOGGLE_ALL_GROUPS": "Toggle all Groups",
"TOGGLE_FILTER_ROW": "Toggle Filter Row",
"TOGGLE_PRE_HEADER_ROW": "Toggle Pre-Header Row",
"X_OF_Y_SELECTED": "# of % selected",
Expand Down
2 changes: 2 additions & 0 deletions examples/webpack-demo-vanilla-bundle/assets/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"COMMANDS": "Commandes",
"CONTAINS": "Contient",
"COPY": "Copier",
"DROP_COLUMN_HEADER_TO_GROUP_BY": "Glisser une en-tête de colonne ici pour grouper par cet colonne",
"EMPTY_DATA_WARNING_MESSAGE": "Aucune donnée à afficher.",
"ENDS_WITH": "Se termine par",
"EQUALS": "Égale",
Expand Down Expand Up @@ -57,6 +58,7 @@
"SORT_DESCENDING": "Trier par ordre décroissant",
"STARTS_WITH": "Commence par",
"SYNCHRONOUS_RESIZE": "Redimension synchrone",
"TOGGLE_ALL_GROUPS": "Basculer tous les groupes",
"TOGGLE_FILTER_ROW": "Basculer la ligne des filtres",
"TOGGLE_PRE_HEADER_ROW": "Basculer la ligne de pré-en-tête",
"X_OF_Y_SELECTED": "# de % sélectionnés",
Expand Down
17 changes: 7 additions & 10 deletions examples/webpack-demo-vanilla-bundle/src/examples/example03.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
Aggregators,
BindingEventService,
Column,
DraggableGroupingPlugin,
Editors,
FieldType,
FileType,
Expand All @@ -11,7 +12,6 @@ import {
Grouping,
GroupingGetterFunction,
GroupTotalFormatters,
SlickDraggableGrouping,
SlickNamespace,
SortComparers,
SortDirectionNumber,
Expand Down Expand Up @@ -45,7 +45,7 @@ export class Example3 {
excelExportService: ExcelExportService;
sgb: SlickVanillaGridBundle;
durationOrderByCount = false;
draggableGroupingPlugin: SlickDraggableGrouping;
draggableGroupingPlugin: DraggableGroupingPlugin;
loadingClass = '';
selectedGroupingFields: Array<string | GroupingGetterFunction> = ['', '', ''];

Expand Down Expand Up @@ -310,6 +310,7 @@ export class Example3 {
deleteIconCssClass: 'mdi mdi-close color-danger',
onGroupChanged: (_e, args) => this.onGroupChanged(args),
onExtensionRegistered: (extension) => this.draggableGroupingPlugin = extension,
// groupIconCssClass: 'mdi mdi-drag-vertical',
},
enableCheckboxSelector: true,
enableRowSelection: true,
Expand Down Expand Up @@ -381,7 +382,7 @@ export class Example3 {
}

clearGrouping() {
if (this.draggableGroupingPlugin && this.draggableGroupingPlugin.setDroppedGroups) {
if (this.draggableGroupingPlugin?.setDroppedGroups) {
this.draggableGroupingPlugin.clearDroppedGroups();
}
this.sgb?.slickGrid.invalidate(); // invalidate all rows and re-render
Expand All @@ -404,7 +405,7 @@ export class Example3 {

groupByDuration() {
this.clearGrouping();
if (this.draggableGroupingPlugin && this.draggableGroupingPlugin.setDroppedGroups) {
if (this.draggableGroupingPlugin?.setDroppedGroups) {
this.showPreHeader();
this.draggableGroupingPlugin.setDroppedGroups('duration');
this.sgb?.slickGrid.invalidate(); // invalidate all rows and re-render
Expand All @@ -424,20 +425,16 @@ export class Example3 {

groupByDurationEffortDriven() {
this.clearGrouping();
if (this.draggableGroupingPlugin && this.draggableGroupingPlugin.setDroppedGroups) {
if (this.draggableGroupingPlugin?.setDroppedGroups) {
this.showPreHeader();
this.draggableGroupingPlugin.setDroppedGroups(['duration', 'effortDriven']);
this.sgb?.slickGrid.invalidate(); // invalidate all rows and re-render

// you need to manually add the sort icon(s) in UI
const sortColumns = [{ columnId: 'duration', sortAsc: true }];
this.sgb?.slickGrid.setSortColumns(sortColumns);
}
}

groupByFieldName(_fieldName, _index) {
this.clearGrouping();
if (this.draggableGroupingPlugin && this.draggableGroupingPlugin.setDroppedGroups) {
if (this.draggableGroupingPlugin?.setDroppedGroups) {
this.showPreHeader();

// get the field names from Group By select(s) dropdown, but filter out any empty fields
Expand Down
2 changes: 2 additions & 0 deletions packages/common/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export class Constants {
TEXT_COLUMN_RESIZE_BY_CONTENT: 'Resize by Content',
TEXT_COMMANDS: 'Commands',
TEXT_COPY: 'Copy',
TEXT_DROP_COLUMN_HEADER_TO_GROUP_BY: 'Drop a column header here to group by the column',
TEXT_EQUALS: 'Equals',
TEXT_EQUAL_TO: 'Equal to',
TEXT_ENDS_WITH: 'Ends With',
Expand Down Expand Up @@ -61,6 +62,7 @@ export class Constants {
TEXT_SORT_ASCENDING: 'Sort Ascending',
TEXT_SORT_DESCENDING: 'Sort Descending',
TEXT_STARTS_WITH: 'Starts With',
TEXT_TOGGLE_ALL_GROUPS: 'Toggle all Groups',
TEXT_TOGGLE_FILTER_ROW: 'Toggle Filter Row',
TEXT_TOGGLE_PRE_HEADER_ROW: 'Toggle Pre-Header Row',
TEXT_X_OF_Y_SELECTED: '# of % selected',
Expand Down
4 changes: 2 additions & 2 deletions packages/common/src/enums/columnReorderFunction.type.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { Column, SlickGrid } from '../interfaces/index';
import { Column, SlickEvent, SlickGrid } from '../interfaces/index';

export type ColumnReorderFunction = (grid: SlickGrid, headers: HTMLElement[], headerColumnWidthDiff: any, setColumns: (col: Column) => void, setupColumnResize: () => void, columns: Column[], getColumnIndex: number, uid: string, trigger: boolean) => void;
export type ColumnReorderFunction = (grid: SlickGrid, headers: any, headerColumnWidthDiff: any, setColumns: (cols: Column[]) => void, setupColumnResize: () => void, columns: Column[], getColumnIndex: (column: Column) => number, uid: string, trigger: (slickEvent: SlickEvent, data?: any) => void) => void;

This file was deleted.

84 changes: 0 additions & 84 deletions packages/common/src/extensions/draggableGroupingExtension.ts

This file was deleted.

4 changes: 2 additions & 2 deletions packages/common/src/extensions/extensionUtility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,12 @@ export class ExtensionUtility {
}
}

/** Translate the an array of items from an input key and assign to the output key */
/** Translate the array of items from an input key and assign them to their output key */
translateItems<T = any>(items: T[], inputKey: string, outputKey: string) {
if (Array.isArray(items)) {
for (const item of items) {
if ((item as any)[inputKey]) {
(item as any)[outputKey] = this.translaterService && this.translaterService.getCurrentLanguage && this.translaterService.translate && this.translaterService.translate((item as any)[inputKey]);
(item as any)[outputKey] = this.translaterService?.translate?.((item as any)[inputKey]);
}
}
}
Expand Down
1 change: 0 additions & 1 deletion packages/common/src/extensions/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export * from './cellExternalCopyManagerExtension';
export * from './checkboxSelectorExtension';
export * from './draggableGroupingExtension';
export * from './extensionUtility';
export * from './groupItemMetaProviderExtension';
export * from './rowDetailViewExtension';
Expand Down
5 changes: 5 additions & 0 deletions packages/common/src/global-grid-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ export const GlobalGridOptions: GridOption = {
defaultColumnSortFieldId: 'id',
defaultComponentEventPrefix: '',
defaultSlickgridEventPrefix: '',
draggableGrouping: {
hideToggleAllButton: false,
toggleAllButtonText: '',
dropPlaceHolderTextKey: 'DROP_COLUMN_HEADER_TO_GROUP_BY',
},
editable: false,
editorTypingDebounce: 450,
filterTypingDebounce: 0,
Expand Down
Loading

0 comments on commit 8e6eb48

Please sign in to comment.