Skip to content

Commit

Permalink
feat(plugins): move Row Detail View plugin to universal
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiscoding committed Oct 26, 2021
1 parent 3c37ce9 commit fb327a6
Show file tree
Hide file tree
Showing 30 changed files with 1,110 additions and 218 deletions.
2 changes: 1 addition & 1 deletion packages/common/src/controls/slickGridMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
SlickEventHandler,
SlickNamespace,
} from '../interfaces/index';
import { DelimiterType, FileType } from '../enums';
import { DelimiterType, FileType } from '../enums/index';
import { ExtensionUtility } from '../extensions/extensionUtility';
import { emptyElement, findWidthOrDefault, getHtmlElementOffset, getTranslationPrefix, } from '../services/index';
import { ExcelExportService } from '../services/excelExport.service';
Expand Down
6 changes: 2 additions & 4 deletions packages/common/src/enums/slickPluginList.enum.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import {
SlickEditorLock,
SlickRowDetailView,
} from '../interfaces/index';
import { SlickEditorLock } from '../interfaces/index';
import {
SlickAutoTooltip,
SlickCellExternalCopyManager,
Expand All @@ -15,6 +12,7 @@ import {
SlickGroupItemMetadataProvider,
SlickHeaderButtons,
SlickHeaderMenu,
SlickRowDetailView,
SlickRowMoveManager,
SlickRowSelectionModel,
} from '../plugins/index';
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion packages/common/src/extensions/extensionUtility.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Constants } from '../constants';
import { Column, GridOption, Locale, MenuCommandItem, MenuOptionItem, } from '../interfaces';
import { Column, GridOption, Locale, MenuCommandItem, MenuOptionItem, } from '../interfaces/index';
import { BackendUtilityService } from '../services/backendUtility.service';
import { SharedService } from '../services/shared.service';
import { TranslaterService } from '../services/translater.service';
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,2 +1 @@
export * from './extensionUtility';
export * from './rowDetailViewExtension';
27 changes: 0 additions & 27 deletions packages/common/src/extensions/rowDetailViewExtension.ts

This file was deleted.

5 changes: 4 additions & 1 deletion packages/common/src/formatters/bsDropdownFormatter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { Formatter } from '../interfaces/formatter.interface';

/** A simple Bootstrap Dropdown Formatter which requires a Formatter Label */
/**
* @deprecated @use `CellMenu`, which is a lot more generic instead of `bsDropdownFormatter`.
* A simple Bootstrap Dropdown Formatter which requires a Formatter Label.
*/
export const bsDropdownFormatter: Formatter = (row, cell, _val, columnDef) => {
const columnParams = columnDef && columnDef.params || {};
const label = columnParams.label || columnParams.formatterLabel;
Expand Down
1 change: 1 addition & 0 deletions packages/common/src/formatters/formatters.index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export const Formatters = {
bold: boldFormatter,

/**
* @deprecated @use `CellMenu`, which is a lot more generic instead of `bsDropdownFormatter`.
* a simple Bootstrap Dropdown Formatter which requires a Formatter Label
* example:: { formatter: Formatters.bsDropdown, params: { formatterLabel: 'Label' }}
*/
Expand Down
3 changes: 3 additions & 0 deletions packages/common/src/interfaces/column.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ type Join<T extends any[], D extends string> =
/* eslint-enable @typescript-eslint/indent */

export interface Column<T = any> {
/** do we want to always render the column? */
alwaysRenderColumn?: boolean;

/** async background post-rendering formatter */
asyncPostRender?: (domCellNode: any, row: number, dataContext: T, columnDef: Column) => void;

Expand Down
1 change: 0 additions & 1 deletion packages/common/src/interfaces/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ export * from './slickNamespace.interface';
export * from './slickRange.interface';
export * from './slickRemoteModel.interface';
export * from './slickResizer.interface';
export * from './slickRowDetailView.interface';
export * from './sorter.interface';
export * from './textExportOption.interface';
export * from './treeDataOption.interface';
Expand Down
6 changes: 2 additions & 4 deletions packages/common/src/interfaces/rowDetailView.interface.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { RowDetailViewOption } from './rowDetailViewOption.interface';
import { SlickGrid } from './slickGrid.interface';
import { SlickEventData } from './slickEventData.interface';
import { SlickRowDetailView } from './slickRowDetailView.interface';
import { RowDetailViewOption, SlickEventData, SlickGrid } from './index';
import { SlickRowDetailView } from '../plugins/slickRowDetailView';

export interface RowDetailView extends RowDetailViewOption {
// --
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export interface RowDetailViewOption {
* It's preferable to use the "preloadView" property to use a framework View instead of plain HTML.
* If you still wish to use these methods, we strongly suggest you to sanitize your HTML, e.g. "DOMPurify.sanitize()"
*/
preTemplate?: () => string;
preTemplate?: (item?: any) => string;

/**
* HTML Post Template (when Row Detail data is available) that will be loaded once the async function finishes
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/interfaces/slickNamespace.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import {
SlickRange,
SlickRemoteModel,
SlickResizer,
SlickRowDetailView,
} from './index';
import { SlickGridMenu, } from '../controls/index';
import {
Expand All @@ -43,6 +42,7 @@ import {
SlickGroupItemMetadataProvider,
SlickHeaderButtons,
SlickHeaderMenu,
SlickRowDetailView,
SlickRowMoveManager,
SlickRowSelectionModel,
} from '../plugins/index';
Expand Down
78 changes: 0 additions & 78 deletions packages/common/src/interfaces/slickRowDetailView.interface.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { DelimiterType, FileType } from '../../enums/index';
import { ContextMenu, Column, ElementPosition, GridOption, MenuCommandItem, MenuOptionItem, SlickDataView, SlickGrid, SlickNamespace, } from '../../interfaces/index';
import { SlickContextMenu } from '../slickContextMenu';
import { BackendUtilityService, deepCopy, ExcelExportService, PubSubService, SharedService, TextExportService, TreeDataService, } from '../../services';
import { BackendUtilityService, deepCopy, ExcelExportService, PubSubService, SharedService, TextExportService, TreeDataService, } from '../../services/index';
import { ExtensionUtility } from '../../extensions/extensionUtility';
import { TranslateServiceStub } from '../../../../../test/translateServiceStub';
import { Formatters } from '../../formatters';
import { DelimiterType, FileType } from '../../enums';
import { TranslateServiceStub } from '../../../../../test/translateServiceStub';
import { SlickContextMenu } from '../slickContextMenu';

declare const Slick: SlickNamespace;

Expand Down
69 changes: 69 additions & 0 deletions packages/common/src/plugins/__tests__/slickRowDetail.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import { SlickRowDetailView } from '../slickRowDetailView';

describe('SlickRowDetailView plugin', () => {
let plugin: SlickRowDetailView;

beforeEach(() => {
plugin = new SlickRowDetailView();
});

it('should throw a not implemented error when calling "init" method', () => {
expect(() => plugin.init({} as any)).toThrow('SlickRowDetailView the "init" method must be implemented');
});

it('should throw a not implemented error when calling "create" method', () => {
expect(() => plugin.create([], {} as any)).toThrow('SlickRowDetailView the "create" method must be implemented');
});

it('should throw a not implemented error when calling "destroy" method', () => {
expect(() => plugin.destroy()).toThrow('SlickRowDetailView the "destroy" method must be implemented');
});

it('should throw a not implemented error when calling "dispose" method', () => {
expect(() => plugin.dispose()).toThrow('SlickRowDetailView the "dispose" method must be implemented');
});

it('should throw a not implemented error when calling "collapseAll" method', () => {
expect(() => plugin.collapseAll()).toThrow('SlickRowDetailView the "collapseAll" method must be implemented');
});

it('should throw a not implemented error when calling "collapseDetailView" method', () => {
expect(() => plugin.collapseDetailView({} as any, true)).toThrow('SlickRowDetailView the "collapseDetailView" method must be implemented');
});

it('should throw a not implemented error when calling "expandDetailView" method', () => {
expect(() => plugin.expandDetailView({} as any)).toThrow('SlickRowDetailView the "expandDetailView" method must be implemented');
});

it('should throw a not implemented error when calling "expandableOverride" method', () => {
expect(() => plugin.expandableOverride({} as any)).toThrow('SlickRowDetailView the "expandableOverride" method must be implemented');
});

it('should throw a not implemented error when calling "getColumnDefinition" method', () => {
expect(() => plugin.getColumnDefinition()).toThrow('SlickRowDetailView the "getColumnDefinition" method must be implemented');
});

it('should throw a not implemented error when calling "getExpandedRows" method', () => {
expect(() => plugin.getExpandedRows()).toThrow('SlickRowDetailView the "getExpandedRows" method must be implemented');
});

it('should throw a not implemented error when calling "getFilterItem" method', () => {
expect(() => plugin.getFilterItem({} as any)).toThrow('SlickRowDetailView the "getFilterItem" method must be implemented');
});

it('should throw a not implemented error when calling "getOptions" method', () => {
expect(() => plugin.getOptions()).toThrow('SlickRowDetailView the "getOptions" method must be implemented');
});

it('should throw a not implemented error when calling "resizeDetailView" method', () => {
expect(() => plugin.resizeDetailView({} as any)).toThrow('SlickRowDetailView the "resizeDetailView" method must be implemented');
});

it('should throw a not implemented error when calling "saveDetailView" method', () => {
expect(() => plugin.saveDetailView({} as any)).toThrow('SlickRowDetailView the "saveDetailView" method must be implemented');
});

it('should throw a not implemented error when calling "setOptions" method', () => {
expect(() => plugin.setOptions({} as any)).toThrow('SlickRowDetailView the "setOptions" method must be implemented');
});
});
1 change: 1 addition & 0 deletions packages/common/src/plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ export * from './slickDraggableGrouping';
export * from './slickGroupItemMetadataProvider';
export * from './slickHeaderButtons';
export * from './slickHeaderMenu';
export * from './slickRowDetailView';
export * from './slickRowMoveManager';
export * from './slickRowSelectionModel';
5 changes: 2 additions & 3 deletions packages/common/src/plugins/slickContextMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@ import {
MenuOptionItem,
SlickEventHandler,
} from '../interfaces/index';
import { getCellValueFromQueryFieldGetter, getTranslationPrefix, } from '../services/index';
import { DelimiterType, FileType } from '../enums/index';
import { ExcelExportService, getCellValueFromQueryFieldGetter, getTranslationPrefix, TextExportService } from '../services/index';
import { exportWithFormatterWhenDefined } from '../formatters/formatterUtilities';
import { ExtensionUtility } from '../extensions/extensionUtility';
import { PubSubService } from '../services/pubSub.service';
import { SharedService } from '../services/shared.service';
import { TreeDataService } from '../services/treeData.service';
import { ExcelExportService, TextExportService } from '../services';
import { DelimiterType, FileType } from '../enums';
import { MenuFromCellBaseClass } from './menuFromCellBaseClass';


Expand Down
Loading

0 comments on commit fb327a6

Please sign in to comment.