Skip to content
Permalink
Browse files
fix(project): bug fix in project member management (DSP-1563) (#425)
* fix(project): add user to project

* fix(project): store project in cache as ReadProject

* refactor(project): no need for project cache in user form
  • Loading branch information
kilchenmann committed Apr 22, 2021
1 parent 5b39ad3 commit ac820dd54637430b4bdbcebfbfa8ccdf9f4dea22
@@ -7,6 +7,7 @@ import {
KnoraApiConnection,
MembersResponse,
ProjectResponse,
ReadProject,
ReadUser,
UserResponse,
UsersResponse
@@ -298,9 +299,9 @@ export class AddUserComponent implements OnInit {

// get project iri by projectcode
this._cache.get(this.projectcode).subscribe(
(p: ApiResponseData<ProjectResponse>) => {
(p: ReadProject) => {
// add user to project
this._dspApiConnection.admin.usersEndpoint.addUserToProjectMembership(this.selectedUser.id, p.body.project.id).subscribe(
this._dspApiConnection.admin.usersEndpoint.addUserToProjectMembership(this.selectedUser.id, p.id).subscribe(
(userAdded: ApiResponseData<UserResponse>) => {

// successful post
@@ -509,10 +509,12 @@ export class ProjectFormComponent implements OnInit {
this.loading = true;
// update the cache
this._cache.del(this.projectcode);
this._cache.get(this.projectcode, this._dspApiConnection.admin.projectsEndpoint.getProjectByShortcode(this.projectcode));
this._cache.get(this.projectcode, this._dspApiConnection.admin.projectsEndpoint.getProjectByShortcode(this.projectcode)).subscribe(
this._dspApiConnection.admin.projectsEndpoint.getProjectByShortcode(this.projectcode).subscribe(
(response: ApiResponseData<ProjectResponse>) => {
this.project = response.body.project;

this._cache.set(this.projectcode, this.project);

this.buildForm(this.project);
window.location.reload();
this.loading = false;
@@ -7,6 +7,7 @@ import {
Constants,
KnoraApiConnection,
ProjectResponse,
ReadProject,
ReadUser,
StringLiteral,
UpdateUserRequest,
@@ -422,14 +423,12 @@ export class UserFormComponent implements OnInit, OnChanges {
if (this.projectcode) {
// if a projectcode exists, add the user to the project
// get project iri by projectcode
this._cache.get(this.projectcode, this._dspApiConnection.admin.projectsEndpoint.getProjectByShortcode(this.projectcode));
this._cache.get(this.projectcode, this._dspApiConnection.admin.projectsEndpoint.getProjectByShortcode(this.projectcode)).subscribe(
(res: ApiResponseData<ProjectResponse>) => {
this._cache.get(this.projectcode).subscribe(
(res: ReadProject) => {
// add user to project
this._dspApiConnection.admin.usersEndpoint.addUserToProjectMembership(this.user.id, res.body.project.id).subscribe(
this._dspApiConnection.admin.usersEndpoint.addUserToProjectMembership(this.user.id, res.id).subscribe(
() => {
// update project cache and member of project cache
this._cache.get(this.projectcode, this._dspApiConnection.admin.projectsEndpoint.getProjectByShortcode(this.projectcode));
this._cache.get('members_of_' + this.projectcode, this._dspApiConnection.admin.projectsEndpoint.getProjectMembersByShortcode(this.projectcode));
this.closeDialog.emit(this.user);
this.loading = false;

0 comments on commit ac820dd

Please sign in to comment.