src/it/ht/rcs/console/home/view/HomeSection.mxml
<?xml version="1.0" encoding="utf-8"?>
<main:Section 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:itemfield="it.ht.rcs.console.utils.itemfield.*"
xmlns:main="it.ht.rcs.console.main.*"
xmlns:quick="it.ht.rcs.console.home.view.quick.*"
creationComplete="init()"
addedToStage="onAddedToStage()">
<fx:Script>
<![CDATA[
import it.ht.rcs.console.DB;
import it.ht.rcs.console.accounting.controller.UserManager;
import it.ht.rcs.console.accounting.model.User;
import it.ht.rcs.console.events.SectionEvent;
import it.ht.rcs.console.search.controller.SearchManager;
import it.ht.rcs.console.utils.itemfield.ItemFieldEvent;
import locale.R;
import mx.core.FlexGlobals;
[Bindable]
private var enable_items:Boolean;
[Bindable]
private var goto_kinds:Array;
private function init():void
{
if (recents)
recents.selectedItem=null;
if (Console.currentSession.user.is_any())
currentState='any';
else
currentState='none';
if (Console.currentSession.user.is_admin() || Console.currentSession.user.is_tech() || Console.currentSession.user.is_view())
UserManager.instance.show(Console.currentSession.user._id, refreshRecents);
enable_items=(Console.currentSession.user.is_admin() || Console.currentSession.user.is_tech() || Console.currentSession.user.is_view());
if (Console.currentSession.user.is_admin())
goto_kinds=['operation', 'target'];
if (Console.currentSession.user.is_tech() || Console.currentSession.user.is_view())
goto_kinds=['operation', 'target', 'factory', 'agent'];
if (Console.currentSession.user.is_view_profiles())
goto_kinds.push('entity');
if (Console.currentSession.user.is_sys())
goto_kinds=[];
}
private function refreshRecents(user:User):void
{
if (recents)
{
recents.dataProvider=null;
recents.dataProvider=user.recent_ids;
}
}
private function onGoTo(e:ItemFieldEvent):void
{
var event:SectionEvent=new SectionEvent(SectionEvent.CHANGE_SECTION);
if (e.selectedItem._kind == 'entity')
event.section='Intelligence';
else
event.section='Operations';
event.item=SearchManager.instance.getItem(e.selectedItem._id);
FlexGlobals.topLevelApplication.dispatchEvent(event);
}
protected function onAddedToStage():void
{
refreshRecents(Console.currentSession.user);
}
]]>
</fx:Script>
<main:states>
<s:State name="any"/>
<s:State name="none"/>
</main:states>
<s:Image width="100%"
height="100%"
horizontalAlign="right"
source="@Embed('/img/windows/sfondo_galileo.png')"
verticalAlign="bottom"
/>
<s:Image bottom="80" left="50"
source="@Embed('/img/windows/galileo_logo.png')" />
<s:Image right="10"
top="10"
alpha="0.6"
source="{DB.instance.demo ? '/img/logo.png' : DB.hostAutocomplete(Console.currentSession.server) + 'logo'}"/>
<!--<s:Image
top="10"
left="10"
alpha="0.8"
source="{DB.instance.demo ? '/img/logo_area_ht.png' : DB.hostAutocomplete(Console.currentSession.server) + 'logo'}"/>
-->
<s:VGroup includeIn="any"
width="100%"
height="100%"
gap="80"
horizontalAlign="center"
verticalAlign="middle">
<s:BorderContainer borderColor="#E3E6EC"
borderWeight="2"
cornerRadius="20"
visible="{Console.currentSession.user.is_admin() || Console.currentSession.user.is_tech() || Console.currentSession.user.is_view()}">
<s:Rect width="100%"
height="100%"
radiusX="20"
radiusY="20">
<s:fill>
<s:LinearGradient rotation="90">
<s:GradientEntry color="#E3E6EC"/>
<s:GradientEntry color="#ffffff"/>
<s:GradientEntry color="#ffffff"/>
</s:LinearGradient>
</s:fill>
</s:Rect>
<s:VGroup gap="10"
horizontalAlign="center"
paddingBottom="20"
paddingLeft="20"
paddingRight="20"
paddingTop="20">
<s:HGroup gap="15"
verticalAlign="middle">
<s:Label fontFamily="Myriad"
fontSize="16"
fontWeight="bold"
paddingTop="2"
text="{R.get('GO_TO')}"/>
<itemfield:ItemField id="goTo"
width="300"
itemSelected="onGoTo(event)"
kinds="{goto_kinds}"/>
</s:HGroup>
<s:Label fontFamily="Myriad"
fontSize="16"
fontWeight="bold"
paddingTop="20"
text="{R.get('RECENT_ITEMS')}"/>
<s:List id="recents"
width="330"
height="100%"
borderVisible="false"
contentBackgroundAlpha="0"
itemRenderer="it.ht.rcs.console.home.view.RecentItemsRenderer"/>
</s:VGroup>
</s:BorderContainer>
<quick:QuickButtons/>
</s:VGroup>
</main:Section>