Skip to content
This repository was archived by the owner on Jun 22, 2020. It is now read-only.

Commit 78dd826

Browse files
committed
!fixup
1 parent f314e24 commit 78dd826

28 files changed

+354
-302
lines changed

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
"test": "jest --config ./jest.config.js"
1313
},
1414
"devDependencies": {
15-
"@angular-devkit/build-angular": "0.803.25",
15+
"@angular-devkit/build-angular": "0.803.26",
1616
"@angular-ru/eslint-config": "12.3.0",
1717
"@angular-ru/prettier-config": "12.6.0",
1818
"@angular/animations": "8.2.14",
1919
"@angular/cdk": "8.2.3",
20-
"@angular/cli": "8.3.25",
20+
"@angular/cli": "8.3.26",
2121
"@angular/common": "8.2.14",
2222
"@angular/compiler": "8.2.14",
2323
"@angular/compiler-cli": "8.2.14",
@@ -31,7 +31,6 @@
3131
"@types/jest": "24.0.13",
3232
"@types/node": "12.7.5",
3333
"acorn": "6.1.1",
34-
"codelyzer": "5.0.1",
3534
"colors": "1.3.3",
3635
"core-js": "2.6.9",
3736
"eslint": "6.8.0",

projects/table-builder/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@angular-ru/ng-table-builder",
3-
"version": "0.40.0",
3+
"version": "0.41.0",
44
"license": "MIT",
55
"bugs": {
66
"url": "https://github.com/Angular-RU/ng-table-builder/issues"

projects/table-builder/src/lib/table/components/common/modal-view-layer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export abstract class ModalViewLayer<T extends PositionState> implements OnDestr
8181
public updateView(): void {
8282
detectChanges(this.cd);
8383

84-
this.ngZone.runOutsideAngular((): void => {
84+
this.ngZone.run((): void => {
8585
window.requestAnimationFrame((): void => {
8686
detectChanges(this.cd);
8787
this.app.tick();

projects/table-builder/src/lib/table/components/table-tbody/table-tbody.component.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ import {
33
ChangeDetectionStrategy,
44
ChangeDetectorRef,
55
Component,
6+
EventEmitter,
67
Injector,
78
Input,
89
NgZone,
10+
Output,
911
ViewEncapsulation
1012
} from '@angular/core';
1113

@@ -52,11 +54,11 @@ export class TableTbodyComponent {
5254
@Input('produce-disable-fn') public produceDisableFn: ProduceDisableFn = null;
5355
@Input('client-row-height') public clientRowHeight: number;
5456
@Input('column-schema') public columnSchema: ColumnsSchema;
57+
@Output() public changed: EventEmitter<void> = new EventEmitter(true);
5558
private readonly app: ApplicationRef;
5659
private readonly ngZone: NgZone;
5760

5861
constructor(public cd: ChangeDetectorRef, injector: Injector) {
59-
this.cd.reattach();
6062
this.selection = injector.get<SelectionService>(SelectionService);
6163
this.contextMenu = injector.get<ContextMenuService>(ContextMenuService);
6264
this.app = injector.get<ApplicationRef>(ApplicationRef);
@@ -87,12 +89,11 @@ export class TableTbodyComponent {
8789

8890
// eslint-disable-next-line max-params
8991
public handleOnClick(row: TableRow, key: string, event: MouseEvent, emitter: TableClickEventEmitter): void {
90-
this.ngZone.runOutsideAngular((): void => {
92+
this.ngZone.run((): void => {
9193
if (this.enableSelection) {
9294
this.selection.selectionTaskIdle = window.setTimeout((): void => {
9395
this.selection.selectRow(row, event, this.source);
94-
event.preventDefault();
95-
window.requestAnimationFrame((): void => this.app.tick());
96+
this.changed.emit();
9697
}, SELECTION_DELAY);
9798
}
9899
});

projects/table-builder/src/lib/table/directives/observer-view.directive.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ export class ObserverViewDirective implements AfterViewInit, OnDestroy {
2828
public ngOnDestroy(): void {
2929
this.element = { nativeElement: null };
3030
cancelAnimationFrame(this.frameId);
31-
this.observer.disconnect();
31+
if (this.observer) {
32+
this.observer.disconnect();
33+
}
3234
}
3335

3436
private observeChange(entry: IntersectionObserverEntry): void {

projects/table-builder/src/lib/table/directives/rows/template-cell.common.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import { KeyMap } from '../../interfaces/table-builder.internal';
55

66
export abstract class TemplateCellCommon {
77
public type: string = null;
8-
@Input() public row: boolean = null;
9-
@Input() public bold: boolean = null;
8+
@Input() public row: boolean = false;
9+
@Input() public bold: boolean = false;
1010
@Input() public nowrap: boolean = true;
1111
@Input() public width: number = null;
1212
@Input() public height: number = null;

projects/table-builder/src/lib/table/services/selection/selection.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export class SelectionService implements OnDestroy {
9393
if (checkValueIsEmpty(id)) {
9494
throw new Error(
9595
`Can't select item, make sure you pass the correct primary key, or you forgot enable selection
96-
<ngx-table-builder [enable-selection]="true" primary-key="fieldId" />
96+
<ngx-table-builder enable-selection primary-key="fieldId" />
9797
`
9898
);
9999
}

projects/table-builder/src/lib/table/services/template-parser/template-parser.service.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ export class TemplateParserService {
5353
onClick: cell.onClick,
5454
dblClick: cell.dblClick,
5555
useDeepPath: key.includes('.'),
56-
context: cell.row ? ImplicitContext.ROW : ImplicitContext.CELL,
56+
context: TemplateParserService.getValidHtmlBooleanAttribute(cell.row)
57+
? ImplicitContext.ROW
58+
: ImplicitContext.CELL,
5759
nowrap: TemplateParserService.getValidPredicate(options.nowrap, cell.nowrap)
5860
};
5961
}
@@ -137,8 +139,8 @@ export class TemplateParserService {
137139
key,
138140
isModel,
139141
isVisible: true,
140-
verticalLine: column.verticalLine,
141142
excluded: !this.allowedKeyMap[key],
143+
verticalLine: TemplateParserService.getValidHtmlBooleanAttribute(column.verticalLine),
142144
td: TemplateParserService.templateContext(key, tdTemplate, this.columnOptions),
143145
stickyLeft: TemplateParserService.getValidHtmlBooleanAttribute(column.stickyLeft),
144146
stickyRight: TemplateParserService.getValidHtmlBooleanAttribute(column.stickyRight),

projects/table-builder/src/lib/table/services/utils/utils.service.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,9 @@ export class UtilsService implements UtilsInterface {
8181
});
8282
}
8383

84-
public microtask(callback: Fn): Promise<void> {
84+
public macrotaskInZone(callback: Fn, time: number = 0): Promise<void> {
8585
return new Promise((resolve: Fn): void => {
86-
callback();
87-
resolve();
88-
});
89-
}
90-
91-
public macrotask(callback: Fn, time: number = 0): Promise<void> {
92-
return new Promise((resolve: Fn): void => {
93-
this.zone.runOutsideAngular((): void => {
86+
this.zone.run((): void => {
9487
window.setTimeout((): void => {
9588
callback();
9689
resolve();

projects/table-builder/src/lib/table/table-builder.api.ts

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ export abstract class TableBuilderApiImpl
6868
@Input('auto-height') public autoHeightDetect: boolean = true;
6969
@Input('native-scrollbar') public nativeScrollbar: boolean = false;
7070
@Input('primary-key') public primaryKey: string = PrimaryKey.ID;
71-
@Input('head-height') public headHeight: string | number = null;
72-
@Input('row-height') public rowHeight: string | number = null;
7371
@Input('vertical-border') public verticalBorder: boolean = true;
7472
@Input('enable-selection') public enableSelection: boolean = false;
7573
@Input('enable-filtering') public enableFiltering: boolean = false;
@@ -79,36 +77,26 @@ export abstract class TableBuilderApiImpl
7977
@Output() public schemaChanges: EventEmitter<SimpleSchemaColumns> = new EventEmitter();
8078
@Output() public onChanges: EventEmitter<TableRow[] | null> = new EventEmitter();
8179
@Output() public sortChanges: EventEmitter<OrderedField[]> = new EventEmitter();
82-
8380
@ContentChild(NgxOptionsComponent, { static: false })
8481
public columnOptions: NgxOptionsComponent = null;
85-
8682
@ContentChildren(NgxColumnComponent)
8783
public columnTemplates: QueryListRef<NgxColumnComponent> = null;
88-
8984
@ContentChild(NgxContextMenuComponent, { static: false })
9085
public contextMenuTemplate: NgxContextMenuComponent = null;
91-
9286
@ContentChild(NgxHeaderComponent, { static: false })
9387
public headerTemplate: NgxHeaderComponent = null;
94-
9588
@ContentChild(NgxFooterComponent, { static: false })
9689
public footerTemplate: NgxFooterComponent = null;
97-
9890
@ContentChild(NgxFilterComponent, { static: false })
9991
public filterTemplate: NgxFilterComponent = null;
100-
10192
@ViewChild('tableViewport', { static: true })
10293
public scrollContainer: ElementRef<HTMLElement>;
103-
10494
@ViewChildren('column', { read: false })
10595
public columnList: QueryList<ElementRef<HTMLDivElement>>;
106-
10796
public scrollbarWidth: number = SCROLLBAR_WIDTH;
10897
public columnListWidth: number = 0;
10998
public viewPortInfo: ViewPortInfo = {};
11099
public tableViewportChecked: boolean = true;
111-
112100
/**
113101
* @description: the custom names of the column list to be displayed in the view.
114102
* @example:
@@ -121,7 +109,6 @@ export abstract class TableBuilderApiImpl
121109
* modelColumnKeys === [ 'id', 'hello', 'value' ]
122110
*/
123111
public modelColumnKeys: string[] = [];
124-
125112
/**
126113
* @description: the custom names of the column list to be displayed in the view.
127114
* @example:
@@ -132,7 +119,6 @@ export abstract class TableBuilderApiImpl
132119
* customModelColumnsKeys === [ 'name' ]
133120
*/
134121
public customModelColumnsKeys: string[] = [];
135-
136122
public isDragging: KeyMap<boolean> = {};
137123
public accessDragging: boolean = false;
138124
public abstract readonly templateParser: TemplateParserService;
@@ -146,12 +132,25 @@ export abstract class TableBuilderApiImpl
146132
public abstract readonly ngZone: NgZone;
147133
protected originalSource: TableRow[];
148134
protected renderedCountKeys: number;
135+
protected isDragMoving: boolean = false;
149136
protected abstract readonly app: ApplicationRef;
150137
protected abstract readonly viewChanges: NgxTableViewChangesService;
151138
protected abstract readonly draggable: DraggableService;
152139
private filterIdTask: number = null;
153140
private idleDetectChangesId: number;
154141
private columnFrameId: number;
142+
private _headHeight: number;
143+
private _rowHeight: number = null;
144+
145+
@Input('head-height')
146+
public set headHeight(val: string | number) {
147+
this._headHeight = parseInt(val as string);
148+
}
149+
150+
@Input('row-height')
151+
public set rowHeight(val: string | number) {
152+
this._rowHeight = parseInt(val as string);
153+
}
155154

156155
/**
157156
* @description - <table-builder [keys]=[ 'id', 'value', 'id', 'position', 'value' ] />
@@ -204,7 +203,7 @@ export abstract class TableBuilderApiImpl
204203
}
205204

206205
public get clientRowHeight(): number {
207-
return (this.rowHeight as number) || ROW_HEIGHT;
206+
return this._rowHeight || ROW_HEIGHT;
208207
}
209208

210209
public get columnVirtualHeight(): number {
@@ -216,7 +215,7 @@ export abstract class TableBuilderApiImpl
216215
}
217216

218217
public get headLineHeight(): number {
219-
return this.headHeight ? (this.headHeight as number) : this.clientRowHeight;
218+
return this._headHeight ? this._headHeight : this.clientRowHeight;
220219
}
221220

222221
public get size(): number {
@@ -227,8 +226,20 @@ export abstract class TableBuilderApiImpl
227226
return this.source && this.source.length ? this.source : [];
228227
}
229228

229+
public get isEnableFiltering(): boolean {
230+
return this.enableFiltering !== false;
231+
}
232+
233+
public get isSkippedInternalSort(): boolean {
234+
return this.skipSort !== false;
235+
}
236+
237+
public get isEnableSelection(): boolean {
238+
return this.enableSelection !== false;
239+
}
240+
230241
private get filterValueExist(): boolean {
231-
return this.filterable.filterValueExist && this.enableFiltering;
242+
return this.filterable.filterValueExist && this.isEnableFiltering;
232243
}
233244

234245
private get notEmpty(): boolean {
@@ -276,10 +287,8 @@ export abstract class TableBuilderApiImpl
276287
this.ngZone.runOutsideAngular((): void => {
277288
window.clearInterval(this.filterIdTask);
278289
this.filterIdTask = window.setTimeout((): void => {
279-
if (!this.enableFiltering) {
280-
throw new Error(
281-
'You forgot to enable filtering: \n <ngx-table-builder [enable-filtering]="true" />'
282-
);
290+
if (!this.isEnableFiltering) {
291+
throw new Error('You forgot to enable filtering: \n <ngx-table-builder enable-filtering />');
283292
}
284293

285294
this.sortAndFilter().then((): void => this.reCheckDefinitions());
@@ -301,6 +310,7 @@ export abstract class TableBuilderApiImpl
301310
public drop({ previousIndex, currentIndex }: CdkDragSortEvent): void {
302311
const previousKey: string = this.visibleColumns[previousIndex];
303312
const currentKey: string = this.visibleColumns[currentIndex];
313+
this.isDragMoving = false;
304314
this.draggable.drop(previousKey, currentKey);
305315
this.changeSchema();
306316
}
@@ -381,6 +391,10 @@ export abstract class TableBuilderApiImpl
381391
}
382392

383393
protected calculateColumnWidthSummary(): void {
394+
if (this.isDragMoving) {
395+
return;
396+
}
397+
384398
this.ngZone.runOutsideAngular((): void => {
385399
clearInterval(this.columnFrameId);
386400
this.columnFrameId = window.setTimeout((): void => {

0 commit comments

Comments
 (0)