-
Notifications
You must be signed in to change notification settings - Fork 39
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
27 changed files
with
1,984 additions
and
241 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
import Component from '@ember/component'; | ||
import { inject as service } from '@ember/service'; | ||
import { task, timeout } from 'ember-concurrency'; | ||
import { A } from '@ember/array'; | ||
import config from 'ember-get-config'; | ||
|
||
export default Component.extend({ | ||
store: service(), | ||
toast: service(), | ||
isLoading: false, | ||
canLoadMore: false, | ||
page: 1, | ||
selectedJournal: null, | ||
keyword: '', | ||
preprint: null, | ||
journals: A(), | ||
publisherFilterKeyword: null, | ||
|
||
didReceiveAttrs() { | ||
this.get('_fetchAllApprovedJournals').perform(); | ||
}, | ||
|
||
actions: { | ||
/* | ||
This action is not used because we only need 7 journals from APA | ||
*/ | ||
getInitialJournals(keyword) { | ||
this.get('_fetchInitialJournals').perform(keyword); | ||
}, | ||
/* | ||
This action is not used because we only need 7 journals from APA | ||
*/ | ||
getMoreJournals() { | ||
this.get('_fetchMoreJournals').perform(); | ||
}, | ||
journalSelected(journal) { | ||
this.set('selectedJournal', journal); | ||
}, | ||
cancelSubmission() { | ||
this.set('journals', A()); | ||
this.set('selectedJournal', null); | ||
}, | ||
}, | ||
|
||
_fetchAllApprovedJournals: task(function* () { | ||
const approvedJournals = yield this.get('store').query( | ||
'chronos-journal', | ||
{ | ||
page: 1, | ||
'filter[id]': config.approvedChronosJournalIds.join(','), | ||
'page[size]': 100, | ||
}, | ||
); | ||
this.set('journals', approvedJournals); | ||
}), | ||
/* | ||
This function is not used because we only need 7 journals for APA. | ||
*/ | ||
_fetchInitialJournals: task(function* (keyword) { | ||
// Wait a bit for the user to finish typing. | ||
yield timeout(500); | ||
// Reset the list of journals | ||
this.set('journals', A()); | ||
// Reset page number | ||
this.set('page', 1); | ||
this.set('isLoading', true); | ||
const journals = yield this.get('store').query('chronos-journal', { page: 1, 'filter[title]': keyword, 'filter[name]': this.get('publisherFilterKeyword') }); | ||
this.set('isLoading', false); | ||
const canLoadMore = !(journals.get('meta.total_pages') === this.get('page')); | ||
// Set the keyword | ||
this.set('keyword', keyword); | ||
this.set('canLoadMore', canLoadMore); | ||
this.set('journals', journals); | ||
}).restartable(), | ||
|
||
/* | ||
This function is not used because we only need 7 journals for APA. | ||
*/ | ||
_fetchMoreJournals: task(function* () { | ||
const journals = this.get('journals'); | ||
const page = this.get('page'); | ||
const keyword = this.get('keyword'); | ||
this.set('isLoading', true); | ||
const moreJournals = yield this.get('store').query('chronos-journal', { page: page + 1, 'filter[title]': keyword, 'filter[name]': this.get('publisherFilterKeyword') }); | ||
journals.pushObjects(moreJournals.toArray().map(item => item._internalModel)); | ||
this.set('isLoading', false); | ||
const canLoadMore = page + 1 < journals.get('meta.total_pages'); | ||
if (canLoadMore) { | ||
this.set('page', page + 1); | ||
} | ||
this.set('canLoadMore', canLoadMore); | ||
}).enqueue(), | ||
_submit: task(function* () { | ||
const newTab = window.open(); | ||
const submission = this.get('store').createRecord('chronos-submission', { | ||
journal: this.get('selectedJournal'), | ||
preprint: this.get('preprint'), | ||
}); | ||
try { | ||
yield submission.save(); | ||
newTab.location.href = submission.get('submissionUrl'); | ||
window.location.reload(true); | ||
} catch (e) { | ||
newTab.close(); | ||
this.get('toast').error(e.errors[0].detail); | ||
} | ||
}).drop(), | ||
}); |
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,28 @@ | ||
{{#cp-panel}} | ||
{{#cp-panel-toggle}} | ||
<p>{{t 'components.chronos-submission-panel.link_text'}}</p> | ||
{{/cp-panel-toggle}} | ||
|
||
{{#cp-panel-body}} | ||
<div> | ||
{{!-- This section is commented out because we only need 7 APA journals. | ||
{{#power-select search=(perform _fetchInitialJournals) optionsComponent=(component 'lazy-options' loadMore=(action "getMoreJournals") isLoading=isLoading canLoadMore=canLoadMore) options=journals placeholder="Select a journal" selected=selectedJournal onfocus=(action "getInitialJournals" "") oninput=(action "getInitialJournals") onchange=(action "journalSelected") as |journal|}} | ||
<strong>{{journal.title}}</strong> | ||
{{/power-select}} | ||
--}} | ||
{{#power-select options=journals placeholder="Select a journal" selected=selectedJournal onchange=(action "journalSelected") as |journal|}} | ||
<strong>{{journal.title}}</strong> | ||
{{/power-select}} | ||
</div> | ||
{{#if selectedJournal}} | ||
<div style="padding-top: 5px"> | ||
<p>{{t 'components.chronos-submission-panel.helper_text'}}</p> | ||
</div> | ||
|
||
<div class="pull-right"> | ||
<button class="btn btn-default" onClick={{action 'cancelSubmission'}}>Cancel</button> | ||
<button class="btn btn-success" onClick={{perform _submit}}>Submit</button> | ||
</div> | ||
{{/if}} | ||
{{/cp-panel-body}} | ||
{{/cp-panel}} |
49 changes: 49 additions & 0 deletions
49
app/components/chronos-submission-status-list-row/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,49 @@ | ||
import Component from '@ember/component'; | ||
import { inject as service } from '@ember/service'; | ||
import { computed } from '@ember/object'; | ||
|
||
const DRAFTED = 'DRAFT'; | ||
const SUBMITTED = 'SUBMITTED'; | ||
const ACCEPTED = 'ACCEPTED'; | ||
const REJECTED = 'CANCELLED'; | ||
const PUBLISHED = 'PUBLISHED'; | ||
|
||
const STATUS_ICON = { | ||
[DRAFTED]: 'fa-file-text-o', | ||
[SUBMITTED]: 'fa-hourglass-o', | ||
[ACCEPTED]: 'fa-check-circle-o', | ||
[REJECTED]: 'fa-times-circle-o', | ||
[PUBLISHED]: 'fa-book', | ||
}; | ||
|
||
const ICON_CLASS = { | ||
[DRAFTED]: 'chronos-status-drafted', | ||
[SUBMITTED]: 'chronos-status-submitted', | ||
[ACCEPTED]: 'chronos-status-accepted', | ||
[REJECTED]: 'chronos-status-rejected', | ||
[PUBLISHED]: 'chronos-status-published', | ||
}; | ||
|
||
const STATUS_LANGUAGE = { | ||
[DRAFTED]: 'components.chronos-submission-status-list-row.drafted', | ||
[SUBMITTED]: 'components.chronos-submission-status-list-row.submitted', | ||
[ACCEPTED]: 'components.chronos-submission-status-list-row.accepted', | ||
[REJECTED]: 'components.chronos-submission-status-list-row.rejected', | ||
[PUBLISHED]: 'components.chronos-submission-status-list-row.published', | ||
}; | ||
|
||
|
||
export default Component.extend({ | ||
i18n: service(), | ||
submission: null, | ||
isContributor: false, | ||
statusIcon: computed('submission.status', function () { | ||
return STATUS_ICON[this.get('submission.status')]; | ||
}), | ||
statusIconClass: computed('submission.status', function () { | ||
return ICON_CLASS[this.get('submission.status')]; | ||
}), | ||
statusLanguage: computed('submission.{status,journal.title}', function () { | ||
return this.get('i18n').t(STATUS_LANGUAGE[this.get('submission.status')], { title: this.get('submission.journal.title') }); | ||
}), | ||
}); |
6 changes: 6 additions & 0 deletions
6
app/components/chronos-submission-status-list-row/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,6 @@ | ||
<div> | ||
{{fa-icon statusIcon class=statusIconClass}} {{statusLanguage}} | ||
{{#if isContributor}} | ||
<a target="_blank" rel="noopener" class="fa fa-external-link" href={{submission.submissionUrl}}></a> | ||
{{/if}} | ||
</div> |
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,7 @@ | ||
import Component from '@ember/component'; | ||
import { inject as service } from '@ember/service'; | ||
|
||
export default Component.extend({ | ||
store: service(), | ||
submissions: null, | ||
}); |
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,9 @@ | ||
{{#each submissions as |submission|}} | ||
{{#if isContributor}} | ||
{{chronos-submission-status-list-row submission=submission isContributor=isContributor}} | ||
{{else}} | ||
{{#if (or (eq submission.status "ACCEPTED") (eq submission.status "PUBLISHED"))}} | ||
{{chronos-submission-status-list-row submission=submission isContributor=isContributor}} | ||
{{/if}} | ||
{{/if}} | ||
{{/each}} |
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,28 @@ | ||
import Component from '@ember/component'; | ||
import { inject as service } from '@ember/service'; | ||
import { task } from 'ember-concurrency'; | ||
|
||
export default Component.extend({ | ||
store: service(), | ||
preprint: null, | ||
submissions: null, | ||
isAllowSubmissions: false, | ||
isAdmin: false, | ||
isContributor: false, | ||
didReceiveAttrs() { | ||
this.get('fetchSubmissions').perform(this.get('preprint.id')); | ||
}, | ||
fetchSubmissions: task(function* (preprintId) { | ||
const submissions = yield this.get('store').query('chronos-submission', { preprintId }); | ||
this.set('submissions', submissions); | ||
const submittedOrRejectedSubmissions = submissions.filter((item) => { | ||
const status = item.get('status'); | ||
return status === 'SUBMITTED' || status === 'PUBLISHED' || status === 'ACCEPTED'; | ||
}); | ||
if (submittedOrRejectedSubmissions.length > 0) { | ||
this.set('isAllowSubmissions', false); | ||
} else if (this.get('isAdmin') && this.get('preprint.reviewsState') === 'accepted' && (this.get('preprint.provider.reviewsWorkflow') === 'pre-moderation' || this.get('preprint.provider.reviewsWorkflow') === 'post-moderation')) { | ||
this.set('isAllowSubmissions', true); | ||
} | ||
}), | ||
}); |
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 @@ | ||
{{ yield preprint submissions isAllowSubmissions isContributor }} |
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
Oops, something went wrong.