Skip to content

Commit

Permalink
Merged in bugfix/dupes (pull request #303)
Browse files Browse the repository at this point in the history
Bugfix/dupes
  • Loading branch information
Jonathan Johnson committed Feb 26, 2019
2 parents 08bf9f0 + 46ecc7b commit 19f9ae0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ void setupUIInfo(EntityDescriptor ed, EntityDescriptorRepresentation representat
void setupContacts(EntityDescriptor ed, EntityDescriptorRepresentation representation) {
// set up contacts
if (representation.getContacts() != null && representation.getContacts().size() > 0) {
ed.getContactPersons().clear();
for (ContactRepresentation contactRepresentation : representation.getContacts()) {
ContactPerson contactPerson = ((ContactPersonBuilder) openSamlObjects.getBuilderFactory().getBuilder(ContactPerson.DEFAULT_ELEMENT_NAME)).buildObject();

Expand Down Expand Up @@ -325,7 +326,7 @@ void setupSPSSODescriptor(EntityDescriptor ed, EntityDescriptorRepresentation re
);
}


spssoDescriptor.getNameIDFormats().clear();
if (representation.getServiceProviderSsoDescriptor() != null && representation.getServiceProviderSsoDescriptor().getNameIdFormats() != null && representation.getServiceProviderSsoDescriptor().getNameIdFormats().size() > 0) {
for (String nameidFormat : representation.getServiceProviderSsoDescriptor().getNameIdFormats()) {
NameIDFormat nameIDFormat = openSamlObjects.buildDefaultInstanceOfType(NameIDFormat.class);
Expand Down
6 changes: 3 additions & 3 deletions ui/src/app/schema-form/widget/array/array.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@
<ul class="mt-2"
[ngClass]="{'bg-light border rounded p-3 list-group': getListType(formProperty) === 'object'}"
[class.no-style]="getListType(formProperty) !== 'object'">
<li *ngFor="let itemProperty of formProperty.properties; let i=index; trackBy:trackByIndex"
<li *ngFor="let itemProperty of formProperty.properties; let i=index;"
[class.mt-2]="i > 0"
[class.list-group-item]="itemProperty.type === 'object'">
<div [ngClass]="{ 'd-flex justify-content-between': itemProperty.type !== 'object' }">
<ng-container [ngSwitch]="itemProperty.type">
<ng-container *ngSwitchDefault>
<sf-form-element class="flex-grow-1" [formProperty]="itemProperty"></sf-form-element>
<div class="py-2">
<button class="btn btn-link pt-1" (click)="removeItem(i)" role="button">
<button class="btn btn-link pt-1" (click)="removeItem(i, itemProperty); $event.stopPropagation()" role="button">
<i class="fa fa-fw fa-trash fa-lg text-danger"></i>
<span class="sr-only" translate="action.remove">Remove</span>
</button>
Expand All @@ -48,7 +48,7 @@
<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">
<button class="btn btn-link pt-1" (click)="removeItem(i, itemProperty); $event.stopPropagation()" role="button">
<i class="fa fa-fw fa-trash fa-lg text-danger"></i>
<span class="sr-only" translate="action.remove">Remove</span>
</button>
Expand Down
6 changes: 6 additions & 0 deletions ui/src/app/schema-form/widget/array/array.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Component, AfterViewInit, OnDestroy } from '@angular/core';
import { ArrayWidget } from 'ngx-schema-form';
import { map } from 'rxjs/operators';
import { Observable, Subscription } from 'rxjs';
import { FormProperty } from 'ngx-schema-form/lib/model/formproperty';

export interface FormError {
code: string;
Expand Down Expand Up @@ -42,6 +43,11 @@ export class CustomArrayComponent extends ArrayWidget implements AfterViewInit,
this.hasErrorSub.unsubscribe();
}

removeItem(index: number, item: FormProperty = null): void {
this.formProperty.properties = (<FormProperty[]>this.formProperty.properties).filter(i => i !== item);
this.formProperty.updateValueAndValidity(false, true);
}

addItem(): void {
super.addItem();
}
Expand Down

0 comments on commit 19f9ae0

Please sign in to comment.