Skip to content

Commit

Permalink
Merge pull request #47 from KorzhCom/dev
Browse files Browse the repository at this point in the history
Version 1.3.1
  • Loading branch information
antifree authored Jul 27, 2021
2 parents f3d4030 + 23ab91f commit ab4acf7
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 21 deletions.
27 changes: 23 additions & 4 deletions easydata.js/packs/crud/src/form/entity_edit_form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ export class EntityEditFormBuilder {
},
onDestroy: () => {
lookupGrid.destroy();
// return focus on button
b.toDOM().focus();
}
});
});
Expand Down Expand Up @@ -233,7 +235,7 @@ export class EntityEditFormBuilder {
}
else {
b.mask(mask)
b.on('keypress', (ev) => this.applySumbit(ev as KeyboardEvent))
.on('input', ev => {
b.removeClass('is-invalid');
try {
Expand Down Expand Up @@ -314,7 +316,7 @@ export class EntityEditFormBuilder {
if (readOnly)
b.attr('readonly', '');
b.attr('name', attr.id)

b.on('keypress', (ev) => this.applySumbit(ev as KeyboardEvent))
if (values) {
for (let i = 0; i < values.length; i++) {
const val = values[i];
Expand Down Expand Up @@ -355,7 +357,8 @@ export class EntityEditFormBuilder {
if (value)
b.attr('checked', '');
} else {
b.value(dataUtils.IsDefinedAndNotNull(value)
b.on('keypress', (ev) => this.applySumbit(ev as KeyboardEvent))
.value(dataUtils.IsDefinedAndNotNull(value)
? value.toString()
: '');
}
Expand Down Expand Up @@ -434,6 +437,22 @@ export class EntityEditFormBuilder {
return editor;
}

private applySumbit(ev: KeyboardEvent): boolean {
if (ev.keyCode === 13) {
this.sumbitCallback && this.sumbitCallback();
return false;
}

return false;
}

private sumbitCallback: () => void;

public onSubmit(sumbitCallback: () => void) {
this.sumbitCallback = sumbitCallback;
return this;
}

public build(): EntityEditForm {
let fb: DomElementBuilder<HTMLDivElement>;
const formHtml =
Expand Down Expand Up @@ -537,7 +556,7 @@ export class EntityEditForm {
const property = input.name.substring(input.name.lastIndexOf('.') + 1);
const attr = this.context.getMetaData().getAttributeById(input.name);

if (input.type === 'checbox') {
if (input.type === 'checkbox') {
obj[property] = (input as HTMLInputElement).checked;
}
else if (input.type === 'file') {
Expand Down
13 changes: 9 additions & 4 deletions easydata.js/packs/crud/src/views/entity_data_view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,13 @@ export class EntityDataView {
private addClickHandler() {

const activeEntity = this.context.getActiveEntity();
const form = new EntityEditFormBuilder(this.context).build();
const form = new EntityEditFormBuilder(this.context)
.onSubmit(() => dlg.submit())
.build();

form.useValidators(this.defaultValidators);

this.dlg.open({
const dlg = this.dlg.open({
title: i18n.getText('AddDlgCaption')
.replace('{entity}', activeEntity.caption),
body: form.getHtml(),
Expand Down Expand Up @@ -167,10 +169,13 @@ export class EntityDataView {
private showEditForm(row: DataRow) {
const activeEntity = this.context.getActiveEntity();

const form = new EntityEditFormBuilder(this.context, { isEditForm: true, values: row }).build();
const form = new EntityEditFormBuilder(this.context, { isEditForm: true, values: row })
.onSubmit(() => dlg.submit())
.build();

form.useValidators(this.defaultValidators);

this.dlg.open({
const dlg = this.dlg.open({
title: i18n.getText('EditDlgCaption')
.replace('{entity}', activeEntity.caption),
body: form.getHtml(),
Expand Down
14 changes: 12 additions & 2 deletions easydata.js/packs/crud/src/widgets/text_filter_widget.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { i18n, utils as dataUtils } from '@easydata/core';
import { browserUtils, CellRendererType, domel, EasyGrid, GridCellRenderer, GridColumn } from '@easydata/ui';
import {
browserUtils, CellRendererType,
domel, EasyGrid,
GridCellRenderer, GridColumn, DFMT_REGEX
} from '@easydata/ui';
import { DataFilter } from '../filter/data_filter';

export interface TextFilterWidgetOptions {
Expand Down Expand Up @@ -143,7 +147,13 @@ export class TextFilterWidget {
if (dataUtils.isIntType(column.type)
|| dataUtils.getStringDataTypes().indexOf(column.type) >= 0) {
if (value) {
if(typeof value == 'number') {
if (column.dataColumn && column.dataColumn.displayFormat
&& DFMT_REGEX.test(column.dataColumn.displayFormat)) {
value = column.dataColumn.displayFormat.replace(DFMT_REGEX, (_, $1) => {
return i18n.numberToStr(value, $1);
});
}
else {
value = value.toLocaleString();
}

Expand Down
4 changes: 2 additions & 2 deletions easydata.js/packs/ui/src/grid/easy_grid_cell_renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { domel } from '../utils/dom_elem_builder';
import { EasyGridOptions } from './easy_grid_options';

const cssPrefix = "keg";
const DFMT_REGEX = /{0:(.*?)}/g;
export const DFMT_REGEX = /{0:(.*?)}/g;

export enum CellRendererType {
STRING = 1,
Expand All @@ -26,7 +26,7 @@ const StringCellRendererDefault: GridCellRenderer = (value: any, column: GridCol
.title(value || '');

if (column.align == GridColumnAlign.NONE) {
builder.addClass(`${cssPrefix}-cell-value-align-right`);
builder.addClass(`${cssPrefix}-cell-value-align-left`);
}
}

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.0",
"baseVersion": "1.3.0",
"assetVersion": "01_03_00"
"version": "1.3.1",
"baseVersion": "1.3.1",
"assetVersion": "01_03_01"
}
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.0.8",
"packageVersion": "1.3.0",
"assetVersion": "01_03_00"
"assemblyVersion": "1.3.1.0",
"packageVersion": "1.3.1",
"assetVersion": "01_03_01"
}
1 change: 1 addition & 0 deletions playground/EasyDataAspNetCoreTest01/Models/NWind/Order.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class Order
{
[DatabaseGenerated(DatabaseGeneratedOption.None)]
[Column("OrderID")]
[MetaEntityAttr(Editable = false, DisplayFormat = "{0:D8}")]
public int Id { get; set; }

[NotMapped]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class Order
{
[DatabaseGenerated(DatabaseGeneratedOption.None)]
[Column("OrderID")]
[MetaEntityAttr(DisplayFormat = "{0:D8}")]
public int Id { get; set; }

[NotMapped]
Expand All @@ -21,7 +22,7 @@ public string Name {
}

[Display(Name = "Ordered")]
[MetaEntityAttr(Editable = false)]
[MetaEntityAttr(Editable = false, DisplayFormat = "{0:dd.MM.yyyy}", Sorting = -1)]
public DateTime? OrderDate { get; set; }

[Display(Name = "Required")]
Expand All @@ -30,6 +31,7 @@ public string Name {
[Display(Name = "Shipped")]
public DateTime? ShippedDate { get; set; }

[MetaEntityAttr(DisplayFormat = "{0:C2} грн")]
public decimal? Freight { get; set; }

public string CustomerID { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
using System.ComponentModel.DataAnnotations.Schema;

using EasyData.EntityFrameworkCore;

namespace EasyDataBasicDemo.Models
{
[MetaEntity(false)]
public class Shipper
{
[Column("ShipperID")]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using EasyData.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations.Schema;
using EasyData.EntityFrameworkCore;

namespace EasyDataBasicDemo.Models
{
[MetaEntity(false)]
public class Supplier
{

Expand Down

0 comments on commit ab4acf7

Please sign in to comment.