Skip to content

Commit

Permalink
Handle Documentation based on viewDocumentation - hide "Getting Started"
Browse files Browse the repository at this point in the history
- "Install" button is now handled based on installApps property instead roles (reference #65)
  • Loading branch information
piotrzarzycki21 committed Nov 19, 2024
1 parent 6425f8c commit e5ea696
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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
{
Expand Down Expand Up @@ -109,7 +110,7 @@ package mediator.applications
view.learnMore["html"] = "<a href='http://genesis.directory/articles/what-is-genesis' target='_blank'>Learn More</a>";
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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
]);

Expand Down

0 comments on commit e5ea696

Please sign in to comment.