Skip to content

Commit

Permalink
LEAF 3428 add initial connection methods
Browse files Browse the repository at this point in the history
  • Loading branch information
aerinkayne committed Jan 10, 2024
1 parent e2af992 commit 6147e5b
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 12 deletions.
5 changes: 2 additions & 3 deletions LEAF_Request_Portal/admin/templates/mod_form.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -1377,10 +1377,9 @@ function getForm(indicatorID, series) {
type: 'GET',
url: '../api/form/_' + currCategoryID + '/flat',
success: function(res) {
const shortName = (name = "") => {
const maxLen = 65;
const shortName = (name = "", len = 50) => {
const displayName = XSSHelpers.stripAllTags(name || "").trim();
return displayName.length <= maxLen ? displayName : displayName.slice(0, maxLen) + '...';
return displayName.length <= len ? displayName : displayName.slice(0, len) + '...';
}
let buffer = '<select id="parentID" style="width:300px;">';
buffer += '<option value="">None</option>';
Expand Down
66 changes: 57 additions & 9 deletions LEAF_Request_Portal/admin/templates/mod_workflow.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -1354,6 +1354,7 @@
dialog.indicateIdle();
dialog.setContent(buffer);
$('#xhrDialog').css('overflow', 'visible');
$('#actionType').chosen({disable_search_threshold: 5});
// TODO: Figure out why this triggers even when the user clicks save
/*
Expand Down Expand Up @@ -1643,6 +1644,10 @@
cache: false
})
.then(function(indicatorList) {
const shortName = (name = "", len = 50) => {
name = XSSHelpers.stripAllTags(name || "").trim();
return name.length <= len ? name : name.slice(0, len) + '...';
}
var stapledInternalIndicators;
for (let i in associatedCategories) {
for (let j in indicatorList) {
Expand All @@ -1652,7 +1657,7 @@
indicatorList[j].parentIndicatorID == null) {
$('#workflowIndicator_' + stepID).append('<option value="' + indicatorList[
j].indicatorID + '">' + indicatorList[j].categoryName + ': ' +
indicatorList[j].name + ' (id: ' + indicatorList[j].indicatorID +
shortName(indicatorList[j].name) + ' (id: ' + indicatorList[j].indicatorID +
')</option>');
} else if (indicatorList[j].parentStaples != null) {
for (let k in indicatorList[j].parentStaples) {
Expand Down Expand Up @@ -1699,6 +1704,19 @@
});
}
function addConnection(fromStepID = null, toStepID = null) {
if(Number.isInteger(parseInt(fromStepID)) && Number.isInteger(parseInt(toStepID))) {
console.log(fromStepID, toStepID)
const jsPlumbParams = {
sourceId: `step_${fromStepID}`,
targetId: `step_${toStepID}`,
}
createAction(jsPlumbParams);
} else {
console.log('unexpected arguments')
}
}
function showStepInfo(stepID) {
$('#stepInfo_' + stepID).html('');
if ($('#stepInfo_' + stepID).css('display') != 'none') { // hide info window on second click
Expand Down Expand Up @@ -1803,11 +1821,31 @@
}
output += '</ul><div>';
// TODO: This will eventually be moved to some sort of Workflow extension plugin
output += '<fieldset><legend>Options</legend><ul>';
output += '<li><label for="workflowIndicator_' + stepID + '" style="font-family: Source Sans Pro Web">Form Field:</label> <select id="workflowIndicator_' + stepID +
'" style="width: 240px"><option value="">None</option></select></li>';
output += '</ul></fieldset>';
const stepKeys = Object.keys(steps);
let step_options = ""
stepKeys.forEach(k => {
step_options += `<option value="${k}">${steps[k].stepTitle}(id#${k})</option>`;
});
output += `<fieldset>
<legend>Options</legend>
<div style="display:flex;flex-direction:column;gap:0.5rem;">
<div>
<label for="workflowIndicator_${stepID}" style="font-family: Source Sans Pro Web;display:block;">Form Field:</label>
<select id="workflowIndicator_${stepID}" style="width:250px;">
<option value="">None</option>
</select>
</div>
<div>
<label for="create_route" style="font-family: Source Sans Pro Web;display:block;">New Connection:</label>
<select id="create_route" style="width:250px;" onchange="addConnection(${stepID}, this.value)">
<option value="">Choose a Step</option>
<option value="-1">Requestor</option>
<option value="0">End</option>
${step_options}
</select>
<div>
</div>
</fieldset>`;
// button options for steps
output += '<hr />';
Expand Down Expand Up @@ -1873,11 +1911,11 @@
}
position = $('#step_' + stepID).offset();
width = $('#step_' + stepID).width();
height = $('#step_' + stepID).height();
$('#stepInfo_' + stepID).css({
left: position.left + width + 'px',
top: position.top + 'px'
left: position.left + 'px',
top: position.top + height + 20 + 'px'
});
$('#stepInfo_' + stepID).show('slide', null, 200);
}
Expand Down Expand Up @@ -2207,6 +2245,16 @@
});
$('#workflow_steps_chosen input.chosen-search-input').attr('role', 'combobox');
$('#workflow_steps_chosen input.chosen-search-input').attr('aria-labelledby', 'steps_label');
$('#workflow_steps').on('change', function() {
showStepInfo($('#workflow_steps').val());
});
$('#workflow_steps + .chosen-container').on('keydown', function(event) {
const code = (event?.code || "").toLowerCase()
if (code === 'space') {
event.preventDefault();
showStepInfo($('#workflow_steps').val());
}
});
}
function viewHistory() {
Expand Down

0 comments on commit 6147e5b

Please sign in to comment.