Fuzzy search on Toolbar.searchTextInput
This commit is contained in:
@@ -10,26 +10,25 @@ import openfl.events.EventDispatcher;
|
||||
import t9.util.ColorTraces.*;
|
||||
|
||||
class AppModelLocator extends EventDispatcher implements IModelLocator {
|
||||
|
||||
// events constants
|
||||
public static final VIEWING_CHANGE:String = "viewingChange";
|
||||
public static final RIDERS_LIST_DP_CHANGE:String = "ridersListDPChange";
|
||||
// events constants
|
||||
public static final VIEWING_CHANGE:String = "viewingChange";
|
||||
public static final RIDERS_LIST_DP_CHANGE:String = "ridersListDPChange";
|
||||
public static final DRAWER_STATE_CHANGE:String = "drawerStateChange";
|
||||
public static final RIDER_SELECT_CHANGE:String = "riderSelectChange";
|
||||
|
||||
// this instance stores a static reference to itself
|
||||
// this instance stores a static reference to itself
|
||||
private static var model:AppModelLocator;
|
||||
|
||||
// available values for the main viewstack defined as constants to help uncover errors at compile time instead of run time
|
||||
// available values for the main viewstack defined as constants to help uncover errors at compile time instead of run time
|
||||
// Navigator
|
||||
public static final ADMIN_LOGIN = 0;
|
||||
public static final RIDERS_LIST = 1;
|
||||
public static final RIDER_DETAIL = 2;
|
||||
|
||||
// viewstack starts out on the admin login screen
|
||||
// viewstack starts out on the admin login screen
|
||||
public var viewing(default, set):Int = ADMIN_LOGIN;
|
||||
|
||||
private function set_viewing(value:Int):Int {
|
||||
private function set_viewing(value:Int):Int {
|
||||
viewing = value;
|
||||
dispatchEvent(new Event(VIEWING_CHANGE));
|
||||
return viewing;
|
||||
@@ -38,7 +37,7 @@ class AppModelLocator extends EventDispatcher implements IModelLocator {
|
||||
// at startup, the drawer is closed
|
||||
public var drawerIsOpen(default, set):Bool = false;
|
||||
|
||||
private function set_drawerIsOpen(pIsOpen:Bool):Bool {
|
||||
private function set_drawerIsOpen(pIsOpen:Bool):Bool {
|
||||
drawerIsOpen = pIsOpen;
|
||||
dispatchEvent(new Event(AppModelLocator.DRAWER_STATE_CHANGE));
|
||||
return drawerIsOpen;
|
||||
@@ -48,7 +47,7 @@ class AppModelLocator extends EventDispatcher implements IModelLocator {
|
||||
// this gets copied into or added onto the main rider list
|
||||
public var selectedRider(default, set):RiderVO = null;
|
||||
|
||||
private function set_selectedRider(pRider:RiderVO):RiderVO {
|
||||
private function set_selectedRider(pRider:RiderVO):RiderVO {
|
||||
selectedRider = pRider;
|
||||
dispatchEvent(new Event(AppModelLocator.RIDER_SELECT_CHANGE));
|
||||
return selectedRider;
|
||||
@@ -61,23 +60,31 @@ class AppModelLocator extends EventDispatcher implements IModelLocator {
|
||||
traceYellow(Reflect.field(selectedRider, pProperty));
|
||||
}
|
||||
|
||||
// contains the main riders list which is populated on startup
|
||||
// contains the main riders list which is populated on startup
|
||||
// mx:application's creationComplete event is mutated into a cairngorm event
|
||||
// that calls the httpservice for the data
|
||||
public var ridersListDP(default, set):ArrayCollection<RiderVO>;
|
||||
|
||||
private function set_ridersListDP(value:ArrayCollection<RiderVO>):ArrayCollection<RiderVO> {
|
||||
private function set_ridersListDP(value:ArrayCollection<RiderVO>):ArrayCollection<RiderVO> {
|
||||
ridersListDP = value;
|
||||
dispatchEvent(new Event(AppModelLocator.RIDERS_LIST_DP_CHANGE));
|
||||
return ridersListDP;
|
||||
}
|
||||
|
||||
// variable to store error messages from the httpservice
|
||||
// nothinng currently binds to it, but an Alert or the login box could to show startup errors
|
||||
public function filterRiderListDP(pTestValue:String) {
|
||||
ridersListDP.filterFunction = function(rider:RiderVO):Bool {
|
||||
return StringTools.contains(rider.firstName, pTestValue);
|
||||
};
|
||||
//ridersListDP.refresh();
|
||||
dispatchEvent(new Event(AppModelLocator.RIDERS_LIST_DP_CHANGE));
|
||||
traceCyan(ridersListDP.length);
|
||||
}
|
||||
|
||||
// variable to store error messages from the httpservice
|
||||
// nothinng currently binds to it, but an Alert or the login box could to show startup errors
|
||||
public var errorStatus:String;
|
||||
|
||||
|
||||
// singleton: constructor only allows one model locator
|
||||
// singleton: constructor only allows one model locator
|
||||
public function new() {
|
||||
super();
|
||||
if (AppModelLocator.model != null) {
|
||||
@@ -95,5 +102,4 @@ class AppModelLocator extends EventDispatcher implements IModelLocator {
|
||||
public function addRider(pRider:RiderVO) {
|
||||
ridersListDP.add(pRider);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -17,7 +17,6 @@ class MainDrawer extends Drawer {
|
||||
|
||||
private var openDrawerButton:Button;
|
||||
private var closeDrawerButton:Button;
|
||||
private var coucou:Bool;
|
||||
|
||||
public function new() {
|
||||
super();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package view;
|
||||
|
||||
import openfl.events.Event;
|
||||
import feathers.controls.Panel;
|
||||
import feathers.controls.navigators.StackItem;
|
||||
import feathers.controls.navigators.StackNavigator;
|
||||
|
||||
@@ -149,7 +149,6 @@ class RiderCardDrawer extends Drawer {
|
||||
// this function will be exectuted when the user will click on the ConfirmationPanel's "confirm" button
|
||||
var f:Function = function() {
|
||||
trace("remove 1 credit to selected rider in model");
|
||||
// TODO remove 1 credit to selected rider in model
|
||||
model.selectedRider.credit--;
|
||||
}
|
||||
PopUpManager.addPopUp(new ConfirmationPanel(Strings.CP_S2, Strings.CP_S3, f), parent, true, true);
|
||||
@@ -197,7 +196,6 @@ class RiderCardDrawer extends Drawer {
|
||||
updateCreditUIElments(null, model.selectedRider.credit);
|
||||
Bind.bind(model.selectedRider.credit, updateCreditUIElments);
|
||||
|
||||
|
||||
openDrawer();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package view;
|
||||
|
||||
import feathers.data.ArrayCollection;
|
||||
import fuzzaldrin.Fuzzaldrin;
|
||||
import com.adobe.cairngorm.control.CairngormEventDispatcher;
|
||||
import components.RidersListRendererAccessory;
|
||||
@@ -23,9 +24,11 @@ import vo.RiderVO;
|
||||
class RidersList extends ListView {
|
||||
private var model = AppModelLocator.getInstance();
|
||||
private var rowHeight:Int;
|
||||
private var localRidersListDP:ArrayCollection<RiderVO>;
|
||||
|
||||
public function new() {
|
||||
super();
|
||||
localRidersListDP = new ArrayCollection();
|
||||
addEventListener(FeathersEvent.CREATION_COMPLETE, onCreationComplete);
|
||||
//addEventListener(Event.CHANGE, onRiderSelect);
|
||||
addEventListener(ListViewEvent.ITEM_TRIGGER, onRiderSelect);
|
||||
@@ -84,7 +87,11 @@ class RidersList extends ListView {
|
||||
}
|
||||
|
||||
private function onRiderListDpChange(e:Event):Void {
|
||||
dataProvider = model.ridersListDP;
|
||||
|
||||
if(localRidersListDP.length > 0) localRidersListDP.removeAll();
|
||||
localRidersListDP.addAll(model.ridersListDP);
|
||||
dataProvider = localRidersListDP;
|
||||
//dataProvider = model.ridersListDP;
|
||||
|
||||
/*itemToText = function(item:Dynamic):String {
|
||||
return item.firstName;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package view;
|
||||
|
||||
import lime.app.Event;
|
||||
import model.Constants;
|
||||
import feathers.skins.RectangleSkin;
|
||||
import feathers.layout.VerticalLayoutData;
|
||||
@@ -9,6 +10,7 @@ import feathers.events.FeathersEvent;
|
||||
import feathers.layout.VerticalLayout;
|
||||
import feathers.controls.ScrollContainer;
|
||||
import t9.util.ColorTraces.*;
|
||||
import openfl.events.Event;
|
||||
|
||||
class RidersScreen extends ScrollContainer {
|
||||
|
||||
@@ -33,6 +35,8 @@ class RidersScreen extends ScrollContainer {
|
||||
var vld1 = new VerticalLayoutData();
|
||||
vld1.percentHeight = 10.0;
|
||||
tb.layoutData = vld1;
|
||||
// TODO implémenter le fuzzy search
|
||||
//addEventListener("ToolbarEvent", (e:Event) -> {traceRed(e);});
|
||||
addChild(tb);
|
||||
|
||||
rl = new RidersList();
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package view;
|
||||
|
||||
import model.AppModelLocator;
|
||||
import openfl.events.Event;
|
||||
import model.String.Strings;
|
||||
import ui.SVGIconFactory;
|
||||
import ui.LPTCTheme;
|
||||
@@ -51,6 +53,8 @@ class ToolBar extends LayoutGroup {
|
||||
searchTextInput.variant = LPTCTheme.TEXT_INPUT_VARIANT_SEARCH;
|
||||
searchTextInput.leftView = SVGIconFactory.makeIcon("vector/magnifier_icon_black.svg", Constants.FONT_SIZE_22, Constants.MAIN_COLOR3);
|
||||
searchTextInput.prompt = Strings.TB_S1;
|
||||
searchTextInput.addEventListener(Event.CHANGE, onTextInputChange);
|
||||
|
||||
addChild(searchTextInput);
|
||||
|
||||
//lbl1.layoutData = ld1;
|
||||
@@ -61,4 +65,10 @@ class ToolBar extends LayoutGroup {
|
||||
traceBlue(this + " --> onCreationComplete() - w: " + width + " h: " + height );
|
||||
}
|
||||
|
||||
private function onTextInputChange(e:Event) {
|
||||
var ti:TextInput = cast(e.currentTarget, TextInput);
|
||||
trace("text input change: " + ti.text);
|
||||
AppModelLocator.getInstance().filterRiderListDP(ti.text);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user