Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/458-edit-and-delete-button-always-shown #459

Merged
merged 12 commits into from
Apr 28, 2021
25 changes: 8 additions & 17 deletions src/app/modules/project/details/details.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class DetailsComponent implements OnInit {

public displayEditButton = false;
public displayDeleteProjectButton = false;
public displayCallToActionButton = false;
public displayCallToActionButton = true;
public displayHighlightButton = false;
public displayEmbedButton = false;

Expand Down Expand Up @@ -129,9 +129,7 @@ export class DetailsComponent implements OnInit {
(result) => {
this.project = result;
const desc = (this.project.shortDescription) ? this.project.shortDescription : this.project.description;
this.determineDisplayEditProjectButton();
this.determineDisplayDeleteProjectButton();
this.determineDisplayCallToActionButton();
this.determineDisplayEditAndDeleteProjectButton();
this.determineDisplayEmbedButton();
this.determineDisplayHighlightButton();

Expand Down Expand Up @@ -313,24 +311,17 @@ export class DetailsComponent implements OnInit {
* Method to display the edit project button based on the current user and the project user.
* If the user either has the ProjectWrite scope or is the creator of the project
*/
private determineDisplayEditProjectButton(): void {
private determineDisplayEditAndDeleteProjectButton(): void {
if (this.currentUser == null || this.project == null || this.project.user == null) {
this.displayEditButton = false;
return;
}
this.displayEditButton = this.project.user.id === this.currentUser.id;
}

/**
* Method to display the delete project button based on the current user and the project user.
* If the user either has the ProjectWrite scope or is the creator of the project
*/
private determineDisplayDeleteProjectButton(): void {
if (this.currentUser == null || this.project == null || this.project.user == null) {
this.displayDeleteProjectButton = false;
return;
}
this.displayDeleteProjectButton = this.project.user.id === this.currentUser.id;
if (this.project.user.id === this.currentUser.id ||
this.authService.getCurrentBackendUser().role.name === 'Administrator') {
RubenFricke marked this conversation as resolved.
Show resolved Hide resolved
RubenFricke marked this conversation as resolved.
Show resolved Hide resolved
this.displayEditButton = true;
this.displayDeleteProjectButton = true;
}
}

/**
Expand Down