hackedteam/rcs-console

View on GitHub
src/it/ht/rcs/console/entities/view/EntityActionBar.mxml

Summary

Maintainability
Test Coverage
<?xml version="1.0" encoding="utf-8"?>
<actionbar:ActionBar 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:actionbar="it.ht.rcs.console.main.actionbar.*"
                                         xmlns:view="it.ht.rcs.console.entities.view.*">

    <fx:Metadata>
    [Event(name="update", type="flash.events.Event")]
    [Event(name="edit", type="flash.events.Event")]
    [Event(name="popupclose", type="flash.events.Event")]
  </fx:Metadata>
    <s:Button label="{R.get('EDIT')}"
                        icon="@Embed('/img/NEW/edit.png')"
                        click="onEditClick()"
                        enabled="{Console.currentSession.user.is_view_profiles()}"/>
    <!--
        <s:Button label="{R.get('DELETE')}"
                            icon="@Embed('/img/NEW/delete_32.png')"/>-->


    <actionbar:Separator visible="{entity.type=='target'}"
                       includeInLayout="{entity.type=='target'}"/>
    <s:Button label="{R.get('JUMP_TO_TARGET')}"
                        click="onJumpClick()"
                        icon="@Embed('/img/NEW/jumpToTarget.png')"
                        visible="{entity.type=='target'}"
                        includeInLayout="{entity.type=='target'}"/>
  <actionbar:Separator visible="{LicenseManager.instance.intelligence}"
                       includeInLayout="{LicenseManager.instance.intelligence}"/>
  <s:Button label="{R.get('EXPORT')}"
            icon="@Embed('/img/NEW/export.png')"
            visible="{LicenseManager.instance.intelligence}" click="exportEntity(event)"
            includeInLayout="{LicenseManager.instance.intelligence}"
            enabled="{Console.currentSession.user.is_view_profiles()}"/>
    <s:Spacer width="100%"/>

    <fx:Script>
        <![CDATA[
            import it.ht.rcs.console.dashboard.controller.DashboardController;
            import it.ht.rcs.console.entities.controller.EntityManager;
            import it.ht.rcs.console.entities.model.Entity;
            import it.ht.rcs.console.events.SectionEvent;
            import it.ht.rcs.console.monitor.controller.LicenseManager;
            import it.ht.rcs.console.search.controller.SearchManager;
            import it.ht.rcs.console.utils.AlertPopUp;
            
            import locale.R;
            
            import mx.core.FlexGlobals;
            import mx.events.CloseEvent;
            import mx.managers.PopUpManager;

            [Bindable]
            public var section:EntitiesSection;

            [Bindable]
            public var entity:Entity;

            [Bindable]
            public var sheet:EntitySheet;

            private function onNewClick():void
            {

            }

            private function onEditClick():void
            {
        dispatchEvent(new Event("edit"))
                var popup:EntityForm=PopUpManager.createPopUp(FlexGlobals.topLevelApplication as DisplayObject, EntityForm, true) as EntityForm;
                popup.addEventListener("update", onUpdate)
        popup.addEventListener("close", onClose)
                popup.entity=entity;
                popup.entity.desc=sheet.entity.desc;
                popup.currentState=EntityForm.EDIT
                PopUpManager.centerPopUp(popup);
            }

            private function onJumpClick():void
            {
                var event:SectionEvent=new SectionEvent(SectionEvent.CHANGE_SECTION);
                event.section=SectionEvent.OPERATIONS;
                event.subsection='target';

                var targetId:String=entity.path[entity.path.length - 1];
                event.item=SearchManager.instance.getItem(targetId);
                FlexGlobals.topLevelApplication.dispatchEvent(event);
            }

            private function onUpdate(e:Event):void
            {
                entity.name=e.currentTarget.entity.name;
                entity.desc=e.currentTarget.entity.desc;
                dispatchEvent(e)
            }

            private function onDeleteClick():void
            {

            }

            private function onClose(e:Event):void
            {
        dispatchEvent(new Event("popupclose"))
            }
      
      private function exportEntity(event:MouseEvent):void
      {
        var popup:EntityExport=PopUpManager.createPopUp(root, EntityExport, true) as EntityExport;
        popup.operation=section.stateManager.selectedOperation;
        popup.type="entity"
        var ids:Array=[entity._id];
        popup.ids=ids
        PopUpManager.centerPopUp(popup);
      }

            private function onRemovedFromStage():void
            {
                //section.stateManager.view.refresh();
                //section.stateManager.tableView.refresh();
            }
        ]]>
    </fx:Script>

</actionbar:ActionBar>