blob: bdaae998c4314d7867aeccada2984fd8d9f49264 [file] [log] [blame]
<?xml version="1.0" encoding="utf-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:valueObjects="valueObjects.*"
xmlns:employeeservice="services.employeeservice.*"
title="Add Employee" add="view1_addHandler(event)">
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
import mx.rpc.events.ResultEvent;
protected function saveBtn_clickHandler(event:MouseEvent):void
{
if(currentState=="Add")
{
createEmployeeResult.token = employeeService.createEmployee(employee);
}
else
{
updateEmployeeResult.token = employeeService.updateEmployee(employee);
}
}
protected function createEmployeeResult_resultHandler(event:ResultEvent):void
{
navigator.replaceView(DetailView,event.result as int);
}
protected function cancelBtn_clickHandler(event:MouseEvent):void
{
navigator.popView();
}
protected function view1_addHandler(event:FlexEvent):void
{
if(data==null)
{
currentState="Add";
}
else
{
currentState="Edit";
employee=data as Employee;
title="Edit Employee";
}
}
protected function updateEmployeeResult_resultHandler(event:ResultEvent):void
{
navigator.popView();
}
]]>
</fx:Script>
<s:states>
<s:State name="Add"/>
<s:State name="Edit"/>
</s:states>
<fx:Declarations>
<valueObjects:Employee id="employee"/>
<s:CallResponder id="createEmployeeResult" result="createEmployeeResult_resultHandler(event)"/>
<employeeservice:EmployeeService id="employeeService"/>
<s:CallResponder id="updateEmployeeResult" result="updateEmployeeResult_resultHandler(event)"/>
</fx:Declarations>
<s:Scroller left="0" right="0" top="0" bottom="{saveBtn.height+10}">
<s:VGroup width="100%" gap="10" paddingLeft="15" paddingRight="15">
<s:Label fontWeight="bold" text="First Name" paddingTop="15"/>
<s:TextInput width="100%" text="@{employee.firstname}"/>
<s:Label fontWeight="bold" text="Last Name" paddingTop="15"/>
<s:TextInput width="100%" text="@{employee.lastname}"/>
<s:Label fontWeight="bold" text="Title" paddingTop="15"/>
<s:TextInput width="100%" text="@{employee.title}"/>
<s:Label fontWeight="bold" text="Cell Phone" paddingTop="15"/>
<s:TextInput width="100%" text="@{employee.cellphone}"/>
<s:Label fontWeight="bold" text="Office Phone" paddingTop="15"/>
<s:TextInput width="100%" text="@{employee.officephone}"/>
<s:Label fontWeight="bold" text="Email" paddingTop="15"/>
<s:TextInput width="100%" text="@{employee.email}"/>
<s:Label fontWeight="bold" text="Office" paddingTop="15"/>
<s:TextInput width="100%" text="@{employee.office}"/>
<s:Label fontWeight="bold" text="Street" paddingTop="15"/>
<s:TextInput width="100%" text="@{employee.street}"/>
<s:Label fontWeight="bold" text="City" paddingTop="15"/>
<s:TextInput width="100%" text="@{employee.city}"/>
<s:Label fontWeight="bold" text="State" paddingTop="15"/>
<s:TextInput width="100%" text="@{employee.state}"/>
<s:Label fontWeight="bold" text="Zipcode" paddingTop="15"/>
<s:TextInput width="100%" text="@{employee.zipcode}"/>
<s:Label fontWeight="bold" text="Photo File" paddingTop="15"/>
<s:TextInput width="100%" text="@{employee.photofile}"/>
</s:VGroup>
</s:Scroller>
<s:Button id="saveBtn" bottom="0" label="Save" horizontalCenter="{-saveBtn.width/2-10}"
click="saveBtn_clickHandler(event)">
<s:icon>
<s:MultiDPIBitmapSource source160dpi="@Embed('assets/save160.png')"
source240dpi="@Embed('assets/save240.png')"
source320dpi="@Embed('assets/save320.png')"/>
</s:icon>
</s:Button>
<s:Button id="cancelBtn" label="Cancel" bottom="0" horizontalCenter="{cancelBtn.width/2+10}"
click="cancelBtn_clickHandler(event)">
<s:icon>
<s:MultiDPIBitmapSource source160dpi="@Embed('assets/cancel160.png')"
source240dpi="@Embed('assets/cancel240.png')"
source320dpi="@Embed('assets/cancel320.png')"/>
</s:icon>
</s:Button>
</s:View>