hackedteam/rcs-console

View on GitHub
src/it/ht/rcs/console/dashboard/view/AddToDashboardPopup.mxml

Summary

Maintainability
Test Coverage
<?xml version="1.0" encoding="utf-8"?>
<utils:TitleWindowSaveCancel 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:utils="it.ht.rcs.console.utils.*"
                             xmlns:itemfield="it.ht.rcs.console.utils.itemfield.*"
                             creationComplete="init()" showCancelButton="true"
                             showSaveButton="true" title="{R.get('ADD_TO_DASHBOARD')}" save="onSave()">
  
  <fx:Script>
    <![CDATA[
      import it.ht.rcs.console.dashboard.controller.DashboardController;
      import it.ht.rcs.console.utils.itemfield.ItemFieldEvent;
      
      import locale.R;
    
      
      private function init():void
      {
        searchInput.setFocus();
        saveButton.label=R.get('ADD');
        cancelButton.label=R.get('DONE');
        saveButton.enabled=false;
      }
      
      private function onSelectSearchItem(event:ItemFieldEvent):void
      {
        saveButton.enabled=searchInput.selectedItem!=null;
      }
      
      private function onChange():void
      {
       
        saveButton.enabled=searchInput.selectedItem!=null;
      }
      
      private function onSave():void
      {
        DashboardController.instance.newDashboardItem(searchInput.selectedItem._id);
      }
    ]]>
  </fx:Script>
  
  <s:VGroup horizontalAlign="center" paddingLeft="20" paddingRight="20" paddingTop="20">

    <itemfield:ItemField id="searchInput" width="220" itemSelected="onSelectSearchItem(event)"
                       kinds="{['operation', 'target', 'agent']}" change="onChange()"/>
    
  </s:VGroup>
  
</utils:TitleWindowSaveCancel>