-
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.
SHIBUI-580 Re-organized code for provider wizard containers
- Loading branch information
Showing
12 changed files
with
153 additions
and
78 deletions.
There are no files selected for viewing
5 changes: 0 additions & 5 deletions
5
ui/src/app/metadata/provider/container/new-provider.component.scss
This file was deleted.
Oops, something went wrong.
5 changes: 5 additions & 0 deletions
5
ui/src/app/metadata/provider/container/provider-wizard-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,5 @@ | ||
<sf-form | ||
[schema]="schema$ | async" | ||
[model]="formModel" | ||
(onChange)="changeSubject.next($event)" | ||
(isValid)="onStatusChange($event)"></sf-form> |
92 changes: 92 additions & 0 deletions
92
ui/src/app/metadata/provider/container/provider-wizard-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,92 @@ | ||
import { Component, OnDestroy } from '@angular/core'; | ||
import { Observable, Subject } from 'rxjs'; | ||
import { withLatestFrom } from 'rxjs/operators'; | ||
import { Store } from '@ngrx/store'; | ||
|
||
import * as fromProvider from '../reducer'; | ||
import * as fromWizard from '../../../wizard/reducer'; | ||
|
||
import { SetDisabled, SetDefinition } from '../../../wizard/action/wizard.action'; | ||
import { LoadSchemaRequest, UpdateStatus } from '../action/editor.action'; | ||
import { startWith } from 'rxjs/operators'; | ||
import { Wizard } from '../../../wizard/model'; | ||
import { MetadataProvider } from '../../domain/model'; | ||
import { MetadataProviderTypes, MetadataProviderWizard } from '../model'; | ||
import { UpdateProvider } from '../action/entity.action'; | ||
import { pick } from '../../../shared/util'; | ||
|
||
@Component({ | ||
selector: 'provider-wizard-step', | ||
templateUrl: './provider-wizard-step.component.html', | ||
styleUrls: [] | ||
}) | ||
|
||
export class ProviderWizardStepComponent implements OnDestroy { | ||
changeSubject = new Subject<Partial<any>>(); | ||
private changeEmitted$ = this.changeSubject.asObservable(); | ||
|
||
schema$: Observable<any>; | ||
schema: any; | ||
definition$: Observable<Wizard<MetadataProvider>>; | ||
changes$: Observable<MetadataProvider>; | ||
currentPage: string; | ||
valid$: Observable<boolean>; | ||
|
||
constructor( | ||
private store: Store<fromProvider.ProviderState> | ||
) { | ||
this.store | ||
.select(fromWizard.getCurrentWizardSchema) | ||
.subscribe(s => { | ||
this.store.dispatch(new LoadSchemaRequest(s)); | ||
}); | ||
|
||
this.schema$ = this.store.select(fromProvider.getSchema); | ||
this.valid$ = this.store.select(fromProvider.getEditorIsValid); | ||
this.definition$ = this.store.select(fromWizard.getWizardDefinition); | ||
this.changes$ = this.store.select(fromProvider.getEntityChanges); | ||
|
||
this.valid$ | ||
.pipe(startWith(false)) | ||
.subscribe((valid) => { | ||
this.store.dispatch(new SetDisabled(!valid)); | ||
}); | ||
|
||
this.schema$.subscribe(s => this.schema = s); | ||
|
||
this.changeEmitted$ | ||
.pipe( | ||
withLatestFrom(this.schema$, this.definition$), | ||
) | ||
.subscribe( | ||
([changes, schema, definition]) => { | ||
const type = changes.value['@type']; | ||
if (type && type !== definition.type) { | ||
const newDefinition = MetadataProviderTypes.find(def => def.type === type); | ||
if (newDefinition) { | ||
this.store.dispatch(new SetDefinition({ | ||
...MetadataProviderWizard, | ||
...newDefinition, | ||
steps: [ | ||
...MetadataProviderWizard.steps, | ||
...newDefinition.steps | ||
] | ||
})); | ||
changes = { value: pick(Object.keys(schema.properties))(changes.value) }; | ||
} | ||
} | ||
this.store.dispatch(new UpdateProvider(changes.value)); | ||
} | ||
); | ||
} | ||
|
||
ngOnDestroy() { | ||
this.changeSubject.complete(); | ||
} | ||
|
||
onStatusChange(value): void { | ||
const status = { [this.currentPage]: value ? 'VALID' : 'INVALID' }; | ||
this.store.dispatch(new UpdateStatus(status)); | ||
} | ||
} | ||
|
File renamed without changes.
21 changes: 21 additions & 0 deletions
21
ui/src/app/metadata/provider/container/provider-wizard-summary.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,21 @@ | ||
import { Component } from '@angular/core'; | ||
import { Store } from '@ngrx/store'; | ||
|
||
import * as fromProvider from '../reducer'; | ||
|
||
@Component({ | ||
selector: 'provider-wizard-summary', | ||
templateUrl: './provider-wizard-summary.component.html', | ||
styleUrls: [] | ||
}) | ||
|
||
export class ProviderWizardSummaryComponent { | ||
constructor( | ||
private store: Store<fromProvider.ProviderState> | ||
) {} | ||
|
||
save(): void { | ||
console.log('Save!'); | ||
} | ||
} | ||
|
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
File renamed without changes.
File renamed without changes.
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