TODO RiderList line 92
This commit is contained in:
@@ -146,6 +146,6 @@ class LoadRidersCommand implements ICommand implements IResponder {
|
|||||||
public function fault(rpcEvent:Dynamic):Void {
|
public function fault(rpcEvent:Dynamic):Void {
|
||||||
// store an error message in the model locator
|
// store an error message in the model locator
|
||||||
// labels, alerts, etc can bind to this to notify the user of errors
|
// labels, alerts, etc can bind to this to notify the user of errors
|
||||||
model.errorStatus = "Fault occured in LoadEmployeesCommand.";
|
model.errorStatus = "Fault occured in LoadRidersCommand.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package command;
|
||||||
|
|
||||||
|
import model.Constants;
|
||||||
|
import com.adobe.cairngorm.commands.ICommand;
|
||||||
|
import com.adobe.cairngorm.control.CairngormEvent;
|
||||||
|
import model.AppModelLocator;
|
||||||
|
import t9.util.ColorTraces.*;
|
||||||
|
|
||||||
|
class RiderSelectCommand implements ICommand {
|
||||||
|
private var model = AppModelLocator.getInstance();
|
||||||
|
|
||||||
|
public function execute(e:CairngormEvent):Void {
|
||||||
|
trace(e.data);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package control;
|
package control;
|
||||||
|
|
||||||
|
import command.RiderSelectCommand;
|
||||||
import command.CloseDrawerCommand;
|
import command.CloseDrawerCommand;
|
||||||
import command.LoadRidersCommand;
|
import command.LoadRidersCommand;
|
||||||
import command.OpenDrawerCommand;
|
import command.OpenDrawerCommand;
|
||||||
@@ -10,6 +11,7 @@ class AppController extends FrontController {
|
|||||||
public static final LOAD_RIDERS_EVENT = "loadRidersEvent";
|
public static final LOAD_RIDERS_EVENT = "loadRidersEvent";
|
||||||
public static final OPEN_DRAWER_EVENT = "openDrawerEvent";
|
public static final OPEN_DRAWER_EVENT = "openDrawerEvent";
|
||||||
public static final CLOSE_DRAWER_EVENT = "closeDrawerEvent";
|
public static final CLOSE_DRAWER_EVENT = "closeDrawerEvent";
|
||||||
|
public static final RIDER_SELECT_EVENT = "riderSelect";
|
||||||
|
|
||||||
|
|
||||||
public function new() {
|
public function new() {
|
||||||
@@ -17,5 +19,6 @@ class AppController extends FrontController {
|
|||||||
addCommand(AppController.LOAD_RIDERS_EVENT, LoadRidersCommand);
|
addCommand(AppController.LOAD_RIDERS_EVENT, LoadRidersCommand);
|
||||||
addCommand(AppController.OPEN_DRAWER_EVENT, OpenDrawerCommand);
|
addCommand(AppController.OPEN_DRAWER_EVENT, OpenDrawerCommand);
|
||||||
addCommand(AppController.CLOSE_DRAWER_EVENT, CloseDrawerCommand);
|
addCommand(AppController.CLOSE_DRAWER_EVENT, CloseDrawerCommand);
|
||||||
|
addCommand(AppController.RIDER_SELECT_EVENT, RiderSelectCommand);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class AppModelLocator extends EventDispatcher implements IModelLocator {
|
|||||||
public static final VIEWING_CHANGE:String = "viewingChange";
|
public static final VIEWING_CHANGE:String = "viewingChange";
|
||||||
public static final RIDERS_LIST_DP_CHANGE:String = "ridersListDPChange";
|
public static final RIDERS_LIST_DP_CHANGE:String = "ridersListDPChange";
|
||||||
public static final DRAWER_STATE_CHANGE:String = "drawerStateChange";
|
public static final DRAWER_STATE_CHANGE:String = "drawerStateChange";
|
||||||
|
public static final RIDER_SELECT:String = "riderSelect";
|
||||||
|
|
||||||
// this instance stores a static reference to itself
|
// this instance stores a static reference to itself
|
||||||
private static var model:AppModelLocator;
|
private static var model:AppModelLocator;
|
||||||
@@ -44,6 +44,15 @@ class AppModelLocator extends EventDispatcher implements IModelLocator {
|
|||||||
return drawerIsOpen;
|
return drawerIsOpen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// selected rider
|
||||||
|
public var selectedRider(default, set):RiderVO = null;
|
||||||
|
|
||||||
|
private function set_selectedRider(pRider:RiderVO):RiderVO {
|
||||||
|
selectedRider = pRider;
|
||||||
|
dispatchEvent(new Event(AppModelLocator.DRAWER_STATE_CHANGE));
|
||||||
|
return selectedRider;
|
||||||
|
}
|
||||||
|
|
||||||
// rider object contains uid/passwd
|
// rider object contains uid/passwd
|
||||||
// its value gets set at login and cleared at logout but nothing binds to it or uses it
|
// its value gets set at login and cleared at logout but nothing binds to it or uses it
|
||||||
// retained since it was used in the original Adobe CafeTownsend example app
|
// retained since it was used in the original Adobe CafeTownsend example app
|
||||||
|
|||||||
+19
-5
@@ -1,5 +1,8 @@
|
|||||||
package view;
|
package view;
|
||||||
|
|
||||||
|
import com.adobe.cairngorm.control.CairngormEventDispatcher;
|
||||||
|
import control.AppController;
|
||||||
|
import com.adobe.cairngorm.control.CairngormEvent;
|
||||||
import components.RidersListRendererAccessory;
|
import components.RidersListRendererAccessory;
|
||||||
import components.RoundAvatar;
|
import components.RoundAvatar;
|
||||||
import feathers.controls.ListView;
|
import feathers.controls.ListView;
|
||||||
@@ -23,6 +26,7 @@ class RidersList extends ListView {
|
|||||||
public function new() {
|
public function new() {
|
||||||
super();
|
super();
|
||||||
addEventListener(FeathersEvent.CREATION_COMPLETE, onCreationComplete);
|
addEventListener(FeathersEvent.CREATION_COMPLETE, onCreationComplete);
|
||||||
|
addEventListener(Event.CHANGE, onRiderSelect);
|
||||||
}
|
}
|
||||||
|
|
||||||
override private function initialize():Void {
|
override private function initialize():Void {
|
||||||
@@ -30,7 +34,6 @@ class RidersList extends ListView {
|
|||||||
|
|
||||||
// set common properties for all renderers in the same container here
|
// set common properties for all renderers in the same container here
|
||||||
var recycler = DisplayObjectRecycler.withFunction(() -> {
|
var recycler = DisplayObjectRecycler.withFunction(() -> {
|
||||||
|
|
||||||
final fnt1:Font = Assets.getFont(Constants.MONTSERRAT_MEDIUM_500);
|
final fnt1:Font = Assets.getFont(Constants.MONTSERRAT_MEDIUM_500);
|
||||||
final fnt2:Font = Assets.getFont(Constants.MONTSERRAT_BOLD_700);
|
final fnt2:Font = Assets.getFont(Constants.MONTSERRAT_BOLD_700);
|
||||||
|
|
||||||
@@ -43,7 +46,6 @@ class RidersList extends ListView {
|
|||||||
itemRenderer.secondaryTextFormat = new TextFormat(fnt2.fontName, Std.int(rowHeight * 0.2), Constants.MAIN_COLOR2);
|
itemRenderer.secondaryTextFormat = new TextFormat(fnt2.fontName, Std.int(rowHeight * 0.2), Constants.MAIN_COLOR2);
|
||||||
|
|
||||||
return itemRenderer;
|
return itemRenderer;
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
itemRendererRecycler = recycler;
|
itemRendererRecycler = recycler;
|
||||||
@@ -59,7 +61,6 @@ class RidersList extends ListView {
|
|||||||
// TODO change this to real iamge path
|
// TODO change this to real iamge path
|
||||||
// loader.source = "https://lepetittrot.com/path/to/pp_pictures" + state.data.id + ".jpg";
|
// loader.source = "https://lepetittrot.com/path/to/pp_pictures" + state.data.id + ".jpg";
|
||||||
// loader.source = "https://testingbot.com/free-online-tools/random-avatar/50?u=" + Uuid.nanoId();
|
// loader.source = "https://testingbot.com/free-online-tools/random-avatar/50?u=" + Uuid.nanoId();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
recycler.reset = (itemRenderer:ItemRenderer, state:ListViewItemState) -> {
|
recycler.reset = (itemRenderer:ItemRenderer, state:ListViewItemState) -> {
|
||||||
@@ -69,14 +70,14 @@ class RidersList extends ListView {
|
|||||||
loader.source = null; */
|
loader.source = null; */
|
||||||
};
|
};
|
||||||
|
|
||||||
model.addEventListener(AppModelLocator.RIDERS_LIST_DP_CHANGE, onRideListDpChange);
|
model.addEventListener(AppModelLocator.RIDERS_LIST_DP_CHANGE, onRiderListDpChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function onCreationComplete(event:FeathersEvent):Void {
|
private function onCreationComplete(event:FeathersEvent):Void {
|
||||||
traceBlue(this + " --> onCreationComplete() - w: " + width + " h: " + height);
|
traceBlue(this + " --> onCreationComplete() - w: " + width + " h: " + height);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function onRideListDpChange(e:Event):Void {
|
private function onRiderListDpChange(e:Event):Void {
|
||||||
dataProvider = model.ridersListDP;
|
dataProvider = model.ridersListDP;
|
||||||
|
|
||||||
/*itemToText = function(item:Dynamic):String {
|
/*itemToText = function(item:Dynamic):String {
|
||||||
@@ -84,4 +85,17 @@ class RidersList extends ListView {
|
|||||||
};*/
|
};*/
|
||||||
traceGreen(this + " --> onRideListDpChange() - w: " + width + " h: " + height);
|
traceGreen(this + " --> onRideListDpChange() - w: " + width + " h: " + height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onRiderSelect(e:Event):Void {
|
||||||
|
var riderVO:RiderVO = cast(selectedItem, RiderVO);
|
||||||
|
var ce:CairngormEvent = new CairngormEvent(AppController.RIDER_SELECT_EVENT);
|
||||||
|
CairngormEventDispatcher.getInstance().dispatchEvent(ce); //TODO how to pass the selected user to AppModelLocator ?
|
||||||
|
//trace(riderVO.firstName);
|
||||||
|
//clearSelectedRider();
|
||||||
|
}
|
||||||
|
|
||||||
|
// de-select any selected List items
|
||||||
|
private function clearSelectedRider():Void {
|
||||||
|
selectedIndex = -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user