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
refactor(project landing page): use metadata endpoint to get data from backend (DSP-1199) #400
Conversation
|
||
// return the type of agent to use correct template to display it | ||
getAgentType(agent: IPerson | IOrganisation) { | ||
if (agent.hasOwnProperty('familyName')) { | ||
setAgent (agent: Person | Organization | IId) { |
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.
Method return type is missing.
let atype = this.getAgentType(agent); | ||
if (atype) { | ||
this.currentAgent = agent; | ||
return atype; | ||
} | ||
this.currentAgent = this.subProperties[agent.id]; | ||
atype = this.getAgentType(this.currentAgent); | ||
return atype; |
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.
why not if...else
with one return
outside?
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.
When I used if..else before, linter was complaining about else condition and my tests were failing because of that. So I updated the code like this.
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.
Same here, this answer.
getAgentType (agent: Person | Organization | IId) { | ||
if (agent instanceof Person) { | ||
return 'person'; | ||
} | ||
if (agent.hasOwnProperty('url')) { | ||
if (agent instanceof Organization) { | ||
return 'organisation'; | ||
} | ||
return undefined; | ||
} |
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.
method return type is missing and if...else
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.
linter was complaining same for else block here so I removed it.
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've applied below and on vscode, linter doesn't complain. Could you show me (screen) how it looks on your side?
setAgent (agent: Person | Organization | IId): string {
let atype = this._datasetMetadataService.getContactType(agent);
if (atype) {
this.currentAgent = agent;
} else {
this.currentAgent = this.subProperties[agent.id];
atype = this._datasetMetadataService.getContactType(this.currentAgent);
}
return atype;
}
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.
Here it is: https://github.com/dasch-swiss/dsp-app/runs/1987482010?check_suite_focus=true.
It shows misplaced else error in multiple places.
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.
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.
Thanks for pointing it out. Changes are done in d8b4993.
<!-- Functionality to be implemented --> | ||
<a href *ngFor="let dformat of metadataDownloadFormats" class="download-metadata"> {{ dformat }} </a> |
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.
indention
[cdkCopyToClipboard]="selectedProject.id" | ||
(click)="copyToClipboard('Persistent identifier')" | ||
class="btn-copy-to-clipboard"> | ||
<mat-icon [inline]="true" class="icon-arkurl">content_copy</mat-icon> |
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.
indention
<div class="property-label display-inline-block"> | ||
Email: | ||
</div> |
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.
Indention or you can make it one-liner.
|
||
ngOnInit() { | ||
// check if members list is the list of [Organization] or [Iid] | ||
let isOrganizationType: boolean = false; |
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.
If property is initiated with value, type annotation is redundant. It's not wrong, but not necessary for primitive types.
SingleProject, | ||
DataManagementPlan, | ||
Person, | ||
Organization, | ||
IId, | ||
Grant |
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.
alphabetise imports
|
||
} | ||
|
||
getDMP(currenDmps: DataManagementPlan | IId[]) { |
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.
return type is missing
getFunderType(funder: Person | Organization | IId) { | ||
if (funder instanceof Person) { | ||
return 'person'; | ||
} | ||
if (funder instanceof Organization) { | ||
return 'organization'; | ||
} | ||
return undefined; | ||
} |
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.
like few comments above, this can be reused from service
b688416
to
6bb29d8
Compare
Requested changes are done in 6bb29d8. |
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.
Where possible, bring back correct form of if...else
or if...else if
blocks.
getContactType(obj: Person | Organization | IId): string { | ||
if (obj instanceof Person) { | ||
return 'person'; | ||
} | ||
if (obj instanceof Organization) { | ||
return 'organization'; | ||
} | ||
return undefined; | ||
} |
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.
Use if..else if
block here, have a look at this answer.
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.
Thanks. Changes are done in d8b4993.
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class DatasetMetadataService { |
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 would just name it MetadataService
, or MetadataUtilService
where all helpers method could be stored.
Also this repository has using 4 spaces indentions.
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.
done in d8b4993.
…lable for selected project.
…ng to new metadata schema
…ntact page for new metadata schema Note: need to work on UI for person and organisation templates (mainly used in funder, grant, attribution and contact sections)
…adata is not available
6bb29d8
to
d8b4993
Compare
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.
;)
} | ||
return undefined; |
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.
ending else
is missing here
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.
From my understanding if the case is default (and there is no further code to run in the function, we can add it without using else block. isn't it right?
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.
Correct.
} | ||
return undefined; |
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.
Correct.
resolves DSP-1199
In this PR: