Skip to content

Commit

Permalink
Handle table cell get/setters better (#4799)
Browse files Browse the repository at this point in the history
- get and set were moved into abstract base class as part of ts bump
- we now need to ensure we get/set the correct way
- also contains minor cell tidy ups
  • Loading branch information
richard-cox authored Nov 26, 2020
1 parent 9a3ef32 commit cbd6cf5
Show file tree
Hide file tree
Showing 41 changed files with 97 additions and 106 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export class AppAutoscalerMetricChartCardComponent extends CardCell<APIResource<

@Input('row')
set row(row: APIResource<AppScalingTrigger>) {
super.row = row;
if (row) {
if (row.entity.query && row.entity.query.params) {
this.paramsMetricsStart = row.entity.query.params.start * 1000;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export class TableCellCfCellComponent extends TableCellCustom<ListAppInstance> i
metricEntityService: EntityService<IMetrics<IMetricMatrixResult<IMetricCell>>>;
cfGuid: string;
}) {
super.config = config;
if (!config) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export class TableCellAppCfOrgSpaceComponent extends TableCellAppCfOrgSpaceBase

@Input('row')
set row(row: APIResource<IApp>) {
super.row = row;
if (row) {
this.init(row.entity.cfGuid, (row.entity.space as APIResource<ISpace>).entity.organization_guid, row.entity.space_guid);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export class TableCellAppStatusComponent extends TableCellCustom<APIResource<IAp
applicationState: ApplicationStateData;
@Input('config')
set config(value: { hideIcon: boolean, initialStateOnly: boolean, }) {
super.config = value;
value = value || {
hideIcon: false,
initialStateOnly: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export class TableCellConfirmOrgSpaceComponent extends TableCellCustom<CfRoleCha
chipsConfig: AppChip<CfRoleChangeWithNames>[];
@Input('row')
set row(row: CfRoleChangeWithNames) {
super.row = row;
const chipConfig = new AppChip<CfRoleChangeWithNames>();
chipConfig.key = row;
chipConfig.value = row.spaceGuid ? `Space: ${row.spaceName}` : `Org: ${row.orgName}`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export class TableCellFeatureFlagDescriptionComponent extends TableCellCustom<IF

@Input()
set row(row: IFeatureFlag) {
super.row = row;
this.description = row ? FeatureFlagDescriptions[row.name] : null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,16 @@ export class TableCellRouteAppsAttachedComponent extends TableCellCustom<any> im

@Input('config')
set config(config: any) {
super.config = config;
this.config$.next(config);
}

@Input('row')
set row(route: APIResource<CfRoute>) {
super.row = route;
this.row$.next(route);
}

constructor() {
super();
}

ngOnInit(): void {
this.boundApps$ = combineLatest([
this.config$.asObservable().pipe(first()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export class CfServiceCardComponent extends CardCell<APIResource<IService>> {

@Input('row')
set row(row: APIResource<IService>) {
super.row = row;
if (row) {
this.serviceEntity = row;
this.extraInfo = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class TableCellServiceBrokerComponent extends

@Input()
set row(row: APIResource<IService>) {
this.pRow = row;
super.row = row;
if (row && !this.spaceLink$) {
this.broker$ = cfEntityCatalog.serviceBroker.store.getEntityService(
this.row.entity.service_broker_guid,
Expand Down Expand Up @@ -62,7 +62,7 @@ export class TableCellServiceBrokerComponent extends
}
}
get row(): APIResource<IService> {
return this.pRow;
return super.row;
}

public spaceLink$: Observable<{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export class TableCellServiceCfBreadcrumbsComponent extends TableCellCustom<APIR

@Input()
set row(pService: APIResource<IService>) {
super.row = pService;
if (!pService || !!this.cfOrgSpace) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,12 @@ export class TableCellServiceProviderComponent extends TableCellCustom<APIResour

@Input()
set row(pService: APIResource<IService>) {
super.row = pService;
if (!!pService && !!pService.entity.extra && !this.extraInfo) {
try {
this.extraInfo = JSON.parse(pService.entity.extra);
} catch { }
}
}

constructor() {
super();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export class TableCellServiceReferencesComponent extends TableCellCustom<APIReso

@Input()
set row(pService: APIResource<IService>) {
super.row = pService;
if (!!pService && !!pService.entity.extra && !this.extraInfo) {
try {
this.extraInfo = JSON.parse(pService.entity.extra);
Expand All @@ -23,10 +24,6 @@ export class TableCellServiceReferencesComponent extends TableCellCustom<APIReso

}

constructor() {
super();
}

hasDocumentationUrl() {
return !!(this.getDocumentationUrl());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ export class TableCellServiceTagsComponent extends TableCellCustom<APIResource<I

tags: AppChip<ServiceTag>[] = [];

private service;
@Input()
set row(pService: APIResource<IService>) {
this.service = pService;
super.row = pService;
if (!pService) {
return;
}
Expand All @@ -29,10 +28,7 @@ export class TableCellServiceTagsComponent extends TableCellCustom<APIResource<I
}));
}
get row(): APIResource<IService> {
return this.service;
return super.row;
}

constructor() {
super();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ export class TableCellServiceInstanceAppsAttachedComponent

@Input('config')
set config(config: any) {
super.config = config;
this.config$.next(config);
}

@Input('row')
set row(row: APIResource<IServiceInstance>) {
super.row = row;
this.row$.next(row);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export class TableCellServiceInstanceTagsComponent
tags: AppChip<Tag>[] = [];
@Input('row')
set row(row) {
super.row = row;
if (row) {
this.tags.length = 0;
if (row.entity && row.entity.service_instance && row.entity.service_instance.entity.tags) {
Expand All @@ -42,9 +43,4 @@ export class TableCellServiceInstanceTagsComponent
}
}
}

constructor() {
super();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@ export abstract class CfPermissionCellDirective<T> extends TableCellCustom<APIRe

@Input('row')
set row(row: APIResource<CfUser>) {
super.row = row;
this.rowSubject.next(row);
this.guid = row.metadata.guid;
this.userEntity.next(row.entity);
}

@Input()
set config(config: any) {
super.config = config;
this.configSubject.next(config);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,16 @@ export class TableCellAServicePlanPriceComponent extends TableCellCustom<APIReso
isFree: boolean;
canShowCosts: boolean;

private pServicePlan;
@Input()
set row(servicePlan: APIResource<IServicePlan>) {
this.pServicePlan = servicePlan;
super.row = servicePlan;
if (!servicePlan) {
return;
}
this.isFree = servicePlan.entity.free;
this.canShowCosts = canShowServicePlanCosts(servicePlan);
}
get row(): APIResource<IServicePlan> {
return this.pServicePlan;
return super.row;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class ServiceInstanceCardComponent extends CardCell<APIResource<IServiceI

@Input('row')
set row(row: APIResource<IServiceInstance>) {

super.row = row;
if (row) {
this.serviceInstanceEntity = row;
const schema = cfEntityFactory(serviceInstancesEntityType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export class UserProvidedServiceInstanceCardComponent extends CardCell<APIResour

@Input('row')
set row(row: APIResource<IUserProvidedServiceInstance>) {
super.row = row;
if (row) {
this.setup(row);
}
Expand Down Expand Up @@ -107,14 +108,14 @@ export class UserProvidedServiceInstanceCardComponent extends CardCell<APIResour
false,
true
);
}
};

private delete = () => this.serviceActionHelperService.deleteServiceInstance(
this.serviceInstanceEntity.metadata.guid,
this.serviceInstanceEntity.entity.name,
this.serviceInstanceEntity.entity.cfGuid,
true
)
);

private edit = () => this.serviceActionHelperService.startEditServiceBindingStepper(
this.serviceInstanceEntity.metadata.guid,
Expand All @@ -123,7 +124,7 @@ export class UserProvidedServiceInstanceCardComponent extends CardCell<APIResour
[CSI_CANCEL_URL]: '/services'
},
true
)
);

getSpaceBreadcrumbs = () => ({ breadcrumbs: 'services-wall' });

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { AfterContentInit, Component, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core';
import { FormControl, FormGroup } from '@angular/forms';
import { ErrorStateMatcher, ShowOnDirtyErrorStateMatcher } from '@angular/material/core';
import { JsonPointer } from '@cfstratos/ajsf-core';
import { BehaviorSubject, Subscription } from 'rxjs';
import { delay } from 'rxjs/operators';
import { JsonPointer } from '@cfstratos/ajsf-core';

import { safeStringToObj } from '../../../../../core/src/core/utils.service';
import { isValidJsonValidator } from '../../../../../core/src/shared/form-validators';
Expand Down Expand Up @@ -125,7 +125,7 @@ export class SchemaFormComponent implements OnInit, OnDestroy, AfterContentInit
return obj;
}, {});
return Object.keys(filterSchema).length > 0 ? filterSchema : null;
}
};

onFormChange(formData) {
this.formData = formData;
Expand All @@ -149,6 +149,6 @@ export class SchemaFormComponent implements OnInit, OnDestroy, AfterContentInit
}, '');
return `${a} ${arrMessage} ${c.message} <br>`;
}, '');
}
};

}
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export class MetricsEndpointDetailsComponent extends EndpointListDetailsComponen

@Input()
set row(data: EndpointModel) {
super.row = data;
this.guid$.next(data.guid);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ export class TableCellDefaultComponent<T> extends TableCellCustom<T> implements
public cellDefinition: ICellDefinition<T>;

@Input('row')
get row() { return this.pRow; }
get row() { return super.row; }
set row(row: T) {
this.pRow = row;
super.row = row;
if (row) {
this.setValue(row, this.schemaKey);
this.setSyncLink();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ export class TableCellActionsComponent<T> extends TableCellCustom<T> implements
rowState: Observable<RowState>;

@Input('row')
get row() { return this.pRow; }
get row() { return super.row; }
set row(row: T) {
this.pRow = row;
super.row = row;
if (row) {
this.initialise(row);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ export interface TableCellBooleanIndicatorComponentConfig<T> {
export class TableCellBooleanIndicatorComponent<T = any> extends TableCellCustom<T, TableCellBooleanIndicatorComponentConfig<T>> {

@Input('row')
get row() { return this.pRow; }
get row() { return super.row; }
set row(row: T) {
this.pRow = row;
super.row = row;
if (this.config) {
this.enabled = this.config.isEnabled(row);
}
}

@Input('config')
get config() { return this.pConfig; }
get config() { return super.config; }
set config(config: TableCellBooleanIndicatorComponentConfig<T>) {
this.pConfig = config;
super.config = config;
if (!config) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,20 @@ export class TableCellEditComponent<T> extends TableCellCustom<T> {

@Input()
get row(): T {
return this.pRow;
return super.row;
}
set row(row: T) {
this.pRow = row;
super.row = row;
}

@Input()
set dataSource(dataSource: IListDataSource<T>) {
this.pDataSource = dataSource;
super.dataSource = dataSource;
}
get dataSource(): IListDataSource<T> {
return this.pDataSource;
return super.dataSource;
}


@Input()
subtle: boolean;

Expand Down
Loading

0 comments on commit cbd6cf5

Please sign in to comment.