Home remove link if user has not permission to visit a specific dashboard, search stakeholders open visibility filter.
This commit is contained in:
parent
386fe30ff7
commit
9c286c3451
|
@ -186,32 +186,17 @@
|
|||
<div class="stakeholders uk-margin-large-top uk-child-width-1-1 uk-child-width-1-2@s uk-child-width-1-3@m uk-grid uk-flex-top uk-flex-wrap-top"
|
||||
uk-grid="masonry: true" uk-height-match="target: .uk-card; row: false;">
|
||||
<div *ngFor="let stakeholder of stakeholders" [attr.data-type]="stakeholder.type">
|
||||
<a *ngIf="directLink" [href]="getStakeholderPageUrl(stakeholder)" target="_blank">
|
||||
<a *ngIf="directLink && hasPermission(stakeholder)" [href]="getStakeholderPageUrl(stakeholder)" target="_blank">
|
||||
<div class="uk-card uk-card-default uk-text-center uk-position-relative">
|
||||
<div *ngIf="stakeholder.visibility && stakeholder.visibility !== 'PUBLIC'"
|
||||
class="uk-position-top-right uk-margin-top uk-margin-right uk-flex uk-flex-middle">
|
||||
<icon [name]="visibilityIcon.get(stakeholder.visibility)"></icon>
|
||||
<span class="space uk-text-small uk-text-capitalize">{{stakeholder.visibility.toLowerCase()}}</span>
|
||||
</div>
|
||||
<img *ngIf="stakeholder.logoUrl && stakeholder.isUpload" class="uk-margin-auto"
|
||||
[src]="properties.utilsService + '/download/' + stakeholder.logoUrl">
|
||||
<img *ngIf="stakeholder.logoUrl && !stakeholder.isUpload" class="uk-margin-auto" [src]="stakeholder.logoUrl | urlPrefix">
|
||||
<div class="uk-text-light uk-margin-medium-top">{{stakeholder.name}}</div>
|
||||
<ng-container *ngTemplateOutlet="stakeholderCard; context: {stakeholder: stakeholder}"></ng-container>
|
||||
</div>
|
||||
</a>
|
||||
<a *ngIf="!directLink" (click)="confirmModalOpen(stakeholder)">
|
||||
<div class="uk-card uk-card-default uk-text-center">
|
||||
<div *ngIf="stakeholder.visibility && stakeholder.visibility !== 'PUBLIC'"
|
||||
class="uk-position-top-right uk-margin-top uk-margin-right uk-flex uk-flex-middle">
|
||||
<icon [name]="visibilityIcon.get(stakeholder.visibility)"></icon>
|
||||
<span class="space uk-text-small uk-text-capitalize">{{stakeholder.visibility.toLowerCase()}}</span>
|
||||
</div>
|
||||
<img *ngIf="stakeholder.logoUrl && stakeholder.isUpload" class="uk-margin-auto"
|
||||
[src]="properties.utilsService + '/download/' + stakeholder.logoUrl">
|
||||
<img *ngIf="stakeholder.logoUrl && !stakeholder.isUpload" class="uk-margin-auto" [src]="stakeholder.logoUrl | urlPrefix">
|
||||
<div class="uk-text-light uk-margin-medium-top">{{stakeholder.name}}</div>
|
||||
</div>
|
||||
<a *ngIf="!directLink && hasPermission(stakeholder)" (click)="confirmModalOpen(stakeholder)">
|
||||
<ng-container *ngTemplateOutlet="stakeholderCard; context: {stakeholder: stakeholder}"></ng-container>
|
||||
</a>
|
||||
<ng-container *ngIf="!hasPermission(stakeholder)">
|
||||
<ng-container *ngTemplateOutlet="stakeholderCard; context: {stakeholder: stakeholder}"></ng-container>
|
||||
</ng-container>
|
||||
</div>
|
||||
<div *ngIf="stakeholdersNumber === 0" [attr.data-type]="type"
|
||||
class="uk-text-center uk-text-large uk-width-1-1 uk-margin-large-top uk-padding-large">
|
||||
|
@ -242,3 +227,16 @@
|
|||
You will be navigated to a new tab. Are you sure that you want to proceed?
|
||||
</div>
|
||||
</modal-alert>
|
||||
<ng-template #stakeholderCard let-stakeholder="stakeholder">
|
||||
<div class="uk-card uk-card-default uk-text-center">
|
||||
<div *ngIf="stakeholder.visibility && stakeholder.visibility !== 'PUBLIC'"
|
||||
class="uk-position-top-right uk-margin-top uk-margin-right uk-flex uk-flex-middle">
|
||||
<icon [name]="visibilityIcon.get(stakeholder.visibility)"></icon>
|
||||
<span class="space uk-text-small uk-text-capitalize">{{stakeholder.visibility.toLowerCase()}}</span>
|
||||
</div>
|
||||
<img *ngIf="stakeholder.logoUrl && stakeholder.isUpload" class="uk-margin-auto"
|
||||
[src]="properties.utilsService + '/download/' + stakeholder.logoUrl">
|
||||
<img *ngIf="stakeholder.logoUrl && !stakeholder.isUpload" class="uk-margin-auto" [src]="stakeholder.logoUrl | urlPrefix">
|
||||
<div class="uk-text-light uk-margin-medium-top">{{stakeholder.name}}</div>
|
||||
</div>
|
||||
</ng-template>
|
||||
|
|
|
@ -244,7 +244,6 @@ export class HomeComponent {
|
|||
this.subscriberErrorMessage = "";
|
||||
this.subscriptions.push(this._stakeholderService.getStakeholders(this.properties.monitorServiceAPIURL).subscribe(
|
||||
stakeholders => {
|
||||
stakeholders = stakeholders.filter(stakeholder => stakeholder.visibility !== 'PRIVATE');
|
||||
if (!stakeholders || stakeholders.length == 0) {
|
||||
this.status = this.errorCodes.NONE;
|
||||
} else {
|
||||
|
@ -259,8 +258,12 @@ export class HomeComponent {
|
|||
));
|
||||
}
|
||||
|
||||
private isStakeholderManager() {
|
||||
return Session.isPortalAdministrator(this.user) || Session.isMonitorCurator(this.user) || Session.isCommunityCurator(this.user);
|
||||
private isManager(stakeholder: Stakeholder) {
|
||||
return Session.isPortalAdministrator(this.user) || Session.isMonitorCurator(this.user) || Session.isManager(stakeholder.type, stakeholder.alias, this.user);
|
||||
}
|
||||
|
||||
private isMember(stakeholder: Stakeholder) {
|
||||
return Session.isMember(stakeholder.type, stakeholder.alias, this.user);
|
||||
}
|
||||
|
||||
public confirmModalOpen(result: Stakeholder) {
|
||||
|
@ -301,6 +304,10 @@ export class HomeComponent {
|
|||
this.clearTimeouts();
|
||||
}
|
||||
|
||||
hasPermission(stakeholder: Stakeholder) {
|
||||
return stakeholder.visibility === "PUBLIC" || this.isManager(stakeholder) || this.isMember(stakeholder);
|
||||
}
|
||||
|
||||
private handleError(message: string, error): number {
|
||||
var code = "";
|
||||
if (!error.status) {
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 18dd1379ad151d4988d7c58ae63a8ad8bfad5602
|
||||
Subproject commit 0b3e699796585c12ed06744d69a0e95e7629aa63
|
|
@ -61,10 +61,9 @@ export class SearchStakeholdersComponent {
|
|||
public keyword = "";
|
||||
public searchLink;
|
||||
properties: EnvProperties = properties;
|
||||
@ViewChild(NewSearchPageComponent, { static: true }) searchPage: NewSearchPageComponent;
|
||||
@ViewChild(NewSearchPageComponent, {static: true}) searchPage: NewSearchPageComponent;
|
||||
private user: User;
|
||||
private userFilterLoaded: boolean = false;
|
||||
|
||||
|
||||
constructor(private route: ActivatedRoute,
|
||||
private _stakeholderService: StakeholderService,
|
||||
private userManagementService: UserManagementService) {
|
||||
|
@ -72,7 +71,7 @@ export class SearchStakeholdersComponent {
|
|||
this.errorMessages = new ErrorMessagesComponent();
|
||||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
}
|
||||
|
||||
|
||||
public ngOnInit() {
|
||||
this.piwikSiteId = this.properties.piwikSiteId;
|
||||
this.baseUrl = this.properties.searchLinkToStakeholders;
|
||||
|
@ -92,8 +91,7 @@ export class SearchStakeholdersComponent {
|
|||
this.searchLink = this.properties.searchLinkToStakeholders;
|
||||
this.selectedFields = [];
|
||||
this.searchPage.prepareSearchPage(this.fieldIds, this.selectedFields, this.refineFields, [], this.fieldIdsMap, null, params, "stakeholder", null);
|
||||
|
||||
let queryParams = params;//this.searchPage.getQueryParamsFromUrl(params);
|
||||
let queryParams = params;
|
||||
if (typeof document !== 'undefined') {
|
||||
this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
|
||||
this.user = user;
|
||||
|
@ -104,7 +102,7 @@ export class SearchStakeholdersComponent {
|
|||
}
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
ngOnDestroy() {
|
||||
this.subscriptions.forEach(subscription => {
|
||||
if (subscription instanceof Subscriber) {
|
||||
|
@ -112,8 +110,8 @@ export class SearchStakeholdersComponent {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Initialize stakeholders from Communities APIs
|
||||
*
|
||||
|
@ -125,11 +123,10 @@ export class SearchStakeholdersComponent {
|
|||
if (!data) {
|
||||
return;
|
||||
}
|
||||
data = data.filter(stakeholder => stakeholder.visibility !== 'PRIVATE');
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
this.totalResults[i] = data[i];
|
||||
this.totalResults[i].isManager = this.isStakeholderManager(data[i]);
|
||||
this.totalResults[i].isMember = this.isStakeholderMember(data[i]);
|
||||
this.totalResults[i].isManager = this.isManager(data[i]);
|
||||
this.totalResults[i].isMember = this.isMember(data[i]);
|
||||
}
|
||||
this._getResults(params);
|
||||
},
|
||||
|
@ -140,8 +137,8 @@ export class SearchStakeholdersComponent {
|
|||
}
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get all stakeholders from mock API and apply permission access validator,
|
||||
* keyword searching, filter, paging and sorting.
|
||||
|
@ -157,22 +154,7 @@ export class SearchStakeholdersComponent {
|
|||
this.searchUtils.totalResults = 0;
|
||||
this.applyParams(params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the stakeholders in which user has permission to view or manage.
|
||||
*/
|
||||
private showFunders() {
|
||||
let ret = [];
|
||||
for (let result of this.results) {
|
||||
if(result.visibility === 'PUBLIC' ||
|
||||
(result.visibility === 'RESTRICTED' && this.isStakeholderMember(result))
|
||||
) {
|
||||
ret.push(result);
|
||||
}
|
||||
}
|
||||
this.results = ret;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Apply permission access validator,
|
||||
* keyword searching, filter, paging and sorting.
|
||||
|
@ -181,7 +163,6 @@ export class SearchStakeholdersComponent {
|
|||
* @param status
|
||||
*/
|
||||
public applyParams(params) {
|
||||
this.showFunders();
|
||||
if (this.keyword && this.keyword != '') {
|
||||
this.searchForKeywords();
|
||||
}
|
||||
|
@ -207,8 +188,8 @@ export class SearchStakeholdersComponent {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Parse the given keywords into array and check if any of the requirements field of a funder includes
|
||||
* one of the given words.
|
||||
|
@ -228,7 +209,7 @@ export class SearchStakeholdersComponent {
|
|||
}
|
||||
this.results = ret;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check the current results if they satisfy the values of each filter category and
|
||||
* update the number of possible results in each value.
|
||||
|
@ -239,13 +220,13 @@ export class SearchStakeholdersComponent {
|
|||
let typeResults: StakeholderInfo[] = this.applyFilter('type', params);
|
||||
let accessResults: StakeholderInfo[] = this.results;
|
||||
let roleResults: StakeholderInfo[] = this.results;
|
||||
accessResults = this.applyFilter('access', params);
|
||||
roleResults = this.applyFilter('role', params);
|
||||
this.resetFilterNumbers('access');
|
||||
this.updateFilterNumbers(typeResults.filter(value => {
|
||||
return roleResults.includes(value);
|
||||
}), 'access');
|
||||
if (this.user) {
|
||||
accessResults = this.applyFilter('access', params);
|
||||
roleResults = this.applyFilter('role', params);
|
||||
this.resetFilterNumbers('access');
|
||||
this.updateFilterNumbers(typeResults.filter(value => {
|
||||
return roleResults.includes(value);
|
||||
}), 'access');
|
||||
this.resetFilterNumbers('role');
|
||||
this.updateFilterNumbers(accessResults.filter(value => {
|
||||
return typeResults.includes(value);
|
||||
|
@ -262,7 +243,7 @@ export class SearchStakeholdersComponent {
|
|||
return roleResults.includes(value);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Apply filter with filterId and return the results
|
||||
*
|
||||
|
@ -337,7 +318,7 @@ export class SearchStakeholdersComponent {
|
|||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reset the values of filter with id filterId with zero.
|
||||
*
|
||||
|
@ -353,7 +334,7 @@ export class SearchStakeholdersComponent {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update the values of filter with id filterId based on
|
||||
* results.
|
||||
|
@ -392,7 +373,7 @@ export class SearchStakeholdersComponent {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sorting results based on sortBy.
|
||||
*/
|
||||
|
@ -429,16 +410,16 @@ export class SearchStakeholdersComponent {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
private isStakeholderManager(stakeholder) {
|
||||
|
||||
private isManager(stakeholder) {
|
||||
return Session.isPortalAdministrator(this.user) || Session.isMonitorCurator(this.user)
|
||||
|| Session.isCommunityCurator(this.user) || Session.isManager(stakeholder.type, stakeholder.alias, this.user);
|
||||
}
|
||||
|
||||
private isStakeholderMember(stakeholder) {
|
||||
return this.isStakeholderManager(stakeholder) || Session.isSubscribedTo(stakeholder.type, stakeholder.alias, this.user);
|
||||
|
||||
private isMember(stakeholder) {
|
||||
return this.isManager(stakeholder) || Session.isSubscribedTo(stakeholder.type, stakeholder.alias, this.user);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create Search Stakeholder filters.
|
||||
*
|
||||
|
@ -452,16 +433,15 @@ export class SearchStakeholdersComponent {
|
|||
filter_ids.push("type");
|
||||
value_names.push(["Funders", "Research Initiatives", "Organizations"]);
|
||||
value_original_ids.push(["funder", "ri", "organization"]);
|
||||
if (this.user) {
|
||||
filter_names.push("Accessibility");
|
||||
filter_ids.push("access");
|
||||
value_names.push(["Public", "Restricted"]);
|
||||
value_original_ids.push(["public", "restricted"]);
|
||||
filter_names.push("Accessibility");
|
||||
filter_ids.push("access");
|
||||
value_names.push(["Public", "Restricted"]);
|
||||
value_original_ids.push(["public", "restricted"]);
|
||||
if(this.user) {
|
||||
filter_names.push("Role");
|
||||
filter_ids.push("role");
|
||||
value_names.push(["Manager", "Member"]);
|
||||
value_original_ids.push(["manager", "member"]);
|
||||
this.userFilterLoaded = true;
|
||||
}
|
||||
let filters: Filter[] = [];
|
||||
for (let i = 0; i < filter_names.length; i++) {
|
||||
|
@ -484,9 +464,9 @@ export class SearchStakeholdersComponent {
|
|||
}
|
||||
return filters;
|
||||
}
|
||||
|
||||
|
||||
private handleError(message: string, error) {
|
||||
console.error('Communities Search Page: ' + message, error);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 10dbbb5610afa279837add9be683938e86acd659
|
||||
Subproject commit 363790356aeb20339fab6d36516864ab44931dd7
|
Loading…
Reference in New Issue