Skip to content

Commit

Permalink
SHIBUI-799 Removed console log
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathis committed Dec 7, 2018
1 parent 8e51c38 commit 0430312
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 5 deletions.
11 changes: 8 additions & 3 deletions ui/src/app/metadata/domain/domain.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,17 @@ export const getInCollectionFn = (entities, selectedId) => {
};
export const getEntityIdsFn = list => list.map(entity => entity.entityId);

export const getId = (entity: Metadata): string => {
return entity.resourceId ? entity.resourceId : entity.id;
};

export const mergeOrderFn = (entities: Metadata[], order: string[]): Metadata[] => {
return [...entities.sort(
const ordered = [...entities.sort(
(a: Metadata, b: Metadata) => {
const aIndex = order.indexOf(a.id);
const bIndex = order.indexOf(b.id);
const aIndex = order.indexOf(getId(a));
const bIndex = order.indexOf(getId(b));
return aIndex > bIndex ? 1 : bIndex > aIndex ? -1 : 0;
}
)];
return ordered;
};
1 change: 1 addition & 0 deletions ui/src/app/metadata/domain/model/metadata-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {

export interface MetadataResolver extends MetadataBase {
id: string;
resourceId?: string;
entityId?: string;
serviceProviderName: string;
organization?: Organization;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { SchemaFormModule, WidgetRegistry, DefaultWidgetRegistry } from 'ngx-sch
import { SchemaService } from '../../../schema-form/service/schema.service';
import { HttpClientModule } from '@angular/common/http';
import { MockI18nModule } from '../../../../testing/i18n.stub';
import { MetadataFilterTypes } from '../model';

describe('Edit Metadata Filter Page', () => {
let fixture: ComponentFixture<EditFilterComponent>;
Expand Down Expand Up @@ -67,6 +68,7 @@ describe('Edit Metadata Filter Page', () => {
describe('preview method', () => {
it('should dispatch a preview action', () => {
fixture.detectChanges();
instance.definition = MetadataFilterTypes.EntityAttributes;
instance.preview('foo');
expect(store.dispatch).toHaveBeenCalled();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export class EditFilterComponent {
private statusChangeEmitted$ = this.statusChangeSubject.asObservable();

definition$: Observable<FormDefinition<MetadataFilter>>;
definition: FormDefinition<MetadataFilter>;
schema$: Observable<any>;

model$: Observable<MetadataFilter>;
Expand All @@ -46,6 +47,9 @@ export class EditFilterComponent {
filter(t => !!t),
map(t => MetadataFilterTypes[t])
);

this.definition$.subscribe(d => this.definition = d);

this.schema$ = this.definition$.pipe(
filter(d => !!d),
switchMap(d => {
Expand Down Expand Up @@ -94,7 +98,7 @@ export class EditFilterComponent {
preview(id: string): void {
this.store.dispatch(new PreviewEntity({
id,
entity: new EntityAttributesFilterEntity(this.filter)
entity: this.definition.getEntity(this.filter)
}));
}
}
Expand Down
4 changes: 3 additions & 1 deletion ui/src/app/metadata/filter/model/entity-attributes.filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ export const EntityAttributesFilter: FormDefinition<MetadataFilter> = {
label: 'EntityAttributes',
type: 'EntityAttributes',
schema: '/api/ui/EntityAttributesFilters',
getEntity(filter: MetadataFilter): EntityAttributesFilterEntity {
return new EntityAttributesFilterEntity(filter);
},
getValidators(namesList: string[] = []): any {
const validators = {
'/': (value, property, form_current) => {
Expand All @@ -25,7 +28,6 @@ export const EntityAttributesFilter: FormDefinition<MetadataFilter> = {
return errors;
},
'/name': (value, property, form) => {
console.log(namesList);
const err = namesList.indexOf(value) > -1 ? {
code: 'INVALID_NAME',
path: `#${property.path}`,
Expand Down
4 changes: 4 additions & 0 deletions ui/src/app/metadata/filter/model/nameid.filter.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import { FormDefinition } from '../../../wizard/model';
import { MetadataFilter } from '../../domain/model';
import { NameIDFormatFilterEntity } from '../../domain/entity/filter/nameid-format-filter';

export const NameIDFilter: FormDefinition<MetadataFilter> = {
label: 'NameIDFilter',
type: 'NameIDFormat',
schema: '/api/ui/NameIdFormatFilter',
getEntity(filter: MetadataFilter): NameIDFormatFilterEntity {
return new NameIDFormatFilterEntity(filter);
},
getValidators(namesList: string[] = []): any {
const validators = {
'/': (value, property, form_current) => {
Expand Down
1 change: 1 addition & 0 deletions ui/src/app/wizard/model/form-definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export interface FormDefinition<T> {
type: string;
schema?: string;
bindings?: any;
getEntity?(entity: any): any;
parser(changes: Partial<T>, schema?: any);
formatter(changes: Partial<T>, schema?: any);
getValidators?(...args: any[]): { [key: string]: any };
Expand Down

0 comments on commit 0430312

Please sign in to comment.