Permalink
Browse files

finished mate version much better!

  • Loading branch information...
seanhess committed May 19, 2009
1 parent e7fdca6 commit c4f0606b9c4b309de1e652edfe77b6e94f04ab8a
@@ -6,42 +6,78 @@
]]>
</mx:Script>
+ <!-- You can put related commands in a separate file if you like. Pass in the references of the actual managers -->
+ <Command id="loadEmployees">
+ <Action watch="{employeesService}" call="employeesService.send()">
+ <result>
+ <Action call="scope.employees = parser.loadEmployeesFromXML(scope.event.result)"/>
+ <Action call="employeeManager.saveEmpoyeeList(scope.employees)"/>
+ </result>
+ </Action>
+ </Command>
+
<Command id="login" user="user" pass="pass">
<Action call="authManager.login(scope.user, scope.pass)"/>
<Action call="navManager.loginChanged(authManager.state)"/>
</Command>
+ <Command id="logout">
+ <Action call="authManager.logout()"/>
+ <Action call="navManager.loginChanged(authManager.state)"/>
+ </Command>
+
+ <Command id="newEmployee">
+ <Action call="navManager.showEmployee()"/>
+ <Action call="employeeManager.newEmployee()"/>
+ </Command>
+
+ <Command id="selectEmployee" employee="none">
+ <Action call="employeeManager.selectEmployee(scope.employee)"/>
+ <Action call="navManager.showEmployee()"/>
+ </Command>
+
+ <Command id="deleteEmployee">
+ <Action call="employeeManager.deleteEmployee()"/>
+ <Action call="navManager.goBack()"/>
+ </Command>
+
+ <Command id="saveEmployee" employee="none">
+ <Action call="employeeManager.saveEmployee(scope.employee)"/>
+ <Action call="navManager.goBack()"/>
+ </Command>
+
<!-- Manager -->
<manager:AuthorizationManager id="authManager" />
<manager:EmployeeManager id="employeeManager" />
<manager:NavigationManager id="navManager"/>
-
+
<!-- Views -->
<Glue match="MainUI">
<Inject selectedPage="{navManager.currentPage}"/>
- <!--<Route event="{FlexEvent.CREATION_COMPLETE}" call="employeeManager.loadEmployees()"/>-->
+ <Route event="{FlexEvent.CREATION_COMPLETE}" call="loadEmployees.execute()"/>
</Glue>
<Glue match="EmployeeLogin">
<Inject authState="{authManager.state}"/>
<Route event="login" call="login.execute({user:view.username, pass:view.password})"/>
</Glue>
- <!--<Glue match="EmployeeList">
- <Inject employees="{employees.employeeList}"/>
- <Route event="logout" call="authManager.logout()"/>
- <Route event="newEmployee" call="employeeManager.newEmployee()"/>
- <Route event="selectEmployee" call="employeeManager.selectEmployee(scope.target.selectedEmployee)"/>
+ <Glue match="EmployeeList">
+ <Inject employees="{employeeManager.employeeList}"/>
+ <Route event="logout" call="logout.execute()"/>
+ <Route event="newEmployee" call="newEmployee.execute()"/>
+ <Route event="selectEmployee" call="selectEmployee.execute({employee:view.selectedEmployee})"/>
</Glue>
<Glue match="EmployeeDetail">
- <Inject selectedEmployee="{employees.employee}"/>
- <Route event="back" call="employeeManager.goBack()"/>
- <Route event="remove" call="employeeManager.deleteEmployee(employees.employee)"/>
- <Route event="save" call="employeeManager.saveEmployee(view.tempEmployee)"/>
- </Glue>-->
+ <Inject selectedEmployee="{employeeManager.employee}"/>
+ <Route event="back" call="navManager.goBack()"/>
+ <Route event="remove" call="deleteEmployee.execute()"/>
+ <Route event="save" call="saveEmployee.execute({employee:view.tempEmployee})"/>
+ </Glue>
<!-- Services :: Put these in another file -->
<mx:HTTPService id="employeesService" url="assets/data/Employees.xml" resultFormat="e4x" />
+ <service:EmployeeParser id="parser"/>
</GlueMap>
@@ -44,13 +44,23 @@ package cafe.manager
}
// -----------------------------------------------------------
- public function deleteEmployee (employee:Employee) : void {
+ public function deleteEmployee () : void {
_employeeList.removeItemAt(_employeeList.getItemIndex(employee));
// clear out the selected employee just in case
selectEmployee(null);
}
+
+ public function newEmployee():void
+ {
+ var employee:Employee = new Employee();
+ employee.firstname = "";
+ employee.lastname = "";
+
+ saveEmployee(employee);
+ selectEmployee(employee);
+ }
// -----------------------------------------------------------
public function saveEmployee (employee:Employee) : void {
@@ -12,5 +12,15 @@ package cafe.manager
{
currentPage = (state == Authentication.AUTHENTICATED) ? Navigation.LIST : Navigation.LOGIN;
}
+
+ public function showEmployee():void
+ {
+ currentPage = Navigation.DETAILS;
+ }
+
+ public function goBack():void
+ {
+ currentPage = Navigation.LIST;
+ }
}
}
@@ -1,6 +1,6 @@
package cafe.service
{
- import com.cafetownsend.vos.Employee;
+ import cafe.vo.Employee;
public class EmployeeParser
{
View
Binary file not shown.
@@ -16,7 +16,7 @@ package net.seanhess.glue.tags
protected var dispatcher:IEventDispatcher = new EventDispatcher();
protected var listeners:Dictionary = new Dictionary();
- public function execute():void
+ public function execute():void
{
addListeners();
dispatchEvent(new Event("call"));

0 comments on commit c4f0606

Please sign in to comment.