<textarea cols="50" rows="15" name="code" class="c-sharp"><?xml version="1.0" encoding="utf-8"?> <mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:tenant="dps.component.tenant.*" width="100%" height="100%" headerHeight="0" initialize="init()"> <mx:Script source="../../../DPSImage.as"/> <mx:Script> <!--[CDATA[ import mx.events.EffectEvent; import mx.effects.Fade; import mx.events.DynamicEvent; import dps.model.GlobalEmployeeEntityBean; import dps.model.GlobalTenantEntityBean; import dps.control.TenantControl; import mx.collections.ArrayCollection; import mx.managers.PopUpManager; import mx.controls.Alert; import mx.core.Application; import dps.core.util.DateUtil; [Bindable] private var tenantInfo:ArrayCollection = new ArrayCollection( ); private var isPendingView:Boolean = true; public function init():void { TenantControl.getInstance().getTenantList(callback); function callback(data:ArrayCollection):void { tenantInfo = data; } } public function editTenant(data:GlobalTenantEntityBean):void { var addTenant:TenantAddView = TenantAddView(PopUpManager.createPopUp(Application.application as DisplayObject,TenantAddView,true)); addTenant.globalTenantEntityBean = data as GlobalTenantEntityBean; addTenant.addEventListener("UPDATE",refresh) PopUpManager.centerPopUp(addTenant); } public function refresh(event:DynamicEvent=null):void { init(); } private function tpLabelFunction(item:Object, column:DataGridColumn):String { var globalTenantEntityBean:GlobalTenantEntityBean = item as GlobalTenantEntityBean; var strTp:String = ""; if(globalTenantEntityBean.topManagers != null){ for(var j:int = 0; j<globalTenantEntityBean.topManagers.length; j++){ strTp += GlobalEmployeeEntityBean((globalTenantEntityBean.topManagers)[j]).notesId + ','; } return strTp.substr(0,strTp.length-1); }else{ return ""; } } private function taLabelFunction(item:Object, column:DataGridColumn):String { var globalTenantEntityBean:GlobalTenantEntityBean = item as GlobalTenantEntityBean; var strTa:String = ""; if(globalTenantEntityBean.tenantAdmins != null){ for(var k:int = 0; k<globalTenantEntityBean.tenantAdmins.length; k++){ strTa += GlobalEmployeeEntityBean((globalTenantEntityBean.tenantAdmins)[k]).notesId + ','; } return strTa.substr(0,strTa.length-1); }else{ return ""; } } private function labelFunction(item:Object, column:DataGridColumn):String { var globalTenantEntityBean:GlobalTenantEntityBean = item as GlobalTenantEntityBean; var strTa:String = ""; if(globalTenantEntityBean.contractStartDate != null&&globalTenantEntityBean.contractEndDate!=null) { strTa = globalTenantEntityBean.contractStartDate+"~"+globalTenantEntityBean.contractEndDate; return strTa.substr(0,strTa.length-1); }else{ return ""; } } public function changeViewClick():void { if(isPendingView) { lbl.text = "Role Management"; link.label = "Tenant Management"; } else { lbl.text = "Tenant Management"; link.label = "Role Management"; } changeView(); } public function changeView():void { var fa:Fade = new Fade(); if(isPendingView) { fa.target = tenantV; } else { fa.target = roleV; } fa.alphaTo = 0; fa.addEventListener(EffectEvent.EFFECT_END,effectEndFunction); fa.play(); function effectEndFunction(evt:EffectEvent):void { var fade:Fade = new Fade(); if(isPendingView) { tenantV.visible = false; tenantV.setStyle("alpha",0); fade.target = roleV; roleV.visible = true; } else { roleV.visible = false; roleV.setStyle("alpha",0); fade.target = tenantV; tenantV.visible = true; } isPendingView = !isPendingView; fade.alphaFrom = 0; fade.alphaTo = 1; fade.play(); } } ]]> </mx:Script> <mx:Canvas width="100%" height="100%"> <mx:Canvas width="100%" height="100%"> <mx:Panel width="100%" height="100%"> <mx:DataGrid id="tenantV" width="100%" height="100%" dataProvider="{tenantInfo}"> <mx:columns> <mx:DataGridColumn headerText="Tenant Name" dataField="tanentName"/> <mx:DataGridColumn headerText="Top Manager" labelFunction="tpLabelFunction" /> <mx:DataGridColumn headerText="Tenant Admin" labelFunction="taLabelFunction"/> <mx:DataGridColumn headerText="Package" dataField="rentFuncPacks" /> <mx:DataGridColumn headerText="Contract Period" labelFunction="labelFunction"/> <mx:DataGridColumn headerText="Tenant Status" dataField="tenantStatus"/> <mx:DataGridColumn headerText="Description" dataField="description" sortable="false"/> <mx:DataGridColumn width="60"> <mx:itemRenderer> <mx:Component> <mx:HBox horizontalAlign="center" verticalAlign="middle" width="100%" height="100%"> <mx:Script source="../../../DPSImage.as"/> <mx:Script> <![CDATA[ import dps.model.GlobalTenantEntityBean; import mx.events.DynamicEvent; import mx.managers.PopUpManager; import mx.core.Application; import dps.constant.Globalization; private function editItem(evt:MouseEvent):void { (outerDocument as TenantView).editTenant(data as GlobalTenantEntityBean); /*var addTenant:TenantAddView = TenantAddView(PopUpManager.createPopUp(Application.application as DisplayObject,TenantAddView,true)); addTenant.globalTenantEntityBean = data as GlobalTenantEntityBean; PopUpManager.centerPopUp(addTenant);*/ } ]]--> </mx:Script> <mx:Image source="{editIcon}" buttonMode="true" toolTip="{Globalization.EDIT}" click="editItem(event)"/> </mx:HBox> </mx:Component> </mx:itemRenderer> </mx:DataGridColumn> </mx:columns> </mx:DataGrid> </mx:Panel> <tenant:RoleManagementView width="100%" height="100%" visible="false" id="roleV"/> </mx:Canvas> <mx:HBox width="100%" verticalAlign="middle" borderStyle="solid" cornerRadius="5" height="30" backgroundColor="#FEE6AD" paddingLeft="5" paddingRight="5"> <mx:Label text="Tenant Management" fontWeight="bold" id="lbl" width="130"/> <mx:VRule height="20"/> <mx:LinkButton label="Role Management" id="link" styleName="blueLink" click="changeViewClick()"/> <mx:Spacer width="100%"/> </mx:HBox> </mx:Canvas> </mx:Panel></textarea>