diff options
author | Erlend <erlendniko@hotmail.com> | 2022-07-01 16:07:32 +0200 |
---|---|---|
committer | Erlend <erlendniko@hotmail.com> | 2022-07-01 16:07:32 +0200 |
commit | 19cd92e1ea8e186c0d518f5cc00ce43a7880aff4 (patch) | |
tree | d862c7f13eff51d57d8605a775e0d4901a6d6a65 /client | |
parent | 39a38ad6c803e06f8b86b1ccd3c3ae8199989543 (diff) |
Added some comments
Diffstat (limited to 'client')
3 files changed, 12 insertions, 6 deletions
diff --git a/client/js/app/src/app/pages/querybuilder/Components/Buttons/CopyResponseButton.jsx b/client/js/app/src/app/pages/querybuilder/Components/Buttons/CopyResponseButton.jsx index 65665d4419a..de0079a21f9 100644 --- a/client/js/app/src/app/pages/querybuilder/Components/Buttons/CopyResponseButton.jsx +++ b/client/js/app/src/app/pages/querybuilder/Components/Buttons/CopyResponseButton.jsx @@ -19,8 +19,6 @@ export default function CopyResponseButton() { width="30" tooltip="Copy" onClick={handleCopy} - > - Copy - </OverlayImageButton> + /> ); } diff --git a/client/js/app/src/app/pages/querybuilder/Components/Buttons/PasteJSONButton.jsx b/client/js/app/src/app/pages/querybuilder/Components/Buttons/PasteJSONButton.jsx index 8260e0442db..73b68b707fb 100644 --- a/client/js/app/src/app/pages/querybuilder/Components/Buttons/PasteJSONButton.jsx +++ b/client/js/app/src/app/pages/querybuilder/Components/Buttons/PasteJSONButton.jsx @@ -10,7 +10,7 @@ export default function PasteJSONButton() { //TODO: fix that the second-level dropdowns do not get set properly when pasting a JSON query - const handleClick = (e) => { + const handleClick = () => { //alert('Button is non-functional'); setPaste(true); window.addEventListener('paste', handlePaste); @@ -18,6 +18,9 @@ export default function PasteJSONButton() { const handlePaste = (e) => { setPaste(false); + // Stop data actually being pasted into div + e.stopPropagation(); + e.preventDefault(); const pastedData = e.clipboardData.getData('text'); alert('Converting JSON: \n\n ' + pastedData); window.removeEventListener('paste', handlePaste); @@ -27,7 +30,7 @@ export default function PasteJSONButton() { const convertPastedJSON = (pastedData) => { try { var json = JSON.parse(pastedData); - const newInputs = buildFromJSON(json, 3); + const newInputs = buildFromJSON(json, 2); setInputs(newInputs); } catch (error) { console.log(error); @@ -41,14 +44,17 @@ export default function PasteJSONButton() { for (let i = 0; i < keys.length; i++) { let childId = 1; let newInput = { id: `${id}`, type: keys[i] }; + //If the value for the key is a child object if (typeof json[keys[i]] === 'object') { newInput['typeof'] = 'Parent'; newInput['input'] = ''; newInput['hasChildren'] = true; + // Construct the id of the correct pattern let tempId = id + '.' + childId; childId += 1; let type; if (id.length > 1) { + //Used to get the correct value from childMap type = parentTypeof + '_' + keys[i]; } else { type = keys[i]; @@ -78,7 +84,7 @@ export default function PasteJSONButton() { id="pasteJSON" className="pasteJSON" image={pasteImage} - style={{ marginTop: '-2px', marginRight: '3px' }} + //style={{ marginTop: '-2px', marginRight: '3px' }} onClick={handleClick} > {paste ? 'Press CMD + V' : 'Paste JSON'} diff --git a/client/js/app/src/app/pages/querybuilder/Components/Text/QueryDropDownForm.jsx b/client/js/app/src/app/pages/querybuilder/Components/Text/QueryDropDownForm.jsx index 00294037bc1..d2de94b2e28 100644 --- a/client/js/app/src/app/pages/querybuilder/Components/Text/QueryDropDownForm.jsx +++ b/client/js/app/src/app/pages/querybuilder/Components/Text/QueryDropDownForm.jsx @@ -33,6 +33,8 @@ export default function QueryDropdownForm({ let parentTypes = newInputs[index].type; let children = newInputs[index].children; let childChoices = childMap[parentTypes]; + //TODO: try to rafactor this loop into a separate function that can be + //used everywhere in the code similar loops are used for (let i = 3; i < id.length; i += 2) { currentId = id.substring(0, i); index = children.findIndex((element) => element.id === currentId); |