Skip to content

Commit

Permalink
SHIBUI-812 Implemented dynamic attribute release list
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathis committed Sep 24, 2018
1 parent c2a614f commit 56bf45c
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 37 deletions.
4 changes: 3 additions & 1 deletion ui/src/app/metadata/domain/domain.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { MetadataProviderService } from './service/provider.service';
import { EntityEffects } from './effect/entity.effect';
import { PreviewDialogComponent } from './component/preview-dialog.component';
import { MetadataFilterService } from './service/filter.service';
import { AttributesService } from './service/attributes.service';

export const COMPONENTS = [
PreviewDialogComponent
Expand Down Expand Up @@ -44,7 +45,8 @@ export class DomainModule {
ProviderStatusEmitter,
ProviderValueEmitter,
MetadataProviderService,
MetadataFilterService
MetadataFilterService,
AttributesService
]
};
}
Expand Down
24 changes: 8 additions & 16 deletions ui/src/app/metadata/domain/service/list-values.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@ import { Injectable } from '@angular/core';
import { Observable, of } from 'rxjs';

import { debounceTime, distinctUntilChanged, combineLatest } from 'rxjs/operators';
import { AttributesService } from './attributes.service';
import { ReleaseAttribute } from '../model/properties/release-attribute';

@Injectable()
export class ListValuesService {
constructor() {}
constructor(
private attributes: AttributesService
) {}

readonly nameIdFormats: Observable<string[]> = of([
'urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified',
Expand All @@ -20,21 +24,9 @@ export class ListValuesService {
'urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport'
]);

readonly attributesToRelease: Observable<{ key: string, label: string }[]> = of([
{ key: 'eduPersonPrincipalName', label: 'eduPersonPrincipalName (EPPN)' },
{ key: 'uid', label: 'uid' },
{ key: 'mail', label: 'mail' },
{ key: 'surname', label: 'surname' },
{ key: 'givenName', label: 'givenName' },
{ key: 'displayName', label: 'displayName' },
{ key: 'eduPersonAffiliation', label: 'eduPersonAffiliation' },
{ key: 'eduPersonScopedAffiliation', label: 'eduPersonScopedAffiliation' },
{ key: 'eduPersonPrimaryAffiliation', label: 'eduPersonPrimaryAffiliation' },
{ key: 'eduPersonEntitlement', label: 'eduPersonEntitlement' },
{ key: 'eduPersonAssurance', label: 'eduPersonAssurance' },
{ key: 'eduPersonUniqueId', label: 'eduPersonUniqueId' },
{ key: 'employeeNumber', label: 'employeeNumber' }
]);
get attributesToRelease(): Observable<ReleaseAttribute[]> {
return this.attributes.query();
}

searchStringList = (list: Observable<string[]>): Function =>
(text$: Observable<string>) =>
Expand Down
10 changes: 5 additions & 5 deletions ui/src/app/schema-form/widget/check/checklist.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
</tr>
</thead>
<tbody>
<tr *ngFor="let attr of schema.widget.data; let i=index;">
<td scope="col">{{ attr.label }}</td>
<tr *ngFor="let attr of data | async; let i=index;">
<td scope="col">{{ attr.label | translate }}</td>
<td scope="col">
<fieldset>
<div class="custom-control custom-checkbox">
Expand All @@ -18,13 +18,13 @@
(change)="onCheck(attr.key)"
[checked]="checked[attr.key]"
id="input-{{ i }}"
[attr.name]="attr.label"
[attr.aria-label]="attr.label"
[attr.name]="attr.label | translate"
[attr.aria-label]="attr.label | translate"
role="checkbox"
aria-checked="false"
/>
<label class="custom-control-label" for="input-{{ i }}">
<span class="sr-only">Toggle {{ attr.label }}</span>
<span class="sr-only">Toggle {{ attr.label | translate }}</span>
</label>
</div>
</fieldset>
Expand Down
12 changes: 12 additions & 0 deletions ui/src/app/schema-form/widget/check/checklist.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Component, AfterViewInit } from '@angular/core';

import { ArrayWidget } from 'ngx-schema-form';
import { AttributesService } from '../../../metadata/domain/service/attributes.service';
import { Observable, of } from 'rxjs';

/* istanbul ignore next */
@Component({
Expand All @@ -10,6 +12,12 @@ import { ArrayWidget } from 'ngx-schema-form';
export class ChecklistComponent extends ArrayWidget implements AfterViewInit {
checked: any = {};

constructor(
private attributes: AttributesService
) {
super();
}

ngAfterViewInit(): void {
super.ngAfterViewInit();
this.formProperty.value.forEach(val => this.checked[val] = true);
Expand All @@ -19,6 +27,10 @@ export class ChecklistComponent extends ArrayWidget implements AfterViewInit {
this.formProperty.setValue(Object.keys(this.checked), false);
}

get data(): Observable<{ key: string, label: string }[]> {
return this.schema.widget.data ? of(this.schema.widget.data) : this.attributes.query(this.schema.widget.dataUrl);
}

onCheck(value) {
if (!this.checked[value]) {
this.checked[value] = true;
Expand Down
16 changes: 1 addition & 15 deletions ui/src/assets/schema/filter/entity-attributes.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,21 +182,7 @@
"description": "Attribute release table - select the attributes you want to release (default unchecked)",
"widget": {
"id": "checklist",
"data": [
{ "key": "eduPersonPrincipalName", "label": "eduPersonPrincipalName (EPPN)" },
{ "key": "uid", "label": "uid" },
{ "key": "mail", "label": "mail" },
{ "key": "surname", "label": "surname" },
{ "key": "givenName", "label": "givenName" },
{ "key": "displayName", "label": "displayName" },
{ "key": "eduPersonAffiliation", "label": "eduPersonAffiliation" },
{ "key": "eduPersonScopedAffiliation", "label": "eduPersonScopedAffiliation" },
{ "key": "eduPersonPrimaryAffiliation", "label": "eduPersonPrimaryAffiliation" },
{ "key": "eduPersonEntitlement", "label": "eduPersonEntitlement" },
{ "key": "eduPersonAssurance", "label": "eduPersonAssurance" },
{ "key": "eduPersonUniqueId", "label": "eduPersonUniqueId" },
{ "key": "employeeNumber", "label": "employeeNumber" }
]
"dataUrl": "/customAttributes"
},
"items": {
"type": "string"
Expand Down

0 comments on commit 56bf45c

Please sign in to comment.