Skip to content

Commit

Permalink
feat(bindgen): output file demo support
Browse files Browse the repository at this point in the history
  • Loading branch information
thewtex committed Sep 23, 2023
1 parent a7594b7 commit 3d4eb6c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/bindgen/typescript/demo/input-parameters-demo-html.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ function inputParametersDemoHtml (functionName, prefix, indent, parameter, requi
}
break
case 'TEXT':
case 'OUTPUT_TEXT_FILE':
case 'OUTPUT_BINARY_FILE':
result += `${prefix}${indent}<sl-input ${requiredAttr}name="${parameter.name}" type="text" label="${label}" help-text="${description}"></sl-input>\n`
break
case 'INT':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,16 @@ function inputParametersDemoTypeScript(functionName, indent, parameter, required
result += `${indent}})\n\n`
break
case 'TEXT':
case 'OUTPUT_TEXT_FILE':
case 'OUTPUT_BINARY_FILE':
result += `${indent}const ${inputIdentifier} = document.querySelector('#${functionName}Inputs sl-input[name=${parameter.name}]')\n`
result += `${indent}${inputIdentifier}.addEventListener('sl-change', (event) => {\n`
result += `${indent}${indent}model.${modelProperty}.set("${parameterName}", ${inputIdentifier}.value)\n`
if (parameter.itemsExpectedMax > 1) {
result += `${indent}${indent}const values = ${inputIdentifier}.value.split(',').map(s => s.trim())\n`
result += `${indent}${indent}model.${modelProperty}.set("${parameterName}", values)\n`
} else {
result += `${indent}${indent}model.${modelProperty}.set("${parameterName}", ${inputIdentifier}.value)\n`
}
result += `${indent}})\n\n`
break
case 'BOOL':
Expand Down
5 changes: 5 additions & 0 deletions src/bindgen/typescript/demo/interface-functions-demo-html.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ function interfaceFunctionsDemoHtml(interfaceJson, functionName, useCamelCase) {
result += inputParametersDemoHtml(functionName, prefix, indent, parameter, false, useCamelCase)
})
}
interfaceJson.outputs.forEach((output) => {
if (output.type.includes('FILE')) {
result += inputParametersDemoHtml(functionName, prefix, indent, output, true, useCamelCase)
}
})

result += `${prefix}<sl-divider></sl-divider>\n`
const loadSampleInputsId = useCamelCase ? 'loadSampleInputs' : 'load-sample-inputs'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ class ${functionNamePascalCase}Model {
})
}

interfaceJson.outputs.forEach((output) => {
if (output.type.includes('FILE')) {
result += inputParametersDemoTypeScript(functionName, indent, output, true, 'options')
}
})

result += `${indent}// ----------------------------------------------\n${indent}// Outputs`
interfaceJson.outputs.forEach((output) => {
result += outputDemoTypeScript(functionName, '', indent, output)
Expand Down

0 comments on commit 3d4eb6c

Please sign in to comment.