ilscipio/scipio-erp

View on GitHub
framework/resources/templates/shop-override/widget/CommonScreens.xml

Summary

Maintainability
Test Coverage
<?xml version="1.0" encoding="UTF-8"?>
<screens xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/widget-screen.xsd">

    <!-- SCIPIO: CommonScreens.xml for the application.
        For more information on the patterns herein, refer to the common screens and menu files of the Admin and Common apps,
        as well as the widget language definitions files (component://widget/dtd/widget-*.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" -->
        <!-- When a decorator-screen lookup fails to find a decorator using parameters.mainDecoratorLocation (or other), it will look in our file instead. This prevents extensibility issues. -->
        <decorator-screen-settings default-fallback-location="component://@component-name@/widget/CommonScreens.xml"/>
        <!-- Static (webapp-agnostic) auto-included actions: these actions will be included at start of render for all top-level screens we define, regardless of which webapp they're rendered through -->
        <render-init><local><actions><include-screen-actions name="static-common-actions" location="component://@component-name@/widget/CommonScreens.xml"/></actions></local></render-init>
    </screen-settings>
        
    <!-- SCIPIO: The settings for this file (active) (if the above are also active, they are merged together to provide effective settings for this file) -->
    <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 (through a special lookup by renderer) -->
        <auto-include-settings>
            <!-- Every *Screens.xml file in same folder should include our common-settings defined above -->
            <include-settings as-name="local-settings" name="common-settings" location="component://@component-name@/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) (webapp-aware auto-included actions) -->
    <screen name="webapp-common-actions">
        <actions>
        </actions>
    </screen>

    <!-- SCIPIO: Actions automatically included at beginning of the first local screen rendered in a request, regardless of webapp (static, webapp-agnostic auto-included actions) -->
    <screen name="static-common-actions">
        <actions>
        </actions>
    </screen>

    <!-- All actions for ShopDecorator. NOTE: does not include GlobalDecorator actions. -->
    <screen name="ThisShopActions">
        <actions>
            <!-- base/top/specific map first, then more common map added for shared labels -->
            <property-map resource="@component-resource-name@UiLabels" map-name="uiLabelMap" global="true"/>

            <set field="layoutSettings.companyName" from-field="layoutSettings.companyName" default-value="${uiLabelMap['@component-resource-name@CompanyName']}" global="true"/>

            <set field="shopSetupScriptLocation" from-field="shopSetupScriptLocation" default-value="component://@component-name@/webapp/@webapp-name@/WEB-INF/actions/ShopSetup.groovy" />
        </actions>
    </screen>

    <screen name="ShopActions">
        <actions>
            <include-screen-actions name="ThisShopActions"/>
            <include-screen-actions name="ShopActions" location="component://shop/widget/CommonScreens.xml"/>
        </actions>
    </screen>

    <screen name="ShopDecorator">
        <section>
            <actions>
                <include-screen-actions name="ThisShopActions"/>
            </actions>
            <widgets>
                <decorator-screen name="ShopDecorator" location="component://shop/widget/CommonScreens.xml">
                </decorator-screen>
            </widgets>
        </section>
    </screen>

    <!-- SCIPIO: duplicated component://shop/widget/CommonScreens.xml#main-decorator -->
    <screen name="main-decorator">
        <section>
            <actions>
                <!-- Scipio: NOTE: Here we set defaults in the parameters maps. It is okay because it is run once
                    for the main request, but other screens with local scopes should usually set context vars instead (which have priority) -->
                <set field="parameters.VIEW_SIZE" from-field="parameters.VIEW_SIZE" default-value="12"/> <!-- Number of items to be displayed on a page -->
                <set field="parameters.INDEX_SIZE" from-field="parameters.INDEX_SIZE" default-value="0"/> <!-- View index for a list of items-->
            </actions>
            <widgets>
                <decorator-screen name="ShopDecorator" location="${parameters.mainDecoratorLocation}">
                    <decorator-section name="pre-content">
                        <container style="${styles.grid_row} ${styles.grid_theme_pre}" id="pre-content-section">
                            <decorator-section-include name="pre-content"/>
                        </container>
                    </decorator-section>
                    <decorator-section name="left-column" use-when="${context.widePage != true}" override-by-auto-include="true">
                        <include-screen name="leftbar"/>
                    </decorator-section>
                    <decorator-section name="pre-body" >
                        <decorator-section-include name="pre-body"/>
                    </decorator-section>
                    <decorator-section name="body" >
                        <section>
                            <condition>
                                <not><if-empty field="globalContext.productStore"/></not>
                            </condition>
                            <actions>
                            </actions>
                            <widgets>
                                <decorator-section-include name="body"/>
                            </widgets>
                            <fail-widgets>
                                <!-- Scipio: now points to shop -->
                                <label style="warning" text="A Product Store has not been defined for this shop."/>
                            </fail-widgets>
                        </section>
                    </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="Common@component-resource-name@AppDecorator">
        <section>
            <widgets>
                <!-- delegates to /applications/shop -->
                <decorator-screen name="CommonShopAppDecorator" location="component://shop/widget/CommonScreens.xml"/>
            </widgets>
        </section>
        <!--
        <section>
            <actions>
            </actions>
            <widgets>
                <decorator-screen name="main-decorator" location="${parameters.mainDecoratorLocation}">
                    <decorator-section name="body">
                        <decorator-section-include name="body"/>
                    </decorator-section>
                </decorator-screen>
            </widgets>
        </section>
        -->
    </screen>
    
    <!-- OVERRIDE for the extended app's app-wide common decorator
        NOTE: Because this is a pure derivative application, there may be redundancy between this and the one above; use either or both as-needed
    <screen name="CommonShopAppDecorator">
        <section>
            <widgets>
                <decorator-screen name="CommonShopAppDecorator" location="component://shop/widget/CommonScreens.xml"/>
            </widgets>
        </section>
        <!-
        <section>
            <actions>
            </actions>
            <widgets>
                <decorator-screen name="main-decorator" location="${parameters.mainDecoratorLocation}">
                    <decorator-section name="body">
                        <decorator-section-include name="body"/>
                    </decorator-section>
                </decorator-screen>
            </widgets>
        </section>
        ->
    </screen>
    -->

    <screen name="leftbar">
        <section>
            <widgets>
                <!-- delegates to /applications/shop -->
                <include-screen name="leftbar" location="component://shop/widget/CommonScreens.xml"/>
            </widgets>
        </section>
    </screen>

    <!-- Main screen definition -->
    <screen name="main">
        <section>
            <widgets>
                <!-- delegates to /applications/shop -->
                <include-screen name="main" location="component://shop/widget/CommonScreens.xml"/>
                <!-- this would replace the entire main screen with a custom FTL template
                <platform-specific><html><html-template location="component://@component-name@/webapp/@webapp-name@/main.ftl"/></html></platform-specific>-->
            </widgets>
        </section>
    </screen>
    
</screens>