Fixed warnings
This commit is contained in:
parent
139dd82de0
commit
52b8c90bbf
@ -1,9 +1,10 @@
|
|||||||
import { Component, EventEmitter, Input, Output } from '@angular/core';
|
import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'iqser-hidden-action',
|
selector: 'iqser-hidden-action',
|
||||||
templateUrl: './hidden-action.component.html',
|
templateUrl: './hidden-action.component.html',
|
||||||
styleUrls: ['./hidden-action.component.scss']
|
styleUrls: ['./hidden-action.component.scss'],
|
||||||
|
changeDetection: ChangeDetectionStrategy.OnPush
|
||||||
})
|
})
|
||||||
export class HiddenActionComponent {
|
export class HiddenActionComponent {
|
||||||
@Input() requiredClicks = 4;
|
@Input() requiredClicks = 4;
|
||||||
|
|||||||
@ -18,10 +18,10 @@ export function humanize(value: string, lowercase = true): string {
|
|||||||
|
|
||||||
export const log = tap(console.log);
|
export const log = tap(console.log);
|
||||||
|
|
||||||
export const toNumber = (str: string) => {
|
export function toNumber(str: string): number {
|
||||||
try {
|
try {
|
||||||
return parseInt(`${str}`.replace(/\D/g, ''), 10);
|
return parseInt(`${str}`.replace(/\D/g, ''), 10);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|||||||
@ -3,26 +3,27 @@ import { TranslateLoader } from '@ngx-translate/core';
|
|||||||
import { map } from 'rxjs/operators';
|
import { map } from 'rxjs/operators';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
|
|
||||||
|
interface T {
|
||||||
|
[key: string]: string | T;
|
||||||
|
}
|
||||||
|
|
||||||
export class PruningTranslationLoader implements TranslateLoader {
|
export class PruningTranslationLoader implements TranslateLoader {
|
||||||
constructor(private _http: HttpClient, private _prefix: string, private _suffix: string) {}
|
constructor(private _http: HttpClient, private _prefix: string, private _suffix: string) {}
|
||||||
|
|
||||||
getTranslation(lang: string): Observable<Record<string, unknown>> {
|
getTranslation(lang: string): Observable<T> {
|
||||||
return this._http
|
return this._http.get(`${this._prefix}${lang}${this._suffix}`).pipe(map(result => this._process(result as T)));
|
||||||
.get(`${this._prefix}${lang}${this._suffix}`)
|
|
||||||
.pipe(map((result: Record<string, unknown>) => this._process(result)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private _process(object: unknown): Record<string, unknown> {
|
private _process(object: T): T {
|
||||||
return (
|
return (
|
||||||
Object.keys(object)
|
Object.keys(object)
|
||||||
// eslint-disable-next-line no-prototype-builtins
|
// eslint-disable-next-line no-prototype-builtins
|
||||||
.filter(key => object.hasOwnProperty(key) && object[key] !== '')
|
.filter(key => object.hasOwnProperty(key) && object[key] !== '')
|
||||||
.reduce(
|
.reduce(
|
||||||
(result: Record<string, unknown>, key) => (
|
(result: T, key) => (
|
||||||
(result[key] = typeof object[key] === 'object' ? this._process(object[key]) : object[key]),
|
(result[key] = typeof object[key] === 'object' ? this._process(object[key] as T) : object[key]), result
|
||||||
result
|
|
||||||
),
|
),
|
||||||
{},
|
{}
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user