Skip to content

Commit

Permalink
Merge branch 'release/24.07.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
cslzchen committed Sep 18, 2024
2 parents 9b0a0a7 + bd5f554 commit 1583fa4
Show file tree
Hide file tree
Showing 50 changed files with 1,880 additions and 79 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [24.07.0] - 2024-09-18
### Added
- Preprints Affiliation Project - FE Release
- My Preprints Page: preprint card and paginated public preprint list

## [24.06.0] - 2024-08-21
### Added
- Misc bug and a11y fixes
Expand Down
8 changes: 8 additions & 0 deletions app/models/preprint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import AbstractNodeModel from 'ember-osf-web/models/abstract-node';
import CitationModel from 'ember-osf-web/models/citation';
import PreprintRequestModel from 'ember-osf-web/models/preprint-request';
import { ReviewsState } from 'ember-osf-web/models/provider';
import ReviewActionModel from 'ember-osf-web/models/review-action';
import InstitutionModel from 'ember-osf-web/models/institution';

import ContributorModel from './contributor';
import FileModel from './file';
Expand Down Expand Up @@ -81,6 +83,12 @@ export default class PreprintModel extends AbstractNodeModel {
@belongsTo('preprint-provider', { inverse: 'preprints' })
provider!: AsyncBelongsTo<PreprintProviderModel> & PreprintProviderModel;

@hasMany('institution')
affiliatedInstitutions!: AsyncHasMany<InstitutionModel>;

@hasMany('review-action')
reviewActions!: AsyncHasMany<ReviewActionModel>;

@hasMany('contributors', { inverse: 'preprint'})
contributors!: AsyncHasMany<ContributorModel> & ContributorModel;

Expand Down
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;
}
}
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}}
49 changes: 49 additions & 0 deletions app/preprints/-components/preprint-card/component-test.ts
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',
);
});
});
30 changes: 30 additions & 0 deletions app/preprints/-components/preprint-card/component.ts
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);
}

}
121 changes: 121 additions & 0 deletions app/preprints/-components/preprint-card/styles.scss
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;
}
Loading

0 comments on commit 1583fa4

Please sign in to comment.