-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Implement image column - Added ImageColumn class - Added ImageColumnClick event - Added Column Config Image - Changed ActionColumnFactory to CellTemplateFactory * Update ColumnConfigImage * Fix code smells
- Loading branch information
1 parent
11923ce
commit 0400e09
Showing
12 changed files
with
140 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/OSFramework/DataGrid/Configuration/Column/ColumnConfigImage.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/// <reference path="../../Types/index.ts" /> | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
namespace OSFramework.DataGrid.Configuration.Column { | ||
/** | ||
* Defines the configuration for Action Columns | ||
*/ | ||
export class ColumnConfigImage extends ColumnConfig { | ||
public actionColumnElementType = | ||
DataGrid.Enum.CellTemplateElementType.Image; | ||
public altText: string; | ||
|
||
constructor( | ||
config: DataGrid.Types.IColumnConfigs, | ||
extraConfig: DataGrid.Types.IImageColumnExtraConfigs | ||
) { | ||
super(config); | ||
this.altText = extraConfig.altText; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
namespace OSFramework.DataGrid.Event.Column { | ||
export class ImageColumnClick extends AbstractColumnEvent {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
namespace Providers.DataGrid.Wijmo.Column { | ||
export class ImageColumn extends AbstractProviderColumn<OSFramework.DataGrid.Configuration.Column.ColumnConfigImage> { | ||
constructor( | ||
grid: OSFramework.DataGrid.Grid.IGrid, | ||
columnID: string, | ||
configs: OSFramework.DataGrid.Types.IColumnConfigs, | ||
extraConfig: OSFramework.DataGrid.Types.IImageColumnExtraConfigs | ||
) { | ||
super( | ||
grid, | ||
columnID, | ||
new OSFramework.DataGrid.Configuration.Column.ColumnConfigImage( | ||
configs, | ||
extraConfig | ||
) | ||
); | ||
this._columnEvents = | ||
new OSFramework.DataGrid.Event.Column.ColumnEventsManager(this); | ||
} | ||
|
||
/** Returns all the events associated to the column */ | ||
public get columnEvents(): OSFramework.DataGrid.Event.Column.ColumnEventsManager { | ||
return this._columnEvents; | ||
} | ||
|
||
public get columnType(): OSFramework.DataGrid.Enum.ColumnType { | ||
return OSFramework.DataGrid.Enum.ColumnType.Image; | ||
} | ||
|
||
public get providerType(): wijmo.DataType { | ||
return wijmo.DataType.String; | ||
} | ||
|
||
public getProviderConfig(): OSFramework.DataGrid.Types.IColumnProviderConfigs { | ||
const config = super.getProviderConfig(); | ||
|
||
// Get the cellTemplate based on the actionColumnElementType | ||
config.cellTemplate = Helper.CellTemplateFactory.MakeCellTemplate( | ||
this.config.actionColumnElementType, | ||
config.binding, | ||
this.handleActionEvent.bind(this), | ||
this.config.altText | ||
); | ||
|
||
return config; | ||
} | ||
|
||
public handleActionEvent(ctx: wijmo.grid.ICellTemplateContext): void { | ||
//Let's clone the line, since we will be removing the metadata info from it. | ||
const clonedDataItem = _.cloneDeep(ctx.item); | ||
this.grid.rowMetadata.clear(clonedDataItem); | ||
|
||
this._columnEvents.trigger( | ||
OSFramework.DataGrid.Event.Column.ColumnEventType.ImageClick, | ||
JSON.stringify( | ||
this.grid.isSingleEntity | ||
? OSFramework.DataGrid.Helper.Flatten(clonedDataItem) | ||
: clonedDataItem | ||
) | ||
); | ||
} | ||
} | ||
} |
31 changes: 24 additions & 7 deletions
31
...aGrid/Wijmo/Helper/ActionColumnFactory.ts → ...aGrid/Wijmo/Helper/CellTemplateFactory.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters