diff --git a/Projects/Foundations/UI/Spaces/Design-Space/Workspace.js b/Projects/Foundations/UI/Spaces/Design-Space/Workspace.js index 2905940b6..ccde486e1 100644 --- a/Projects/Foundations/UI/Spaces/Design-Space/Workspace.js +++ b/Projects/Foundations/UI/Spaces/Design-Space/Workspace.js @@ -413,6 +413,8 @@ function newWorkspace() { UI.projects.foundations.spaces.floatingSpace.inMapMode = false thisObject.isInitialized = true + UI.projects.governance.spaces.reportsSpace.reset() + await UI.projects.education.spaces.docsSpace.reset() await UI.projects.education.spaces.tutorialSpace.reset() diff --git a/Projects/Foundations/UI/Spaces/Side-Space/SidePanelTab.js b/Projects/Foundations/UI/Spaces/Side-Space/SidePanelTab.js index bee2650a1..0fe13a547 100644 --- a/Projects/Foundations/UI/Spaces/Side-Space/SidePanelTab.js +++ b/Projects/Foundations/UI/Spaces/Side-Space/SidePanelTab.js @@ -15,7 +15,8 @@ function newSidePanelTab() { physics: physics, draw: draw, getContainer: getContainer, - initialize: initialize + initialize: initialize, + finalize: finalize } const TAB_WIDTH = 60 @@ -26,6 +27,7 @@ function newSidePanelTab() { let animation = 'none' let ORIGINAL_PARENT_POSITON let xOffset = 0 + let onMouseClickEventSubscriptionId thisObject.container = newContainer() thisObject.container.name = MODULE_NAME @@ -35,6 +37,11 @@ function newSidePanelTab() { return thisObject + function finalize() { + thisObject.pointerDirection = undefined + thisObject.container.eventHandler.stopListening(onMouseClickEventSubscriptionId) + } + function initialize(screenside, index) { thisObject.screenside = screenside if (index !== undefined) { @@ -54,7 +61,7 @@ function newSidePanelTab() { thisObject.container.frame.width = TAB_WIDTH thisObject.container.frame.height = TAB_HEIGHT - thisObject.container.eventHandler.listenToEvent('onMouseClick', onMouseClick) + onMouseClickEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseClick', onMouseClick) resize() isInitialized = true } @@ -126,7 +133,7 @@ function newSidePanelTab() { } function positionPhysics() { - thisObject.container.frame.position.y = browserCanvas.height / 2 - TAB_HEIGHT / 2 + thisObject.index * (TAB_HEIGHT - 1) + thisObject.container.frame.position.y = browserCanvas.height / 2 - TAB_HEIGHT / 2 + (thisObject.index - 1) * TAB_HEIGHT } function draw() { diff --git a/Projects/Foundations/UI/Spaces/Side-Space/SideSpace.js b/Projects/Foundations/UI/Spaces/Side-Space/SideSpace.js index 191e925db..54c027dab 100644 --- a/Projects/Foundations/UI/Spaces/Side-Space/SideSpace.js +++ b/Projects/Foundations/UI/Spaces/Side-Space/SideSpace.js @@ -6,7 +6,8 @@ function newFoundationsSideSpace() { rightTabs: undefined, physics: physics, draw: draw, - createSidePanelTab, createSidePanelTab, + createSidePanelTab: createSidePanelTab, + deleteSidePanelTab: deleteSidePanelTab, getContainer: getContainer, initialize: initialize, finalize: finalize @@ -60,28 +61,68 @@ function newFoundationsSideSpace() { return sidePanel } + function deleteSidePanelTab(porject, iconName, label, side) { + + let key = porject + '-' + iconName + '-' + label + '-' + side + if (existingTabs.get(key) !== undefined) { + let sidePanelTab = existingTabs.get(key) + + switch (side) { + case 'left': { + thisObject.leftTabs.splice(sidePanelTab.index - 1, 1) + break + } + case 'right': { + thisObject.rightTabs.splice(sidePanelTab.index - 1, 1) + break + } + } + + sidePanelTab.finalize() + existingTabs.delete(key) + + /* + Reindex Remaining SidTabs + */ + let indexLeft = 1 + let indexRight = 1 + + existingTabs.forEach(reindex) + + function reindex(sideTab, key, map) { + switch (sideTab.screenside) { + case 'left': { + sideTab.index = indexLeft + indexLeft++ + break + } + case 'right': { + sideTab.index = indexRight + indexRight++ + break + } + } + + } + } + } + function getContainer(point, purpose) { } function physics() { - for (let i = 0; i < thisObject.leftTabs.length; i++) { - let sideTab = thisObject.leftTabs[i] - sideTab.physics() - } - for (let i = 0; i < thisObject.rightTabs.length; i++) { - let sideTab = thisObject.rightTabs[i] + existingTabs.forEach(sideTabPhysics) + + function sideTabPhysics(sideTab, key, map) { sideTab.physics() } } function draw() { - for (let i = 0; i < thisObject.leftTabs.length; i++) { - let sideTab = thisObject.leftTabs[i] - sideTab.draw() - } - for (let i = 0; i < thisObject.rightTabs.length; i++) { - let sideTab = thisObject.rightTabs[i] + existingTabs.forEach(sideTabDraw) + + function sideTabDraw(sideTab, key, map) { sideTab.draw() } } diff --git a/Projects/Governance/UI/Spaces/Reports-Space/ReportsSpace.js b/Projects/Governance/UI/Spaces/Reports-Space/ReportsSpace.js index e295028ea..6f3e4abac 100644 --- a/Projects/Governance/UI/Spaces/Reports-Space/ReportsSpace.js +++ b/Projects/Governance/UI/Spaces/Reports-Space/ReportsSpace.js @@ -13,19 +13,10 @@ function newGobernanceReportsSpace() { draw: draw, getContainer: getContainer, finalize: finalize, - initialize: initialize + initialize: initialize, + reset: reset } - thisObject.container = newContainer() - thisObject.container.name = MODULE_NAME - thisObject.container.initialize() - thisObject.container.isClickeable = true - thisObject.container.isDraggeable = false - thisObject.container.detectMouseOver = true - thisObject.container.status = 'hidden' - - resize() - let browserResizedEventSubscriptionId let openingEventSubscriptionId let closingEventSubscriptionId @@ -35,13 +26,19 @@ function newGobernanceReportsSpace() { return thisObject function finalize() { - canvas.eventHandler.stopListening(browserResizedEventSubscriptionId) - thisObject.sidePanelTab.container.eventHandler.stopListening(openingEventSubscriptionId) - thisObject.sidePanelTab.container.eventHandler.stopListening(closingEventSubscriptionId) + + if (isInitialized === false) { return } thisObject.container.finalize() thisObject.container = undefined + canvas.eventHandler.stopListening(browserResizedEventSubscriptionId) + thisObject.sidePanelTab.container.eventHandler.stopListening(openingEventSubscriptionId) + thisObject.sidePanelTab.container.eventHandler.stopListening(closingEventSubscriptionId) + thisObject.sidePanelTab = undefined + + UI.projects.foundations.spaces.sideSpace.deleteSidePanelTab('Governance', 'governance-tab', 'Gov', 'right') + thisObject.reportsPage.finalize() thisObject.reportsPage = undefined @@ -51,12 +48,23 @@ function newGobernanceReportsSpace() { thisObject.userProfiles.finalize() thisObject.userProfiles = undefined - let isInitialized = false + isInitialized = false } function initialize() { + let resultsArary = UI.projects.foundations.spaces.designSpace.workspace.getHierarchyHeadsByNodeType('User Profile') + if (resultsArary.length === 0) { return } + + thisObject.container = newContainer() + thisObject.container.name = MODULE_NAME + thisObject.container.initialize() + thisObject.container.isClickeable = true + thisObject.container.isDraggeable = false + thisObject.container.detectMouseOver = true + thisObject.container.status = 'hidden' + + resize() - thisObject.reportsPage = newGovernanceReportsReportsPage() thisObject.footer = newGovernanceReportsFooter() thisObject.userProfiles = newGovernanceReportsUserProfiles() @@ -68,7 +76,7 @@ function newGobernanceReportsSpace() { setupSidePanelTab() thisObject.tablesSortingOrders = {} - + isInitialized = true function setupSidePanelTab() { @@ -82,6 +90,11 @@ function newGobernanceReportsSpace() { } } + function reset() { + finalize() + initialize() + } + function resize() { thisObject.container.frame.width = UI.projects.governance.globals.reports.REPORTS_SPACE_WIDTH thisObject.container.frame.height = browserCanvas.height // - TOP_SPACE_HEIGHT @@ -94,6 +107,8 @@ function newGobernanceReportsSpace() { } function physics() { + if (isInitialized === false) { return } + docsAppDivPhysics() function docsAppDivPhysics() { @@ -114,6 +129,7 @@ function newGobernanceReportsSpace() { } function getContainer(point, purpose) { + if (isInitialized === false) { return } if (thisObject.sidePanelTab === undefined) { return } let container @@ -127,7 +143,7 @@ function newGobernanceReportsSpace() { } } - function changeTableSortingOrder(table, property, order){ + function changeTableSortingOrder(table, property, order) { thisObject.tablesSortingOrders[table].property = property thisObject.tablesSortingOrders[table].order = order thisObject.reportsPage.render()