From e5ea696e0a873f5adca73334f4835071bae3da4b Mon Sep 17 00:00:00 2001 From: Piotr Zarzycki Date: Tue, 19 Nov 2024 11:05:16 +0100 Subject: [PATCH] Handle Documentation based on viewDocumentation - hide "Getting Started" - "Install" button is now handled based on installApps property instead roles (reference #65) --- .../DocumentationFormProxy.as | 22 ++++++++++++--- .../CommandExecuteRolesMainContent.as | 27 ++++++++++++++----- .../applications/MediatorGenesisApps.as | 9 ++++--- .../model/LeftMenuNavigationModel.as | 2 +- 4 files changed, 45 insertions(+), 15 deletions(-) diff --git a/Super.Human.Portal_Royale/src/generated/Super.Human.Portal_Royale/views/modules/DocumentationForm/DocumentationFormServices/DocumentationFormProxy.as b/Super.Human.Portal_Royale/src/generated/Super.Human.Portal_Royale/views/modules/DocumentationForm/DocumentationFormServices/DocumentationFormProxy.as index 2877fb1..1d1cac8 100644 --- a/Super.Human.Portal_Royale/src/generated/Super.Human.Portal_Royale/views/modules/DocumentationForm/DocumentationFormServices/DocumentationFormProxy.as +++ b/Super.Human.Portal_Royale/src/generated/Super.Human.Portal_Royale/views/modules/DocumentationForm/DocumentationFormServices/DocumentationFormProxy.as @@ -16,6 +16,7 @@ package Super.Human.Portal_Royale.views.modules.DocumentationForm.DocumentationF import org.apache.royale.jewel.Snackbar; import org.apache.royale.net.events.FaultEvent; import org.apache.royale.utils.async.PromiseTask; + import model.proxy.ProxySessionCheck; public class DocumentationFormProxy extends EventDispatcher { @@ -230,7 +231,16 @@ package Super.Human.Portal_Royale.views.modules.DocumentationForm.DocumentationF if (fetchedData) { var json:Object = JSON.parse(fetchedData as String); - if (!json.errorMessage) + var facade:ApplicationFacade = ApplicationFacade.getInstance("SuperHumanPortal_Royale"); + var sessionProxy:ProxySessionCheck = facade.retrieveProxy(ProxySessionCheck.NAME) as ProxySessionCheck; + + if (json.status == sessionProxy.SESSION_AUTHLIMITEDACCESS) + { + items = []; + + this.dispatchEvent(new Event(EVENT_ITEM_UPDATED)); + } + else if (!json.errorMessage) { loadConfig(); @@ -281,8 +291,14 @@ package Super.Human.Portal_Royale.views.modules.DocumentationForm.DocumentationF { var jsonData:Object = JSON.parse(fetchedData); var errorMessage:String = jsonData["errorMessage"]; - - if (errorMessage) + var facade:ApplicationFacade = ApplicationFacade.getInstance("SuperHumanPortal_Royale"); + var sessionProxy:ProxySessionCheck = facade.retrieveProxy(ProxySessionCheck.NAME) as ProxySessionCheck; + + if (jsonData.status == sessionProxy.SESSION_AUTHLIMITEDACCESS) + { + mainItems = []; + } + else if (errorMessage) { this.dispatchEvent( new ErrorEvent( diff --git a/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/controller/roles/executeRoles/CommandExecuteRolesMainContent.as b/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/controller/roles/executeRoles/CommandExecuteRolesMainContent.as index 4a68aba..de2bdc7 100644 --- a/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/controller/roles/executeRoles/CommandExecuteRolesMainContent.as +++ b/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/controller/roles/executeRoles/CommandExecuteRolesMainContent.as @@ -54,21 +54,34 @@ package controller.roles.executeRoles if (loginProxy.user && loginProxy.user.display) { var k:int = -1; - - if (!loginProxy.user.display.viewInstalledApps) + + for (k = mainContentModel.navigationLinks.length - 1; k >= 0; k--) { - for (k = mainContentModel.navigationLinks.length - 1; k >= 0; k--) + navItem = mainContentModel.navigationLinks.getItemAt(k) as NavigationLinkVO; + if (!loginProxy.user.display.viewInstalledApps) { - navItem = mainContentModel.navigationLinks.getItemAt(k) as NavigationLinkVO; if (navItem.idSelectedItem == "installedApps") { mainContentModel.navigationLinks.removeItemAt(k); } } + } + + for (k = mainContentModel.mainNavigation.length - 1; k >= 0; k--) + { + navItem = mainContentModel.mainNavigation.getItemAt(k) as NavigationLinkVO; + + if (!loginProxy.user.display.viewInstalledApps) + { + if (navItem.idSelectedItem == MediatorGenesisApps.NAME) + { + mainContentModel.mainNavigation.removeItemAt(k); + } + } - for (k = mainContentModel.mainNavigation.length - 1; k >= 0; k--) + if (!loginProxy.user.display.viewDocumentation) { - navItem = mainContentModel.mainNavigation.getItemAt(k) as NavigationLinkVO; - if (navItem.idSelectedItem == MediatorGenesisApps.NAME) { + if (navItem.idSelectedItem == "GettingStartedDoc") + { mainContentModel.mainNavigation.removeItemAt(k); } } diff --git a/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/mediator/applications/MediatorGenesisApps.as b/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/mediator/applications/MediatorGenesisApps.as index ab3c5d8..33da1c9 100644 --- a/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/mediator/applications/MediatorGenesisApps.as +++ b/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/mediator/applications/MediatorGenesisApps.as @@ -1,11 +1,15 @@ package mediator.applications { + import classes.com.devexpress.js.dataGrid.events.DataGridEvent; + import constants.ApplicationConstants; import constants.PopupType; + import constants.Roles; import interfaces.IGenesisAppsView; import model.proxy.applicationsCatalog.ProxyGenesisApps; + import model.proxy.login.ProxyLogin; import model.proxy.urlParams.ProxyUrlParameters; import model.vo.ApplicationVO; import model.vo.PopupVO; @@ -16,9 +20,6 @@ package mediator.applications import org.puremvc.as3.multicore.interfaces.IMediator; import org.puremvc.as3.multicore.interfaces.INotification; import org.puremvc.as3.multicore.patterns.mediator.Mediator; - import classes.com.devexpress.js.dataGrid.events.DataGridEvent; - import model.proxy.login.ProxyLogin; - import constants.Roles; public class MediatorGenesisApps extends Mediator implements IMediator { @@ -109,7 +110,7 @@ package mediator.applications view.learnMore["html"] = "Learn More"; view.selectedApp = "Select an application from the list below"; - var hasAdminRole:Boolean = loginProxy.user && loginProxy.user.hasRole(Roles.ADMINISTRATOR); + var hasAdminRole:Boolean = loginProxy.user && loginProxy.user.display.installApps; view.installApplicationButton["text"] = hasAdminRole ? "Install" : "Install (Admin-only)"; if (!genesisAppsProxy.getData()) diff --git a/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/model/LeftMenuNavigationModel.as b/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/model/LeftMenuNavigationModel.as index bbb3d66..48d4d93 100644 --- a/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/model/LeftMenuNavigationModel.as +++ b/Super.Human.Portal_Royale/src/net/apacheRoyaleTemplatedApp/model/LeftMenuNavigationModel.as @@ -18,7 +18,7 @@ package model private var genesisApps:NavigationLinkVO = new NavigationLinkVO("Genesis Apps", ApplicationConstants.NOTE_OPEN_GENESIS_APPLICATIONS, "mdi mdi-apps mdi-24px", MediatorGenesisApps.NAME, null, MediatorGenesisApps.NAME); private var _mainNavigation:ArrayList = new ArrayList([ - new NavigationLinkVO("Getting Started", ApplicationConstants.NOTE_OPEN_VIEW_HELLO, "mdi mdi-apps mdi-24px", "", null, "DocumentationForm"), + new NavigationLinkVO("Getting Started", ApplicationConstants.NOTE_OPEN_VIEW_HELLO, "mdi mdi-apps mdi-24px", "GettingStartedDoc", null, "DocumentationForm"), genesisApps ]);