Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ locales:
msgfmt -o modules/oidc/locale/ja/LC_MESSAGES/oidc.mo modules/oidc/locale/ja/LC_MESSAGES/oidc.po
msgfmt -o modules/publication/locale/ja/LC_MESSAGES/publication.mo modules/publication/locale/ja/LC_MESSAGES/publication.po
msgfmt -o modules/schedule_module/locale/ja/LC_MESSAGES/schedule_module.mo modules/schedule_module/locale/ja/LC_MESSAGES/schedule_module.po
msgfmt -o modules/publication/locale/hi/LC_MESSAGES/publication.mo modules/publication/locale/hi/LC_MESSAGES/publication.po
npx i18next-conv -l hi -s modules/publication/locale/hi/LC_MESSAGES/publication.po -t modules/publication/locale/hi/LC_MESSAGES/publication.json
msgfmt -o modules/server_processes_manager/locale/ja/LC_MESSAGES/server_processes_manager.mo modules/server_processes_manager/locale/ja/LC_MESSAGES/server_processes_manager.po
msgfmt -o modules/statistics/locale/ja/LC_MESSAGES/statistics.mo modules/statistics/locale/ja/LC_MESSAGES/statistics.po
npx i18next-conv -l ja -s modules/statistics/locale/ja/LC_MESSAGES/statistics.po -t modules/statistics/locale/ja/LC_MESSAGES/statistics.json
Expand Down Expand Up @@ -209,9 +211,10 @@ candidate_parameters: modules/candidate_parameters/locale/ja/LC_MESSAGES/candida
dashboard: modules/dashboard/locale/ja/LC_MESSAGES/dashboard.mo
target=dashboard npm run compile

publication: modules/publication/locale/ja/LC_MESSAGES/publication.mo
publication:
msgfmt -o modules/publication/locale/hi/LC_MESSAGES/publication.mo modules/publication/locale/hi/LC_MESSAGES/publication.po
npx i18next-conv -l hi -s modules/publication/locale/hi/LC_MESSAGES/publication.po -t modules/publication/locale/hi/LC_MESSAGES/publication.json
target=publication npm run compile

server_processes_manager: modules/server_processes_manager/locale/ja/LC_MESSAGES/server_processes_manager.mo
target=server_processes_manager npm run compile

Expand Down
231 changes: 130 additions & 101 deletions modules/publication/jsx/publicationIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ import React from 'react';
import PropTypes from 'prop-types';
import {ButtonElement} from 'jsx/Form';
import StaticDataTable from 'jsx/StaticDataTable';
import i18n from 'I18nSetup';
import {withTranslation} from 'react-i18next';
import hiStrings from '../locale/hi/LC_MESSAGES/publication.json';
import FilterableDataTable from 'FilterableDataTable';

/**
* Publication index component
*/
class PublicationIndex extends React.Component {
/**
* @constructor
*/
constructor() {
super();
loris.hiddenHeaders = [
Expand All @@ -25,127 +26,170 @@ class PublicationIndex extends React.Component {
filter: {},
};

// Bind component instance to custom methods
this.fetchData = this.fetchData.bind(this);
this.updateFilter = this.updateFilter.bind(this);
this.resetFilters = this.resetFilters.bind(this);
}

/**
* Called by React when the component has been rendered on the page.
*/
componentDidMount() {
this.fetchData();
}

/**
* Fetch data
*/
fetchData() {
fetch(this.props.DataURL, {
method: 'GET',
}).then(
(response) => {
fetch(this.props.DataURL, {method: 'GET'})
.then((response) => {
if (!response.ok) {
console.error(response.status);
return;
}

response.json().then(
(data) => this.setState({
response.json().then((data) =>
this.setState({
Data: data,
isLoaded: true,
})
);
}).catch((error) => console.error(error));
})
.catch((error) => console.error(error));
}

/**
* Update filter
*
* @param {*} filter
*/
updateFilter(filter) {
this.setState({filter});
}

/**
* Reset filters
*/
resetFilters() {
this.publicationsFilter.clearFilter();
}

/**
* Renders the React component.
*
* @return {JSX} - React markup for the component
*/
render() {
const {t} = this.props;

if (!this.state.isLoaded) {
return (
<button className="btn-info has-spinner">
Loading
<span
className="glyphicon glyphicon-refresh glyphicon-refresh-animate">
</span>
{t('Loading', {ns: 'publication'})}
<span className="glyphicon glyphicon-refresh glyphicon-refresh-animate"></span>
</button>
);
}
let tabList = [
{
id: 'browse',
label: 'Browse',
},
];

let tabList = [{id: 'browse', label: t('Browse', {ns: 'publication'})}];
let proposalTab;

if (loris.userHasPermission('publication_propose')) {
tabList.push({
id: 'propose',
label: 'Propose a Project',
});
tabList.push({id: 'propose', label: t('Propose a Project', {ns: 'publication'})});

proposalTab = (
<TabPane TabId={tabList[1].id}>
<PublicationUploadForm
DataURL={loris.BaseURL
+'/publication/ajax/getData.php?action=getData'}
action={loris.BaseURL
+ '/publication/ajax/FileUpload.php?action=upload'}
DataURL={`${loris.BaseURL}/publication/ajax/getData.php?action=getData`}
action={`${loris.BaseURL}/publication/ajax/FileUpload.php?action=upload`}
editMode={false}
/>
</TabPane>
);
}

const filterRef = function(f) {
this.publicationsFilter = f;
}.bind(this);
const filterRef = (f) => (this.publicationsFilter = f);

const fields = [
{
label: t('Title', {ns: 'publication'}),
show: true,
filter: {name: 'Title', type: 'text'},
},
{
label: t('Lead Investigator', {ns: 'publication'}),
show: true,
filter: {name: 'leadInvestigator', type: 'text'},
},
{
label: t('Date Proposed', {ns: 'publication'}),
show: true,
filter: {hide: true},
},
{
label: t('Approval Status', {ns: 'publication'}),
show: true,
filter: {
name: 'approvalStatus',
type: 'select',
options: this.state.Data.form.approvalStatus.options,
},
},
{
label: t('Project', {ns: 'publication'}),
show: true,
filter: {
name: 'project',
type: 'select',
options: this.state.Data.form.project.options,
},
},
{
label: t('Journal', {ns: 'publication'}),
show: true,
filter: {name: 'journal', type: 'text'},
},
{
label: t('Link', {ns: 'publication'}),
show: true,
filter: {name: 'link', type: 'text'},
},
{
label: t('Publishing Status', {ns: 'publication'}),
show: true,
filter: {
name: 'publishingStatus',
type: 'select',
options: this.state.Data.form.publishingStatus.options,
},
},
{
label: t('Date Published', {ns: 'publication'}),
show: true,
filter: {name: 'datePublished', type: 'date', hide: true},
},
{
label: t('Project Proposal Creator', {ns: 'publication'}),
show: true,
filter: {name: 'projectProposalCreator', type: 'text'},
},
{
label: 'Description',
show: false,
filter: {name: 'description',hide: true},
},
{
label: t('Collaborators', {ns: 'publication'}),
show: true,
filter: {name: 'collaborators',hide: true},
},
{
label: t('Variables Of Interest', {ns: 'publication'}),
show: true,
filter: {name: 'variablesOfInterest', type: 'text'},
},
{
label: t('Keywords', {ns: 'publication'}),
show: true,
filter: {name: 'keywords', type: 'text'},
},
{
label: 'Publication ID',
show: false,
filter: {name: 'PublicationID', hide: true},
},
];

return (
<Tabs tabs={tabList} defaultTab="browse" updateURL={true}>
<TabPane TabId={tabList[0].id}>
<FilterForm
Module="publication"
name="publications_filter"
id="publications_filter_form"
<FilterableDataTable
ref={filterRef}
columns={3}
formElements={this.state.Data.form}
onUpdate={this.updateFilter}
filter={this.state.filter}
>
<br/>
<ButtonElement
label="Clear Filters"
type="reset"
onUserInput={this.resetFilters}
/>
</FilterForm>
<StaticDataTable
Data={this.state.Data.Data}
Headers={this.state.Data.Headers}
Filter={this.state.filter}
name="publication"
title={t('Publications', {ns: 'publication'})}
data={this.state.Data.Data}
fields={fields}
getFormattedCell={this.formatColumn}
/>
</TabPane>
Expand All @@ -154,51 +198,36 @@ class PublicationIndex extends React.Component {
);
}

/**
* Format column
*
* @param {string} column
* @param {*} cell
* @param {object} rowData
* @param {string[]} rowHeaders
* @return {JSX} - React markup for the component
*/
formatColumn(column, cell, rowData, rowHeaders) {
// If a column if set as hidden, don't display it
if (loris.hiddenHeaders.indexOf(column) > -1) {
return null;
}
// Create the mapping between rowHeaders and rowData in a row object.
let row = {};
rowHeaders.forEach(function(header, index) {
row[header] = rowData[index];
}, this);
let classes = [];
if (column === 'Title') {
let pubID = row['Publication ID'];
let viewURL = loris.BaseURL + '/publication/view_project?id=' + pubID;

// if (column === 'शीर्षक') {
if (rowHeaders[0] === column){
const pubID = rowData['Publication ID'];
const viewURL = `${loris.BaseURL}/publication/view_project?id=${pubID}`;
return (
<td>
<a href={viewURL}>
{cell}
</a>
<a href={viewURL}>{cell}</a>
</td>
);
}
return <td className={classes}>{cell}</td>;
return <td>{cell}</td>;
}
}
PublicationIndex.propTypes = {
DataURL: PropTypes.string,
};

document.addEventListener('DOMContentLoaded', () => {
createRoot(
document.getElementById('lorisworkspace')
).render(
window.addEventListener('load', () => {
i18n.addResourceBundle('hi', 'publication', hiStrings);

const PubIndex = withTranslation(['publication'])(PublicationIndex);

createRoot(document.getElementById('lorisworkspace')).render(
<div className="page-publications">
<PublicationIndex DataURL={`${loris.BaseURL}/publication/?format=json`}/>
<PubIndex DataURL={`${loris.BaseURL}/publication/?format=json`} />
</div>
);
});

Loading
Loading