Skip to content

Commit

Permalink
Merge pull request #459 from DigitalExcellence/bugfix/458-edit-and-de…
Browse files Browse the repository at this point in the history
…lete-button-always-shown
  • Loading branch information
waltersajtos authored Apr 28, 2021
2 parents 29c31fd + 45c8764 commit 4c5f0d1
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 47 deletions.
14 changes: 3 additions & 11 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
### Removed

### Fixed

- Fixed issue where the edit- & delete project would always be shown - [#458](https://github.com/DigitalExcellence/dex-frontend/issues/458)
- Fixed issue where the privacy modal and alerts were not responsive - [#426](https://github.com/DigitalExcellence/dex-frontend/issues/426)
- Fixed issue where the wizard would not import projects that missed a required property. [#471](https://github.com/DigitalExcellence/dex-frontend/issues/471)

Expand All @@ -37,22 +37,14 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
### Fixed
- Added icon for data sources - [#466](https://github.com/DigitalExcellence/dex-frontend/issues/466)


## Release v.1.1.0-beta - 18-03-2021

### Fixed

- Fixed list view animation bug which prevented like animation from playing - [#419](https://github.com/DigitalExcellence/dex-frontend/issues/419)
- Auto dismiss the login warning when liking project if you're not logged in - [#433](https://github.com/DigitalExcellence/dex-frontend/issues/433)
- Hide the active modal when you navigate to another page via browser navigation arrows - [#423](https://github.com/DigitalExcellence/dex-frontend/issues/423)

## Release v.1.1.0-beta - 18-03-2021

### Fixed

- Fixed list view animation bug which prevented like animation from playing - [#419](https://github.com/DigitalExcellence/dex-frontend/issues/419)
- Auto dismiss the login warning when liking project if you're not logged in - [#433](https://github.com/DigitalExcellence/dex-frontend/issues/433)
- Hide the active modal when you navigate to another page via browser navigation arrows - [#423](https://github.com/DigitalExcellence/dex-frontend/issues/423)
- Hide the active modal when you navigate to another page via browser navigation arrows
- [#423](https://github.com/DigitalExcellence/dex-frontend/issues/423)


## Release v.1.0.1-beta - 31-01-2021
Expand Down
23 changes: 13 additions & 10 deletions src/app/models/domain/scopes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,17 @@
* If not, see https://www.gnu.org/licenses/lgpl-3.0.txt
*/
export enum scopes {
ProjectRead = 'ProjectRead',
ProjectWrite = 'ProjectWrite',
UserRead = 'UserRead',
UserWrite = 'UserWrite',
HighlightRead = 'HighlightRead',
HighlightWrite = 'HighlightWrite',
RoleRead = 'RoleRead',
RoleWrite = 'RoleWrite',
EmbedRead = 'EmbedRead',
EmbedWrite = 'EmbedWrite',
ProjectRead = 'ProjectRead',
ProjectWrite = 'ProjectWrite',
UserRead = 'UserRead',
UserWrite = 'UserWrite',
HighlightRead = 'HighlightRead',
HighlightWrite = 'HighlightWrite',
RoleRead = 'RoleRead',
RoleWrite = 'RoleWrite',
EmbedRead = 'EmbedRead',
EmbedWrite = 'EmbedWrite',
AdminProjectWrite = 'AdminProjectWrite',
InstitutionProjectWrite = 'InstitutionProjectWrite'

}
34 changes: 8 additions & 26 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,11 +129,10 @@ 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();
this.determineDisplayCallToActionButton();

// Updates meta and title tags
this.seoService.updateDescription(desc);
Expand Down Expand Up @@ -313,34 +312,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 {
if (this.authService.currentBackendUserHasScope(scopes.ProjectWrite)) {
this.displayEditButton = true;
return;
}

private determineDisplayEditAndDeleteProjectButton(): void {
if (this.currentUser == null || this.project == null || this.project.user == null) {
this.displayEditButton = false;
this.displayDeleteProjectButton = 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.authService.currentBackendUserHasScope(scopes.ProjectWrite)) {
if (this.project.user.id === this.currentUser.id ||
this.authService.currentBackendUserHasScope(scopes.AdminProjectWrite)) {
this.displayEditButton = true;
this.displayDeleteProjectButton = true;
return;
}

if (this.currentUser == null || this.project == null || this.project.user == null) {
this.displayDeleteProjectButton = false;
return;
}
this.displayDeleteProjectButton = this.project.user.id === this.currentUser.id;
}

/**
Expand Down

0 comments on commit 4c5f0d1

Please sign in to comment.