Skip to content

Commit

Permalink
SHIBUI-1060 Fixed bug with retaining filter schema
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathis committed Dec 12, 2018
1 parent b9ebe1d commit d55788f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
8 changes: 7 additions & 1 deletion ui/src/app/metadata/filter/action/filter.action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export enum FilterActionTypes {
SELECT_FILTER_TYPE = '[Filter] Select Filter Type',
UPDATE_FILTER = '[Filter] Update Filter',
CANCEL_CREATE_FILTER = '[Filter] Cancel Create Filter',
CLEAR_FILTER = '[Filter] Clear Filter',
LOAD_ENTITY_PREVIEW = '[Filter] Load Preview data',
LOAD_ENTITY_PREVIEW_SUCCESS = '[Filter] Load Preview data success',
LOAD_ENTITY_PREVIEW_ERROR = '[Filter] Load Preview data error'
Expand Down Expand Up @@ -38,6 +39,10 @@ export class CancelCreateFilter implements Action {
readonly type = FilterActionTypes.CANCEL_CREATE_FILTER;
}

export class ClearFilter implements Action {
readonly type = FilterActionTypes.CLEAR_FILTER;
}

export class UpdateFilterChanges implements Action {
readonly type = FilterActionTypes.UPDATE_FILTER;

Expand All @@ -57,4 +62,5 @@ export type FilterActionsUnion =
| CancelCreateFilter
| LoadEntityPreview
| LoadEntityPreviewSuccess
| LoadEntityPreviewError;
| LoadEntityPreviewError
| ClearFilter;
6 changes: 4 additions & 2 deletions ui/src/app/metadata/filter/container/new-filter.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,21 @@ export class NewFilterComponent implements OnDestroy, OnInit {
this.model = {};

this.definition$ = this.store.select(fromFilter.getFilterType).pipe(
takeUntil(this.ngUnsubscribe),
filter(t => !!t),
map(t => MetadataFilterTypes[t])
);
this.schema$ = this.definition$.pipe(
takeUntil(this.ngUnsubscribe),
filter(d => !!d),
switchMap(d => {
return this.schemaService.get(d.schema);
return this.schemaService.get(d.schema).pipe(takeUntil(this.ngUnsubscribe));
}),
shareReplay()
);

this.validators$ = this.definition$.pipe(
takeUntil(this.ngUnsubscribe),
withLatestFrom(this.store.select(fromFilter.getFilterNames)),
map(([definition, names]) => definition.getValidators(names))
);
Expand Down Expand Up @@ -107,7 +110,6 @@ export class NewFilterComponent implements OnDestroy, OnInit {
}

save(): void {
console.log(this.filter);
this.store.dispatch(new AddFilterRequest(this.filter));
}

Expand Down
8 changes: 7 additions & 1 deletion ui/src/app/metadata/filter/effect/collection.effect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import { removeNulls, array_move } from '../../../shared/util';
import { EntityAttributesFilterEntity } from '../../domain/entity/filter/entity-attributes-filter';
import { MetadataFilterService } from '../../domain/service/filter.service';
import { SelectProviderRequest } from '../../provider/action/collection.action';
import { UpdateFilterChanges } from '../action/filter.action';
import { UpdateFilterChanges, ClearFilter } from '../action/filter.action';

/* istanbul ignore next */
@Injectable()
Expand Down Expand Up @@ -112,6 +112,12 @@ export class FilterCollectionEffects {
map(([filter, provider]) => new SelectProviderRequest(provider))
);

@Effect()
addFilterSuccessResetState$ = this.actions$.pipe(
ofType<AddFilterSuccess>(FilterCollectionActionTypes.ADD_FILTER_SUCCESS),
map(() => new ClearFilter())
);

@Effect()
updateFilter$ = this.actions$.pipe(
ofType<UpdateFilterRequest>(FilterCollectionActionTypes.UPDATE_FILTER_REQUEST),
Expand Down
1 change: 1 addition & 0 deletions ui/src/app/metadata/filter/reducer/filter.reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export function reducer(state = initialState, action: FilterActionsUnion): Filte
}
};
}
case FilterActionTypes.CLEAR_FILTER:
case FilterActionTypes.CANCEL_CREATE_FILTER: {
return {
...initialState
Expand Down

0 comments on commit d55788f

Please sign in to comment.