Browse Source

fix some issues due to ts strict mode

pull/10581/head
mehmet-erim 5 years ago
parent
commit
cac08a8b44
  1. 8
      npm/ng-packs/packages/core/src/lib/directives/autofocus.directive.ts
  2. 4
      npm/ng-packs/packages/core/src/lib/directives/permission.directive.ts
  3. 4
      npm/ng-packs/packages/core/src/lib/services/list.service.ts
  4. 4
      npm/ng-packs/packages/core/src/lib/utils/localization-utils.ts
  5. 4
      npm/ng-packs/packages/setting-management/config/src/components/email-setting-group/email-setting-group.component.html
  6. 2
      npm/ng-packs/packages/setting-management/config/src/components/email-setting-group/email-setting-group.component.ts
  7. 2
      npm/ng-packs/packages/setting-management/config/src/providers/features.token.ts
  8. 4
      npm/ng-packs/packages/setting-management/src/lib/components/setting-management.component.ts
  9. 8
      npm/ng-packs/packages/tenant-management/src/lib/components/tenants/tenants.component.html
  10. 2
      npm/ng-packs/packages/tenant-management/src/lib/components/tenants/tenants.component.ts
  11. 2
      npm/ng-packs/packages/theme-basic/src/lib/components/nav-items/languages.component.ts
  12. 2
      npm/ng-packs/packages/theme-basic/src/lib/components/nav-items/nav-items.component.html
  13. 9
      npm/ng-packs/packages/theme-basic/src/lib/components/routes/routes.component.html
  14. 2
      npm/ng-packs/packages/theme-basic/src/lib/components/routes/routes.component.ts
  15. 2
      npm/ng-packs/packages/theme-shared/extensions/src/lib/components/abstract-actions/abstract-actions.component.ts
  16. 2
      npm/ng-packs/packages/theme-shared/extensions/src/lib/directives/disabled.directive.ts
  17. 6
      npm/ng-packs/packages/theme-shared/extensions/src/lib/directives/prop-data.directive.ts
  18. 8
      npm/ng-packs/packages/theme-shared/extensions/src/lib/utils/enum.util.ts
  19. 10
      npm/ng-packs/packages/theme-shared/extensions/src/lib/utils/localization.util.ts
  20. 3113
      npm/ng-packs/yarn.lock

8
npm/ng-packs/packages/core/src/lib/directives/autofocus.directive.ts

@ -8,17 +8,17 @@ export class AutofocusDirective implements AfterViewInit {
private _delay = 0;
@Input('autofocus')
set delay(val: number | undefined) {
this._delay = val ?? 0;
set delay(val: number | undefined | string) {
this._delay = Number(val) || 0;
}
get delay() {
get delay(): number {
return this._delay;
}
constructor(private elRef: ElementRef) {}
ngAfterViewInit(): void {
setTimeout(() => this.elRef.nativeElement.focus(), this.delay);
setTimeout(() => this.elRef.nativeElement.focus(), this.delay as number);
}
}

4
npm/ng-packs/packages/core/src/lib/directives/permission.directive.ts

@ -16,7 +16,7 @@ import { PermissionService } from '../services/permission.service';
selector: '[abpPermission]',
})
export class PermissionDirective implements OnDestroy, OnChanges {
@Input('abpPermission') condition!: string;
@Input('abpPermission') condition: string | undefined;
subscription!: Subscription;
@ -33,7 +33,7 @@ export class PermissionDirective implements OnDestroy, OnChanges {
}
this.subscription = this.permissionService
.getGrantedPolicy$(this.condition)
.getGrantedPolicy$(this.condition || '')
.pipe(distinctUntilChanged())
.subscribe(isGranted => {
this.vcRef.clear();

4
npm/ng-packs/packages/core/src/lib/services/list.service.ts

@ -21,7 +21,7 @@ import { PagedResultDto } from '../models/dtos';
import { LIST_QUERY_DEBOUNCE_TIME } from '../tokens/list.token';
@Injectable()
export class ListService<QueryParamsType = ABP.PageQueryParams> implements OnDestroy {
export class ListService<QueryParamsType = ABP.PageQueryParams | any> implements OnDestroy {
private _filter = '';
set filter(value: string) {
this._filter = value;
@ -112,7 +112,7 @@ export class ListService<QueryParamsType = ABP.PageQueryParams> implements OnDes
switchMap(query => streamCreatorCallback(query).pipe(catchError(() => of(null)))),
filter(Boolean),
tap(() => this._isLoading$.next(false)),
shareReplay({ bufferSize: 1, refCount: true }),
shareReplay<any>({ bufferSize: 1, refCount: true }),
takeUntil(this.destroy$),
);
}

4
npm/ng-packs/packages/core/src/lib/utils/localization-utils.ts

@ -35,7 +35,7 @@ export function createLocalizationPipeKeyGenerator(
) {
const findLocalization = createLocalizationFinder(localization);
return (resourceNames: string[], keys: string[], defaultKey: string) => {
return (resourceNames: string[], keys: string[], defaultKey: string | undefined) => {
const { resourceName, key } = findLocalization(resourceNames, keys);
return !resourceName ? defaultKey : resourceName === '_' ? key : `${resourceName}::${key}`;
};
@ -45,7 +45,7 @@ function createLocalizationFinder(localization: ApplicationLocalizationConfigura
const localize = createLocalizer(localization);
return (resourceNames: string[], keys: string[]) => {
resourceNames = resourceNames.concat(localization.defaultResourceName).filter(Boolean);
resourceNames = resourceNames.concat(localization.defaultResourceName || '').filter(Boolean);
const resourceCount = resourceNames.length;
const keyCount = keys.length;

4
npm/ng-packs/packages/setting-management/config/src/components/email-setting-group/email-setting-group.component.html

@ -2,7 +2,7 @@
<hr class="my-3" />
<form *ngIf="form" [formGroup]="form" (ngSubmit)="submit()" validateOnSubmit>
<form *ngIf="form" [formGroup]="form" (ngSubmit)="submit()" [validateOnSubmit]="true">
<div class="mb-3 form-group">
<label class="form-label">{{
'AbpSettingManagement::DefaultFromDisplayName' | abpLocalization
@ -49,7 +49,7 @@
<div
[@collapse]="{
value: form.get('smtpUseDefaultCredentials').value ? 'collapsed' : 'expanded',
value: form.get('smtpUseDefaultCredentials')?.value ? 'collapsed' : 'expanded',
params: { time: '200ms', easing: 'linear' }
}"
>

2
npm/ng-packs/packages/setting-management/config/src/components/email-setting-group/email-setting-group.component.ts

@ -11,7 +11,7 @@ import { EmailSettingsDto } from '../../proxy/models';
animations: [collapse],
})
export class EmailSettingGroupComponent implements OnInit {
form: FormGroup;
form!: FormGroup;
saving = false;

2
npm/ng-packs/packages/setting-management/config/src/providers/features.token.ts

@ -10,7 +10,7 @@ export const SETTING_MANAGEMENT_FEATURES = new InjectionToken<Observable<{ enabl
factory: () => {
const configState = inject(ConfigStateService);
const featureKey = 'SettingManagement.Enable';
const mapFn = features => ({
const mapFn = (features: Record<string, string>) => ({
enable: features[featureKey].toLowerCase() !== 'false',
});
return featuresFactory(configState, [featureKey], mapFn);

4
npm/ng-packs/packages/setting-management/src/lib/components/setting-management.component.ts

@ -1,6 +1,6 @@
import { ABP } from '@abp/ng.core';
import { Component, OnDestroy, OnInit, TrackByFunction } from '@angular/core';
import { SettingTabsService } from '@abp/ng.setting-management/config';
import { Component, OnDestroy, OnInit, TrackByFunction } from '@angular/core';
import { Subscription } from 'rxjs';
@Component({
@ -11,7 +11,7 @@ export class SettingManagementComponent implements OnDestroy, OnInit {
private subscription = new Subscription();
settings: ABP.Tab[] = [];
selected: ABP.Tab;
selected!: ABP.Tab;
trackByFn: TrackByFunction<ABP.Tab> = (_, item) => item.name;

8
npm/ng-packs/packages/tenant-management/src/lib/components/tenants/tenants.component.html

@ -23,8 +23,8 @@
</div>
<abp-extensible-table
[data]="data.items"
[recordsTotal]="data.totalCount"
[data]="data.items || []"
[recordsTotal]="data.totalCount || 0"
[list]="list"
></abp-extensible-table>
</div>
@ -41,7 +41,7 @@
</ng-template>
<ng-template #abpBody>
<form [formGroup]="tenantForm" (ngSubmit)="save()" validateOnSubmit>
<form [formGroup]="tenantForm" (ngSubmit)="save()" [validateOnSubmit]="true">
<abp-extensible-form [selectedRecord]="selected"></abp-extensible-form>
</form>
</ng-template>
@ -63,7 +63,7 @@
providerKey: { value: providerKey },
visible: { value: visibleFeatures, twoWay: true }
},
outputs: { visibleChange: onVisibleFeaturesChange },
outputs: { visibleChange: $any(onVisibleFeaturesChange) },
componentKey: featureManagementKey
}"
[(visible)]="visibleFeatures"

2
npm/ng-packs/packages/tenant-management/src/lib/components/tenants/tenants.component.ts

@ -34,7 +34,7 @@ export class TenantsComponent implements OnInit {
visibleFeatures = false;
providerKey: string;
providerKey!: string;
modalBusy = false;

2
npm/ng-packs/packages/theme-basic/src/lib/components/nav-items/languages.component.ts

@ -7,7 +7,7 @@ import { map } from 'rxjs/operators';
selector: 'abp-languages',
template: `
<div
*ngIf="(dropdownLanguages$ | async).length > 0"
*ngIf="((dropdownLanguages$ | async)?.length || 0) > 0"
class="dropdown"
ngbDropdown
#languageDropdown="ngbDropdown"

2
npm/ng-packs/packages/theme-basic/src/lib/components/nav-items/nav-items.component.html

@ -1,6 +1,6 @@
<ul class="navbar-nav">
<ng-container *ngFor="let item of navItems.items$ | async; trackBy: trackByFn">
<ng-container *ngIf="item.visible()">
<ng-container *ngIf="item.visible && item.visible()">
<li class="nav-item d-flex align-items-center" *abpPermission="item.requiredPolicy">
<ng-container
*ngIf="item.component; else htmlTemplate"

9
npm/ng-packs/packages/theme-basic/src/lib/components/routes/routes.component.html

@ -18,14 +18,13 @@
<ng-template #dropdownLink let-route>
<ng-container *ngIf="route.children?.length">
<li
#navbarRootDropdown
class="nav-item dropdown"
display="static"
*abpPermission="route.requiredPolicy"
(click)="
navbarRootDropdown.expand
? (navbarRootDropdown.expand = false)
: (navbarRootDropdown.expand = true)
rootDropdownExpand[route.name]
? (rootDropdownExpand[route.name] = false)
: (rootDropdownExpand[route.name] = true)
"
>
<a
@ -42,7 +41,7 @@
#routeContainer
class="dropdown-menu border-0 shadow-sm"
(click)="$event.preventDefault(); $event.stopPropagation()"
[class.d-block]="smallScreen && navbarRootDropdown.expand"
[class.d-block]="smallScreen && rootDropdownExpand[route.name]"
>
<ng-container
*ngTemplateOutlet="forTemplate; context: { $implicit: route }"

2
npm/ng-packs/packages/theme-basic/src/lib/components/routes/routes.component.ts

@ -18,6 +18,8 @@ export class RoutesComponent {
@ViewChildren('childrenContainer') childrenContainers!: QueryList<ElementRef<HTMLDivElement>>;
rootDropdownExpand = {} as { [key: string]: boolean };
trackByFn: TrackByFunction<TreeNode<ABP.Route>> = (_, item) => item.name;
constructor(public readonly routesService: RoutesService, protected renderer: Renderer2) {}

2
npm/ng-packs/packages/theme-shared/extensions/src/lib/components/abstract-actions/abstract-actions.component.ts

@ -13,7 +13,7 @@ export abstract class AbstractActionsComponent<L extends ActionList<any>> extend
readonly getInjected: InferredData<L>['getInjected'];
@Input() readonly record!: InferredData<L>['record'];
@Input() record!: InferredData<L>['record'];
constructor(injector: Injector) {
super();

2
npm/ng-packs/packages/theme-shared/extensions/src/lib/directives/disabled.directive.ts

@ -6,7 +6,7 @@ import { NgControl } from '@angular/forms';
})
export class DisabledDirective implements OnChanges {
@Input()
abpDisabled: boolean;
abpDisabled = false;
constructor(@Host() private ngControl: NgControl) {}

6
npm/ng-packs/packages/theme-shared/extensions/src/lib/directives/prop-data.directive.ts

@ -18,11 +18,11 @@ export class PropDataDirective<L extends PropList<any>>
extends PropData<InferredData<L>>
implements OnChanges, OnDestroy
{
@Input('abpPropDataFromList') readonly propList?: L;
@Input('abpPropDataFromList') propList?: L;
@Input('abpPropDataWithRecord') readonly record!: InferredData<L>['record'];
@Input('abpPropDataWithRecord') record!: InferredData<L>['record'];
@Input('abpPropDataAtIndex') readonly index?: number;
@Input('abpPropDataAtIndex') index?: number;
readonly getInjected: InferredData<L>['getInjected'];

8
npm/ng-packs/packages/theme-shared/extensions/src/lib/utils/enum.util.ts

@ -8,7 +8,7 @@ import { PropCallback } from '../models/props';
export function createEnum(members: ObjectExtensions.ExtensionEnumFieldDto[]) {
const enumObject: any = {};
members.forEach(({ name, value }) => {
members.forEach(({ name = '', value }) => {
enumObject[(enumObject[name] = value as any)] = name;
});
@ -21,7 +21,7 @@ export function createEnumValueResolver<T = any>(
propName: string,
): PropCallback<T, Observable<string>> {
return data => {
const value = data.record[EXTRA_PROPERTIES_KEY][propName];
const value = (data.record as any)[EXTRA_PROPERTIES_KEY][propName];
const key = lookupEnum.transformed[value];
const l10n = data.getInjected(LocalizationService);
const localizeEnum = createEnumLocalizer(l10n, enumType, lookupEnum);
@ -40,7 +40,7 @@ export function createEnumOptions<T = any>(
return createLocalizationStream(
l10n,
lookupEnum.fields.map(({ name, value }) => ({
lookupEnum.fields.map(({ name = '', value }) => ({
key: localizeEnum(name),
value,
})),
@ -62,7 +62,7 @@ function createEnumLocalizer(
return key =>
l10n.localizeWithFallbackSync(
[resource],
[resource || ''],
['Enum:' + shortType + '.' + key, shortType + '.' + key, key],
key,
);

10
npm/ng-packs/packages/theme-shared/extensions/src/lib/utils/localization.util.ts

@ -15,19 +15,23 @@ export function createDisplayNameLocalizationPipeKeyGenerator(
) => {
if (displayName && displayName.name)
return generateLocalizationPipeKey(
[displayName.resource],
[displayName.resource || ''],
[displayName.name],
displayName.name,
);
const key = generateLocalizationPipeKey(
[fallback.resource],
[fallback.resource || ''],
['DisplayName:' + fallback.name],
undefined,
);
if (key) return key;
return generateLocalizationPipeKey([fallback.resource], [fallback.name], fallback.name);
return generateLocalizationPipeKey(
[fallback.resource || ''],
[fallback.name || ''],
fallback.name,
);
};
}

3113
npm/ng-packs/yarn.lock

File diff suppressed because it is too large
Loading…
Cancel
Save