Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…ortal into main
  • Loading branch information
JoelProminic committed Aug 22, 2023
2 parents 06c87ef + ebfa1a7 commit 9371999
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ package classes.managers
return _genesisDirUpdate;
}

private var _genesisDirDelete:String = "/SuperHumanPortal.nsf/GenesisDirectoryUpdate?OpenAgent";
private var _genesisDirDelete:String = "/SuperHumanPortal.nsf/GenesisDirectoryDelete?OpenAgent";

public function get genesisDirDelete():String
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ 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 mediator.popup.MediatorPopup;

public class MediatorGenesisDirs extends Mediator implements IMediator
{
Expand All @@ -35,6 +36,7 @@ package mediator.applications

view.newDir.addEventListener(MouseEvent.CLICK, onNewDirClick);
view.genesisDirsList.addEventListener(DataGridEvent.DOUBLE_CLICK_ROW, onGenesisDirsDoubleClicked);
view.genesisDirsList.addEventListener(DataGridEvent.CLICK_CELL, onGenesisDirsClickCell);

this.genesisDirsProxy = facade.retrieveProxy(ProxyGenesisDirs.NAME) as ProxyGenesisDirs;

Expand All @@ -47,15 +49,20 @@ package mediator.applications

view.newDir.removeEventListener(MouseEvent.CLICK, onNewDirClick);
view.genesisDirsList.removeEventListener(DataGridEvent.DOUBLE_CLICK_ROW, onGenesisDirsDoubleClicked);
view.genesisDirsList.removeEventListener(DataGridEvent.CLICK_CELL, onGenesisDirsClickCell);

this.genesisDirsProxy = null;
}

override public function listNotificationInterests():Array
{
var interests:Array = super.listNotificationInterests();
interests.push(ApplicationConstants.NOTE_OK_POPUP + MediatorPopup.NAME + this.getMediatorName());
interests.push(ApplicationConstants.NOTE_CANCEL_POPUP + MediatorPopup.NAME + this.getMediatorName());
interests.push(ProxyGenesisDirs.NOTE_GENESIS_DIRS_LIST_FETCHED);
interests.push(ProxyGenesisDirs.NOTE_GENESIS_DIRS_LIST_FETCH_FAILED);
interests.push(ProxyGenesisDirs.NOTE_GENESIS_DIR_DELETE_SUCCESS);
interests.push(ProxyGenesisDirs.NOTE_GENESIS_DIR_DELETE_FAILED);

return interests;
}
Expand All @@ -70,6 +77,15 @@ package mediator.applications
case ProxyGenesisDirs.NOTE_GENESIS_DIRS_LIST_FETCH_FAILED:
sendNotification(ApplicationConstants.COMMAND_SHOW_POPUP, new PopupVO(PopupType.ERROR, this.getMediatorName(), String(note.getBody())));
break;
case ApplicationConstants.NOTE_OK_POPUP + MediatorPopup.NAME + this.getMediatorName():
genesisDirsProxy.deleteDir();
break;
case ProxyGenesisDirs.NOTE_GENESIS_DIR_DELETE_SUCCESS:
view.genesisDirsList["refreshDataProvider"]();
break;
case ProxyGenesisDirs.NOTE_GENESIS_DIR_DELETE_FAILED:
sendNotification(ApplicationConstants.COMMAND_SHOW_POPUP, new PopupVO(PopupType.ERROR, this.getMediatorName(), String(note.getBody())));
break;
}
}

Expand All @@ -92,6 +108,16 @@ package mediator.applications
sendNotification(ApplicationConstants.NOTE_OPEN_ADD_EDIT_GENESIS_DIR, event.item);
}

private function onGenesisDirsClickCell(event:DataGridEvent):void
{
if (event.dataGridData.column.dataField == "delete")
{
this.genesisDirsProxy.selectedDir = event.item as GenesisDirVO;
sendNotification(ApplicationConstants.COMMAND_SHOW_POPUP, new PopupVO(PopupType.QUESTION, this.getMediatorName(),
"Are you sure you want to delete Genesis directory " + event.item.label + "?"));
}
}

private function updateView():void
{
this.genesisDirsProxy.getDirsList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ package model
public class LeftMenuNavigationModel
{
private var genesisDirectories:ArrayList = new ArrayList([
new NavigationLinkVO("Additional directories", ApplicationConstants.NOTE_OPEN_GENESIS_DIRS_VIEW, "mdi mdi-apps mdi-24px", MediatorGenesisDirs.NAME, null, MediatorGenesisDirs.NAME)
new NavigationLinkVO("Additional directories", ApplicationConstants.NOTE_OPEN_GENESIS_DIRS_VIEW, "mdi mdi-folder-table mdi-24px", MediatorGenesisDirs.NAME, null, MediatorGenesisDirs.NAME)
]);

private var genesisApps:NavigationLinkVO = new NavigationLinkVO("Genesis App", ApplicationConstants.NOTE_OPEN_GENESIS_APPLICATIONS, "mdi mdi-apps mdi-24px", MediatorGenesisApps.NAME, null, MediatorGenesisApps.NAME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ package model.proxy.applicationsCatalog
public static const NOTE_GENESIS_DIR_UPDATE_SUCCESS:String = NAME + "NoteGenesisDirUpdateSuccess";
public static const NOTE_GENESIS_DIR_UPDATE_FAILED:String = NAME + "NoteGenesisDirUpdateFailed";

public static const NOTE_GENESIS_DIR_DELETE_SUCCESS:String = NAME + "NoteGenesisDirDeleteSuccess";
public static const NOTE_GENESIS_DIR_DELETE_FAILED:String = NAME + "NoteGenesisDirDeleteFailed";

private var genesisPrivteDirDelegate:GenesisDirsDelegate;
private var sessionCheckProxy:ProxySessionCheck;
private var busyManagerProxy:ProxyBusyManager;
Expand Down Expand Up @@ -86,6 +89,14 @@ package model.proxy.applicationsCatalog
genesisPrivteDirDelegate.updateGenesisDir(this.selectedDir.dominoUniversalID, this.selectedDir.toRequestObject(), successCallback, failureCallback);
}

public function deleteDir():void
{
var successCallback:Function = this.busyManagerProxy.wrapSuccessFunction(onGenesisDirDeleteSuccess);
var failureCallback:Function = this.busyManagerProxy.wrapFailureFunction(onGenesisDirDeleteFailed);

genesisPrivteDirDelegate.deleteDir(this.selectedDir.dominoUniversalID, successCallback, failureCallback);
}

private function onGenesisDirsListFetched(event:Event):void
{
var fetchedData:String = event.target["data"];
Expand Down Expand Up @@ -188,5 +199,42 @@ package model.proxy.applicationsCatalog
{
sendNotification(NOTE_GENESIS_DIR_UPDATE_FAILED, "Updating Genesis directory failed: " + event.message.toLocaleString());
}

private function onGenesisDirDeleteSuccess(event:Event):void
{
var fetchedData:String = event.target["data"];
if (fetchedData)
{
var jsonData:Object = JSON.parse(fetchedData);
if (!sessionCheckProxy.checkUserSession(jsonData))
{
return;
}

var errorMessage:String = jsonData["errorMessage"];

if (errorMessage)
{
sendNotification(NOTE_GENESIS_DIR_DELETE_FAILED, "Deleting Genesis direcotry failed: " + errorMessage);
}
else
{
var dirs:Array = getData() as Array;
var deleteDirIndex:int = dirs.indexOf(this.selectedDir);
dirs.splice(deleteDirIndex, 1);

sendNotification(NOTE_GENESIS_DIR_DELETE_SUCCESS);
}
}
else
{
sendNotification(NOTE_GENESIS_DIR_DELETE_FAILED, "Deleting Genesis direcotry failed.");
}
}

private function onGenesisDirDeleteFailed(event:FaultEvent):void
{
sendNotification(NOTE_GENESIS_DIR_DELETE_FAILED, "Deleting Genesis direcotry failed: " + event.message.toLocaleString());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@
<dataGrid:columns>
<models:DataGridColumnModel caption="Label" dataField="label" dataType="string" allowFiltering="true"/>
<models:DataGridColumnModel caption="URL" dataField="url" dataType="string" allowFiltering="true"/>
<models:DataGridColumnModel caption="{' '}" dataField="delete" dataType="string" width="50"
itemRenderer="view.renderers.DeleteIconGridRenderer"/>
</dataGrid:columns>
</dataGrid:DataGrid>
</j:VGroup>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<j:DataGridItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:j="library://ns.apache.org/royale/jewel"
xmlns:js="library://ns.apache.org/royale/basic"
xmlns:itemRenderers="org.apache.royale.jewel.beads.itemRenderers.*" xmlns:beads="classes.beads.*"
className="gridJSRendererClean">
<j:beads>
<js:ItemRendererDataBinding/>
<j:VerticalCenteredLayout />
</j:beads>
<fx:Script>
<![CDATA[
override public function get data():Object
{
return _data;
}
override public function set data(value:Object):void
{
_data = value;
}
]]>
</fx:Script>
<j:IconButton localId="deleteIcon" style="padding: 0px;">
<j:icon>
<js:MaterialIcon text="{MaterialIconType.DELETE}" />
</j:icon>
</j:IconButton>
</j:DataGridItemRenderer>

0 comments on commit 9371999

Please sign in to comment.