Skip to content

Commit

Permalink
Updated UI, updated schema
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathis committed Dec 6, 2018
1 parent d533107 commit fc7cb92
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 22 deletions.
23 changes: 20 additions & 3 deletions backend/src/main/resources/nameid-filter.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,13 @@
"description": "tooltip.nameid-formats",
"items": {
"type": "object",
"title": "label.nameid-format",
"widget": {
"id": "inline-obj"
},
"properties": {
"format": {
"type": "string",
"title": "label.nameid-formats-format",
"description": "tooltip.nameid-formats-format"
"$ref": "#/definitions/NameIDFormat"
},
"value": {
"type": "string",
Expand Down Expand Up @@ -114,5 +113,23 @@
}
}
}
},
"definitions": {
"NameIDFormat": {
"type": "string",
"title": "label.nameid-formats-format",
"description": "tooltip.nameid-formats-format",
"minLength": 1,
"maxLength": 255,
"widget": {
"id": "datalist",
"data": [
"urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified",
"urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress",
"urn:oasis:names:tc:SAML:2.0:nameid-format:persistent",
"urn:oasis:names:tc:SAML:2.0:nameid-format:transient"
]
}
}
}
}
25 changes: 18 additions & 7 deletions ui/src/app/metadata/filter/container/edit-filter.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { UpdateFilterRequest } from '../action/collection.action';
import { CancelCreateFilter, UpdateFilterChanges } from '../action/filter.action';
import { PreviewEntity } from '../../domain/action/entity.action';
import { EntityAttributesFilterEntity } from '../../domain/entity';
import { shareReplay, map, withLatestFrom } from 'rxjs/operators';
import { shareReplay, map, withLatestFrom, filter, switchMap } from 'rxjs/operators';

@Component({
selector: 'edit-filter-page',
Expand All @@ -25,7 +25,7 @@ export class EditFilterComponent {
statusChangeSubject = new Subject<{ value: any[] }>();
private statusChangeEmitted$ = this.statusChangeSubject.asObservable();

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

model$: Observable<MetadataFilter>;
Expand All @@ -41,9 +41,17 @@ export class EditFilterComponent {
private store: Store<fromFilter.State>,
private schemaService: SchemaService
) {
this.definition = MetadataFilterTypes.EntityAttributes;

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

Expand All @@ -54,9 +62,10 @@ export class EditFilterComponent {

this.validators$ = this.store.select(fromFilter.getFilterNames).pipe(
withLatestFrom(
this.store.select(fromFilter.getSelectedFilter)
this.store.select(fromFilter.getSelectedFilter),
this.definition$
),
map(([names, provider]) => this.definition.getValidators(
map(([names, provider, definition]) => definition.getValidators(
names.filter(n => n !== provider.name)
))
);
Expand All @@ -70,6 +79,8 @@ export class EditFilterComponent {
this.preview(parameters.id);
}
};

this.definition$.subscribe(d => console.log(d));
}

save(): void {
Expand Down
8 changes: 8 additions & 0 deletions ui/src/app/metadata/filter/effect/collection.effect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +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';

/* istanbul ignore next */
@Injectable()
Expand Down Expand Up @@ -74,6 +75,13 @@ export class FilterCollectionEffects {
)
);

@Effect()
selectFilterRequestSetChanges$ = this.actions$.pipe(
ofType<SelectFilterSuccess>(FilterCollectionActionTypes.SELECT_FILTER_SUCCESS),
map(action => action.payload),
map(filter => new UpdateFilterChanges({...filter, type: filter['@type']}))
);

@Effect()
addFilter$ = this.actions$.pipe(
ofType<AddFilterRequest>(FilterCollectionActionTypes.ADD_FILTER_REQUEST),
Expand Down
7 changes: 6 additions & 1 deletion ui/src/app/metadata/filter/reducer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,12 @@ export const getFilterNames = createSelector(getAllFilters, (filters: MetadataFi
*/

export const mergeFn = (changes, filter) => ({ ...filter, ...changes });
export const detectFilterType = (changes) => changes.type ? changes.type : changes.hasOwnProperty('@type') ? changes['@type'] : null;

export const getFilterWithChanges = createSelector(getFilter, getSelectedFilter, mergeFn);
export const getFilterType = createSelector(getFilter, (changes: MetadataFilter) => changes ? changes.type : null);
export const getFilterType = createSelector(getFilter, (changes: MetadataFilter) => {
const type = changes ? detectFilterType(changes) : null;
console.log(type, changes);
return type;
});

30 changes: 22 additions & 8 deletions ui/src/app/schema-form/widget/array/inline-obj-list.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,28 @@
</div>
<ul class="mt-2 no-style d-flex justify-content-between flex-wrap">
<li *ngFor="let itemProperty of formProperty.properties; let i=index; trackBy:trackByIndex" class="w-50">
<div class="d-flex flex-row justify-content-between m-3">
<div class="flex-grow-1 bg-light border rounded p-3">
<sf-form-element class="" [formProperty]="itemProperty"></sf-form-element>
<div class="py-2 text-right">
<button class="btn btn-danger" (click)="removeItem(i)" role="button">
<i class="fa fa-fw fa-trash fa-lg"></i>
<span translate="action.remove">Remove</span>
</button>
<div class="d-flex flex-row justify-content-between m-3 bg-light p-3 border rounded">
<div class="flex-grow-1 bg-white border rounded p-3">
<div #acc>
<div class="d-flex justify-content-between" (click)="acc.isHidden = !acc.isHidden">
<span>
<i class="fa fa-fw" [ngClass]="{'fa-chevron-right': acc.isHidden, 'fa-chevron-down': !acc.isHidden}"></i>
&nbsp;
<translate-i18n key="label.new-of-type" [params]="{ type: (itemProperty.schema.title | translate) }"></translate-i18n>
<ng-container *ngIf="itemProperty.schema.properties.makeDefault">
<i class="fa fa-fw fa-check-square fa-lg text-success" aria-hidden="true" *ngIf="itemProperty.value.makeDefault === true"></i>
<small class="sr-only" *ngIf="itemProperty.value.makeDefault === true" translate="label.default">(default)</small>
</ng-container>
</span>
<button class="btn btn-link pt-1" (click)="removeItem(i)" role="button">
<i class="fa fa-fw fa-trash fa-lg text-danger"></i>
<span class="sr-only" translate="action.remove">Remove</span>
</button>
</div>
<div class="collapse" [ngClass]="{'show': !acc.isHidden}">
<hr />
<sf-form-element [formProperty]="itemProperty"></sf-form-element>
</div>
</div>
</div>
</div>
Expand Down
23 changes: 20 additions & 3 deletions ui/src/assets/schema/filter/nameid.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,13 @@
"description": "tooltip.nameid-formats",
"items": {
"type": "object",
"title": "label.nameid-format",
"widget": {
"id": "inline-obj"
},
"properties": {
"format": {
"type": "string",
"title": "label.nameid-formats-format",
"description": "tooltip.nameid-formats-format"
"$ref": "#/definitions/NameIDFormat"
},
"value": {
"type": "string",
Expand Down Expand Up @@ -114,5 +113,23 @@
}
}
}
},
"definitions": {
"NameIDFormat": {
"type": "string",
"title": "label.nameid-formats-format",
"description": "tooltip.nameid-formats-format",
"minLength": 1,
"maxLength": 255,
"widget": {
"id": "datalist",
"data": [
"urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified",
"urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress",
"urn:oasis:names:tc:SAML:2.0:nameid-format:persistent",
"urn:oasis:names:tc:SAML:2.0:nameid-format:transient"
]
}
}
}
}

0 comments on commit fc7cb92

Please sign in to comment.