-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ENG-4760] User secondary metadata (#2031)
* Add preprint relation to users * Update result card for user info * Group dt and dl a little closer * CR feedback; Refactor secondary metatadata components * CR feedback; Add test selector * Better refactor * Remove leftover arg
- Loading branch information
1 parent
a9b403d
commit bfb3f12
Showing
15 changed files
with
194 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,4 +90,3 @@ | |
</dd> | ||
{{/if}} | ||
</dl> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,4 +57,4 @@ | |
</InlineList> | ||
</dd> | ||
{{/if}} | ||
</dl> | ||
</dl> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,8 +80,11 @@ | |
padding-top: 10px; | ||
} | ||
|
||
dt, | ||
dd { | ||
dt { | ||
margin: 15px 0 0 5px; | ||
} | ||
|
||
dd { | ||
margin-left: 5px; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
lib/osf-components/addon/components/search-result-card/user-secondary-metadata/component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { inject as service } from '@ember/service'; | ||
import Store from '@ember-data/store'; | ||
import Component from '@glimmer/component'; | ||
import Intl from 'ember-intl/services/intl'; | ||
import { taskFor } from 'ember-concurrency-ts'; | ||
|
||
import SearchResultModel from 'ember-osf-web/models/search-result'; | ||
import UserModel from 'ember-osf-web/models/user'; | ||
import { alias } from '@ember/object/computed'; | ||
import { task } from 'ember-concurrency'; | ||
import { waitFor } from '@ember/test-waiters'; | ||
|
||
interface Args { | ||
result: SearchResultModel; | ||
} | ||
|
||
export default class UserSecondaryMetadata extends Component<Args> { | ||
@service intl!: Intl; | ||
@service store!: Store; | ||
|
||
@alias('args.result.indexCard.osfModel') user?: UserModel; | ||
|
||
constructor(owner: unknown, args: Args) { | ||
super(owner, args); | ||
if (!this.user) { | ||
taskFor(this.getOsfUserModel).perform(); | ||
} | ||
} | ||
|
||
@task | ||
@waitFor | ||
async getOsfUserModel() { | ||
const options = { | ||
adapterOptions: { | ||
query: { | ||
related_counts: 'nodes,registrations,preprints', | ||
}, | ||
}, | ||
reload: true, | ||
}; | ||
await taskFor(this.args.result.indexCard.get('getOsfModel')).perform(options); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
lib/osf-components/addon/components/search-result-card/user-secondary-metadata/template.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{{#if this.getOsfUserModel.isRunning}} | ||
<LoadingIndicator @dark={{true}}/> | ||
{{else if this.getOsfUserModel.isError}} | ||
{{t 'osf-components.search-result-card.fetch_user_error'}} | ||
{{else if (not this.user)}} | ||
{{t 'osf-components.search-result-card.no_user'}} | ||
{{else}} | ||
<dl> | ||
{{#if this.user.employment.length}} | ||
<dt>{{t 'osf-components.search-result-card.employment'}}</dt> | ||
<dd>{{this.user.employment.[0].institution}}</dd> | ||
{{/if}} | ||
{{#if this.user.education.length}} | ||
<dt>{{t 'osf-components.search-result-card.education'}}</dt> | ||
<dd>{{this.user.education.[0].institution}}</dd> | ||
{{/if}} | ||
<dt>{{t 'osf-components.search-result-card.public_projects'}}</dt> | ||
<dd>{{this.user.relatedCounts.nodes}}</dd> | ||
<dt>{{t 'osf-components.search-result-card.public_registrations'}}</dt> | ||
<dd>{{this.user.relatedCounts.registrations}}</dd> | ||
<dt>{{t 'osf-components.search-result-card.public_preprints'}}</dt> | ||
<dd>{{this.user.relatedCounts.preprints}}</dd> | ||
</dl> | ||
{{/if}} |
1 change: 1 addition & 0 deletions
1
lib/osf-components/app/components/search-result-card/user-secondary-metadata/component.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from 'osf-components/components/search-result-card/user-secondary-metadata/component'; |
1 change: 1 addition & 0 deletions
1
lib/osf-components/app/components/search-result-card/user-secondary-metadata/template.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from 'osf-components/components/search-result-card/user-secondary-metadata/template'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters