-
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.
- Loading branch information
1 parent
824be68
commit 8cd165b
Showing
1 changed file
with
31 additions
and
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,44 @@ | ||
const colField = document.querySelector('.inputCol'); | ||
const input = document.querySelector('.inputarea'); | ||
const btn = document.querySelector('button'); | ||
const checkbox = document.querySelector('.filterCheckbox'); | ||
const output = document.querySelector('.outputarea'); | ||
|
||
input.addEventListener("input",generateFetch); | ||
checkbox.addEventListener("click",generateFetch); | ||
|
||
function generateFetchXML() { | ||
|
||
const colField = document.querySelector('.inputCol'); | ||
const input = document.querySelector('.inputarea'); | ||
const btn = document.querySelector('button'); | ||
const checkbox = document.querySelector('.filterCheckbox'); | ||
const output = document.querySelector('.outputarea'); | ||
|
||
function generateFetch(filterOption) { | ||
//set focus on column field | ||
colField.focus() | ||
//colField.focus() | ||
|
||
const attribute = colField.value.trim(); | ||
const entryString = input.value; | ||
|
||
btn.onclick = () => { | ||
const attribute = colField.value.trim(); | ||
const entryString = input.value; | ||
let arr = entryString.split(/\r?\n/); | ||
arr = arr.map((x) => x.trim()); | ||
arr = arr.filter((x) => x.length > 0); | ||
|
||
let arr = entryString.split(/\r?\n/); | ||
arr = arr.map((x) => x.trim()); | ||
arr = arr.filter((x) => x.length > 0); | ||
const outputArr = []; | ||
|
||
const outputArr = []; | ||
for (const name of arr) { | ||
|
||
for (const name of arr) { | ||
let converted = ` <value>${name}</value>`; | ||
outputArr.push(converted); | ||
}; | ||
|
||
let converted = ` <value>${name}</value>`; | ||
outputArr.push(converted); | ||
}; | ||
//add condition filter | ||
|
||
//add condition filter | ||
|
||
outputArr.unshift(`<condition attribute="${attribute}" operator="in">`); | ||
outputArr.push('</condition>') | ||
outputArr.unshift(`<condition attribute="${attribute}" operator="in">`); | ||
outputArr.push('</condition>'); | ||
|
||
//add filter tags before and after | ||
if (checkbox.checked) { | ||
//add filter tags before and after | ||
if (checkbox.checked) { | ||
outputArr.unshift('<filter type="or">'); | ||
outputArr.push('</filter>') | ||
}; | ||
const outputString = outputArr.join('\n'); | ||
outputArr.push('</filter>'); | ||
}; | ||
|
||
const outputString = outputArr.join('\n'); | ||
|
||
output.value = outputString; | ||
output.value = outputString; | ||
|
||
} | ||
} | ||
} |