Skip to content

Commit

Permalink
Merge pull request #51 from KorzhCom/dev
Browse files Browse the repository at this point in the history
Version 1.3.2
  • Loading branch information
antifree authored Aug 11, 2021
2 parents 8f45785 + 902385c commit 016ff95
Show file tree
Hide file tree
Showing 13 changed files with 533 additions and 509 deletions.
4 changes: 2 additions & 2 deletions easydata.js/packs/core/src/i18n/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ export namespace i18n {

export function numberToStr(number: number, format?: string): string {
if (format && format.length > 0) {
const type = format.charAt(0);
const type = format.charAt(0).toUpperCase();
if (type === 'S') {
return formatWithSequence(number, format.slice(1));
}
Expand All @@ -444,7 +444,7 @@ export namespace i18n {
export function booleanToStr(bool: boolean, format?: string) {

if (format && format.length > 0) {
const type = format.charAt(0);
const type = format.charAt(0).toUpperCase();
if (type === 'S') {
const values = format.slice(1).split('|');
if (values.length > 1) {
Expand Down
487 changes: 3 additions & 484 deletions easydata.js/packs/crud/src/form/entity_edit_form.ts

Large diffs are not rendered by default.

489 changes: 489 additions & 0 deletions easydata.js/packs/crud/src/form/entity_form_builder.ts

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions easydata.js/packs/crud/src/public_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export * from './filter/data_filter'
export * from './filter/text_data_filter'

export * from './form/entity_edit_form'
export * from './form/entity_form_builder'

export * from './widgets/text_filter_widget'
export * from './widgets/progress_bar'
Expand Down
2 changes: 1 addition & 1 deletion easydata.js/packs/crud/src/views/entity_data_view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
GridCellRenderer, GridColumn, RowClickEvent
} from '@easydata/ui';

import { EntityEditFormBuilder } from '../form/entity_edit_form';
import { EntityEditFormBuilder } from '../form/entity_form_builder';
import { TextFilterWidget } from '../widgets/text_filter_widget';

import { DataContext } from '../main/data_context';
Expand Down
6 changes: 3 additions & 3 deletions easydata.js/version.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.3.1",
"baseVersion": "1.3.1",
"assetVersion": "01_03_01"
"version": "1.3.2",
"baseVersion": "1.3.2",
"assetVersion": "01_03_02"
}
2 changes: 1 addition & 1 deletion easydata.net/src/EasyData.Core/Export/ExportHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static Dictionary<string, IFormatProvider> GetPredefinedFormatters(IReadO
var dfmt = cols[i].DisplayFormat;
if (!string.IsNullOrEmpty(dfmt) && !result.ContainsKey(dfmt)) {
var format = GetFormat(dfmt);
if (format.StartsWith("S")) {
if (format.StartsWith("S", StringComparison.InvariantCultureIgnoreCase)) {
result.Add(dfmt, new SequenceFormat(format, settings.Culture));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,23 +94,18 @@ public virtual void LoadFromDbContext(DbContext context)

protected string GetEntityId(IEntityType entityType)
{
var entityName = GetEntityNameByType(entityType);
var entityName = Utils.GetEntityNameByType(entityType);
return DataUtils.ComposeKey(null, entityName);
}

protected string GetEntityNameByType(IEntityType entityType)
{
return entityType.ClrType.Name.Split('`').First();
}



#region auxiliary functions for LoadFromDbContext
protected virtual MetaEntity ProcessEntityType(IModel contextModel, IEntityType entityType)
{
var entity = Model.CreateEntity();
var tableName = entityType.GetTableName();
entity.Id = GetEntityId(entityType);
entity.Name = DataUtils.PrettifyName(GetEntityNameByType(entityType));
entity.Name = DataUtils.PrettifyName(Utils.GetEntityNameByType(entityType));
entity.NamePlural = DataUtils.MakePlural(entity.Name);

entity.ClrType = entityType.ClrType;
Expand Down Expand Up @@ -221,10 +216,13 @@ protected virtual void ProcessNavigationProperty(MetaEntity entity, IEntityType
if (lookupDataAttr != null) {
lookUpAttr.LookupDataAttribute = lookupDataAttr;

if (dataAttr.Index == int.MaxValue) {
dataAttr.Index = attrCounter;
if (lookupDataAttr.Index == int.MaxValue) {
lookupDataAttr.Index = attrCounter;
}

// hide lookup data field of lookup field on managing data
lookupDataAttr.ShowOnEdit = lookupDataAttr.ShowOnCreate = false;

attrCounter++;
entity.Attributes.Add(lookUpAttr);
}
Expand Down Expand Up @@ -280,7 +278,7 @@ private bool ApplyMetaEntityAttrAttribute(MetaEntityAttr entityAttr, PropertyInf

protected virtual MetaEntityAttr CreateEntityAttribute(MetaEntity entity, IEntityType entityType, IProperty property)
{
var entityName = GetEntityNameByType(entityType);
var entityName = Utils.GetEntityNameByType(entityType);
var propertyName = property.Name;
var columnName = property.GetColumnName();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public override async Task<EasyDataResultSet> GetEntitiesAsync(string modelId,
var result = new EasyDataResultSet();

var modelEntity = Model.EntityRoot.SubEntities.FirstOrDefault(e => e.ClrType == entityType.ClrType);
var attrIdProps = entityType.GetProperties().ToDictionary(prop => DataUtils.ComposeKey(entityType.Name.Split('.').Last(), prop.Name), prop => prop );
var attrIdProps = entityType.GetProperties().ToDictionary(prop => DataUtils.ComposeKey(entityContainer, prop.Name), prop => prop );

var attrs = modelEntity.Attributes.Where(attr => attr.Kind != EntityAttrKind.Lookup);
foreach (var attr in attrs) {
Expand Down Expand Up @@ -168,8 +168,7 @@ public override async Task DeleteEntityAsync(string modelId, string entityContai
private IEntityType GetCurrentEntityType(DbContext dbContext, string entityContainer)
{
var entityType = dbContext.Model.GetEntityTypes()
.FirstOrDefault(ent =>
ent.Name.Split('.').LastOrDefault() == entityContainer);
.FirstOrDefault(ent => Utils.GetEntityNameByType(ent) == entityContainer);

if (entityType == null) {
throw new ContainerNotFoundException(entityContainer);
Expand Down
17 changes: 17 additions & 0 deletions easydata.net/src/EasyData.EntityFrameworkCore.Relational/Utils.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.EntityFrameworkCore.Metadata;

namespace EasyData.EntityFrameworkCore
{
internal static class Utils
{
public static string GetEntityNameByType(IEntityType entityType)
{
return entityType.ClrType.Name.Split('`').First();
}
}
}
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.3.1.0",
"packageVersion": "1.3.1",
"assetVersion": "01_03_01"
"assemblyVersion": "1.3.2.0",
"packageVersion": "1.3.2",
"assetVersion": "01_03_02"
}
2 changes: 1 addition & 1 deletion playground/EasyDataAspNetCoreTest01/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
model.DisplayFormats.SetDefault(EasyData.DataType.DateTime, "Long date & time");
});
options.UseDbContext<AppDbContext>(opts => opts.KeepDbSetDeclarationOrder = true);
options.UseDbContext<AppDbContext>(opts => opts.SkipForeignKeys = false);
});
//.RequireAuthorization();

Expand Down
1 change: 1 addition & 0 deletions playground/EasyDataAspNetCoreTest02/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
app.UseEndpoints(endpoints => {
endpoints.MapEasyData(options => {
options.UseDbContext<ApplicationDbContext>(loaderOptions => {
loaderOptions.SkipForeignKeys = false;
//loaderOptions.AddFilter(entityType => !entityType.ClrType.Name.StartsWith("Identity"));
});
});
Expand Down

0 comments on commit 016ff95

Please sign in to comment.