Skip to content

Commit

Permalink
Merged in bugfix/SHIBUI-458 (pull request #64)
Browse files Browse the repository at this point in the history
Bugfix/SHIBUI-458

* Fixed issue with preview section disappearing during save

* Fixed issue with dashboard filters expanding more than one with same entity id

* Fixed issue with search modal not populating field

Approved-by: Ryan Mathis <rmathis@unicon.net>
  • Loading branch information
rmathis committed Apr 30, 2018
1 parent 061dada commit a595855
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 35 deletions.
2 changes: 1 addition & 1 deletion ui/src/app/dashboard/container/dashboard.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<li *ngFor="let entity of limited$ | async; index as i" [ngClass]="{'mt-2': i > 0}" aria-label="Provider Item Accordion. Press Spacebar to open">
<entity-item
[entity]="entity"
[isOpen]="(entitiesOpen$ | async)[entity.entityId]"
[isOpen]="(entitiesOpen$ | async)[entity.id || entity.entityId]"
(select)="edit(entity)"
(toggle)="toggleProvider(entity)"
(preview)="openPreviewDialog(entity)"
Expand Down
3 changes: 2 additions & 1 deletion ui/src/app/dashboard/container/dashboard.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ export class DashboardComponent implements OnInit {
}

toggleProvider(entity: MetadataEntity): void {
this.store.dispatch(new ToggleEntityDisplay(entity.entityId));
let id = entity.id ? entity.id : entity.entityId;
this.store.dispatch(new ToggleEntityDisplay(id));
}

openPreviewDialog(entity: MetadataEntity): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
<ng-container i18n="@@action--save-changes">Preview XML</ng-container>
</button>
<button
(click)="this.save()"
(click)="this.save($event)"
type="submit"
class="btn btn-primary"
[disabled]="form.invalid || (isSaving$ | async)">
Expand Down
53 changes: 32 additions & 21 deletions ui/src/app/metadata-filter/container/edit-filter.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ export class EditFilterComponent implements OnInit, OnDestroy {
isSaving$: Observable<boolean>;

form: FormGroup = this.fb.group({
entityId: ['', [Validators.required]],
entityId: [
'',
[Validators.required]
],
filterName: ['', [Validators.required]],
filterEnabled: [false]
});
Expand Down Expand Up @@ -81,18 +84,20 @@ export class EditFilterComponent implements OnInit, OnDestroy {

this.entityIds$.subscribe(ids => this.ids = ids);

this.filter$.subscribe(filter => {
let { entityId, filterName, filterEnabled } = new Filter(filter);
this.form.reset({
entityId,
filterName,
filterEnabled
});
this.filter = filter;
this.filterEntity = new Filter(filter);
this.filter$
.withLatestFrom(this.isSaving$)
.subscribe(([filter, saving]) => {
let { entityId, filterName, filterEnabled } = new Filter(filter);
this.form.reset({
entityId,
filterName,
filterEnabled
});
this.filter = filter;
this.filterEntity = new Filter(filter);

this.store.dispatch(new SelectId(entityId));
});
this.store.dispatch(new SelectId(entityId));
});
}

ngOnInit(): void {
Expand All @@ -116,14 +121,19 @@ export class EditFilterComponent implements OnInit, OnDestroy {

this.form.get('entityId').disable();

id
.valueChanges
.distinctUntilChanged()
.subscribe(entityId => {
if (id.valid) {
this.store.dispatch(new SelectId(entityId));
}
});
id.valueChanges
.distinctUntilChanged()
.subscribe(entityId => {
if (id.valid) {
this.store.dispatch(new SelectId(entityId));
}
});

this.selected$
.distinctUntilChanged()
.subscribe(entityId => {
id.setValue(entityId);
});
}

ngOnDestroy(): void {
Expand Down Expand Up @@ -163,7 +173,8 @@ export class EditFilterComponent implements OnInit, OnDestroy {
this.isValid = status === 'VALID';
}

save(): void {
save($event): void {
$event.preventDefault();
this.store.dispatch(new UpdateFilterRequest({...this.filter, ...this.changes.serialize()}));
}

Expand Down
17 changes: 7 additions & 10 deletions ui/src/app/metadata-filter/container/new-filter.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,21 +104,18 @@ export class NewFilterComponent implements OnInit, OnDestroy {
.startWith(this.form.value)
.subscribe(changes => this.store.dispatch(new UpdateFilterChanges(changes)));

/*this.statusEmitSubscription = this.form
.statusChanges
.takeUntil(this.ngUnsubscribe)
.startWith(this.form.status)
.subscribe(status => this.onStatusChange.emit(status));*/


id
.valueChanges
id.valueChanges
.distinctUntilChanged()
.subscribe(entityId => {
if (id.valid) {
this.store.dispatch(new SelectId(entityId));
}
});
this.selected$
.distinctUntilChanged()
.subscribe(entityId => {
id.setValue(entityId);
});
}

ngOnDestroy(): void {
Expand All @@ -127,7 +124,7 @@ export class NewFilterComponent implements OnInit, OnDestroy {
}

searchEntityIds(term: string): void {
if (term.length >= 4 && this.ids.indexOf(term) < 0) {
if (term && term.length >= 4 && this.ids.indexOf(term) < 0) {
this.store.dispatch(new QueryEntityIds({
term,
limit: 10
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/metadata-filter/reducer/filter.reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export function reducer(state = initialState, action: filter.Actions | FilterCol
case FilterCollectionActionTypes.ADD_FILTER:
case FilterCollectionActionTypes.UPDATE_FILTER_REQUEST: {
return {
...initialState,
...state,
saving: true
};
}
Expand Down

0 comments on commit a595855

Please sign in to comment.