Fuzzy search on Toolbar.searchTextInput
This commit is contained in:
@@ -10,7 +10,6 @@ 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";
|
||||
@@ -72,11 +71,19 @@ class AppModelLocator extends EventDispatcher implements IModelLocator {
|
||||
return ridersListDP;
|
||||
}
|
||||
|
||||
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
|
||||
public function new() {
|
||||
super();
|
||||
@@ -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