Skip to content

Commit

Permalink
Bookmarks: Add UI for Add/Edit bookmarks
Browse files Browse the repository at this point in the history
- Move Bookmark display part to separate component (reference #30)
  • Loading branch information
piotrzarzycki21 committed Aug 8, 2023
1 parent ce8404d commit 6cb4b96
Show file tree
Hide file tree
Showing 13 changed files with 585 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ package classes.beads
import org.apache.royale.html.beads.IListView;
import org.apache.royale.jewel.beads.controllers.ListSingleSelectionMouseController;
import org.apache.royale.jewel.beads.models.IJewelSelectionModel;

import view.renderers.navigation.CollapsibleDrawerLinkItemRenderer;

public class CollapsibleNavSingleSelectionMouseController extends ListSingleSelectionMouseController
{
Expand Down Expand Up @@ -35,16 +37,18 @@ package classes.beads
var dataGroup:IItemRendererOwnerView = view.dataGroup;

var ir:Object = null;
var selectedSubMenu:Object = null;

var n:int = dataGroup.numItemRenderers;
var selectedItem:Object = view.host["selectedItem"];

if (selectedItem)
{
for (var i:int = 0; i < n; i++)
{
ir = dataGroup.getItemRendererAt(i);

var selectedSubMenu:Object = ir.getSelectedSubmenuItem();
selectedSubMenu = ir.getSelectedSubmenuItem();
if (selectedSubMenu && selectedItem != ir.data)
{
ir.unsetSelectedSubmenuItem();
Expand All @@ -57,6 +61,19 @@ package classes.beads
}
}
}
else
{
for (var j:int = 0; j < n; j++)
{
ir = dataGroup.getItemRendererAt(j);

selectedSubMenu = ir.getSelectedSubmenuItem();
if (selectedSubMenu && selectedItem != ir.data)
{
ir.unsetSelectedSubmenuItem();
}
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ package constants

public static const NOTE_OPEN_VIEW_HELLO:String = NAME + SEPARATOR + "NoteOpenViewHello";
public static const NOTE_OPEN_GENESIS_APPLICATIONS:String = NAME + SEPARATOR + "NoteOpenGenesisApplications";

public static const NOTE_OPEN_ADD_EDIT_BOOKMARK:String = NAME + SEPARATOR + "NoteOpenAddEditBookmark";
public static const NOTE_OPEN_SELECTED_BOOKMARK_GROUP:String = NAME + SEPARATOR + "NoteOpenSelectedBookmarkGroup";

//----------------------------------
// Commands
//----------------------------------
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package interfaces
{
import org.apache.royale.events.IEventDispatcher;
import model.vo.BookmarkVO;

public interface IEditBookmarkView
{
function get bookmark():BookmarkVO;
function set bookmark(value:BookmarkVO):void;
function get saveBookmark():IEventDispatcher;
function get cancelBookmark():IEventDispatcher;
function get titleBookmark():String;
function set titleBookmark(value:String):void;
function get typeBookmark():Object;
function get browserForm():Object;
function get databaseForm():Object;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ package interfaces

function get bookmarksView():IBookmarksView;
function get bookmarksViewSection():Object;
function get viewEditBookmark():IEditBookmarkView;

function set title(value:String):void;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package mediator
import interfaces.IMainContentView;

import mediator.applications.MediatorGenesisApps;
import mediator.bookmarks.MediatorEditBookmark;

import model.proxy.ProxyVersion;
import model.proxy.applicationsCatalog.ProxyGenesisApps;
Expand All @@ -18,12 +19,14 @@ package mediator
import model.vo.UserVO;

import org.apache.royale.events.Event;
import org.apache.royale.events.IEventDispatcher;
import org.apache.royale.events.MouseEvent;
import org.apache.royale.events.ValueEvent;
import org.apache.royale.reflection.getQualifiedClassName;
import org.puremvc.as3.multicore.interfaces.IMediator;
import org.puremvc.as3.multicore.interfaces.INotification;
import org.puremvc.as3.multicore.patterns.mediator.Mediator;
import org.apache.royale.collections.ArrayList;

public class MediatorMainContentView extends Mediator implements IMediator
{
Expand Down Expand Up @@ -86,6 +89,8 @@ package mediator

interests.push(ApplicationConstants.NOTE_OPEN_VIEW_HELLO);
interests.push(ApplicationConstants.NOTE_OPEN_GENESIS_APPLICATIONS);
interests.push(ApplicationConstants.NOTE_OPEN_ADD_EDIT_BOOKMARK);
interests.push(ApplicationConstants.NOTE_OPEN_SELECTED_BOOKMARK_GROUP);

return interests;
}
Expand Down Expand Up @@ -132,6 +137,12 @@ package mediator
case ApplicationConstants.NOTE_OPEN_GENESIS_APPLICATIONS:
initializeGenesisApplicationsList();
break;
case ApplicationConstants.NOTE_OPEN_ADD_EDIT_BOOKMARK:
initializeAddEditBookmark();
break;
case ApplicationConstants.NOTE_OPEN_SELECTED_BOOKMARK_GROUP:
selectBookmarkGroup(String(note.getBody()));
break;
}
}

Expand Down Expand Up @@ -192,8 +203,6 @@ package mediator
}

view.selectedContent = MediatorNewRegistration.NAME;


}

/*
Expand Down Expand Up @@ -230,24 +239,61 @@ package mediator

private function initializeGenesisApplicationsList():void
{
//Remove mediator from second navigation
var selectedItem:NavigationLinkVO = view.viewInstalledAppsNavigation["selectedItem"];
if (selectedItem)
{
var currentSelection:NavigationLinkVO = selectedItem;
if (selectedItem.selectedChild)
{
currentSelection = selectedItem.selectedChild;
}
facade.removeMediator(currentSelection.idSelectedItem);
}

this.removeMediatorFromAdditionalNavigation(view.viewInstalledAppsNavigation);
this.removeMediatorFromAdditionalNavigation(view.viewBookmarksNavigation);
sendNotification(ApplicationConstants.COMMAND_REMOVE_REGISTER_MAIN_VIEW, {
view: view,
currentView: view.viewGenesisApps,
currentSelection: MediatorGenesisApps.NAME
}, "mediator.applications.MediatorGenesisApps");
}

private function initializeAddEditBookmark():void
{
this.removeMediatorFromAdditionalNavigation(view.viewBookmarksNavigation);

sendNotification(ApplicationConstants.COMMAND_REMOVE_REGISTER_MAIN_VIEW, {
view: view,
currentView: view.viewEditBookmark,
currentSelection: MediatorEditBookmark.NAME,
mediatorName: MediatorEditBookmark.NAME
}, "mediator.bookmarks.MediatorEditBookmark");
}

private function selectBookmarkGroup(group:String):void
{
var bookmarkGroup:NavigationLinkVO = null;
var bookmarkNavGroup:ArrayList = view.viewBookmarksNavigation["dataProvider"];

for (var i:int = 0; i < bookmarkNavGroup.length; i++)
{
bookmarkGroup = bookmarkNavGroup.getItemAt(i) as NavigationLinkVO;
if (bookmarkGroup.subMenu)
{
for (var j:int = 0; j < bookmarkGroup.subMenu.length; j++)
{
var subBookmarkNav:NavigationLinkVO = bookmarkGroup.subMenu.getItemAt(j) as NavigationLinkVO;
if (subBookmarkNav.name == subBookmarkNav.data.name)
{
bookmarkGroup.selectedChild = subBookmarkNav;
break;
}
}
}
else
{
bookmarkGroup = null;
}

if (bookmarkGroup != null && bookmarkGroup.selectedChild != null)
{
break;
}
}

view.viewBookmarksNavigation["selectedItem"] = bookmarkGroup;
onNavigationBookmarksSelectionChange(null);
}

//----------------------------------
// MENU
Expand Down Expand Up @@ -313,6 +359,8 @@ package mediator

private function onNavigationBookmarksSelectionChange(event:Event):void
{
this.removeMediatorFromAdditionalNavigation(view.viewInstalledAppsNavigation);

var selectedItem:NavigationLinkVO = view.viewBookmarksNavigation["selectedItem"];
var currentSelection:NavigationLinkVO = selectedItem;
if (selectedItem.selectedChild)
Expand All @@ -335,6 +383,8 @@ package mediator

private function onNavigationInstalledAppSectionChange(event:Event):void
{
this.removeMediatorFromAdditionalNavigation(view.viewBookmarksNavigation);

var selectedItem:NavigationLinkVO = view.viewInstalledAppsNavigation["selectedItem"];
var currentSelection:NavigationLinkVO = selectedItem;
if (selectedItem.selectedChild)
Expand Down Expand Up @@ -372,5 +422,26 @@ package mediator
{
sendNotification(ApplicationConstants.COMMAND_ADJUST_TAB_BAR_SIZE);
}

private function removeMediatorFromAdditionalNavigation(navigation:IEventDispatcher):void
{
//Remove mediator from second navigation
var selectedItem:NavigationLinkVO = navigation["selectedItem"];
if (selectedItem)
{
var currentSelection:NavigationLinkVO = selectedItem;
if (selectedItem.selectedChild)
{
currentSelection = selectedItem.selectedChild;
}

if (facade.hasMediator(currentSelection.idSelectedItem))
{
facade.removeMediator(currentSelection.idSelectedItem);

navigation["selectedItem"] = null;
}
}
}
}
}
Loading

0 comments on commit 6cb4b96

Please sign in to comment.