use methods isPublic, isRestricted, isPrivate instead of using the previous checks and add validateStatus method
This commit is contained in:
parent
8aae6d6d80
commit
7eb2335c20
|
@ -458,7 +458,7 @@ export class AppComponent implements OnInit, OnDestroy {
|
|||
this.communityId = null;
|
||||
this.configurationService.initPortal(this.properties, "connect");
|
||||
this.buildConnectMenu(true);
|
||||
if (this.community && this.community.status == "manager") {
|
||||
if (this.community && this.community.isRestricted()) {
|
||||
if (!this.user) {
|
||||
if (typeof location !== 'undefined' && location.pathname.indexOf("user-info") == -1) {
|
||||
this.router.navigate(['/user-info'], {
|
||||
|
@ -473,7 +473,7 @@ export class AppComponent implements OnInit, OnDestroy {
|
|||
this.router.navigate(['/'], {queryParamsHandling: "merge"});
|
||||
}
|
||||
}
|
||||
} else if (this.community && this.community.status == "hidden") {
|
||||
} else if (this.community && (this.community.isPrivate())) {
|
||||
this.router.navigate([this.properties.errorLink]);
|
||||
} else {
|
||||
this.router.navigate(['/'], this.community && this.community.status ? {queryParamsHandling: "merge"} : {});
|
||||
|
|
|
@ -174,7 +174,7 @@ export class CommunitiesComponent implements OnInit, OnDestroy, AfterViewInit {
|
|||
let showCommunity: boolean = true;
|
||||
community.isSubscribed = Session.isSubscribedTo('community', community.communityId, this.user);
|
||||
|
||||
if (community['status'] == "hidden" || community['status'] == "manager") {
|
||||
if (community.isPrivate() || community.isRestricted()) {
|
||||
showCommunity = false;
|
||||
}
|
||||
if (showCommunity) {
|
||||
|
@ -192,7 +192,7 @@ export class CommunitiesComponent implements OnInit, OnDestroy, AfterViewInit {
|
|||
}
|
||||
|
||||
hasPermission(communityInfo: CommunityInfo) {
|
||||
return communityInfo.status === "all" || (communityInfo.status === "manager" && communityInfo.isManager);
|
||||
return communityInfo.isPublic() || (communityInfo.isRestricted() && communityInfo.isManager);
|
||||
}
|
||||
|
||||
private sort(results: CommunityInfo[]) {
|
||||
|
|
|
@ -175,9 +175,9 @@ export class SearchCommunitiesComponent {
|
|||
private showCommunities() {
|
||||
let ret: CommunityInfo[] = [];
|
||||
for (let result of this.results) {
|
||||
if (result.status == 'hidden' && result.isManager) {
|
||||
if (result.isPrivate() && result.isManager) {
|
||||
ret.push(result);
|
||||
} else if (result.status == "manager" || result.status == "all") {
|
||||
} else if (result.isRestricted() || result.isPublic()) {
|
||||
ret.push(result);
|
||||
}
|
||||
}
|
||||
|
@ -284,6 +284,7 @@ export class SearchCommunitiesComponent {
|
|||
if (params[filterId]) {
|
||||
values = (StringUtils.URIDecode(params[filterId])).split(/,(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/, -1);
|
||||
}
|
||||
console.log(filterId + ": " +values)
|
||||
if (filterId == 'type') {
|
||||
for (let i = 0; i < this.results.length; i++) {
|
||||
if (values.length == 0) {
|
||||
|
@ -302,19 +303,20 @@ export class SearchCommunitiesComponent {
|
|||
if (values.length == 0) {
|
||||
results.push(this.results[i]);
|
||||
} else {
|
||||
// console.log(this.results[i].status, this.results[i].isPublic(),this.results[i].isRestricted(), this.results[i].isPrivate() )
|
||||
for (let value of values) {
|
||||
if (value.replace(/["']/g, "") == 'public') {
|
||||
if (this.results[i].status === 'all') {
|
||||
if (this.results[i].isPublic()) {
|
||||
results.push(this.results[i]);
|
||||
break;
|
||||
}
|
||||
} else if (value.replace(/["']/g, "") == 'restricted') {
|
||||
if (this.results[i].status === 'manager') {
|
||||
if (this.results[i].isRestricted()) {
|
||||
results.push(this.results[i]);
|
||||
break;
|
||||
}
|
||||
} else if (value.replace(/["']/g, "") == 'private') {
|
||||
if (this.results[i].status === 'hidden') {
|
||||
if (this.results[i].isPrivate()) {
|
||||
results.push(this.results[i]);
|
||||
break;
|
||||
}
|
||||
|
@ -381,9 +383,9 @@ export class SearchCommunitiesComponent {
|
|||
}
|
||||
}
|
||||
} else if (this.filters[i].filterId == 'access') {
|
||||
if (results[k].status === 'all') {
|
||||
if (results[k].isPublic()) {
|
||||
this.filters[i].values[0].number++;
|
||||
} else if (results[k].status === 'manager') {
|
||||
} else if (results[k].isRestricted()) {
|
||||
this.filters[i].values[1].number++;
|
||||
} else if (this.user) {
|
||||
this.filters[i].values[2].number++;
|
||||
|
|
Loading…
Reference in New Issue