Skip to content

Conversation

@CaitlinOCallaghan
Copy link
Collaborator

@CaitlinOCallaghan CaitlinOCallaghan commented Jun 20, 2018

Addresses #813, and is a MVP for #815.

  • Token input methods are located in file token-input.js
  • Tokens are submitted through a div --> this will be iterated upon and improved in the future (use of an external library like slate)
  • Tokens are stored on state in the form of a map where keys are token names and values (true or false) correspond to token validity
  • Input alterations are allowed and only new tokens are sent for validation
  • Invalid tokens are currently displayed in a div that updates as invalid tokens are removed from the list --> the mechanism for user feedback will be iterated upon and improved in the future, tied to input box changes

NOTE: code will only run if ComponentDidMount() is commented out in base-network-view.js since the network has not been set up yet

…iv - div expands with text, marks invalid tokens with red and underline
…iv - div expands with text, marks invalid tokens with red and underline
@maxkfranz
Copy link
Member

Tokens are submitted through a div

Is there a textarea in the div, or are you using contenteditable? It might be simpler to use a textarea at this point.

@CaitlinOCallaghan
Copy link
Collaborator Author

I'm currently using contenteditable, but I can look to change it to a textarea (I agree, textarea will probably be simpler).

@@ -0,0 +1,75 @@
//const React = require('react');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if you turned this into it's own React component, complete with all of its own display and logic, this would be much more logical/readable.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To clarify, I was referring to an 'gene input' component.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this should be using a React component with a render() function.

//seperate div text input into an array, remove all elements that have already been validated
//this method will be altered later depending on the type/format of the final input box (slate or some other library)
parseTokenList() {
this.state.query = document.getElementById('gene-input-box').innerText;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't be reading from the DOM. Use a listener in render()


//call validation service API to retrieve unrecognized tokens as an array
retrieveValidationAPIResult(tokensToValidate){
ServerAPI.enrichmentAPI({genes: _.pull(tokensToValidate,"")}, "validation").then((result) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Promises are not returned and so can't be chained

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the ServerAPI.enrichmentAPI calls upon the validation index.js which then returns a promise

h('img', {
src: '/img/humanIcon.png'
}),
h('div.gene-input-container', [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything above the gene-input-container should go in parent. Everything below can stay.

query: '',
titleContainer: []
titleContainer: [],
invalidTokenContainer: [],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Purpose of invalidTokenContainer and similar array inside of the render function?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was initially used to hide the toolbar and replace that section with a feedback box. In the latest commit, I changed the structure to be more logical and to make it easier to open and close both the toolbar and feedback box.

@CaitlinOCallaghan
Copy link
Collaborator Author

Currently, the input component is in a separate file than the main index.js . I have an alternative version saved on my desktop that has everything in the index file, if that would be preferable, but it's about 175 lines long. In both versions, there aren't any console warnings or errors.

Copy link
Member

@jvwong jvwong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my view, we could keep retrieveValidationAPIResult and remove the others and it would read a lot easier.

onClick: () => {this.parseTokenList();} },
[h('button.submit', 'Submit')]
),
h('div.invalid-token-container',[
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • maybe use the term 'unrecognized' rather than 'invalid'. Same goes for what the UI displays.

h('div.invalid-token-container',[
h(Textarea, {
className:'invalid-tokens-feedback',
value: "InvalidTokens: \n" + this.state.invalidTokens.join("\n"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest to use value "Unrecognized: \n" + ...


//call validation service API to retrieve validation result in the form of []
//****** NOTE: currently only checking for unrecognized tokens, not duplicates
retrieveValidationAPIResult(tokensToValidate){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Keep this function, and remove all the others.

Copy link
Collaborator Author

@CaitlinOCallaghan CaitlinOCallaghan Jun 29, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. Since each submission will validate every token, regardless if it was already validated, I scraped the token map for now. Once we have a method for visually altering unrecognized input content (underline or change font), a map will be needed, but for now I think arrays that track the recognized and unrecognized tokens fulfill our current needs.

retrieveValidationAPIResult(){
//reset state values
this.state.unrecognizedTokens = [];
this.state.validTokens = [];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

//store validation data on state as arrays [validTokens] and [unrecognizedTokens]
//lift [validTokens] to parent file index.js
interpretValidationResult(tokenList, unrecognizedTokens){
tokenList.forEach((element) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is all of this necessary?
You already have 1. unrecognized 2. recognized tokens. Also I believe you're attempting to set state on each iteration of the loop which is probably slow.

@jvwong jvwong merged commit 3467111 into PathwayCommons:development Jul 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants