Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/angular strict/qgrid ngx plugins #616

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
0270ae8
Merge pull request #2 from qgrid/master
Dalantren May 16, 2022
5a8ab6d
Added strict rules for angular and explicit any for eslint
Dalantren May 18, 2022
c755d15
Fixed traverse service
Dalantren May 18, 2022
4213ed7
fixed typo
Dalantren May 18, 2022
2636f33
Fixed some ease issues
Dalantren May 18, 2022
7237758
Fixed pipes
Dalantren May 18, 2022
dbdc505
Removed strict property initilize
Dalantren May 19, 2022
21da663
Updates to other libs
Dalantren May 19, 2022
e8c388b
Work in progress
Dalantren May 19, 2022
f8a57cd
CHanges for expression builder
Dalantren May 19, 2022
a2e2b72
Changes for query-builder
Dalantren May 19, 2022
d7efb07
Fixed rest in expression-builder
Dalantren May 19, 2022
dc488a3
Fixed expression and query builders
Dalantren May 19, 2022
1028409
little eslint fixes
Dalantren May 19, 2022
676364e
Fixed Number and Date pipes
Dalantren May 19, 2022
784c77c
Fixed File directive, attr return type, options in example
Dalantren May 19, 2022
a50693b
Temporary disabled 3 rules for tsconfig
Dalantren May 19, 2022
9899f0d
Added Evaluated type
Dalantren May 20, 2022
a15ce71
Changes for Evaluate and Watch utils
Dalantren May 25, 2022
eec73f0
Enabled no Implicit this. Fixed query builder and expression builder
Dalantren May 26, 2022
0ebfa36
Merge branch 'feature/angular-strict/qgrid-ngx-plugins-2' into featur…
Dalantren May 26, 2022
686b220
Removed console.log
Dalantren May 26, 2022
44430d8
Merge branch 'feature/angular-strict/qgrid-ngx-plugins' into feature/…
Dalantren May 26, 2022
e0482df
Enabled No Implicit any
Dalantren May 26, 2022
35a10a5
Fixed expression builder & query-builder
Dalantren May 26, 2022
d315d36
Little fixes
Dalantren May 26, 2022
4910ce2
Fixed live-columns and live-rows components
Dalantren May 26, 2022
2374565
Fixed Pane component
Dalantren May 26, 2022
4035bf8
Updated return type of getErrors() for Validator
Dalantren May 26, 2022
6b187fc
Merge branch 'feature/angular-strict/qgrid-ngx-plugins-2' into featur…
Dalantren May 26, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,6 @@
"@typescript-eslint/semi": ["error", "always"],
"@typescript-eslint/type-annotation-spacing": "error",
"@typescript-eslint/unified-signatures": "error",
"@typescript-eslint/no-explicit-any": "off"
"@typescript-eslint/no-explicit-any": "warn"
}
}
2 changes: 1 addition & 1 deletion packages/qgrid-core/public-api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ export { Resource } from './src/resource/resource';
// export { EnumerableResource } from './src/resource/resource.enumerable';
// export { factory } from './src/resource/resource.factory';
// rest
export { RestState } from './src/rest/rest.state';
export { RestState, RestSerialized } from './src/rest/rest.state';
// row-details
export { RowDetails } from './src/row-details/row.details';
export { RowDetailsLet } from './src/row-details/row.details.let';
Expand Down
79 changes: 40 additions & 39 deletions packages/qgrid-core/src/column-type/editor.options.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,43 +11,44 @@ export declare type EditorOptionsTrigger = 'click' | 'custom' | 'focus';
*/
export interface EditorOptions {

/**
* Says when cell should go to the edit mode.
*
* * `click` edit mode activates when user clicks on cell.
* * `custom` if user defines own edit mode trigger, like button for reference column edit, this option should be used.
* * `focus` edit mode activates when cell receives focus.
*/
trigger?: EditorOptionsTrigger;

/**
* Defines navigation behavior when cell is in edit mode.
*
* * `control` when cell is in edit mode, keyboard navigation events are disabled(in general, `tab` and `shift+tab` still works).
* * `transparent` when cell is in edit mode, keyboard navigation event are still applicable.
*/
cruise?: EditorOptionsCruise;

/**
* q-grid model factory, can be used by reference column to draw a another q-grid in edit cell mode.
*/
modelFactory?: (context: {
row: any;
column: ColumnModel;
getValue: (row: any) => any;
reference: { commit: Command; cancel: Command; value: any };
}) => Model;

/**
* Can be used by e.g. `auto-complete` editor to populate list of items.
*/
fetch?: () => Promise<any> | { subscribe: (x: any) => void } | any;

/**
* List of actions, can be used by row-options column to draw menu with commands.
*/
actions?: Action[];

label?: any;
value?: any;
/**
* Says when cell should go to the edit mode.
*
* * `click` edit mode activates when user clicks on cell.
* * `custom` if user defines own edit mode trigger, like button for reference column edit, this option should be used.
* * `focus` edit mode activates when cell receives focus.
*/
trigger?: EditorOptionsTrigger;

/**
* Defines navigation behavior when cell is in edit mode.
*
* * `control` when cell is in edit mode, keyboard navigation events are disabled(in general, `tab` and `shift+tab` still works).
* * `transparent` when cell is in edit mode, keyboard navigation event are still applicable.
*/
cruise?: EditorOptionsCruise;

/**
* q-grid model factory, can be used by reference column to draw a another q-grid in edit cell mode.
*/
modelFactory?: (context: {
row: any;
column: ColumnModel;
getValue: (row: any) => any;
reference: { commit: Command; cancel: Command; value: any };
createDefaultModel?: () => Model;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added this property.
Rest file didn't changed

}) => Model;

/**
* Can be used by e.g. `auto-complete` editor to populate list of items.
*/
fetch?: () => Promise<any> | { subscribe: (x: any) => void } | any;

/**
* List of actions, can be used by row-options column to draw menu with commands.
*/
actions?: Action[];

label?: any;
value?: any;
}
14 changes: 8 additions & 6 deletions packages/qgrid-core/src/rest/rest.state.d.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { Model } from '../model/model';

export interface RestSerialized {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure about naming

order: string;
filter: string;
skip: number;
take: number;
}

export declare class RestState {
url: string;
method: string;
serialize: (model: Model) => {
order: string;
filter: string;
skip: number;
take: number;
};
serialize: (model: Model) => RestSerialized;
}
4 changes: 2 additions & 2 deletions packages/qgrid-core/src/validation/validation.service.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export declare interface Validator {
validate(value: any): boolean;
getErrors(): Array<string>;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@klumba12 check here, please. I updated this type because Validator is using LIVR and this return type described in livr.d.ts.

validate(value: any): boolean;
getErrors(): { [key: string]: (Array<string> | string) };
}

export declare function hasRules(rules: any, key: string): boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<q-grid-columns generation="deep">
</q-grid-columns>

<q-grid-import options="{head:'numeric'}">
<q-grid-import [options]="{head:'numeric'}">
<ng-template for="trigger"
let-$action>
<button mat-button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { GridPlugin, TemplateHostService } from '@qgrid/ngx';
providers: [GridPlugin, TemplateHostService],
})
export class ActionComponent implements OnInit {
@ContentChild(TemplateRef, { static: true }) templateRef: TemplateRef<any>;
@ContentChild(TemplateRef, { static: true }) templateRef: TemplateRef<unknown>;

@Input() title: string;
@Input() icon: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { isArray, predicateFactory } from '@qgrid/core';
import { ColumnModel, Fetch, isArray, predicateFactory } from '@qgrid/core';
import { GridPlugin } from '@qgrid/ngx';

@Component({
Expand All @@ -13,15 +13,15 @@ export class AutoCompleteEditorComponent {
return this.plugin.view.edit.cell;
}

options: any[] = [];
options: unknown[] = [];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure


// eslint-disable-next-line no-use-before-define
context: { $implicit: AutoCompleteEditorComponent } = {
$implicit: this,
};

get items() {
return (this.cell.fetch as any).result;
return (this.cell.fetch as Fetch).result as unknown[];
}

get title() {
Expand Down Expand Up @@ -53,12 +53,12 @@ export class AutoCompleteEditorComponent {
this.options = [];
}

itemLabelFactory(column) {
itemLabelFactory(column: ColumnModel) {
const { itemLabel } = column;
if (itemLabel) {
return item => itemLabel(item);
return (item: unknown) => itemLabel(item);
}

return item => item;
return (item: unknown) => item;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import { BackdropService } from './backdrop.service';
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class BackdropComponent implements OnInit, OnDestroy {
@ViewChild(TemplateRef, { static: true }) template: TemplateRef<any>;
@Output('close') closeEvent = new EventEmitter<any>();
@ViewChild(TemplateRef, { static: true }) template: TemplateRef<unknown>;
@Output('close') closeEvent = new EventEmitter<void>();
@Input() propagate = true;

// eslint-disable-next-line no-use-before-define
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import {
export class BackdropDirective {
private backdrop: HTMLElement;

@Output('q-grid-backdrop') close = new EventEmitter<any>();
@Output('q-grid-backdrop') close = new EventEmitter<void>();

@Input('q-grid-backdrop-selector') selector = '';

@Input('q-grid-backdrop-active') set backdropHost(value: any) {
@Input('q-grid-backdrop-active') set backdropHost(value: boolean) {
if (!value) {
if (this.backdrop) {
this.backdrop.remove();
Expand Down Expand Up @@ -49,6 +49,8 @@ export class BackdropDirective {
});
}

constructor(private zone: NgZone, @Inject(DOCUMENT) private document: any) {
}
constructor(
private zone: NgZone,
@Inject(DOCUMENT) private document: Document,
) { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,20 @@ import {
} from '@angular/core';
import { BoolColumnModel } from '@qgrid/core';

type ValueType = unknown;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets be consistent


@Component({
selector: 'q-grid-bool-editor',
templateUrl: './bool-editor.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class BoolEditorComponent implements OnInit {
private state: any;
private state: ValueType;

@Input() autofocus = false;
@Input() column: BoolColumnModel;
@Input() label: string;
@Output() valueChange = new EventEmitter<any>();
@Output() valueChange = new EventEmitter<ValueType>();

// eslint-disable-next-line no-use-before-define
context: { $implicit: BoolEditorComponent } = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import { GridPlugin } from '@qgrid/ngx';
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class CellEditorComponent implements OnInit {
@ViewChild(TemplateRef, { static: true }) template: TemplateRef<any>;
@Output('close') closeEvent = new EventEmitter<any>();
@ViewChild(TemplateRef, { static: true }) template: TemplateRef<unknown>;
@Output('close') closeEvent = new EventEmitter<void>();

// eslint-disable-next-line no-use-before-define
context: { $implicit: CellEditorComponent } = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ export class RootContext {
export class ColumnChooserComponent implements OnInit, OnChanges {
private ccState = this.stateAccessor.setter(ColumnChooserState);

@Output('submit') submitEvent = new EventEmitter<any>();
@Output('cancel') cancelEvent = new EventEmitter<any>();
@Output('submit') submitEvent = new EventEmitter<void>();
@Output('cancel') cancelEvent = new EventEmitter<void>();

context: {
$implicit: ColumnChooserPlugin;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ColumnFilterItemListDirective } from './column-filter-item-list.directi
selector: '[q-grid-column-filter-item]',
})
export class ColumnFilterItemDirective implements OnInit {
@Input('q-grid-column-filter-item') value: any;
@Input('q-grid-column-filter-item') value: string;

$implicit = this;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
flatten,
getValue,
Guard,
ReadModel,
uniq,
} from '@qgrid/core';
import {
Expand All @@ -26,6 +27,10 @@ import {
import { ColumnFilterPlugin, ColumnFilterState } from '@qgrid/plugins';
import { FocusAfterRender } from '../focus/focus.service';

type ReadModelStatesContains<V> = {
[K in keyof ReadModel as ReadModel[K] extends (() => Readonly<V>) ? K : never]: ReadModel[K];
};

@Component({
selector: 'q-grid-column-filter',
templateUrl: './column-filter.component.html',
Expand All @@ -38,8 +43,8 @@ export class ColumnFilterComponent implements OnInit {
@Input() column: ColumnModel;
@Input() search = '';

@Output('submit') submitEvent = new EventEmitter<any>();
@Output('cancel') cancelEvent = new EventEmitter<any>();
@Output('submit') submitEvent = new EventEmitter<void>();
@Output('cancel') cancelEvent = new EventEmitter<void>();

context: {
$implicit: ColumnFilterPlugin;
Expand Down Expand Up @@ -120,15 +125,15 @@ export class ColumnFilterComponent implements OnInit {
const isBlank = model.filter().assertFactory().isNull;
try {
if (!items.length) {
const source = model[columnFilter.state().source];
const source = (model as ReadModel)[columnFilter.state().source as keyof ReadModelStatesContains<{ rows: unknown[] }>];
Guard.notNull(source, 'source');

const sourceState = source();
Guard.hasProperty(sourceState, 'rows');

let values = null;
if (columnFilterPlugin.column.type === 'array') {
values = flatten(sourceState.rows.map(row => getValue(row, column)));
values = flatten(sourceState.rows.map((row: unknown) => getValue(row, column)));
} else {
values = sourceState.rows.map(columnFilterPlugin.getValue);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { FocusAfterRender } from '../focus/focus.service';
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ColumnSortComponent implements AfterViewInit {
@ViewChild(TemplateRef, { static: true }) template: TemplateRef<any>;
@ViewChild(TemplateRef, { static: true }) template: TemplateRef<unknown>;
@Input() column: ColumnModel;

// eslint-disable-next-line no-use-before-define
Expand Down
16 changes: 9 additions & 7 deletions packages/qgrid-ngx-plugins/src/lib/command/command.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ import {
import { Command, CommandManager, Shortcut, ShortcutDispatcher } from '@qgrid/core';
import { Disposable, GridPlugin } from '@qgrid/ngx';

type CommangArg = unknown;

export class ZoneCommandManager {
constructor(
private run: <T>(f: () => T) => T,
private manager: CommandManager,
private commandArg: any,
private commandArg: CommangArg,
) {
}

Expand All @@ -31,7 +33,7 @@ export class ZoneCommandManager {
);
}

filter(commands) {
filter(commands: Command[]) {
return this.manager.filter(commands);
}
}
Expand All @@ -43,13 +45,13 @@ export class ZoneCommandManager {
export class CommandDirective implements DoCheck, OnChanges, OnInit, AfterViewInit {
private isAfterViewInit = false;

@Input('q-grid-command') command: Command<any>;
@Input('q-grid-command-arg') commandArg: any;
@Input('q-grid-command') command: Command<CommangArg>;
@Input('q-grid-command-arg') commandArg: CommangArg;
@Input('q-grid-command-use-shortcut') useCommandShortcut: boolean;
@Input('q-grid-command-event') commandEvent = 'click';
@Input('q-grid-command-use-zone') useZone: boolean;
@Input('q-grid-command-host') host: 'grid' | 'document' = 'grid';
@Output('q-grid-command-execute') commandExecute = new EventEmitter<any>();
@Output('q-grid-command-execute') commandExecute = new EventEmitter<CommangArg>();

constructor(
private disposable: Disposable,
Expand All @@ -64,7 +66,7 @@ export class CommandDirective implements DoCheck, OnChanges, OnInit, AfterViewIn

this.aroundZone(() =>
nativeElement
.addEventListener(this.commandEvent, e => this.execute(e)),
.addEventListener(this.commandEvent, (e: MouseEvent) => this.execute(e)),
);
}

Expand Down Expand Up @@ -131,7 +133,7 @@ export class CommandDirective implements DoCheck, OnChanges, OnInit, AfterViewIn

const shortcut = new Shortcut(new ShortcutDispatcher());

const keyDown = e => {
const keyDown = (e: KeyboardEvent) => {
shortcut.keyDown(e);
};

Expand Down
Loading