Fix a bug in topics while delete the active entity. Fix a bug with infinity loading when a topic or category is not found.

This commit is contained in:
Konstantinos Triantafyllou 2022-11-08 15:10:20 +02:00
parent 53446ed998
commit 8e978b0c9f
5 changed files with 77 additions and 46 deletions

View File

@ -141,18 +141,9 @@ export class AppComponent implements OnInit, OnDestroy {
this.stakeholder = stakeholder; this.stakeholder = stakeholder;
LinksResolver.setProperties(this.stakeholder.alias); LinksResolver.setProperties(this.stakeholder.alias);
this.setProperties(this.stakeholder.alias, this.stakeholder.type); this.setProperties(this.stakeholder.alias, this.stakeholder.type);
if (params && params['topic'] && !this.activeTopic) {
this.activeTopic = this.stakeholder.topics.find(topic => topic.alias === decodeURIComponent(params['topic']) && this.isPublicOrIsMember(topic.visibility));
} else {
this.activeTopic = this.stakeholder.topics.find(topic => this.isPublicOrIsMember(topic.visibility));
}
if (params && params['category']) {
this.activeCategory = this.activeTopic.categories.find(category => category.alias === decodeURIComponent(params['category']) && this.isPublicOrIsMember(category.visibility));
} else {
this.activeCategory = this.activeTopic.categories.find(category => this.isPublicOrIsMember(category.visibility));
}
this.setSideBar();
this.buildMenu(); this.buildMenu();
this.setActives(params);
this.setSideBar();
this.loading = false; this.loading = false;
} else { } else {
this.stakeholder = null; this.stakeholder = null;
@ -164,16 +155,7 @@ export class AppComponent implements OnInit, OnDestroy {
})); }));
} else { } else {
this.buildMenu(); this.buildMenu();
if (params && params['topic']) { this.setActives(params);
this.activeTopic = this.stakeholder.topics.find(topic => topic.alias === decodeURIComponent(params['topic']) && this.isPublicOrIsMember(topic.visibility));
} else {
this.activeTopic = this.stakeholder.topics.find(topic => this.isPublicOrIsMember(topic.visibility));
}
if (params && params['category']) {
this.activeCategory = this.activeTopic.categories.find(category => category.alias === decodeURIComponent(params['category']) && this.isPublicOrIsMember(category.visibility));
} else {
this.activeCategory = this.activeTopic.categories.find(category => this.isPublicOrIsMember(category.visibility));
}
this.loading = false; this.loading = false;
} }
} else { } else {
@ -207,6 +189,26 @@ export class AppComponent implements OnInit, OnDestroy {
})); }));
} }
setActives(params: Params) {
if (params && params['topic']) {
this.activeTopic = this.stakeholder.topics.find(topic => topic.alias === decodeURIComponent(params['topic']) && this.isPublicOrIsMember(topic.visibility));
} else {
this.activeTopic = this.stakeholder.topics.find(topic => this.isPublicOrIsMember(topic.visibility));
}
if(this.activeTopic) {
if (params && params['category']) {
this.activeCategory = this.activeTopic.categories.find(category => category.alias === decodeURIComponent(params['category']) && this.isPublicOrIsMember(category.visibility));
} else {
this.activeCategory = this.activeTopic.categories.find(category => this.isPublicOrIsMember(category.visibility));
}
if(!this.activeCategory) {
this.navigateToError();
}
} else {
this.navigateToError();
}
}
public setNotificationGroups() { public setNotificationGroups() {
this.entities = this.stakeholderUtils.types.map(option => option.value); this.entities = this.stakeholderUtils.types.map(option => option.value);
this.notificationGroups = []; this.notificationGroups = [];

View File

@ -39,10 +39,10 @@
</ng-template> </ng-template>
<div page-content> <div page-content>
<div header> <div header>
<div class="uk-flex uk-flex-middle uk-margin-medium-top info"> <div *ngIf="stakeholder" class="uk-flex uk-flex-middle uk-margin-medium-top info">
<img [src]="stakeholder | logoUrl" class="uk-margin-right uk-blend-multiply"> <img [src]="stakeholder | logoUrl" class="uk-margin-right uk-blend-multiply">
<div> <div>
<div class="uk-text-background uk-text-bold uk-text-small">Dashboard</div> <div class="uk-text-background uk-text-bold uk-text-small">Monitor Dashboard</div>
<h1 class="uk-h6 uk-margin-remove">{{stakeholder.name}}</h1> <h1 class="uk-h6 uk-margin-remove">{{stakeholder.name}}</h1>
</div> </div>
</div> </div>

View File

@ -199,7 +199,8 @@
</div> </div>
</div> </div>
<div actions> <div actions>
<div class="uk-margin-medium-top uk-margin-bottom"> <div class="uk-margin-medium-top uk-grid" uk-grid>
<div class="uk-width-expand">
<ul *ngIf="stakeholder.topics.length > 0 && stakeholder.topics[topicIndex].categories.length > 0 && stakeholder.topics[topicIndex].categories[categoryIndex]" <ul *ngIf="stakeholder.topics.length > 0 && stakeholder.topics[topicIndex].categories.length > 0 && stakeholder.topics[topicIndex].categories[categoryIndex]"
transition-group class="uk-tab" [id]="'subCategories'"> transition-group class="uk-tab" [id]="'subCategories'">
<ng-template ngFor [ngForOf]=" stakeholder.topics[topicIndex].categories[categoryIndex].subCategories" let-subCategory let-i="index"> <ng-template ngFor [ngForOf]=" stakeholder.topics[topicIndex].categories[categoryIndex].subCategories" let-subCategory let-i="index">
@ -282,6 +283,34 @@
</li> </li>
</ul> </ul>
</div> </div>
<div *ngIf="stakeholder.topics.length > 0" class="uk-width-auto@l uk-width-1-1">
<div class="uk-flex uk-flex-center">
<button class="uk-button uk-button-primary uk-flex uk-flex-middle">
<icon name="visibility" [flex]="true"></icon>
<span class="uk-margin-small-left uk-margin-small-right">Preview</span>
<icon name="expand_more" [flex]="true"></icon>
</button>
<div #element uk-dropdown="mode: click; pos: bottom-left; offset: 5; delay-hide: 0; flip: false">
<ul class="uk-nav uk-dropdown-nav">
<li><a target="_blank"
[routerLink]="'/' + stakeholder.alias + '/' + stakeholder.topics[topicIndex].alias"
[queryParams]="{view: 'public'}"
(click)="hide(element)">Public view</a>
</li>
<li><a target="_blank" [routerLink]="'/' + stakeholder.alias + '/' +
stakeholder.topics[topicIndex].alias"
[queryParams]="{view: 'restricted'}"
(click)="hide(element)">Restricted view</a>
</li>
<!--<li class="disabled"><a class="uk-disabled uk-text-muted"
uk-tooltip="Note: available only in administration dashboard"
(click)="hide(element)">Private view</a>
</li>-->
</ul>
</div>
</div>
</div>
</div>
</div> </div>
<div inner> <div inner>
<input #file id="import-file" type="file" class="uk-hidden" <input #file id="import-file" type="file" class="uk-hidden"

View File

@ -351,7 +351,7 @@ export class TopicComponent implements OnInit, OnDestroy, AfterViewInit, IDeacti
this.topicChanged(() => { this.topicChanged(() => {
this.stakeholder.topics.splice(this.index, 1); this.stakeholder.topics.splice(this.index, 1);
if(this.topicIndex === this.index) { if(this.topicIndex === this.index) {
this.chooseTopic(Math.max(0, this.index)); this.chooseTopic(Math.max(0, this.index - 1));
} }
}, true); }, true);
}; };
@ -492,7 +492,7 @@ export class TopicComponent implements OnInit, OnDestroy, AfterViewInit, IDeacti
this.categoryChanged(() => { this.categoryChanged(() => {
this.stakeholder.topics[this.topicIndex].categories.splice(this.index, 1); this.stakeholder.topics[this.topicIndex].categories.splice(this.index, 1);
if(this.categoryIndex === this.index) { if(this.categoryIndex === this.index) {
this.chooseCategory(Math.max(0, this.index)); this.chooseCategory(Math.max(0, this.index - 1));
} }
}, true); }, true);
}; };
@ -632,7 +632,7 @@ export class TopicComponent implements OnInit, OnDestroy, AfterViewInit, IDeacti
this.subCategoryChanged(() => { this.subCategoryChanged(() => {
this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories.splice(this.index, 1); this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories.splice(this.index, 1);
if(this.subCategoryIndex === this.index) { if(this.subCategoryIndex === this.index) {
this.chooseSubcategory(Math.max(0, this.index)); this.chooseSubcategory(Math.max(0, this.index - 1));
} }
}, true); }, true);
}; };

@ -1 +1 @@
Subproject commit 06e1889730e456e86f728a31410bf550d16ac7d6 Subproject commit 75433ae50ab42a5ad1aea2a26ec26c57e78e4a25