Skip to content

Commit

Permalink
Resolved merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathis committed Jul 3, 2018
2 parents cba08fc + 15cd444 commit 3a3076a
Show file tree
Hide file tree
Showing 28 changed files with 299 additions and 196 deletions.
6 changes: 4 additions & 2 deletions ui/src/app/metadata/domain/domain.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ import {

import {
EntityAttributesFilter,
FileBackedHttpMetadataResolver,
FileBackedHttpMetadataProvider
FileBackedHttpMetadataResolver
} from './entity';
import {
FileBackedHttpMetadataProvider
} from './model/providers';

export type Filter =
| EntityAttributesFilter;
Expand Down
1 change: 0 additions & 1 deletion ui/src/app/metadata/domain/entity/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export * from './filter/entity-attributes-filter';
export * from './provider/file-backed-http-metadata-provider';
export * from './resolver/file-backed-http-metadata-resolver';

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { MetadataProvider } from '../metadata-provider';

export interface FileBackedHttpMetadataProvider extends MetadataProvider {
metadataFilters: any[];
}
1 change: 1 addition & 0 deletions ui/src/app/metadata/domain/model/providers/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './file-backed-http-metadata-provider';
11 changes: 9 additions & 2 deletions ui/src/app/metadata/provider/action/editor.action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ export enum EditorActionTypes {
LOAD_SCHEMA_SUCCESS = '[Provider Editor] Load Schema Success',
LOAD_SCHEMA_FAIL = '[Provider Editor] Load Schema Fail',

SELECT_PROVIDER_TYPE = '[Provider Editor] Select Provider Type'
SELECT_PROVIDER_TYPE = '[Provider Editor] Select Provider Type',

CLEAR = '[Provider Editor] Clear'
}

export class UpdateStatus implements Action {
Expand Down Expand Up @@ -39,9 +41,14 @@ export class SelectProviderType implements Action {
constructor(public payload: string) { }
}

export class ClearEditor implements Action {
readonly type = EditorActionTypes.CLEAR;
}

export type EditorActionUnion =
| UpdateStatus
| LoadSchemaRequest
| LoadSchemaSuccess
| LoadSchemaFail
| SelectProviderType;
| SelectProviderType
| ClearEditor;
8 changes: 7 additions & 1 deletion ui/src/app/metadata/provider/action/entity.action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ export enum EntityActionTypes {
SAVE_PROVIDER_SUCCESS = '[Provider Entity] Save Provider Success',
SAVE_PROVIDER_FAIL = '[Provider Entity] Save Provider Fail',

RESET_CHANGES = '[Provider Entity] Reset Provider Changes'
CLEAR_PROVIDER = '[Provider Entity] Clear',
RESET_CHANGES = '[Provider Entity] Reset Changes'
}

export class SelectProvider implements Action {
Expand Down Expand Up @@ -48,6 +49,10 @@ export class SaveProviderFail implements Action {
constructor(public payload: Error) { }
}

export class ClearProvider implements Action {
readonly type = EntityActionTypes.CLEAR_PROVIDER;
}

export class ResetChanges implements Action {
readonly type = EntityActionTypes.RESET_CHANGES;
}
Expand All @@ -59,4 +64,5 @@ export type EntityActionUnion =
| SaveProviderSuccess
| SaveProviderFail
| CreateProvider
| ClearProvider
| ResetChanges;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<sf-form
[schema]="schema$ | async"
[model]="formModel"
[model]="model$ | async"
(onChange)="changeSubject.next($event)"
(isValid)="onStatusChange($event)"></sf-form>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, OnDestroy } from '@angular/core';
import { Observable, Subject } from 'rxjs';
import { withLatestFrom } from 'rxjs/operators';
import { withLatestFrom, map } from 'rxjs/operators';
import { Store } from '@ngrx/store';

import * as fromProvider from '../reducer';
Expand Down Expand Up @@ -31,6 +31,7 @@ export class ProviderWizardStepComponent implements OnDestroy {
changes$: Observable<MetadataProvider>;
currentPage: string;
valid$: Observable<boolean>;
model$: Observable<any>;

constructor(
private store: Store<fromProvider.ProviderState>
Expand All @@ -52,32 +53,51 @@ export class ProviderWizardStepComponent implements OnDestroy {
this.store.dispatch(new SetDisabled(!valid));
});

this.model$ = this.schema$.pipe(
withLatestFrom(
this.store.select(fromWizard.getModel),
this.changes$,
this.definition$
),
map(([schema, model, changes, definition]) => {
return ({
model: {
...model,
...changes
},
definition
});
}),
map(({ model, definition }) => {
return definition.translate ? definition.translate.formatter(model) : model;
})
);

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.changeEmitted$.pipe(
withLatestFrom(this.schema$, this.definition$),
map(([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));
}
);
return { changes: changes.value, definition };
}),
map(({ changes, definition }) => definition.translate ? definition.translate.parser(changes) : changes)
)
.subscribe(changes => this.store.dispatch(new UpdateProvider(changes)));
}

ngOnDestroy() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
<div class="col col-xl-6 col-lg-9 col-xs-12">
<router-outlet></router-outlet>
</div>
<!--
<div class="col col-xl-6 col-lg-9 col-xs-12">
<!--<div class="col col-xl-6 col-lg-9 col-xs-12">
<code class="bg-light border rounded p-4 d-block"><pre>{{ changes$ | async | json }}</pre></code>
</div>
-->
</div>-->
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,30 @@ import { Store } from '@ngrx/store';

import * as fromProvider from '../reducer';
import * as fromWizard from '../../../wizard/reducer';

import { SetIndex, SetDisabled } from '../../../wizard/action/wizard.action';
import { LoadSchemaRequest } from '../action/editor.action';
import { SetIndex, SetDisabled, ClearWizard } from '../../../wizard/action/wizard.action';
import { LoadSchemaRequest, ClearEditor } from '../action/editor.action';
import { startWith } from 'rxjs/operators';
import { Wizard, WizardStep } from '../../../wizard/model';
import { MetadataProvider } from '../../domain/model';
import { ClearProvider } from '../action/entity.action';


@Component({
selector: 'provider-wizard',
templateUrl: './provider-wizard.component.html',
styleUrls: []
})

export class ProviderWizardComponent {
export class ProviderWizardComponent implements OnDestroy {

schema$: Observable<any>;
schema: any;
definition$: Observable<Wizard<MetadataProvider>>;
changes$: Observable<MetadataProvider>;
model$: Observable<any>;
currentPage: string;
valid$: Observable<boolean>;

formModel: any;

nextStep: WizardStep;
previousStep: WizardStep;

Expand All @@ -48,6 +49,15 @@ export class ProviderWizardComponent {
.subscribe((valid) => {
this.store.dispatch(new SetDisabled(!valid));
});

this.schema$.subscribe(s => this.schema = s);

}

ngOnDestroy() {
this.store.dispatch(new ClearProvider());
this.store.dispatch(new ClearWizard());
this.store.dispatch(new ClearEditor());
}

next(): void {
Expand Down
Loading

0 comments on commit 3a3076a

Please sign in to comment.