-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
478 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Action } from '@ngrx/store'; | ||
|
||
export enum EditorActionTypes { | ||
UPDATE_STATUS = '[Filter Editor] Update Status', | ||
SELECT_PROVIDER_TYPE = '[Filter Editor] Select Filter Type', | ||
CLEAR = '[Filter Editor] Clear' | ||
} | ||
|
||
export class UpdateStatus implements Action { | ||
readonly type = EditorActionTypes.UPDATE_STATUS; | ||
|
||
constructor(public payload: { [key: string]: string }) { } | ||
} | ||
|
||
export class SelectFilterType implements Action { | ||
readonly type = EditorActionTypes.SELECT_PROVIDER_TYPE; | ||
|
||
constructor(public payload: string) { } | ||
} | ||
|
||
export class ClearEditor implements Action { | ||
readonly type = EditorActionTypes.CLEAR; | ||
} | ||
|
||
export type EditorActionUnion = | ||
| UpdateStatus | ||
| SelectFilterType | ||
| ClearEditor; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
ui/src/app/metadata/filter/container/edit-filter-step.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<ng-container *ngIf="definition$ | async"> | ||
<div class="alert alert-danger d-flex justify-content-between font-weight-bold mb-3" *ngIf="(step$ | async).locked"> | ||
<span class="d-flex justify-content-between"> | ||
<toggle-switch id="toggle" [formControl]="lock"></toggle-switch> | ||
<span class="p-1">{{ lock.value ? 'Locked' : 'Unlocked' }}</span> | ||
</span> | ||
<span class="p-1">For Advanced Knowledge Only</span> | ||
</div> | ||
<sf-form | ||
[schema]="schema$ | async" | ||
[model]="model$ | async" | ||
[validators]="validators$ | async" | ||
[bindings]="bindings$ | async" | ||
(onChange)="valueChangeSubject.next($event)" | ||
(onErrorChange)="statusChangeSubject.next($event)"></sf-form> | ||
</ng-container> |
119 changes: 119 additions & 0 deletions
119
ui/src/app/metadata/filter/container/edit-filter-step.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
import { Component, OnDestroy } from '@angular/core'; | ||
import { Store } from '@ngrx/store'; | ||
import { Subject, Observable, Subscription } from 'rxjs'; | ||
|
||
import * as fromFilter from '../reducer'; | ||
import { MetadataFilterTypes } from '../model'; | ||
import { FormDefinition } from '../../../wizard/model'; | ||
import { MetadataFilter } from '../../domain/model'; | ||
import { SchemaService } from '../../../schema-form/service/schema.service'; | ||
import { UpdateFilterRequest } from '../action/collection.action'; | ||
import { CancelCreateFilter, UpdateFilterChanges } from '../action/filter.action'; | ||
import { PreviewEntity } from '../../domain/action/entity.action'; | ||
import { shareReplay, map, withLatestFrom, filter, switchMap, startWith, defaultIfEmpty, takeUntil } from 'rxjs/operators'; | ||
|
||
@Component({ | ||
selector: 'edit-filter-step-page', | ||
templateUrl: './edit-filter-step.component.html' | ||
}) | ||
export class EditFilterStepComponent implements OnDestroy { | ||
|
||
private ngUnsubscribe: Subject<void> = new Subject<void>(); | ||
|
||
valueChangeSubject = new Subject<Partial<any>>(); | ||
private valueChangeEmitted$ = this.valueChangeSubject.asObservable(); | ||
|
||
statusChangeSubject = new Subject<{ value: any[] }>(); | ||
private statusChangeEmitted$ = this.statusChangeSubject.asObservable(); | ||
|
||
definition$: Observable<FormDefinition<MetadataFilter>>; | ||
definition: FormDefinition<MetadataFilter>; | ||
schema$: Observable<any>; | ||
|
||
model$: Observable<MetadataFilter>; | ||
isSaving$: Observable<boolean>; | ||
filter: MetadataFilter; | ||
isValid: boolean; | ||
type$: Observable<string>; | ||
|
||
validators$: Observable<{ [key: string]: any }>; | ||
|
||
actions: any; | ||
|
||
defSub: Subscription; | ||
|
||
constructor( | ||
private store: Store<fromFilter.State>, | ||
private schemaService: SchemaService | ||
) { | ||
this.definition$ = this.store.select(fromFilter.getFilterType).pipe( | ||
takeUntil(this.ngUnsubscribe), | ||
filter(t => !!t), | ||
map(t => MetadataFilterTypes[t]) | ||
); | ||
|
||
this.defSub = this.definition$.subscribe(d => this.definition = d); | ||
|
||
this.definition$.subscribe(console.log); | ||
|
||
this.schema$ = this.definition$.pipe( | ||
takeUntil(this.ngUnsubscribe), | ||
filter(d => !!d), | ||
switchMap(d => { | ||
return this.schemaService.get(d.schema).pipe(takeUntil(this.ngUnsubscribe)); | ||
}), | ||
shareReplay() | ||
); | ||
this.isSaving$ = this.store.select(fromFilter.getCollectionSaving); | ||
this.model$ = this.store.select(fromFilter.getSelectedFilter); | ||
this.type$ = this.model$.pipe(map(f => f && f.hasOwnProperty('@type') ? f['@type'] : '')); | ||
|
||
this.valueChangeEmitted$.subscribe(changes => this.store.dispatch(new UpdateFilterChanges(changes.value))); | ||
this.statusChangeEmitted$.subscribe(valid => { | ||
this.isValid = valid.value ? valid.value.length === 0 : true; | ||
}); | ||
|
||
this.validators$ = this.store.select(fromFilter.getFilterNames).pipe( | ||
takeUntil(this.ngUnsubscribe), | ||
withLatestFrom( | ||
this.store.select(fromFilter.getSelectedFilter), | ||
this.definition$ | ||
), | ||
map(([names, filter, definition]) => definition.getValidators( | ||
names.filter(n => n !== filter.name) | ||
)) | ||
); | ||
|
||
this.store | ||
.select(fromFilter.getFilter) | ||
.subscribe(filter => this.filter = filter); | ||
|
||
this.actions = { | ||
preview: (property: any, parameters: any) => { | ||
this.preview(parameters.filterId); | ||
} | ||
}; | ||
} | ||
|
||
ngOnDestroy(): void { | ||
this.ngUnsubscribe.next(); | ||
this.ngUnsubscribe.complete(); | ||
this.defSub.unsubscribe(); | ||
} | ||
|
||
save(): void { | ||
this.store.dispatch(new UpdateFilterRequest(this.filter)); | ||
} | ||
|
||
cancel(): void { | ||
this.store.dispatch(new CancelCreateFilter()); | ||
} | ||
|
||
preview(id: string): void { | ||
this.store.dispatch(new PreviewEntity({ | ||
id, | ||
entity: this.definition.getEntity(this.filter) | ||
})); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.