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