Skip to content

Commit

Permalink
Merge pull request #140 from KorzhCom/dev
Browse files Browse the repository at this point in the history
Version 1.4.7
  • Loading branch information
korzh authored Jun 3, 2022
2 parents 52d8495 + 1258a8f commit 0b42377
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 17 deletions.
4 changes: 1 addition & 3 deletions easydata.js/packs/core/src/event/event_emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface EqEventTypeRec {
}

/**
* Represents EasyQuery event type
* Represents EasyQuery event
*/
export interface EqEvent {

Expand All @@ -35,7 +35,6 @@ export interface EqEvent {
* The representation of event emitter.
*/
export class EventEmitter {

/**
* The array of events.
*/
Expand Down Expand Up @@ -175,5 +174,4 @@ export class EventEmitter {

return null;
}

}
18 changes: 18 additions & 0 deletions easydata.js/packs/ui/src/grid/easy_grid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ interface PaginationInfo {
const DEFAULT_ROW_HEIGHT = 36;
const DEFAULT_ROW_COUNT = 15;

/** Represents a grid widget with columns rows, paging, custom rendering and more */
export class EasyGrid {
protected eventEmitter: EventEmitter;

Expand Down Expand Up @@ -115,6 +116,7 @@ export class EasyGrid {

public readonly options: EasyGridOptions;

/** Creates and initializes all internal properties of the grid object */
constructor(options: EasyGridOptions) {
if (options && options.paging) {
options.paging = utils.assign(this.defaultDataGridOptions.paging,
Expand Down Expand Up @@ -214,6 +216,7 @@ export class EasyGrid {

private rowsOnPagePromise: Promise<number> = null;

/** Initializes grid widget according to the options passed in the parameter */
protected init(options: EasyGridOptions) {
if (options.onInit) {
this.addEventListener('init', options.onInit);
Expand Down Expand Up @@ -284,6 +287,10 @@ export class EasyGrid {
this.fireEvent('init');
}

/** Fires a grid event. You can pass either an event type
* (like 'init', 'rowClick', 'pageChanged', etc )
* or a ready-to-use grid event object
* */
public fireEvent(event: GridEvent | GridEventType) {
if (typeof event === "string") {
this.eventEmitter.fire(event);
Expand All @@ -293,24 +300,30 @@ export class EasyGrid {
}
}

/** Allows to set the data (represented by a EasyDataTable object)
* or to replace the existing one associated with the grid */
public setData(data: EasyDataTable) {
this.dataTable = data;
this.clear();
this.refresh();
}

/** Returns the EasyDataTable object associated with the grid via `setData()` call */
public getData(): EasyDataTable {
return this.dataTable;
}

/** Gets the list of grid columns */
public getColumns(): GridColumnList {
return this.columns;
}

/** This function is called when the grid is destroyed */
public destroy() {
this.slot.innerHTML = "";
}

/** Clears the current DOM object and re-renders everything from the scratch */
public refresh() {
this.clearDOM();
this.render();
Expand All @@ -320,6 +333,7 @@ export class EasyGrid {
this.slot.innerHTML = '';
}

/** Clears all DOM object in the grid and return it to its initial state */
public clear() {
this.pagination.page = 1;
this.clearDOM();
Expand All @@ -329,6 +343,7 @@ export class EasyGrid {

private firstRender = true;

/** Renders the grid */
protected render() {
if (!this.hasData() && !this.options.showPlusButton)
return;
Expand Down Expand Up @@ -998,6 +1013,7 @@ export class EasyGrid {
return cellElement;
}

/** Sets current grid pages (if paging is used) */
public setPage(page: number) {
this.pagination.page = page;
this.fireEvent({ type: "pageChanged", page: page });
Expand Down Expand Up @@ -1314,10 +1330,12 @@ export class EasyGrid {
return null;
}

/** Makes the grid focused for keyboard events */
public focus() {
this.bodyViewportDiv.focus();
}

/** Resizes columns according to the data they represent */
public resizeColumns() {
if (this.options.columnWidths.autoResize === AutoResizeColumns.Never) return;

Expand Down
6 changes: 3 additions & 3 deletions easydata.js/version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"version": "1.4.6",
"baseVersion": "1.4.6",
"assetVersion": "01_04_06",
"version": "1.4.7",
"baseVersion": "1.4.7",
"assetVersion": "01_04_07",
"tag": "latest"
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public Task ExportAsync(IEasyDataResultSet data, Stream stream, CancellationToke
/// <returns>Task.</returns>
public async Task ExportAsync(IEasyDataResultSet data, Stream stream, IDataExportSettings settings, CancellationToken ct = default)
{
using (var writer = new StreamWriter(stream, new UTF8Encoding(false))) {
using (var writer = new StreamWriter(stream, new UTF8Encoding(false), 2048, true)) {
await ExportAsync(data, writer, settings, ct).ConfigureAwait(false);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public Task ExportAsync(IEasyDataResultSet data, Stream stream, CancellationToke
/// <returns>Task.</returns>
public async Task ExportAsync(IEasyDataResultSet data, Stream stream, IDataExportSettings settings, CancellationToken ct = default)
{
using (var writer = new StreamWriter(stream, new UTF8Encoding(false))) {
using (var writer = new StreamWriter(stream, new UTF8Encoding(false), 2048, true)) {
await ExportAsync(data, writer, settings, ct).ConfigureAwait(false);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,20 @@ public void TestFilters()
var attr = entity.FindAttribute(a => a.Id.Contains("Phone"));
attr.Should().BeNull();
}

[Fact]
public void SkipUnknownTypes()
{
var meta = new MetaData();
var loaderOptions = new DbContextMetaDataLoaderOptions();

meta.LoadFromDbContext(_dbContext, loaderOptions);

var entity = meta.FindEntity(ent => ent.ClrType.Equals(typeof(Customer)));
entity.Should().NotBeNull();

var attr = entity.FindAttributeByExpression("Customer.TimeCreated");
attr.Should().BeNull();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Faker.Net" Version="1.5.150" />
<PackageReference Include="FluentAssertions" Version="5.10.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqLite" Version="3.1.9" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
<PackageReference Include="coverlet.collector" Version="1.2.0" />
</ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqLite" Version="5.0.17" />
<PackageReference Include="NodaTime" Version="3.1.0" />
<PackageReference Include="EntityFrameworkCore.Sqlite.NodaTime" Version="5.1.0" />
<PackageReference Include="Faker.Net" Version="1.5.150" />
<PackageReference Include="FluentAssertions" Version="5.10.3" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\EasyData.EntityFrameworkCore.Relational\EasyData.EntityFrameworkCore.Relational.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text;

using NodaTime;

using Microsoft.EntityFrameworkCore;

Expand Down Expand Up @@ -45,7 +46,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
public static TestDbContext Create()
{
return new TestDbContext(new DbContextOptionsBuilder()
.UseSqlite("Data Source = :memory:")
.UseSqlite("Data Source = :memory:", opts => opts.UseNodaTime())
.Options);
}
}
Expand Down Expand Up @@ -74,6 +75,8 @@ public class Customer
[Column("CustomerID")]
public string Id { get; set; }

public Instant TimeCreated { get; set; }

[Display(Name = "Company Name")]
public string CompanyName { get; set; }

Expand Down
6 changes: 3 additions & 3 deletions easydata.net/version.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"assemblyVersion": "1.4.6.1",
"packageVersion": "1.4.6",
"assetVersion": "01_04_06"
"assemblyVersion": "1.4.7.3",
"packageVersion": "1.4.7",
"assetVersion": "01_04_07"
}

0 comments on commit 0b42377

Please sign in to comment.