ilscipio/scipio-erp

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

Summary

Maintainability
Test Coverage
<?xml version="1.0" encoding="UTF-8"?>
<!--
    Licensed to the Apache Software Foundation (ASF) under one
    or more contributor license agreements.  See the NOTICE file
    distributed with this work for additional information
    regarding copyright ownership.  The ASF licenses this file
    to you under the Apache License, Version 2.0 (the
    "License"); you may not use this file except in compliance
    with the License.  You may obtain a copy of the License at
    
    http://www.apache.org/licenses/LICENSE-2.0
    
    Unless required by applicable law or agreed to in writing,
    software distributed under the License is distributed on an
    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    KIND, either express or implied.  See the License for the
    specific language governing permissions and limitations
    under the License.
-->

<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://setup/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://setup/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="ScipioSetupErrorUiLabels" map-name="uiLabelMap" global="true"/>
                <property-map resource="ScipioSetupUiLabels" map-name="uiLabelMap" global="true"/>
                <property-map resource="SetupUiLabels" map-name="uiLabelMap" global="true"/>
                <property-map resource="WebtoolsUiLabels" map-name="uiLabelMap" global="true"/>
                <property-map resource="ContentUiLabels" map-name="uiLabelMap" global="true"/>
                <property-map resource="MarketingUiLabels" map-name="uiLabelMap" global="true"/>
                <property-map resource="PartyUiLabels" map-name="uiLabelMap" global="true"/>
                <property-map resource="OrderUiLabels" map-name="uiLabelMap" global="true"/>
                <property-map resource="ProductUiLabels" map-name="uiLabelMap" global="true"/>
                <property-map resource="AccountingUiLabels" map-name="uiLabelMap" global="true"/>
                <property-map resource="CommonErrorUiLabels" map-name="uiLabelMap" global="true"/>
                <property-map resource="CommonUiLabels" map-name="uiLabelMap" global="true"/>
                
                <set field="MainColumnStyle" value="nocolumns" global="true"/>
                <set field="layoutSettings.companyName" from-field="uiLabelMap.SetupCompanyName" global="true"/>
                <set field="layoutSettings.companySubtitle" from-field="uiLabelMap.SetupCompanySubtitle" 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="setup" global="true"/>
                <set field="applicationMenuName" value="SetupAppBar" global="true"/>
                <set field="applicationMenuLocation" value="component://setup/widget/Menus.xml" global="true"/>
                <set field="applicationTitle" value="${uiLabelMap.SetupApp}" global="true"/>
                
                <!-- ToDo: Move to themes? -->
                <set field="layoutSettings.javaScripts[+0]" value="/base-theme/bower_components/jquery.cookie/jquery.cookie.js" global="true"/>    
                <set field="layoutSettings.styleSheets[+0]" value="/base-theme/bower_components/jstree/dist/themes/default/style.css" global="true"/>
                <set field="layoutSettings.javaScripts[+0]" value="/base-theme/bower_components/jstree/dist/jstree.min.js" 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-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="CommonSetupAppDecorator">
        <section>
            <actions>
                <!-- SCIPIO: some of the screens need this -->
                <set field="layoutSettings.javaScriptsFooter[]" value="/ordermgr-js/geoAutoCompleter.js" global="true"/>
                
                <!-- FIXME: is there a common setup VIEW app permission appropriate here?
                <condition-to-field field="commonSetupAppBasePermCond" type="Boolean" only-if-field="empty">
                    <if-has-permission permission="SETUP" action="_VIEW"/>
                </condition-to-field> -->
                <set field="commonSetupAppBasePermCond" from-field="commonSetupAppBasePermCond" type="Boolean" default-value="true"/>
            </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="CommonSetupAppSideBarMenu"/>
                    </decorator-section>
                    <decorator-section name="body">
                        <section>
                            <condition>
                                <if-true field="commonSetupAppBasePermCond"/>
                            </condition>
                            <widgets>
                                <decorator-section-include name="body"/>
                            </widgets>
                            <fail-widgets>
                                <label style="common-msg-error-perm">${uiLabelMap.CommonPermissionError}</label>
                            </fail-widgets>
                        </section>
                    </decorator-section>
                </decorator-screen>
            </widgets>
        </section>
    </screen>
    
    <screen name="CommonPartyDecorator">
        <section>
            <widgets>
                <section>
                    <condition>
                        <if-true field="useSetupWizardDec"/>
                    </condition>
                    <widgets>
                        <decorator-screen name="CommonSetupWizardDecorator"/>
                    </widgets>
                    <fail-widgets>
                        <decorator-screen name="CommonSetupDecorator"/>
                    </fail-widgets>
                </section>
            </widgets>
        </section>
    </screen>
    
    <screen name="CommonSetupDecorator">
        <section>
            <actions>
                <set field="activeSubMenu" from-field="activeSubMenu" default-value="component://setup/widget/Menus.xml#Setup" />
                <entity-condition entity-name="PartyRole" list="parties">
                    <condition-expr field-name="roleTypeId" operator="equals" value="INTERNAL_ORGANIZATIO"/>
                </entity-condition>
                <set field="partyId" from-field="parties[0].partyId"/>
                <entity-one entity-name="Party" value-field="party"/>
                <entity-one entity-name="PartyGroup" value-field="lookupGroup"/>
                <condition-to-field field="commonSideBarMenu.condList[]" type="Boolean">
                    <and>
                        <if-service-permission service-name="partyBasePermissionCheck" main-action="VIEW"/>
                        <not><if-empty field="taxAuthority"/></not><!-- SCIPIO: TODO: REVIEW: WHY was this needed? -->
                    </and>
                </condition-to-field>
            </actions>
            <widgets>
                <decorator-screen name="CommonSetupAppDecorator" location="${parameters.mainDecoratorLocation}">
                    <decorator-section name="body">
                        <section>
                            <!-- do check for PARTYMGR, _VIEW permission -->
                            <condition>
                                <if-service-permission service-name="partyBasePermissionCheck" main-action="VIEW"/>
                            </condition>
                            <widgets>
                                <section>
                                    <condition><not><if-empty field="partyId"/></not></condition>
                                    <widgets>
                                        <container style="clear"/>
                                        <container style="h2">
                                            <section>
                                                <condition><not><if-empty field="lookupGroup"/></not></condition>
                                                <widgets>
                                                    <label text="${uiLabelMap.PartyTheProfileOf} ${lookupPerson.personalTitle} ${lookupPerson.firstName} ${lookupPerson.middleName} ${lookupPerson.lastName} ${lookupPerson.suffix} ${lookupGroup.groupName} [${partyId}]"/>
                                                    <horizontal-separator/>
                                                </widgets>
                                                <fail-widgets>
                                                    <label text="${uiLabelMap.PartyNewUser}"/>
                                                </fail-widgets>
                                            </section>
                                        </container>
                                    </widgets>
                                </section>
                               <!-- SCIPIO: Commenting this out for now, I'm not sure what the effect of completing this is, but definitely that button must not be placed here -->
                               <!-- <section>
                                    <condition>
                                        <not><if-empty field="partyId"/></not>
                                    </condition>
                                    <widgets>
                                        <container style="button-bar">
                                            <link target="OrganizationToComplete" text="${uiLabelMap.SetupSetToComplete}" style="${styles.link_run_sys} ${styles.action_complete}">
                                                <parameter param-name="partyId" from-field="organizationPartyId"/>
                                                <parameter param-name="roleTypeId" value="ORGANIZATION_ROLE"/>
                                            </link>
                                        </container>
                                    </widgets>
                                </section>-->
                                <decorator-section-include name="body"/>
                            </widgets>
                            <fail-widgets>
                                <label style="common-msg-error-perm">${uiLabelMap.PartyMgrViewPermissionError}</label>
                            </fail-widgets>
                        </section>
                    </decorator-section>
                </decorator-screen>
            </widgets>
        </section>
    </screen>
    
    <!-- SCIPIO: Setup Wizard decorator
        NOTE: doesn't extend CommonSetupDecorator because it had a legacy use with party check we don't want to confuse -->
    <screen name="CommonSetupWizardDecorator">
        <section>
            <actions>
                <!-- this check to prevent the /viewoverrideuri hack - this should always have been set by the events -->
                <script location="component://setup/webapp/setup/WEB-INF/actions/SetupWizardCommonActions.groovy"/><!-- fallback only; screens should set it themselves -->
                <script lang="groovy"><![CDATA[
                    import org.ofbiz.base.util.*;
                    context.setupStepAllowed = UtilMisc.booleanValueVersatile(parameters.setupForce, false) ||
                        UtilMisc.booleanValue(context.setupForce, false) ||
                        context.setupWorker?.isStepEffectiveAllowedSafe(context.setupStep);
                    // SPECIAL: record the "current" orgPartyId in session, ONLY so stock-like
                    // screens such as editcontactmech can access it (do not use if from scipio-code step screens!)
                    if (context.setupSessionOrgSet != false) {
                        session.setAttribute("scpSetupOrgPartyId", context.orgPartyId);
                    }
                ]]></script>
                
                <set field="activeSubMenuItem" from-field="activeSubMenuItem" default-value="${setupStep}"/>
                <set field="activeSubMenu" from-field="activeSubMenu" default-value="component://setup/widget/Menus.xml#SetupSteps" />
                
                <set field="noTitle" value="true"/>
                
                <set field="settingUpLabelProp" from-field="settingUpLabelProp" default-value="SetupSettingUp"/>
            </actions>
            <widgets>
                <decorator-screen name="CommonSetupAppDecorator">
                    <decorator-section name="body">
                        <include-screen name="SetupProgress" location="${parameters.mainDecoratorLocation}"/>
                        <section>
                            <condition><not><if-empty field="orgPartyGroup"/></not></condition>
                            <widgets>
                                <platform-specific>
                                    <html>
                                        <html-template><![CDATA[
                                          <@heading>${uiLabelMap[raw(settingUpLabelProp)]}: ${orgPartyGroup.groupName} [${uiLabelMap.CommonPartyId}: ${orgPartyGroup.partyId}]<#t/>
                                            <#t/><#if productStore?has_content> - ${productStore.storeName!productStore.productStoreId}</#if></@heading>
                                        ]]></html-template>
                                    </html>
                                </platform-specific>
                            </widgets>
                        </section>
                        <section>
                            <condition>
                                <if-compare field="setupStepAllowed" type="Boolean" operator="equals" value="true"/>
                            </condition>
                            <widgets>
                                <decorator-section-include name="setup-pre-body"/>
                                <decorator-section-include name="body"/>
                                <section>
                                    <condition>
                                        <and>
                                            <not><if-compare field="useDefaultSetupSubmitBar" operator="equals" type="Boolean" value="false"/></not>
                                            <!-- 
                                                IMPORTANT NOTE: This prevents rendering any button if submitFormId is not present, 
                                                which is contradictory to the @setupSubmitBar logic (ie: skip button can be displayed even if submitFormId has no content).
                                                Commented out for now, although it may have some implications I am currently unaware.   
                                            -->
                                            <!-- <not><if-empty field="submitFormId"/></not> -->
                                        </and>
                                    </condition>
                                    <widgets>
                                        <platform-specific>
                                            <html>
                                                <html-template><![CDATA[
                                                  <#include "component://setup/webapp/setup/common/common.ftl">
                                                  <@setupSubmitBar submitFormId=(submitFormId!)><#-- can't rely on this: isCreate=(isCreate!false)-->
                                                    <@render type="section" name="menu-functions"/>
                                                  </@setupSubmitBar>
                                                ]]></html-template>
                                            </html>
                                        </platform-specific>
                                    </widgets>
                                </section>
                                <decorator-section-include name="extra-body"/>
                            </widgets>
                            <fail-widgets>
                                <section>
                                    <actions>
                                        <set field="setupErrorMsg" value="${uiLabelMap.SetupErrorStepNotAccessible}"/>
                                    </actions>
                                    <widgets>
                                        <include-screen name="SetupErrorMsg" location="component://setup/widget/CommonScreens.xml"/>
                                    </widgets>
                                </section>
                            </fail-widgets>
                        </section>
                    </decorator-section>
                </decorator-screen>
            </widgets>
        </section>
    </screen>
    
    <screen name="SetupErrorMsg">
        <section>
            <actions>
                <script lang="groovy"><![CDATA[
                    import org.ofbiz.base.util.*;
                    final module = "SetupError.groovy";
                    
                    // Log this because caller might not have (WARN: setupErrorMsg is already localized; oh well)
                    if (context.logSetupErrorMsg != false) {
                        Debug.logError("Setup: Error occurred (displaying): " + (context.setupErrorMsg ?: "(message missing)"), module);
                    }
                    
                    // this is best-effort to get a 
                    context.autoNextSetupStep = null;
                    try {
                        context.autoNextSetupStep = context.setupWorker?.determineStepAuto();
                    } catch(Exception e) {
                        Debug.logError(e, "Setup: Error trying to display error message: " + e.getMessage(), "SetupErrorMsg.groovy");
                    }
                ]]></script>
            </actions>
            <widgets>
                <platform-specific>
                    <html><html-template location="component://setup/webapp/setup/wizard/setuperrormsg.ftl"/></html>
                </platform-specific>
            </widgets>
        </section>
    </screen>
    
    <!-- SCIPIO: widget to display the current progress -->
    <screen name="SetupProgress">
        <section>
            <actions>
            </actions>
            <widgets>
                <platform-specific>
                    <html><html-template location="component://setup/webapp/setup/wizard/setupprogress.ftl"/></html>
                </platform-specific>
           </widgets>
        </section>
    </screen>
    
    <screen name="EntityExportAll">
        <section>
            <actions>
                <set field="titleProperty" value="PageTitleEntityExportAll"/>
                <set field="activeSubMenuItem" value="entityExportAll"/>
                <!-- SCIPIO: Has no effect because transaction already started + not needed for this screen
                <set field="parameters.TRANSACTION_TIMEOUT" value="7200"/>-->
                <set field="results" from-field="parameters.results"/>
            </actions>
            <widgets>
                <decorator-screen name="CommonSetupAppDecorator" location="${parameters.mainDecoratorLocation}">
                    <decorator-section name="body">
                        <screenlet>
                            <platform-specific><html><html-template><![CDATA[
                                <@alert type="info"><a href="<@serverUrl uri="/admin/control/xmldsdump" extLoginKey=true/>"><#rt/>
                                    <#lt/>${uiLabelMap.SetupExportAdvancedInfo}</a></@alert>
                            ]]></html-template></html></platform-specific>
                            <platform-specific>
                                <html><html-template location="component://webtools/webapp/webtools/entity/EntityExportAll.ftl"/></html>
                            </platform-specific>
                        </screenlet>
                    </decorator-section>
                </decorator-screen>
            </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://setup/widget/Menus.xml"/>
                <set field="menuCfg.name" value="SetupAppSideBar"/>
                <set field="menuCfg.defLocation" value="component://setup/widget/Menus.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="CommonSetupAppSideBarMenu">
        <section>
            <actions>
                <!-- FIXME: is there a common setup VIEW app permission appropriate here?
                <condition-to-field field="commonSetupAppBasePermCond" type="Boolean" only-if-field="empty">
                    <if-has-permission permission="SETUP" action="_VIEW"/>
                </condition-to-field> -->
                <set field="commonSetupAppBasePermCond" from-field="commonSetupAppBasePermCond" type="Boolean" default-value="true"/>
                <set field="commonSideBarMenu.cond" from-field="commonSideBarMenu.cond" type="Boolean" default-value="${commonWebtoolsAppBasePermCond}"/>
            </actions>
            <widgets>
                <include-screen name="CommonSideBarMenu" location="component://common/widget/CommonScreens.xml"/>
            </widgets>
        </section>
    </screen>
    
    <screen name="CommonSetupAccountingTabsAction">    
        <section>
            <actions>
                <set field="setupStep" value="accounting"/>
                
                <script location="component://setup/webapp/setup/WEB-INF/actions/SetupWizardCommonActions.groovy"/>
                <set field="accountingData" from-field="setupStepStates[setupStep].stepData"/>
                
                <script location="component://setup/webapp/setup/WEB-INF/actions/accounting/SetupAccounting.groovy"/>
                <script location="component://setup/webapp/setup/WEB-INF/actions/accounting/EditGLAccountTree.groovy"/>
            
                <property-map resource="ScipioSetupErrorUiLabels" map-name="uiLabelMap" global="true"/>
                <property-map resource="ScipioSetupUiLabels" map-name="uiLabelMap" global="true"/>
                <property-map resource="SetupUiLabels" map-name="uiLabelMap" global="true"/>
                <property-map resource="WebtoolsUiLabels" map-name="uiLabelMap" global="true"/>
                <property-map resource="ContentUiLabels" map-name="uiLabelMap" global="true"/>
                <property-map resource="MarketingUiLabels" map-name="uiLabelMap" global="true"/>
                <property-map resource="PartyUiLabels" map-name="uiLabelMap" global="true"/>
                <property-map resource="OrderUiLabels" map-name="uiLabelMap" global="true"/>
                <property-map resource="ProductUiLabels" map-name="uiLabelMap" global="true"/>
                <property-map resource="AccountingUiLabels" map-name="uiLabelMap" global="true"/>
                <property-map resource="CommonErrorUiLabels" map-name="uiLabelMap" global="true"/>
                <property-map resource="CommonUiLabels" map-name="uiLabelMap" global="true"/>
                
                <set field="commonSetupAppBasePermCond" from-field="commonSetupAppBasePermCond" type="Boolean" default-value="true"/>
            </actions>
            <!-- <widgets>       
                <section>
                    <condition>
                        <if-true field="commonSetupAppBasePermCond"/>
                    </condition>
                    <widgets>
                        <decorator-section-include name="body"/>
                    </widgets>
                    <fail-widgets>
                        <label style="common-msg-error-perm">${uiLabelMap.CommonPermissionError}</label>
                    </fail-widgets>
                </section>
            </widgets> -->
        </section>
    </screen>
    
</screens>