Skip to content

Commit

Permalink
fix(admin-ui): Enable full template type checks and fix issues
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbromley committed Mar 3, 2020
1 parent 31d079d commit db36111
Show file tree
Hide file tree
Showing 19 changed files with 52 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</vdr-action-bar>

<vdr-asset-gallery
[assets]="items$ | async | paginate: (paginationConfig$ | async) || {}"
[assets]="(items$ | async)! | paginate: (paginationConfig$ | async) || {}"
[multiSelect]="true"
></vdr-asset-gallery>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@
#dl
[cdkDropListDisabled]="!('UpdateCatalog' | hasPermission)"
[cdkDropListEnterPredicate]="dropListEnterPredicate"
(cdkDropListDropped)="dropListDropped($event)"
(cdkDropListDropped)="dropListDropped()"
></div>
<div
*ngFor="let asset of assets"
cdkDropList
[cdkDropListDisabled]="!('UpdateCatalog' | hasPermission)"
[cdkDropListEnterPredicate]="dropListEnterPredicate"
(cdkDropListDropped)="dropListDropped($event)"
(cdkDropListDropped)="dropListDropped()"
>
<vdr-dropdown cdkDrag (cdkDragMoved)="dragMoved($event)">
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
<ng-template ng-header-tmp>
<div
class="search-header"
*ngIf="selectComponent.filterValue"
*ngIf="selectComponent.searchTerm"
[class.selected]="isSearchHeaderSelected()"
(click)="selectComponent.selectTag()"
>
{{ 'catalog.search-for-term' | translate }}: {{ selectComponent.filterValue }}
{{ 'catalog.search-for-term' | translate }}: {{ selectComponent.searchTerm }}
</div>
</ng-template>
<ng-template ng-label-tmp let-item="item" let-clear="clear">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class ProductVariantsEditorComponent implements OnInit, DeactivateAware {
}>;
variantFormValues: { [id: string]: VariantInfo } = {};
product: GetProductVariantOptions.Product;
private currencyCode: CurrencyCode;
currencyCode: CurrencyCode;
private languageCode: LanguageCode;

constructor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div
class="variant-container card"
*ngFor="let variant of variants; let i = index"
[class.disabled]="!formArray.get([i, 'enabled']).value"
[class.disabled]="!formArray.get([i, 'enabled'])!.value"
>
<ng-container [formGroup]="formArray.at(i)">
<div class="card-block header-row">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<vdr-dt-column>{{ 'common.enabled' | translate }}</vdr-dt-column>
<ng-template let-variant="item" let-i="index">
<ng-container [formGroup]="formArray.at(i)">
<td class="left align-middle" [class.disabled]="!formArray.get([i, 'enabled']).value">
<td class="left align-middle" [class.disabled]="!formArray.get([i, 'enabled'])!.value">
<div class="card-img">
<div class="featured-asset">
<img
Expand All @@ -23,7 +23,7 @@
</div>
</div>
</td>
<td class="left align-middle" [class.disabled]="!formArray.get([i, 'enabled']).value">
<td class="left align-middle" [class.disabled]="!formArray.get([i, 'enabled'])!.value">
<clr-input-container>
<input
clrInput
Expand All @@ -34,7 +34,7 @@
/>
</clr-input-container>
</td>
<td class="left align-middle" [class.disabled]="!formArray.get([i, 'enabled']).value">
<td class="left align-middle" [class.disabled]="!formArray.get([i, 'enabled'])!.value">
<clr-input-container>
<input
clrInput
Expand All @@ -48,13 +48,13 @@
<ng-container *ngFor="let option of variant.options | sort: 'groupId'">
<td
class="left align-middle"
[class.disabled]="!formArray.get([i, 'enabled']).value"
[class.disabled]="!formArray.get([i, 'enabled'])!.value"
[style.color]="optionGroupName(option.groupId) | stringToColor"
>
{{ option.name }}
</td>
</ng-container>
<td class="left align-middle price" [class.disabled]="!formArray.get([i, 'enabled']).value">
<td class="left align-middle price" [class.disabled]="!formArray.get([i, 'enabled'])!.value">
<clr-input-container>
<vdr-currency-input
clrInput
Expand All @@ -64,7 +64,7 @@
></vdr-currency-input>
</clr-input-container>
</td>
<td class="left align-middle stock" [class.disabled]="!formArray.get([i, 'enabled']).value">
<td class="left align-middle stock" [class.disabled]="!formArray.get([i, 'enabled'])!.value">
<clr-input-container>
<input
clrInput
Expand All @@ -76,7 +76,7 @@
/>
</clr-input-container>
</td>
<td class="left align-middle stock" [class.disabled]="!formArray.get([i, 'enabled']).value">
<td class="left align-middle stock" [class.disabled]="!formArray.get([i, 'enabled'])!.value">
<clr-toggle-wrapper>
<input
type="checkbox"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<clr-icon shape="check-circle" class="verified-user-icon"></clr-icon>
{{ 'customer.verified' | translate }}
</ng-container>
<ng-container *ngIf="!customer.user.verified">
<ng-container *ngIf="!customer.user?.verified">
<clr-icon shape="check-circle" class="registered-user-icon"></clr-icon>
{{ 'customer.registered' | translate }}
</ng-container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
class="btn btn-primary"
(click)="save()"
*vdrIfPermissions="'UpdateAdministrator'"
[disabled]="(detailForm.invalid || detailForm.pristine) && !permissionsChanged"
[disabled]="(detailForm.invalid || detailForm.pristine)"
>
{{ 'common.update' | translate }}
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@
</clr-toggle-wrapper>
</vdr-form-field>

<div class="clr-row" formGroupName="configArgs" *ngIf="(entity$ | async).configArgs?.length">
<div class="clr-row" formGroupName="configArgs" *ngIf="(entity$ | async)?.configArgs?.length">
<div class="clr-col">
<label>{{ 'settings.payment-method-config-options' | translate }}</label>
<section class="form-block" *ngFor="let arg of (entity$ | async).configArgs">
<section class="form-block" *ngFor="let arg of (entity$ | async)?.configArgs">
<vdr-form-field [label]="arg.name" [for]="arg.name" *ngIf="getType(arg) === 'string'">
<input
[id]="arg.name"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ export class ShippingMethodDetailComponent extends BaseDetailComponent<ShippingM
detailForm: FormGroup;
checkers: ConfigurableOperationDefinition[] = [];
calculators: ConfigurableOperationDefinition[] = [];
selectedChecker?: ConfigurableOperation;
selectedChecker?: ConfigurableOperation | null;
selectedCheckerDefinition?: ConfigurableOperationDefinition;
selectedCalculator?: ConfigurableOperation;
selectedCalculator?: ConfigurableOperation | null;
selectedCalculatorDefinition?: ConfigurableOperationDefinition;
activeChannel$: Observable<GetActiveChannel.ActiveChannel>;
testAddress: TestAddress;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@
[label]="'common.price' | translate"
*ngIf="testResult?.quote?.price != null"
>
{{ testResult.quote.price / 100 | currency: currencyCode }}
{{ testResult.quote?.price / 100 | currency: currencyCode }}
</vdr-labeled-data>
<vdr-labeled-data
[label]="'common.price-with-tax' | translate"
*ngIf="testResult?.quote?.priceWithTax != null"
>
{{ testResult.quote.priceWithTax / 100 | currency: currencyCode }}
{{ testResult.quote?.priceWithTax / 100 | currency: currencyCode }}
</vdr-labeled-data>
</div>
<vdr-object-tree
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export class TestOrderBuilderComponent implements OnInit {
}
}

private updateQuantity() {
updateQuantity() {
this.persistToLocalStorage();
this.orderLinesChange.emit(this.lines);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
class="clr-input search-input"
/>
<vdr-asset-gallery
[assets]="assets$ | async | paginate: paginationConfig"
[assets]="(assets$ | async)! | paginate: paginationConfig"
[multiSelect]="true"
(selectionChange)="selection = $event"
></vdr-asset-gallery>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*ngIf="isTextInput"
type="text"
[id]="customField.name"
[pattern]="customField.pattern"
[pattern]="$any(customField).pattern"
[formControl]="formGroup.get(customField.name)"
[readonly]="readonly || customField.readonly"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ export class DatetimePickerComponent implements ControlValueAccessor, AfterViewI
this.datetimePickerService.selectMinute(parseInt(target.value, 10));
}

private closeDatepicker() {
closeDatepicker() {
this.dropdownComponent.toggleOpen();
this.datetimeInput.nativeElement.focus();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<li *ngIf="address.postalCode">{{ address.postalCode }}</li>
<li *ngIf="address.country">
<clr-icon shape="world" size="12"></clr-icon>
{{ address.country.name ? address.country.name : address.country }}
{{ getCountryName() }}
</li>
<li *ngIf="address.phoneNumber">
<clr-icon shape="phone-handset" size="12"></clr-icon>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,16 @@ import { AddressFragment, OrderAddress } from '../../../common/generated-types';
})
export class FormattedAddressComponent {
@Input() address: AddressFragment | OrderAddress;

getCountryName(): string {
if (this.isAddressFragment(this.address)) {
return this.address.country.name;
} else {
return this.address.country || '';
}
}

private isAddressFragment(input: AddressFragment | OrderAddress): input is AddressFragment {
return typeof input.country !== 'string';
}
}
7 changes: 6 additions & 1 deletion packages/admin-ui/src/tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,10 @@
],
"include": [
"src/**/*.d.ts"
]
],
"angularCompilerOptions": {
"strictMetadataEmit": true,
"fullTemplateTypeCheck": true,
"strictInjectionParameters": true
}
}
8 changes: 7 additions & 1 deletion packages/admin-ui/tsconfig.lib.prod.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
{
"extends": "./tsconfig.lib.json",
"angularCompilerOptions": {
"enableIvy": false
"enableIvy": false,
"annotateForClosureCompiler": true,
"skipTemplateCodegen": true,
"strictMetadataEmit": true,
"fullTemplateTypeCheck": true,
"strictInjectionParameters": true,
"enableResourceInlining": true
}
}

0 comments on commit db36111

Please sign in to comment.