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
feat(lists): read mode project member (DEV-1343) #825
Changes from 12 commits
a06b1e1
bd652a0
97da899
b782535
b73ed1e
fb5d97f
9ddbb19
418b6d0
7d014f3
19116da
fd7bb22
cd87150
ff8b5a8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,11 +11,14 @@ import { | |
ListInfoResponse, | ||
ListNode, | ||
ListNodeInfoResponse, | ||
ReadProject, | ||
StringLiteral | ||
} from '@dasch-swiss/dsp-js'; | ||
import { DspApiConnectionToken } from 'src/app/main/declarations/dsp-api-tokens'; | ||
import { DialogComponent } from 'src/app/main/dialog/dialog.component'; | ||
import { ErrorHandlerService } from 'src/app/main/services/error-handler.service'; | ||
import { Session, SessionService } from '../../../main/services/session.service'; | ||
import { CacheService } from '../../../main/cache/cache.service'; | ||
|
||
export class ListNodeOperation { | ||
operation: 'create' | 'insert' | 'update' | 'delete' | 'reposition'; | ||
|
@@ -90,6 +93,14 @@ export class ListItemFormComponent implements OnInit { | |
|
||
@Output() refreshParent: EventEmitter<ListNodeOperation> = new EventEmitter<ListNodeOperation>(); | ||
|
||
// permissions of logged-in user | ||
session: Session; | ||
sysAdmin = false; | ||
projectAdmin = false; | ||
|
||
// project data | ||
project: ReadProject; | ||
|
||
loading: boolean; | ||
|
||
initComponent: boolean; | ||
|
@@ -101,10 +112,30 @@ export class ListItemFormComponent implements OnInit { | |
constructor( | ||
@Inject(DspApiConnectionToken) private _dspApiConnection: KnoraApiConnection, | ||
private _errorHandler: ErrorHandlerService, | ||
private _dialog: MatDialog | ||
private _dialog: MatDialog, | ||
private _session: SessionService, | ||
private _cache: CacheService, | ||
) { } | ||
|
||
ngOnInit() { | ||
// get information about the logged-in user | ||
this.session = this._session.getSession(); | ||
|
||
// is the logged-in user system admin? | ||
this.sysAdmin = this.session.user.sysAdmin; | ||
|
||
// get the project data from cache | ||
this._cache.get(this.projectCode).subscribe( | ||
(response: ReadProject) => { | ||
this.project = response; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can use a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would go further and not even use |
||
|
||
// is logged-in user projectAdmin? | ||
this.projectAdmin = this.sysAdmin ? this.sysAdmin : this.session.user.projectAdmin.some(e => e === this.project.id); | ||
}, | ||
(error: ApiResponseError) => { | ||
this._errorHandler.showMessage(error); | ||
} | ||
); | ||
|
||
this.initComponent = true; | ||
|
||
|
@@ -199,7 +230,9 @@ export class ListItemFormComponent implements OnInit { | |
* show action bubble with various CRUD buttons when hovered over. | ||
*/ | ||
mouseEnter() { | ||
this.showActionBubble = true; | ||
if (this.projectAdmin) { | ||
this.showActionBubble = true; | ||
} | ||
} | ||
|
||
/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,12 +6,15 @@ import { | |
ListChildNodeResponse, | ||
ListNode, | ||
ListResponse, | ||
ReadProject, | ||
RepositionChildNodeRequest, | ||
RepositionChildNodeResponse | ||
RepositionChildNodeResponse, | ||
} from '@dasch-swiss/dsp-js'; | ||
import { DspApiConnectionToken } from 'src/app/main/declarations/dsp-api-tokens'; | ||
import { ErrorHandlerService } from 'src/app/main/services/error-handler.service'; | ||
import { ListNodeOperation } from '../list-item-form/list-item-form.component'; | ||
import { Session, SessionService } from '../../../main/services/session.service'; | ||
import { CacheService } from '../../../main/cache/cache.service'; | ||
|
||
@Component({ | ||
selector: 'app-list-item', | ||
|
@@ -36,14 +39,43 @@ export class ListItemComponent implements OnInit { | |
|
||
@Output() refreshChildren: EventEmitter<ListNode[]> = new EventEmitter<ListNode[]>(); | ||
|
||
// permissions of logged-in user | ||
session: Session; | ||
sysAdmin = false; | ||
projectAdmin = false; | ||
|
||
// project data | ||
project: ReadProject; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same thing here as in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
expandedNode: string; | ||
|
||
constructor( | ||
@Inject(DspApiConnectionToken) private _dspApiConnection: KnoraApiConnection, | ||
private _errorHandler: ErrorHandlerService | ||
private _errorHandler: ErrorHandlerService, | ||
private _session: SessionService, | ||
private _cache: CacheService, | ||
) { } | ||
|
||
ngOnInit() { | ||
// get information about the logged-in user | ||
this.session = this._session.getSession(); | ||
|
||
// is the logged-in user system admin? | ||
this.sysAdmin = this.session.user.sysAdmin; | ||
|
||
// get the project data from cache | ||
this._cache.get(this.projectCode).subscribe( | ||
(response: ReadProject) => { | ||
this.project = response; | ||
|
||
// is logged-in user projectAdmin? | ||
this.projectAdmin = this.sysAdmin ? this.sysAdmin : this.session.user.projectAdmin.some(e => e === this.project.id); | ||
}, | ||
(error: ApiResponseError) => { | ||
this._errorHandler.showMessage(error); | ||
} | ||
); | ||
|
||
// in case of parent node: run the following request to get the entire list | ||
if (!this.childNode) { | ||
this._dspApiConnection.admin.listsEndpoint.getList(this.parentIri).subscribe( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this variable is needed, you can use a
const
to temporarily store the project you get from the cacheThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, it is not needed elsewhere (ff8b5a8)