Skip to content

Instantly share code, notes, and snippets.

@izgeri
Last active September 28, 2022 18:52
Show Gist options
  • Save izgeri/8941879ff203fef2647da70da2b81761 to your computer and use it in GitHub Desktop.
Save izgeri/8941879ff203fef2647da70da2b81761 to your computer and use it in GitHub Desktop.
function build_task() {
return {
name,
assignee_id: `${assignee_id}`,
assignee_type: `${assignee_type}`,
view_config: {
active: active_view
},
status_callbacks: {
before_completed
}
}
}
function name() {
return `Select for ${context.entity.external_id}`;
}
function before_completed() {
return [
{
operation: 'execute_js_template',
params: {
template: 'context.aiData[task_data.my_selection].desc'
},
context_key: 'description'
}
]
}
function build_data_set() {
let dataSet = [];
context.aiData.forEach((data) => {
dataSet.push({
"$html_sandbox": {},
"content": "<div style='position: relative; margin-left: 1em; margin-bottom: 0.5em; margin-top: 0.5em; display: block; width: 70em; border: 2px solid #999; padding: 1.25em 1em 0; border-radius: 0.5em; box-shadow: 0px 1px 5px rgba(25,52,60, 0.4);'><h3 style='position: absolute; top: -0.65em; left: 0.5em;'>" + data.name + "</h3><p>" + data.desc + "</p><div>"
});
});
return dataSet;
}
function active_view() {
const dataSet = build_data_set();
return {
ui: {
"$vbox": [
{
"$header": "Generated Description(s)",
"level": 2
},
...dataSet,
{
"$static_selector": {
"$bind": "task_data.my_selection"
},
"items": context.aiData,
"placeholder": "Choose a description to continue"
}
]
},
full_screen: true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment