Skip to content

Commit

Permalink
Merge pull request #181 from KorzhCom/dev
Browse files Browse the repository at this point in the history
Version 1.5.0
  • Loading branch information
korzh authored Feb 3, 2024
2 parents fe884f0 + fc22caa commit 72120f5
Show file tree
Hide file tree
Showing 23 changed files with 106 additions and 56 deletions.
7 changes: 6 additions & 1 deletion easydata.js/packs/core/src/data/aggr_settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,12 @@ export class AggregationSettings {

public isEmpty(): boolean {
return !(this.hasAggregates() || this.hasGroups() ||
this.hasAggregates() || this.hasRecordCount());
this.hasGrandTotals() || this.hasRecordCount());
}

public isValid() : boolean {
return (this.hasGroups() && (this.hasAggregates() || this.hasRecordCount()))
|| (this.hasAggregates && this.hasGrandTotals());
}

public drop() {
Expand Down
6 changes: 5 additions & 1 deletion easydata.js/packs/core/src/http/http_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ import { HttpMethod } from './http_method';
import { HttpHeaders, HttpRequest, HttpRequestDescriptor, HttpRequestOptions } from './http_request';

export class HttpResponseError extends Error {
constructor(public status: number, message: string) {
public status: number;

constructor(status: number, message: string) {
super(message);
Object.setPrototypeOf(this, HttpResponseError.prototype);
this.status = status;
}
}

Expand Down
22 changes: 11 additions & 11 deletions easydata.js/packs/core/src/i18n/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,14 +286,14 @@ export namespace i18n {
* If the locale does exist yet - it will be added
* @param localeInfo a LocaleInfo object that contains the locale settings and textual resources
*/
export function updateLocaleInfo(localeId: string, localeData: LocaleInfo) : void {
mapInfo(localeData);
export function updateLocaleInfo(localeId: string, localeInfo: LocaleInfo) : void {
mapInfo(localeInfo);

let localeInfoToUpdate = currentLocale;

if (localeId) {
if (!localeData.localeId) {
localeData.localeId = localeId;
if (!localeInfo.localeId) {
localeInfo.localeId = localeId;
}

localeInfoToUpdate = allLocales[localeId];
Expand All @@ -302,7 +302,7 @@ export namespace i18n {
allLocales[localeId] = localeInfoToUpdate;
}
}
utils.assignDeep(localeInfoToUpdate, localeData);
utils.assignDeep(localeInfoToUpdate, localeInfo);
}

/**
Expand Down Expand Up @@ -473,28 +473,28 @@ export namespace i18n {

/**
* Converts a numeric value to the string taking into the account the decimal separator
* @param value - the number to convert
* @param num - the number to convert
* @param format - the format of the number representation (D - decimal, F - float, C - currency)
* @param decimalSeparator - the symbol that represents decimal separator. If not specified the function gets the one from the current locale settings.
*/
export function numberToStr(number: number, format?: string, decimalSeparator?: string): string {
export function numberToStr(num: number, format?: string, decimalSeparator?: string): string {
if (format && format.length > 0) {
const type = format.charAt(0).toUpperCase();
if (type === 'S') {
return formatWithSequence(number, format.slice(1));
return formatWithSequence(num, format.slice(1));
}
else if (['D', 'F', 'C'].indexOf(type) >= 0) {
const locale = getCurrentLocale();
return number.toLocaleString(locale, getNumberFormatOptions(format));
return num.toLocaleString(locale, getNumberFormatOptions(format));
}
else {
return convertWithMask(Math.trunc(number), format);
return convertWithMask(Math.trunc(num), format);
}
}

const localeSettings = getLocaleSettings();
decimalSeparator = decimalSeparator || localeSettings.decimalSeparator;
return number.toString().replace('.', decimalSeparator);
return num.toString().replace('.', decimalSeparator);
}

export function booleanToStr(bool: boolean, format?: string) {
Expand Down
17 changes: 13 additions & 4 deletions easydata.js/packs/core/src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,13 @@ export namespace utils {
* @param args - an array of the source objects
*/
export function assign(target: any, ...args: any[]): any {
if (!target) {
target = {};
}

for (let i = 0; i < args.length; i++) {
let source = args[i];
if (source) {
if (source && source.hasOwnProperty) {
for (let key in source) {
if (source.hasOwnProperty(key)) {
target[key] = source[key];
Expand Down Expand Up @@ -67,14 +71,19 @@ export namespace utils {
}

for (let source of sources) {
if (source) {
if (source && source.hasOwnProperty) {
for (let key in source) {
if (source.hasOwnProperty(key)) {
let sourceVal = source[key];
if (sourceVal !== null && typeof sourceVal === 'object') {

//we don't make a deep copy of HTML elements and any other property makred as a 'reference' (ends with 'Ref')
if (sourceVal !== null && typeof sourceVal === 'object'
&& key.endsWith('Ref') && !(sourceVal instanceof HTMLElement))
{
if (hashSet.has(sourceVal)) {
target[key] = hashSet.get(sourceVal);
} else {
}
else {
if (Array.isArray(sourceVal)) {
target[key] = createArrayFrom(sourceVal);
hashSet.set(sourceVal, target[key]);
Expand Down
9 changes: 6 additions & 3 deletions easydata.js/packs/crud/src/views/easy_data_view_dispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ import { ProgressBar } from '../widgets/progress_bar';
import { DataContext } from '../main/data_context';
import { EntityDataView } from './entity_data_view';
import { EasyDataViewDispatcherOptions } from './options';
import { RootDataView } from './root_data_view';
import { RootDataView, RootDataViewOptions } from './root_data_view';

export class EasyDataViewDispatcher {
private context: DataContext;
private basePath: string;

private container: HTMLElement;

private options: EasyDataViewDispatcherOptions = {
Expand Down Expand Up @@ -114,7 +113,11 @@ export class EasyDataViewDispatcher {
this.basePath, this.options);
}
else {
window['EDView'] = new RootDataView(this.container, this.context, this.basePath);
const rootViewOptions: RootDataViewOptions = {};
if (typeof this.options.usePluralNames !== 'undefined') {
rootViewOptions.usePluralNames = this.options.usePluralNames;
}
window['EDView'] = new RootDataView(this.container, this.context, this.basePath, rootViewOptions);
}
}

Expand Down
8 changes: 6 additions & 2 deletions easydata.js/packs/crud/src/views/entity_data_view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export class EntityDataView {
const gridSlot = document.createElement('div');
this.slot.appendChild(gridSlot);
gridSlot.id = 'Grid';
this.grid = new EasyGrid(dataUtils.assignDeep({
let gridOptions = {
slot: gridSlot,
dataTable: result,
paging: {
Expand All @@ -91,7 +91,11 @@ export class EntityDataView {
onGetCellRenderer: this.manageCellRenderer.bind(this),
onRowDbClick: this.rowDbClickHandler.bind(this),
onSyncGridColumn: this.syncGridColumnHandler.bind(this)
}, this.options.grid || {}));
};

const sourceOptions = this.options.grid || {};
gridOptions = dataUtils.assignDeep(gridOptions, sourceOptions);
this.grid = new EasyGrid(gridOptions);

if (this.options.showFilterBox) {
let filterWidgetSlot: HTMLElement;
Expand Down
1 change: 1 addition & 0 deletions easydata.js/packs/crud/src/views/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ export interface EasyDataViewDispatcherOptions extends EasyDataViewOptions {
basePath? : string;
rootEntity?: string,
container?: HTMLElement | string;
usePluralNames?: boolean;
}
21 changes: 17 additions & 4 deletions easydata.js/packs/crud/src/views/root_data_view.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
import { i18n, MetaData } from '@easydata/core';
import { i18n, utils, MetaData } from '@easydata/core';
import { domel } from '@easydata/ui';
import { setLocation } from '../utils/utils';
import { DataContext } from '../main/data_context';

export interface RootDataViewOptions {
usePluralNames?: boolean;
}

export class RootDataView {
private metaData: MetaData;
private options: RootDataViewOptions = {
usePluralNames: true
}

constructor (
private slot: HTMLElement,
private context: DataContext,
private basePath: string) {

private basePath: string,
options?: RootDataViewOptions)
{
this.metaData = this.context.getMetaData();
this.slot.innerHTML += `<h1>${i18n.getText('RootViewTitle')}</h1>`;
utils.assign(this.options, options);

this.renderEntitySelector();
}
Expand All @@ -30,14 +39,18 @@ export class RootDataView {
.addChild('ul', b => {
b.addClass('ed-entity-menu');
entities.forEach(ent => {
const entCaption = this.options.usePluralNames && ent.captionPlural
? ent.captionPlural
: ent.caption;

b.addChild('li', b => {
b.addClass('ed-entity-item')
.on('click', () => {
setLocation(`${this.basePath}/${decodeURIComponent(ent.id)}`);
})
.addChild('div', b => {
b.addClass('ed-entity-item-caption')
.addText(ent.captionPlural || ent.caption);
.addText(entCaption);
});

if (ent.description) {
Expand Down
2 changes: 1 addition & 1 deletion easydata.js/packs/crud/src/widgets/text_filter_widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class TextFilterWidget {
private filter: DataFilter,
options?: TextFilterWidgetOptions) {

this.options = dataUtils.assignDeep(this.options, options || {});
this.options = dataUtils.assign(this.options, options || {});

const stringDefRenderer = this.grid.cellRendererStore
.getDefaultRendererByType(CellRendererType.STRING);
Expand Down
2 changes: 1 addition & 1 deletion easydata.js/packs/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"defaults"
],
"peerDependencies": {
"@easydata/core": "1.4.21"
"@easydata/core": "^1.4.21"
},
"files": [
"dist"
Expand Down
7 changes: 4 additions & 3 deletions easydata.js/packs/ui/src/grid/easy_grid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class EasyGrid implements EasyGridBase {

protected paginationOptions = {
maxButtonCount: 10,
useBootstrap: false //true
useBootstrap: false
}

protected defaultDataGridOptions : EasyGridOptions = {
Expand Down Expand Up @@ -144,11 +144,13 @@ export class EasyGrid implements EasyGridBase {
}

private mergeOptions(options: EasyGridOptions): EasyGridOptions {
const aggrOptions = utils.assignDeep({}, this.defaultDataGridOptions.aggregates, options.aggregates )
const colWidthOptions = utils.assignDeep({}, this.defaultDataGridOptions.columnWidths, options.columnWidths);
const pagingOptions = utils.assignDeep({}, this.defaultDataGridOptions.paging, options.paging);

const result: EasyGridOptions = utils.assign({}, this.defaultDataGridOptions, options);

result.aggregates = aggrOptions;
result.columnWidths = colWidthOptions;
result.paging = pagingOptions;

Expand Down Expand Up @@ -249,8 +251,7 @@ export class EasyGrid implements EasyGridBase {

this.addEventListener('pageChanged', ev => this.activeRowIndex = -1);


utils.assignDeep(this.paginationOptions, options.pagination);
utils.assign(this.paginationOptions, options.pagination);

this.pagination.pageSize = this.options.paging.pageSize
|| this.pagination.pageSize;
Expand Down
8 changes: 4 additions & 4 deletions easydata.js/version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"version": "1.4.21",
"baseVersion": "1.4.21",
"assetVersion": "01_04_21",
"tag": "latest"
"version": "1.5.0",
"baseVersion": "1.5.0",
"assetVersion": "01_05_00",
"tag": "beta"
}
4 changes: 4 additions & 0 deletions easydata.net/src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<Copyright>Copyright 2020-$([System.DateTime]::Now.Year) (c) Korzh.com. All rights reserved.</Copyright>
<PackageProjectUrl>https://github.com/KorzhCom/EasyData</PackageProjectUrl>
<PackageIcon>easydata-icon02.png</PackageIcon>
<PackageIconUrl>https://cdn.korzh.com/img/easydata-icon02.png</PackageIconUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>

<NoWarn>CS1591,CS1574</NoWarn>

</PropertyGroup>
<ItemGroup>
<None Include="..\images\easydata-icon02.png" Pack="true" Visible="false" PackagePath=""/>
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions easydata.net/src/EasyData.Core/EasyDataResultSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public enum ColumnAlignment
public class EasyDataColStyle
{
public ColumnAlignment Alignment { get; set; } = ColumnAlignment.None;

public bool AllowAutoFormatting { get; set; } = false;
}


Expand Down Expand Up @@ -69,8 +71,6 @@ public class EasyDataColDesc
/// The style of the property to display in UI.
/// </summary>
public EasyDataColStyle Style { get; set; }


}

public class EasyDataCol
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ public Func<EasyDataRow, BeforeRowAddedCallback, CancellationToken, Task> Before
public string Description { get; set; }

/// <summary>
/// Gets or sets value indicating wether title and description will be shown
/// Gets or sets value indicating whether title and description will be shown
/// </summary>
public bool ShowDatasetInfo { get; set; } = true;

/// <summary>
/// Gets or sets value indicating whether the exporter shoud preserve the formatting in the original value
/// Gets or sets value indicating whether the exporter should preserve the formatting in the original value
/// </summary>
public bool PreserveFormatting { get; set; } = true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public interface IDataExportSettings
bool ShowDatasetInfo { get; set; }

/// <summary>
/// Gets or sets value indicating whether the exporter shoud preserve the formatting in the original value
/// Gets or sets value indicating whether the exporter should preserve the formatting in the original value
/// </summary>
bool PreserveFormatting { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,9 @@ public virtual void LoadFromDbContext()
var entityTypes = GetEntityTypes();

if (Options.KeepDbSetDeclarationOrder) {
// EF Core keeps information about entity types
// in alphabetical order.
// EF Core keeps information about entity types in alphabetical order.
// To make it possible to keep the original order
// we reoder the list of entities according to the orer of DbSets
// we reorder the list of entities according to the order of DbSets

entityTypes = entityTypes.OrderBy(t =>
_dbSetTypes.TryGetValue(t.ClrType, out var index) ? index : int.MaxValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace EasyData.EntityFrameworkCore
{
/// <summary>
/// Build entity metadata.
/// Builds entity metadata.
/// </summary>
public class MetadataCustomizer
{
Expand All @@ -21,7 +21,7 @@ public MetadataCustomizer(MetaData metadata)

/// <summary>
/// Gets the customizer for an entity by its type.
/// This is a virtual method that can be overriden in descendants
/// This is a virtual method that can be overridden in descendants
/// </summary>
/// <typeparam name="TEntity">Entity type.</typeparam>
/// <returns>An instance of IMetaEntityCustomizer&lt;TEntity&gt;.</returns>
Expand Down
Loading

0 comments on commit 72120f5

Please sign in to comment.