Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
refactor(projects): don't use the cache when refreshing the projects …
…list. Also renames some labels and methods to clarify that these things are for deactivating a project as opposed to deleting a project. (#597)
  • Loading branch information
mdelez committed Nov 30, 2021
1 parent 56d3227 commit faebe3e
Show file tree
Hide file tree
Showing 8 changed files with 135 additions and 67 deletions.
139 changes: 120 additions & 19 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/app/main/dialog/dialog.component.html
Expand Up @@ -102,9 +102,9 @@
<app-project-form [projectCode]="data.project" (closeDialog)="dialogRef.close()"></app-project-form>
</div>

<!-- Delete project -->
<div *ngSwitchCase="'deleteProject'">
<app-dialog-header [title]="data.name" [subtitle]="'appLabels.form.project.title.delete' | translate">
<!-- Deactivate project -->
<div *ngSwitchCase="'deactivateProject'">
<app-dialog-header [title]="data.name" [subtitle]="'appLabels.form.project.title.deactivate' | translate">
</app-dialog-header>
Do you want to deactivate this project?
<mat-dialog-actions>
Expand Down
Expand Up @@ -79,7 +79,7 @@ <h5 class="mat-subheading-2 link info-longname" (click)="openProjectPage(project
- http://www.knora.org/ontology/knora-admin#DefaultSharedOntologiesProject
-->
<button mat-menu-item *ngIf="status"
(click)="openDialog('deleteProject', project.shortname, project.id)">
(click)="openDialog('deactivateProject', project.shortname, project.id)">
Deactivate project
</button>
<button mat-menu-item *ngIf="!status"
Expand Down
Expand Up @@ -156,8 +156,8 @@ export class ProjectsListComponent implements OnInit {
if (response === true) {
// get the mode
switch (mode) {
case 'deleteProject':
this.deleteProject(id);
case 'deactivateProject':
this.deactivateProject(id);
break;

case 'activateProject':
Expand All @@ -180,7 +180,8 @@ export class ProjectsListComponent implements OnInit {
localStorage.setItem('sortProjectsBy', key);
}

deleteProject(id: string) {
deactivateProject(id: string) {
// the deleteProject() method in js-lib sets the project's status to false, it is not actually deleted
this._dspApiConnection.admin.projectsEndpoint.deleteProject(id).subscribe(
(response: ApiResponseData<ProjectResponse>) => {
this.refreshParent.emit();
Expand Down
24 changes: 0 additions & 24 deletions src/app/system/projects/projects.component.html
@@ -1,16 +1,3 @@
<!--
<form [formGroup]="findProject" class="form" *ngIf="!loading">
<mat-form-field class="large">
<input matInput [placeholder]="Find project…" [formControl]="">
</mat-form-field>
<mat-autocomplete #user="matAutocomplete" (optionSelected)="selectProject()">
<mat-option *ngFor="let project of filteredProjects | async" [value]="project?.name">
{{ project?.label }}
</mat-option>
</mat-autocomplete>
</form>
-->

<app-progress-indicator *ngIf="loading"></app-progress-indicator>

<div *ngIf="!loading" class="app-projects">
Expand All @@ -22,14 +9,3 @@
<app-projects-list [list]="inactive" [status]="false" (refreshParent)="refresh()"></app-projects-list>
</div>

<!--
<div *ngIf="system">
<button mat-raised-button [color]="'primary'" class="add-new" (click)="openDialog('createProject')">
NEW project
</button>
<app-progress-indicator *ngIf="loadSystem"></app-progress-indicator>
<app-projects-list *ngIf="!loadSystem" [list]="active" [system]="system"></app-projects-list>
<app-projects-list *ngIf="!loadSystem" [list]="inactive" [system]="system"></app-projects-list>
</div>
-->
14 changes: 2 additions & 12 deletions src/app/system/projects/projects.component.ts
Expand Up @@ -83,10 +83,9 @@ export class ProjectsComponent implements OnInit {
// clean up list of projects
this.active = [];
this.inactive = [];

if (this.username) {
// logged-in user view: get all projects, where the user is member of
this._cache.get(this.username, this._dspApiConnection.admin.usersEndpoint.getUserByUsername(this.username)).subscribe(
this._dspApiConnection.admin.usersEndpoint.getUserByUsername(this.username).subscribe(
(response: ApiResponseData<UserResponse>) => {

for (const project of response.body.user.projects) {
Expand Down Expand Up @@ -154,17 +153,8 @@ export class ProjectsComponent implements OnInit {
* refresh list of projects after updating one
*/
refresh(): void {
// referesh the component
// refresh the component
this.loading = true;
// update the cache
// this._cache.del('members_of_' + this.projectCode);
this.initList();

// refresh child component: add user
/*
if (this.addUser) {
this.addUser.buildForm();
}
*/
}
}
4 changes: 2 additions & 2 deletions src/assets/i18n/de.json
Expand Up @@ -97,8 +97,8 @@
"new": "Projekt erstellen",
"edit": "Projekt aktualisieren",
"editSuccess": "Das Projekt wurde erfolgreich aktualisiert",
"delete": "Projekt deaktivieren",
"deleteHint": "Möchtest du das Projekt wirklich deaktivieren?",
"deactivate": "Projekt deaktivieren",
"deactivateHint": "Möchtest du das Projekt wirklich deaktivieren?",
"formWizard": {
"step_1": "Projektdaten",
"step_2": "Mitlgieder hinzufügen",
Expand Down
6 changes: 3 additions & 3 deletions src/assets/i18n/en.json
Expand Up @@ -121,9 +121,9 @@
"edit": "Update project",
"profile": "Research project",
"editSuccess": "You have successfully updated this project.",
"delete": "Deactivate project",
"deleteHint": "You're sure to delete this project?",
"deleteButton": "Deactivate project now",
"deactivate": "Deactivate project",
"deactivateHint": "You're sure to deactivate this project?",
"deactivateButton": "Deactivate project now",
"activate": "Do you want to reactivate?",
"activateButton": "Reactivate project now",
"formWizard": {
Expand Down

0 comments on commit faebe3e

Please sign in to comment.