hackedteam/rcs-console

View on GitHub
src/it/ht/rcs/console/operations/view/agents/AgentsView.mxml

Summary

Maintainability
Test Coverage
<?xml version="1.0" encoding="utf-8"?>
<s:VGroup xmlns:fx="http://ns.adobe.com/mxml/2009"
          xmlns:s="library://ns.adobe.com/flex/spark"
          xmlns:mx="library://ns.adobe.com/flex/mx"
          xmlns:agents="it.ht.rcs.console.operations.view.agents.*"
          xmlns:view="it.ht.rcs.console.operations.view.*"
          width="100%" height="100%" 
          addedToStage="onAddeToStage(event)" 
          removedFromStage="onRemovedFromStage(event)">

  <fx:Script>
    <![CDATA[
      import it.ht.rcs.console.agent.controller.AgentManager;
      import it.ht.rcs.console.operations.view.OperationsSection;
      
      import locale.R;
      
      [Bindable]
      public var section:OperationsSection;
      
      private function onDoubleClick(event:MouseEvent):void
      {
        var item:* = event.currentTarget === list ? list.selectedItem : grid.selectedItem;
        if (item) {
          if(item._kind == 'factory' && item.status!="open")
            return;
          section.stateManager.manageItemSelection(item);
        };
      }
      
      private function onKeyUp(event:KeyboardEvent):void
      {
        if (event.keyCode == Keyboard.ENTER) {
          var item:* = event.currentTarget === list ? list.selectedItem : grid.selectedItem;
          if (item) {
            if(item._kind == 'factory' && item.status!="open")
              return;
            section.stateManager.manageItemSelection(item);
          };
        }
      }
      
      protected function onAddeToStage(event:Event):void
      {
        AgentManager.instance.refresh();
        AgentManager.instance.listenAgentPush();
        AgentManager.instance.listenFactoryPush()
        
      }
      
      protected function onRemovedFromStage(event:Event):void
      {
        AgentManager.instance.unlistenAgentPush()
        AgentManager.instance.unlistenFactoryPush()
      }
    ]]>
  </fx:Script>
  
  
  <agents:AgentsActionBar section="{section}" selectedObject="{list.selectedItem}" viewStack="{views}"/>
  
  
  <mx:ViewStack id="views" width="100%" height="100%" creationPolicy="all">
    <s:NavigatorContent label="{R.get('ICON_VIEW')}" hideEffect="{fadeOut}"
                        icon="@Embed('/img/windows/icon.png')" showEffect="{fadeIn}">
      
      <s:HGroup width="100%" height="100%" gap="5">
        
        <view:BaseList id="list" dataProvider="{section.stateManager.view}" selectedItem="{grid.selectedItem}" section="{section}"
                       doubleClick="onDoubleClick(event)" keyUp="onKeyUp(event)"/>
        
        <agents:AgentsInfoPanel selectedItem="{section.stateManager.selectedAgent?section.stateManager.selectedAgent : list.selectedItem}" section="{section}" showDetails="{list.selectedItem || section.currentState == 'singleAgent'}"/>
        
      </s:HGroup>
      
    </s:NavigatorContent>
    <s:NavigatorContent label="{R.get('TABLE_VIEW')}" hideEffect="{fadeOut}"
                        icon="@Embed('/img/windows/list.png')" showEffect="{fadeIn}">
      
      
      <agents:AgentsGrid id="grid" dataProvider="{section.stateManager.tableView}" selectedItem="{list.selectedItem}"
                         doubleClick="onDoubleClick(event)" keyUp="onKeyUp(event)"/>
      
      
    </s:NavigatorContent>
  </mx:ViewStack>

  <fx:Declarations>
    <s:Fade id="fadeIn" alphaFrom="0" alphaTo="1" duration="150"/>
    <s:Fade id="fadeOut" alphaFrom="1" alphaTo="0" duration="150"/>
  </fx:Declarations>
    
</s:VGroup>