Skip to content
Merged
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
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"morgan": "^1.9.1",
"mousetrap": "^1.6.1",
"node-cron": "^2.0.3",
"node-fetch": "^2.1.1",
"node-fetch": "^2.6.1",
"nodemailer": "^4.6.8",
"normalize.css": "^5.0.0",
"p-cancelable": "^0.5.1",
Expand Down Expand Up @@ -126,5 +126,5 @@
"engines": {
"node": ">=10.0.0"
},
"version": "0.10.0"
"version": "0.10.1"
}
15 changes: 10 additions & 5 deletions src/client/components/carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import h from 'react-hyperscript';
import { Component } from 'react';
import _ from 'lodash';
import { formatDistanceToNow } from 'date-fns';
import queryString from 'query-string';

export const CAROUSEL_CONTENT = {
FIGURE: 'figure',
Expand All @@ -21,9 +22,13 @@ export class Carousel extends Component {
content: props.content,
refresh: props.refresh || (() => { // get all docs from service by default
const url = `/api/document`;
const doFetch = () => fetch(url);
const params = queryString.stringify({
status: ['published', 'submitted'].join(','),
limit: 20
});
const doFetch = () => fetch(`${url}?${params}`);
const toJson = res => res.json();

return tryPromise(doFetch).then(toJson);
})
};
Expand Down Expand Up @@ -166,7 +171,7 @@ export class Carousel extends Component {
abstractDiv,
h('div.carousel-doc-footer', [
h('div.carousel-doc-text', doc.text),
h('div.carousel-doc-datestamp', formatDistanceToNow( new Date( doc.lastEditedDate ), { addSuffix: true } ))
h('div.carousel-doc-datestamp', formatDistanceToNow( new Date( doc.lastEditedDate || 0 ), { addSuffix: true } ))
]),
]),
figureDiv,
Expand All @@ -188,8 +193,8 @@ export class Carousel extends Component {
return placeholders;
};

const isPublished = doc => doc.status.toLowerCase() === 'published';
const docs = this.state.docs.filter(isPublished);
const docs = this.state.docs;


return h('div.carousel', {
className: makeClassList({
Expand Down
35 changes: 29 additions & 6 deletions src/client/components/element-info/entity-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const MAX_FIXED_SYNONYMS = 5;
const MAX_SYNONYMS_SHOWN = 10;

let associationCache = new WeakMap();
let chosenTypeCache = new WeakMap();
let nameNotificationCache = new SingleValueCache();
let assocNotificationCache = new SingleValueCache();

Expand All @@ -35,6 +36,8 @@ class EntityInfo extends DataComponent {

let assocNotification = initCache( assocNotificationCache, el, new Notification({ active: true }) );

let chosenType = initCache( chosenTypeCache, el, null );

this.debouncedUpdateMatches = _.debounce( (name, postStep = _.nop) => {
this.updateMatches(name).then(postStep);
}, defs.updateDelay );
Expand All @@ -53,6 +56,7 @@ class EntityInfo extends DataComponent {
this.data = {
element: el,
name: el.name(),
chosenType,
oldName: el.name(),
matches: assoc.matches,
gettingMoreMatches: false,
Expand Down Expand Up @@ -131,6 +135,14 @@ class EntityInfo extends DataComponent {
let s = this.data;
let el = s.element;

if( s.chosenType && match.type !== 'chemical' ){
match = Object.assign({}, match, {
type: s.chosenType
});

delete match.typeOfGene; // n.b. the model overrides via this field
}

el.associate( match );
el.complete();

Expand Down Expand Up @@ -398,11 +410,15 @@ class EntityInfo extends DataComponent {
name: 'entity-info-subtype-radio',
id: `entity-info-subtype-radio-${typeVal}`,
value: typeVal,
defaultChecked: typeVal === m.type,
checked: typeVal === m.type,
onChange: e => {
let newlySelectedType = e.target.value;
let newMatch = Object.assign({}, m, { type: newlySelectedType });

this.setData({ chosenType: newlySelectedType });

chosenTypeCache.set(s.element, newlySelectedType);

this.associate(newMatch);
}
}),
Expand Down Expand Up @@ -434,8 +450,6 @@ class EntityInfo extends DataComponent {
let isOrgMatch = m => isPerfectNameMatch(m) && !isChemicalMatch(m);
let orgMatches = s.matches.filter(isOrgMatch);
let orgToMatches = new Map();
const selectedIndex = _.findIndex(orgMatches, match => match.id === m.id && match.namespace === m.namespace);
const selectedOrg = assoc ? assoc.organism : null;

orgMatches.forEach(om => {
let org = om.organism;
Expand All @@ -451,6 +465,11 @@ class EntityInfo extends DataComponent {
arr.push(om);
});

orgMatches = _.sortBy(orgMatches, m => m.organismName);

const selectedIndex = _.findIndex(orgMatches, match => match.id === m.id && match.namespace === m.namespace);
const selectedOrg = assoc ? assoc.organism : null;

const getSelectDisplay = (om, includeName = false) => {
// const matches = orgToMatches.get(om.organism) || [];
// let count = matches.length;
Expand All @@ -463,7 +482,9 @@ class EntityInfo extends DataComponent {
};

const getDisamtDisplay = (om) => {
return `${om.name} : ` + om.synonyms.slice(0, 3).join(', ');
const sortedSyns = _.sortBy(om.synonyms, syn => stringDistanceMetric(syn, s.name));

return `${om.name} : ` + sortedSyns.slice(0, 3).join(', ');
};

organism = h('div.entity-info-section.entity-info-organism-refinement', [
Expand Down Expand Up @@ -503,14 +524,16 @@ class EntityInfo extends DataComponent {
const needDisam = ambigGrs && ambigGrs.length > 1;

if( needDisam ){
const selectedAmIndex = _.findIndex(ambigGrs, match => match.id === m.id && match.namespace === m.namespace);

disambiguation = h('div.entity-info-section.entity-info-organism-refinement', [
h('span.entity-info-title', 'Which' + (s.name ? ` ${s.name}` : '') + ''),
h('select.entity-info-organism-dropdown', {
defaultValue: selectedIndex,
defaultValue: selectedAmIndex,
onChange: e => {
const val = e.target.value;
const index = parseInt(val);
const om = orgMatches[index];
const om = ambigGrs[index];

if( om ){
this.associate(om);
Expand Down
Loading