Skip to content

Commit

Permalink
Merge pull request #2692 from Smidy13/develop
Browse files Browse the repository at this point in the history
Improvement: Adding List Selector for Missing Projects
  • Loading branch information
Luis-Fernando-Molina authored Nov 22, 2021
2 parents 7112487 + af79109 commit 0359638
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 2 deletions.
10 changes: 9 additions & 1 deletion Projects/Foundations/Schemas/App-Schema/workspace.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@
"actionFunction": "payload.executeAction",
"relatedUiObjectProject": "Foundations"
},
{
"action": "Add Specified Workspace Project",
"label": "Add Specified Workspace Project",
"relatedUiObject": "Workspace",
"actionFunction": "payload.executeAction",
"relatedUiObjectProject": "Foundations"
},
{
"action": "Check For Missing References",
"label": "Check For Missing References",
Expand All @@ -58,7 +65,8 @@
"config": "{\"docsLanguage\": \"EN\"}"
},
"editors": {
"config": true
"config": true,
"list": true
},
"isTitleAllwaysVisible": true,
"addLeftIcons": false,
Expand Down
5 changes: 5 additions & 0 deletions Projects/Foundations/UI/Function-Libraries/ActionSwitch.js
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,11 @@ function newFoundationsActionSwitch() {
UI.projects.foundations.functionLibraries.workspaceFunctions.addMissingWorkspaceProjects(action.node, action.rootNodes)
}
break
case 'Add Specified Workspace Project':
{
UI.projects.foundations.functionLibraries.workspaceFunctions.addSpecifiedWorkspaceProject(action.node, action.rootNodes)
}
break
case 'Check For Missing References':
{
UI.projects.foundations.functionLibraries.workspaceFunctions.checkForMissingReferences(action.rootNodes)
Expand Down
37 changes: 37 additions & 0 deletions Projects/Foundations/UI/Function-Libraries/WorkspaceFunctions.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
function newFoundationsFunctionLibraryWorkspaceFunctions() {
let thisObject = {
addMissingWorkspaceProjects: addMissingWorkspaceProjects,
addSpecifiedWorkspaceProject: addSpecifiedWorkspaceProject,
checkForMissingReferences: checkForMissingReferences,
fixMissingReferences: fixMissingReferences
}
Expand Down Expand Up @@ -32,6 +33,42 @@ function newFoundationsFunctionLibraryWorkspaceFunctions() {
}
}

function addSpecifiedWorkspaceProject(node, rootNodes) {
let action = { node: node }
let validProjects = PROJECTS_SCHEMA

// Find the Projects not already part of the Workspace
for (let i = 0; i < PROJECTS_SCHEMA.length; i++) {
let projectDefinition = PROJECTS_SCHEMA[i]
let project = projectDefinition.name

for (let k = 0; k < rootNodes.length; k++) {
let rootNode = rootNodes[k]
if (rootNode.type === project + ' Project') {
validProjects = validProjects.filter(function(val) {
return val.name + ' Project' !== rootNode.type
})
}
}
}

// Create the Projects as an Array
let projectList = []

for (let i = 0; i < validProjects.length; i++) {
projectList.push(validProjects[i].name)
}

let eventSubscriptionId = node.payload.uiObject.container.eventHandler.listenToEvent('listSelectorClicked', onListSelect)
node.payload.uiObject.listSelector.activate(action, projectList, eventSubscriptionId)

function onListSelect(event) {
UI.projects.visualScripting.functionLibraries.uiObjectsFromNodes.addUIObject(node, event.selectedNode + ' Project', rootNodes, event.selectedNode)
node.payload.uiObject.container.eventHandler.stopListening('listSelectorClicked')
}

}

// This function scales the current workspace and highlights any nodes that have unresolved references
function checkForMissingReferences(rootNodes) {
let nodes
Expand Down
20 changes: 19 additions & 1 deletion Projects/Foundations/UI/Spaces/Floating-Space/ListSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,21 @@ function newListSelector() {

let index = i + selected
let label = ''
let subLabel = ''
if (index >= 0 && index < optionsList.length) {
if (typeof(optionsList[index]) !== "string") {

let path = UI.projects.visualScripting.utilities.hierarchy.getNodeNameTypePath(optionsList[index].payload.parentNode)

for (let i = 0; i < path.length; i++) {
path[i].splice(1, 3)
}

label = optionsList[index].name
subLabel = path.join("->")

if (label.length > 65) { label = label.substring(0,65) + " (cont...)" }
if (subLabel.length > 65) { subLabel = subLabel.substring(0,65) + " (cont...)" }

if (optionsList[index].payload.uiObject.icon !== undefined) {
icon = optionsList[index].payload.uiObject.icon
Expand Down Expand Up @@ -333,13 +345,19 @@ function newListSelector() {

let middleValue = Math.floor(VISIBLE_LABELS / 2)
let evenOffset = 0
let subOffset = 0

if (VISIBLE_LABELS % 2 === 0) {
evenOffset = rowHeight / 2
}

if (subLabel !== '') {
subOffset = 10
}

UI.projects.foundations.utilities.drawPrint.drawIcon(icon, 1 / 2, 1 / 2, - offset + SIZE, (i - middleValue) * rowHeight + evenOffset, SIZE, thisObject.container)
UI.projects.foundations.utilities.drawPrint.drawLabel(label, 1 / 2, 1 / 2, 0, (SIZE - fontSize) / 2 + (i - middleValue) * rowHeight + evenOffset, fontSize, thisObject.container, fontColor, undefined, undefined, opacity)
UI.projects.foundations.utilities.drawPrint.drawLabel(label, 1 / 2, 1 / 2, 0, (SIZE - fontSize) / 2 + (i - middleValue) * rowHeight + evenOffset - subOffset, fontSize, thisObject.container, fontColor, undefined, undefined, opacity)
UI.projects.foundations.utilities.drawPrint.drawLabel(subLabel, 1 / 2, 1 / 2, 0, (SIZE - fontSize) / 2 + (i - middleValue) * rowHeight + evenOffset + subOffset, fontSize / 2, thisObject.container, fontColor, undefined, undefined, opacity)
}
}
}
Expand Down

0 comments on commit 0359638

Please sign in to comment.