ilscipio/scipio-erp

View on GitHub
applications/marketing/widget/CommonScreens.xml

Summary

Maintainability
Test Coverage
<?xml version="1.0" encoding="UTF-8"?>
<!--
This file is subject to the terms and conditions defined in the
files 'LICENSE' and 'NOTICE', which are part of this source
code package.
-->

<screens xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/widget-screen.xsd">
        
    <!-- SCIPIO: Common settings for other *Screens.xml files in this app that primarily use decorators referenced using parameters.mainDecoratorLocation -->
    <screen-settings name="common-settings"><!-- all settings are currently valid/needed for this file as well, so omit: active="false" -->
        <decorator-screen-settings default-fallback-location="component://marketing/widget/CommonScreens.xml"/>
    </screen-settings>
        
    <!-- SCIPIO: The settings for this file (active) -->
    <screen-settings name="local-settings">
        <!-- These settings are automatically included in all *Screens.xml files in the same folder as this CommonScreens.xml file or any subfolder without its own CommonScreens.xml -->
        <auto-include-settings>
            <include-settings as-name="local-settings" name="common-settings" location="component://marketing/widget/CommonScreens.xml"/>
        </auto-include-settings>
    </screen-settings>
        
    <!-- SCIPIO: Actions automatically included at beginning of every render request, for our webapp (discovered via web.xml, mainDecoratorLocation) -->
    <screen name="webapp-common-actions">
        <actions>
            <!-- Make the main side bar name/location available to all (without need for globals) -->
            <include-screen-actions name="MainSideBarMenu"/>
            <set field="mainSideBarMenuCfg" from-field="menuCfg"/>
            <set field="mainComplexMenuCfg" from-field="menuCfg"/>
            <set field="menuCfg" value=""/>
        </actions>
    </screen>
        
    <screen name="main-decorator">
        <section>
            <actions>
                <!-- base/top/specific map first, then more common map added for shared labels -->
                <property-map resource="MarketingUiLabels" map-name="uiLabelMap" global="true"/>
                <property-map resource="PartyUiLabels" map-name="uiLabelMap" global="true"/>
                <property-map resource="ProductUiLabels" map-name="uiLabelMap" global="true"/>
                <property-map resource="CommonUiLabels" map-name="uiLabelMap" global="true"/>

                <set field="layoutSettings.companyName" from-field="uiLabelMap.MarketingCompanyName" global="true"/>
                <set field="layoutSettings.companySubtitle" from-field="uiLabelMap.MarketingCompanySubtitle" global="true"/>
                <!-- layoutSettings.headerImageUrl can be used to specify an application specific logo; if not set,
                     then the global layoutSettings.commonHeaderImageUrl (specified in GlobalDecorator) will be used. -->
                <!--<set field="layoutSettings.headerImageUrl" value="/images/ofbiz_logo.gif" global="true"/>-->
                <!-- <set field="layoutSettings.headerMiddleBackgroundUrl" value="" global="true"/> -->
                <!-- <set field="layoutSettings.headerRightBackgroundUrl" value="" global="true"/> -->
                <set field="activeApp" value="marketing" global="true"/>
                <set field="applicationTitle" from-field="uiLabelMap.MarketingManagerApplication" global="true"/>
                <set field="applicationMenuName" value="MarketingAppBar" global="true"/>
                <set field="applicationMenuLocation" value="component://marketing/widget/MarketingMenus.xml" global="true"/>
                
                <!-- SCIPIO: This uses activeSubMenu/activeSubMenuItem to automatically determine activeMainMenuItem -->
                <set field="menuCfg" from-field="mainComplexMenuCfg"/>
                <include-screen-actions name="DeriveComplexSideBarMenuItems" location="component://common/widget/CommonScreens.xml"/>
            </actions>
            <widgets>
                <decorator-screen name="ApplicationDecorator" location="component://commonext/widget/CommonScreens.xml">
                    <decorator-section name="left-column" use-when="${context.widePage != true}"> <!-- override-by-auto-include="true" -->
                        <section>
                            <condition>
                                <not><if-empty-section section-name="left-column" /></not>
                            </condition>
                            <widgets>
                                <decorator-section-include name="left-column"/>
                            </widgets>
                            <fail-widgets>
                                <!-- provide default column for all others -->
                                <include-screen name="DefMainSideBarMenu" location="${parameters.mainDecoratorLocation}"/>
                            </fail-widgets>
                        </section>
                    </decorator-section>
                    <decorator-section name="body">
                        <decorator-section-include name="body"/>
                    </decorator-section>
                </decorator-screen>
            </widgets>
        </section>
    </screen>

    <!-- SCIPIO: App-wide common decorator, wrapper around main-decorator; expected to have globally unique name. See Admin app CommonScreens.xml for more info. -->
    <screen name="CommonMarketingAppDecorator">
        <section>
            <actions>
                <condition-to-field field="commonMarketingAppBasePermCond" type="Boolean" only-if-field="empty">
                    <!-- do check for MARKETING, _VIEW permission -->
                    <if-has-permission permission="MARKETING" action="_VIEW"/>
                </condition-to-field>
            </actions>
            <widgets>
                <decorator-screen name="main-decorator" location="${parameters.mainDecoratorLocation}">
                    <decorator-section name="left-column" use-when="${context.widePage != true}" override-by-auto-include="true">
                        <include-screen name="CommonMarketingAppSideBarMenu"/>
                    </decorator-section>
                    <decorator-section name="body">
                        <section>
                            <condition>
                                <if-true field="commonMarketingAppBasePermCond"/>
                            </condition>
                            <widgets>
                                <decorator-section-include name="body"/>
                            </widgets>
                            <fail-widgets>
                                <label style="common-msg-error-perm">${uiLabelMap.MarketingViewPermissionError}</label>
                            </fail-widgets>
                        </section>
                    </decorator-section>
                </decorator-screen>
            </widgets>
        </section>
    </screen>

    <screen name="CommonContactListDecorator">
        <section>
            <actions>
                <set field="activeSubMenu" from-field="activeSubMenu" default-value="component://marketing/widget/ContactListMenus.xml#ContactList" />
                <property-map resource="MarketingUiLabels" map-name="uiLabelMap" global="true"/>
                <set field="activeSubMenuItem" from-field="activeSubMenuItem" default-value="ContactList"/>
                <set field="contactListId" from-field="parameters.contactListId"/>
                <entity-one entity-name="ContactList" value-field="contactList"/>
                
                <set field="commonSideBarMenu.condList[]" type="Boolean" value="${not empty context.contactListId}"/>
            </actions>
            <widgets>
                <decorator-screen name="CommonMarketingAppDecorator" location="${parameters.mainDecoratorLocation}">
                    <decorator-section name="body">
                        <section>
                            <condition><not><if-empty field="contactListId"/></not></condition>
                            <widgets>
                                <label style="heading">${uiLabelMap.MarketingContactList} ${contactList.contactListName} [${contactListId}]</label>
                            </widgets>
                        </section>
                        <decorator-section-include name="body"/>
                    </decorator-section>
                </decorator-screen>
            </widgets>
        </section>
    </screen>
    <screen name="main">
        <section>
            <actions>
                <set field="activeSubMenuItem" value="main"/>
                <set field="title" value="${uiLabelMap.MarketingManagerApplication}"/>
                <set field="titleProperty" value="Marketing"/>
            </actions>
            <widgets>
                <decorator-screen name="CommonMarketingAppDecorator" location="${parameters.mainDecoratorLocation}">
                    <decorator-section name="body">
                        <container style="${styles.grid_row}">
                            <container style="${styles.grid_large}4 ${styles.grid_cell}">
                                <include-screen name="DashboardStatsOrderTotalDay" location="component://order/widget/ordermgr/CommonWidgets.xml"/>
                            </container>
                            <container style="${styles.grid_large}4 ${styles.grid_cell}">
                                <include-screen name="BestSellingProducts" location="component://product/widget/catalog/ProductScreens.xml"/>
                            </container>
                            <container style="${styles.grid_large}4 ${styles.grid_cell}">
                                <include-screen name="ScipioNewRegistrations" location="component://party/widget/partymgr/CommonScreens.xml"/>
                            </container>
                        </container>
                        <container style="${styles.grid_row}">
                            <container style="${styles.grid_large}6 ${styles.grid_cell}">
                                <include-screen name="ScipioLastCommunication" location="component://party/widget/partymgr/CommonScreens.xml"/>
                            </container>
                            <container style="${styles.grid_large}6 ${styles.grid_cell}">
                                <include-screen name="ScipioMarketingCampaigns"/>
                            </container>
                        </container>
                    </decorator-section>
                </decorator-screen>
            </widgets>
        </section>
    </screen>
    
    <!-- SCIPIO: Widget implementation -->
    <screen name="ScipioMarketingCampaigns">
        <section>
            <actions>
                <set field="marketingCampaignId" from-field="parameters.marketingCampaignId" />
                <set field="entityName" value="MarketingCampaign" />
                <set field="showActionButtons" value="N" />
            </actions>
            <widgets>
                <section>
                    <condition>
                        <not>
                            <if-empty field="entityName"/>
                        </not>
                    </condition>
                    <widgets>
                        <screenlet title="${uiLabelMap.PageTitleListMarketingCampaign}">                            
                            <include-screen name="MarketingCampaignSearchResults" location="component://marketing/widget/MarketingCampaignScreens.xml"/>
                        </screenlet>
                    </widgets>
                </section>                        
            </widgets>
        </section>
    </screen>

    <!-- SCIPIO: Main SideBar Menu (see component://common/widget/CommonScreens.xml#ComplexSideBarMenu for available arguments and Admin app CommonScreens.xml for more info) -->
    <screen name="MainSideBarMenu">
        <section>
            <actions>
                <set field="menuCfg.location" value="component://marketing/widget/MarketingMenus.xml"/>
                <set field="menuCfg.name" value="MarketingAppSideBar"/>
                <set field="menuCfg.defLocation" value="component://marketing/widget/MarketingMenus.xml"/>
            </actions>
            <widgets>
                <include-screen location="component://common/widget/CommonScreens.xml" name="ComplexSideBarMenu"/>
            </widgets>
        </section>
    </screen>
    
    <!-- SCIPIO: Default Main SideBar Menu, version of MainSideBarMenu that disregards screen's selected/active sub-menu -->
    <screen name="DefMainSideBarMenu">
        <section>
            <actions>
                <script location="component://common/webcommon/WEB-INF/actions/includes/scipio/PrepareDefComplexSideBarMenu.groovy"/>
            </actions>
            <widgets>
                <include-screen name="MainSideBarMenu"/>
            </widgets>
        </section>
    </screen>
    
    <!-- SCIPIO: Common SideBar Menu inclusion logic, for/from Common*AppDecorator, with application-specific logic 
        (see component://common/widget/CommonScreens.xml#CommonSideBarMenu for available arguments and Admin app CommonScreens.xml for more info) -->
    <screen name="CommonMarketingAppSideBarMenu">
        <section>
            <actions>
                <condition-to-field field="commonMarketingAppBasePermCond" type="Boolean" only-if-field="empty">
                    <if-has-permission permission="MARKETING" action="_VIEW"/>
                </condition-to-field>
                <set field="commonSideBarMenu.cond" from-field="commonSideBarMenu.cond" type="Boolean" default-value="${commonMarketingAppBasePermCond}"/>
            </actions>
            <widgets>
                <include-screen name="CommonSideBarMenu" location="component://common/widget/CommonScreens.xml"/>
            </widgets>
        </section>
    </screen>
    
</screens>