-
Couldn't load subscription status.
- Fork 17
Functional Invalid Token Checking Enrichment #813 , #815 #839
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Functional Invalid Token Checking Enrichment #813 , #815 #839
Conversation
…iv - div expands with text, marks invalid tokens with red and underline
…iv - div expands with text, marks invalid tokens with red and underline
…s, improved readability
…n/app-ui into inputErrorCheck
Is there a textarea in the div, or are you using contenteditable? It might be simpler to use a textarea at this point. |
|
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'); | |||
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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) => { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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', [ |
There was a problem hiding this comment.
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.
…or token-input.js
…l data, improve conciseness in code
| query: '', | ||
| titleContainer: [] | ||
| titleContainer: [], | ||
| invalidTokenContainer: [], |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
|
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. |
There was a problem hiding this 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',[ |
There was a problem hiding this comment.
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"), |
There was a problem hiding this comment.
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){ |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
…no need to pass up unrecognized)
…t' entire input will be validated
| retrieveValidationAPIResult(){ | ||
| //reset state values | ||
| this.state.unrecognizedTokens = []; | ||
| this.state.validTokens = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do not modify state directly (https://reactjs.org/docs/state-and-lifecycle.html#do-not-modify-state-directly)
| //store validation data on state as arrays [validTokens] and [unrecognizedTokens] | ||
| //lift [validTokens] to parent file index.js | ||
| interpretValidationResult(tokenList, unrecognizedTokens){ | ||
| tokenList.forEach((element) => { |
There was a problem hiding this comment.
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.
Addresses #813, and is a MVP for #815.
NOTE: code will only run if ComponentDidMount() is commented out in base-network-view.js since the network has not been set up yet