forked from CenterForOpenScience/ember-osf-web
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
50 changed files
with
1,880 additions
and
79 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
50 changes: 50 additions & 0 deletions
50
app/preprints/-components/preprint-affiliated-institutions/styles.scss
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,50 @@ | ||
.osf-institution-link-flex { | ||
img { | ||
width: 35px; | ||
height: 35px; | ||
} | ||
|
||
a { | ||
padding-bottom: 5px; | ||
} | ||
|
||
.img-circle { | ||
border-radius: 50%; | ||
margin-right: 15px; | ||
} | ||
|
||
.img-responsive { | ||
max-width: 100%; | ||
} | ||
|
||
.img-horizontal { | ||
margin-top: 10px; | ||
} | ||
|
||
.link-horizontal { | ||
display: inline; | ||
} | ||
|
||
.link-vertical { | ||
display: block; | ||
} | ||
|
||
} | ||
|
||
.title { | ||
margin-top: 10px; | ||
font-weight: bold; | ||
font-size: 18px; | ||
padding-bottom: 10px; | ||
} | ||
|
||
.content-container { | ||
width: 100%; | ||
margin-top: 20px; | ||
|
||
h4 { | ||
margin-top: 10px; | ||
margin-bottom: 10px; | ||
font-weight: bold; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
app/preprints/-components/preprint-affiliated-institutions/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,26 @@ | ||
{{#if @preprint.affiliatedInstitutions}} | ||
<div local-class='content-container'> | ||
<div local-class='title'> | ||
{{t 'preprints.detail.affiliated_institutions'}} | ||
</div> | ||
<div local-class='osf-institution-link-flex'> | ||
{{#each @preprint.affiliatedInstitutions as |institution|}} | ||
<OsfLink @href={{institution.links.html}} @target='_blank' local-class='{{if @isReviewPage 'link-horizontal'}}{{unless @isReviewPage 'link-vertical'}}'> | ||
<img | ||
data-test-preprint-institution-list={{institution.id}} | ||
local-class='img-circle img-responsive {{if @isReviewPage 'img-horizontal'}}' | ||
src={{institution.logoRoundedUrl}} | ||
alt={{institution.name}} | ||
> | ||
{{#if @isReviewPage}} | ||
<EmberTooltip> | ||
{{institution.name}} | ||
</EmberTooltip> | ||
{{else}} | ||
{{institution.name}} | ||
{{/if}} | ||
</OsfLink> | ||
{{/each}} | ||
</div> | ||
</div> | ||
{{/if}} |
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,49 @@ | ||
import { render } from '@ember/test-helpers'; | ||
import { hbs } from 'ember-cli-htmlbars'; | ||
import { setupMirage } from 'ember-cli-mirage/test-support'; | ||
import { setupIntl, TestContext } from 'ember-intl/test-support'; | ||
import { setupRenderingTest } from 'ember-qunit'; | ||
import { module, test } from 'qunit'; | ||
|
||
import { OsfLinkRouterStub } from 'ember-osf-web/tests/integration/helpers/osf-link-router-stub'; | ||
|
||
module('Integration | Component | preprint-card', hooks => { | ||
setupRenderingTest(hooks); | ||
setupMirage(hooks); | ||
setupIntl(hooks); | ||
|
||
hooks.beforeEach(function(this: TestContext) { | ||
this.store = this.owner.lookup('service:store'); | ||
this.intl = this.owner.lookup('service:intl'); | ||
}); | ||
|
||
test('it renders', async function(this: TestContext, assert) { | ||
this.owner.unregister('service:router'); | ||
this.owner.register('service:router', OsfLinkRouterStub); | ||
const preprint = server.create('preprint', { | ||
tags: ['a', 'b', 'c'], | ||
description: 'Through the night', | ||
}); | ||
server.create('contributor', { preprint, index: 0, bibliographic: true }); | ||
server.create('contributor', { preprint, index: 1, bibliographic: true }); | ||
server.create('contributor', { preprint, index: 2, bibliographic: true }); | ||
const preprintModel = await this.store.findRecord( | ||
'preprint', preprint.id, { include: ['bibliographic_contributors'] }, | ||
); | ||
this.set('preprint', preprintModel); | ||
|
||
await render(hbs` | ||
<Preprints::-Components::PreprintCard | ||
@preprint={{this.preprint}} | ||
@showTags={{true}} | ||
/> | ||
`); | ||
assert.dom('[data-test-preprint-title]').exists('Preprint title exists'); | ||
assert.dom('[data-test-preprint-title]').hasText(preprintModel.title, 'Node title is corrent'); | ||
assert.dom('[data-test-contributors-label]').exists('Contributors label exists'); | ||
assert.dom('[data-test-contributors-label]').hasText( | ||
this.intl.t('node_card.contributors'), | ||
'Contributors label is correct', | ||
); | ||
}); | ||
}); |
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,30 @@ | ||
import { tagName } from '@ember-decorators/component'; | ||
import Component from '@ember/component'; | ||
import config from 'ember-osf-web/config/environment'; | ||
|
||
import { layout } from 'ember-osf-web/decorators/component'; | ||
import Preprint from 'ember-osf-web/models/preprint'; | ||
import pathJoin from 'ember-osf-web/utils/path-join'; | ||
import { Permission } from 'ember-osf-web/models/osf-model'; | ||
|
||
import template from './template'; | ||
import styles from './styles'; | ||
|
||
const { OSF: { url: baseURL } } = config; | ||
|
||
@layout(template, styles) | ||
@tagName('') | ||
export default class PreprintCard extends Component { | ||
|
||
preprint?: Preprint; | ||
delete?: (preprint: Preprint) => void; | ||
showTags = false; | ||
readOnly = false; | ||
|
||
searchUrl = pathJoin(baseURL, 'search'); | ||
|
||
get shouldShowUpdateButton() { | ||
return this.preprint && this.preprint.currentUserPermissions.includes(Permission.Admin); | ||
} | ||
|
||
} |
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,121 @@ | ||
// stylelint-disable max-nesting-depth, selector-max-compound-selectors | ||
|
||
.preprint-card { | ||
width: 100%; | ||
margin: 1px 0; | ||
|
||
.card-contents { | ||
display: block; | ||
flex-direction: row; | ||
position: relative; | ||
display: block; | ||
padding: 10px 15px; | ||
margin-bottom: -1px; | ||
|
||
.heading { | ||
display: flex; | ||
flex-direction: column; | ||
flex-wrap: wrap; | ||
justify-content: flex-start; | ||
align-items: flex-start; | ||
width: 100%; | ||
|
||
:global .ember-content-placeholders-heading__title { | ||
height: 1em; | ||
margin-top: 5px; | ||
margin-bottom: 5px; | ||
|
||
&:first-child { | ||
width: 100%; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
.label-danger { | ||
background-color: $brand-danger; | ||
} | ||
|
||
.heading > span { | ||
line-height: 1.5; | ||
} | ||
|
||
.label-info { | ||
background-color: darken($brand-info, 15%); | ||
} | ||
|
||
.label-primary { | ||
background-color: #337ab7; | ||
} | ||
|
||
.label { | ||
padding: 0.2em 0.6em 0.3em; | ||
font-size: 75%; | ||
font-weight: 700; | ||
color: #fff; | ||
text-align: center; | ||
white-space: nowrap; | ||
vertical-align: baseline; | ||
border-radius: 0.25em; | ||
display: block; | ||
margin-top: 5px; | ||
} | ||
|
||
.osf-link { | ||
margin-left: 5px; | ||
margin-top: 2px; | ||
font-weight: bold; | ||
} | ||
|
||
.osf-link.mobile { | ||
margin-left: 0; | ||
} | ||
|
||
.body { | ||
width: 80%; | ||
|
||
&.mobile { | ||
width: 90%; | ||
} | ||
} | ||
|
||
dl { | ||
margin-bottom: 10px; | ||
|
||
div { | ||
display: flex; | ||
|
||
dt { | ||
width: 110px; | ||
margin-right: 5px; | ||
} | ||
|
||
dd { | ||
flex: 1; | ||
} | ||
} | ||
} | ||
|
||
.tags { | ||
margin-top: 2px; | ||
} | ||
|
||
.link { | ||
composes: Button from 'osf-components/components/button/styles.scss'; | ||
composes: SecondaryButton from 'osf-components/components/button/styles.scss'; | ||
composes: MediumButton from 'osf-components/components/button/styles.scss'; | ||
|
||
&:hover { | ||
text-decoration: none !important; | ||
} | ||
} | ||
|
||
.list-group-item-heading { | ||
margin-top: 0; | ||
margin-bottom: 5px; | ||
} | ||
|
||
.update-button { | ||
color: $color-text-blue-dark; | ||
} |
Oops, something went wrong.