-
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.
Merge pull request #388 from ProteinsWebTeam/shortname_set
Shortname set
- Loading branch information
Showing
12 changed files
with
594 additions
and
328 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
Large diffs are not rendered by default.
Oops, something went wrong.
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,93 @@ | ||
// @flow | ||
import React from 'react'; | ||
import T from 'prop-types'; | ||
|
||
import { connect } from 'react-redux'; | ||
import { createSelector } from 'reselect'; | ||
|
||
import { changeSettingsRaw } from 'actions/creators'; | ||
|
||
import { foundationPartial } from 'styles/foundation'; | ||
|
||
import protvistaCSS from '../style.css'; | ||
|
||
const f = foundationPartial(protvistaCSS); | ||
|
||
const LabelBy = ( | ||
{ labelContent, changeSettingsRaw } /*: { | ||
labelContent: { | ||
accession: boolean, | ||
name: boolean, | ||
short: boolean, | ||
}, | ||
changeSettingsRaw:function } */, | ||
) => { | ||
const updateLabel = (evt) => { | ||
const opt = evt.target.value; | ||
const next = { | ||
...labelContent, | ||
[opt]: !labelContent[opt], | ||
}; | ||
if (!next.accession && !next.name && !next.short) { | ||
next.accession = true; | ||
} | ||
changeSettingsRaw('ui', 'labelContent', next); | ||
}; | ||
return ( | ||
<li> | ||
Label by | ||
<ul className={f('nested-list')}> | ||
<li key={'accession'}> | ||
<label> | ||
<input | ||
type="checkbox" | ||
onChange={updateLabel} | ||
value={'accession'} | ||
checked={labelContent.accession} | ||
/>{' '} | ||
Accession | ||
</label> | ||
</li> | ||
<li key={'name'}> | ||
<label> | ||
<input | ||
type="checkbox" | ||
onChange={updateLabel} | ||
value={'name'} | ||
checked={labelContent.name} | ||
/>{' '} | ||
Name | ||
</label> | ||
</li> | ||
<li key={'shortname'}> | ||
<label> | ||
<input | ||
type="checkbox" | ||
onChange={updateLabel} | ||
value={'short'} | ||
checked={labelContent.short} | ||
/>{' '} | ||
Short Name | ||
</label> | ||
</li> | ||
</ul> | ||
</li> | ||
); | ||
}; | ||
LabelBy.propTypes = { | ||
labelContent: T.shape({ | ||
accession: T.bool, | ||
name: T.bool, | ||
short: T.bool, | ||
}), | ||
changeSettingsRaw: T.func, | ||
}; | ||
|
||
const mapStateToProps = createSelector( | ||
(state) => state.settings.ui, | ||
(ui) => ({ | ||
labelContent: ui.labelContent, | ||
}), | ||
); | ||
|
||
export default connect(mapStateToProps, { changeSettingsRaw })(LabelBy); |
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
Oops, something went wrong.