Moqui form shows up disabled

329 Views Asked by At

I am following the Moqui getting started tutorial. I have created a create form as below.

<?xml version="1.0" encoding="UTF-8"?>
<screen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://staging.azpire.co.in/xsd/xml-screen-2.1.xsd"
    require-authentication="anonymous-all">

    <transition name="findTutorial"><default-response url="."/></transition>
    <transition name="createTutorial">
        <service-call name="create#tutorial.Tutorial"></service-call>
        <default-response url="."/>
    </transition>

    <actions>
        <entity-find entity-name="tutorial.Tutorial" list="tutorialList">
            <search-form-inputs/>
        </entity-find>
    </actions>

    <widgets>

        <container-dialog button-text="Create Tutorial" id="CreateTutorialDialog">
            <form-single name="CreateTutorial" transition="createTutorial">
                <auto-fields-entity entity-name="tutorial.Tutorial" field-type="edit"/>
                <field name="submitButton">
                    <default-field title="Create"><submit/></default-field>
                </field>
            </form-single>
        </container-dialog>

        <form-list name="ListTutorials" list="tutorialList" transition="findTutorial">
            <auto-fields-entity entity-name="tutorial.Tutorial" field-type="find-display"/>
        </form-list>
    </widgets>
</screen>

When I click "Create Tutorial", the form shows up. But, it is disabled(read only) including the submit button.

3

There are 3 best solutions below

1
On BEST ANSWER

If you are following the Moqui getting started tutorial, you need import data about security screen as follow to fix this problem:

    <moqui.security.ArtifactGroup artifactGroupId="TUTORIAL" description="Tutorial"/>
    <moqui.security.ArtifactGroupMember artifactGroupId="TUTORIAL" artifactTypeEnumId="AT_XML_SCREEN"
                                            inheritAuthz="Y" artifactName="component://tutorial/screen/tutorial.xml"/>
<!-- Full permissions for the ADMIN user group -->
    <moqui.security.ArtifactAuthz artifactAuthzId="TUTORIAL_AUTHZ_ALL" userGroupId="ADMIN" artifactGroupId="TUTORIAL"
                                      authzTypeEnumId="AUTHZT_ALWAYS" authzActionEnumId="AUTHZA_ALL"/>
1
On

If the transition exist and the user has permission to access it, then all fields disabled is a bug, please report it by create a issue.

0
On

If you are required temporary solution for one transition then you can use:

<transition name="createTutorial" read-only="true">
    <service-call name="create#tutorial.Tutorial"></service-call>
    <default-response url="."/>
</transition>

If you are required a temporary solution but for more transition then you can use:

<always-actions>
    <script>ec.artifactExecution.disableAuthz()</script>
</always-actions>
<transition name="createTutorial">
    <service-call name="create#tutorial.Tutorial"></service-call>
    <default-response url="."/>
</transition>
<transition name="createEmployee">
    <service-call name="create#employee.Employee"></service-call>
    <default-response url="."/>
</transition>

If you want permanent solution then create below seed data records:

  1. If you want to authrize for availabe UserGroup(ADMIN) then you have to add following seed data: <moqui.security.ArtifactGroup artifactGroupId="ADMIN_ARTIFACTS" description="Administrators"/> <!-- for screen path --> <moqui.security.ArtifactGroupMember artifactGroupId="ADMIN_ARTIFACTS" artifactTypeEnumId="AT_XML_SCREEN" nameIsPattern="N" inheritAuthz="Y" artifactName="component://tutorial/screen/tutorial.xml"/> <!-- for rest calls --> <moqui.security.ArtifactGroupMember artifactGroupId="ADMIN_ARTIFACTS" artifactName="/tutorial/fetch-records" artifactTypeEnumId="AT_REST_PATH" nameIsPattern="N" inheritAuthz="Y"/> <!-- for service path --> <moqui.security.ArtifactGroupMember artifactGroupId="ADMIN_ARTIFACTS" artifactName="TutorialServices.create#Records" artifactTypeEnumId="AT_SERVICE" nameIsPattern="N" inheritAuthz="Y"/> <!-- Give authrization to UserGroup: --> <moqui.security.ArtifactAuthz artifactAuthzId="ADMIN_AUTHZ" userGroupId="ADMIN" artifactGroupId="ADMIN_ARTIFACTS" authzTypeEnumId="AUTHZT_ALWAYS" authzActionEnumId="AUTHZA_ALL"/>

  2. If you want to create your own UserGroupType then you have to add following seed data:

    <moqui.basic.Enumeration enumTypeId="UserGroupType" enumId="UgtMyAdmin" description="My Administrators"/> // If you want to create your own UserGroup then you have to add following seed data: <moqui.security.UserGroup groupTypeEnumId="UgtMyAdmin" userGroupId="MyAdmin" description="My Administrators"/> // you can also create artifact group separately: <moqui.security.ArtifactGroup artifactGroupId="MY_ADMIN_ARTIFACTS" description="My Administrators"/> // Now you have to give screen permission to your own created UserGroup: <!-- for screen path --> <moqui.security.ArtifactGroupMember artifactGroupId="MY_ADMIN_ARTIFACTS" artifactTypeEnumId="AT_XML_SCREEN" nameIsPattern="N" inheritAuthz="Y" artifactName="component://tutorial/screen/tutorial.xml"/> <!-- for rest calls --> <moqui.security.ArtifactGroupMember artifactGroupId="MY_ADMIN_ARTIFACTS" artifactName="/tutorial/fetch-records" artifactTypeEnumId="AT_REST_PATH" nameIsPattern="N" inheritAuthz="Y"/> <!-- for service path --> <moqui.security.ArtifactGroupMember artifactGroupId="MY_ADMIN_ARTIFACTS" artifactName="TutorialServices.create#Records" artifactTypeEnumId="AT_SERVICE" nameIsPattern="N" inheritAuthz="Y"/> <!-- Give authrization to UserGroup: --> <moqui.security.ArtifactAuthz artifactAuthzId="MY_ADMIN_AUTH" userGroupId="MyAdmin" artifactGroupId="MY_ADMIN_ARTIFACTS" authzTypeEnumId="AUTHZT_ALWAYS" authzActionEnumId="AUTHZA_ALL"/>

You can also clone an example component from git:

I hope this will help!