Mauro
Mauro

Reputation: 11

Add others fields to a new DataList instead the Title in Alfresco

Please I need to know, when at the beginning, the user creates a new DataList from web interface :

see the image attached

I did exactly as Muralidharan told me in the response but :

when from interface I create a datalist the Title is not disappeared

and also when I try to modify the datalist show up the Title again and also Description and I don't want them

see screenshot

How to adjust it ?

this is the code of datalist-model.xml

    <types>
<type name="acmedl:dataList">
         <title>Data List container type</title>
         <parent>cm:folder</parent>
         <properties>
            <property name="dl:dataListItemType">
               <title>List Item Type</title>
               <description>Determines which Data Dictionary type will be used when create new items within the Data List.</description>
               <type>d:text</type>
            </property>
            <property name="dl:responsiblePerson">
               <title>Data List Owner</title>               
               <type>d:text</type>
            </property>
         </properties>
        </type>

        <type name="acmedl:projectListItem">
            <title>My document</title>
            <parent>dl:dataListItem</parent>
            <properties>
                <property name="acmedl:x1">
                    <type>d:text</type>
                    <mandatory>true</mandatory>
                    <constraints>
                        <constraint ref="acmedl:x1" />
                    </constraints>
                </property>
                <property name="acmedl:x2">
                    <type>d:text</type>
                    <mandatory>true</mandatory>
                </property>
                <property name="acmedl:x3">
                    <type>d:text</type>
                    <mandatory>true</mandatory>
                </property>
            </properties>
        </type>
    </types>

this is the code of share-config-custom.xml

<!-- dl:dataList type (Creating Data Lists) -->
   <config evaluator="model-type" condition="acmedl:dataList" replace="true">
      <forms>
         <!-- Data Lists: Create new Data List -->
         <form>
            <field-visibility>
                <!-- <show id="cm:title" force="true" /> -->
               <show id="dl:responsiblePerson" force="true" />        <!-- Our custom field -->        
            </field-visibility>
            <create-form template="../data-lists/forms/datalist-new.ftl" />
            <appearance>
             <!-- <field id="cm:title" mandatory="true">
                  <control template="/org/alfresco/components/form/controls/textfield.ftl" />
               </field> -->
               <field id="dl:responsiblePerson" mandatory="true">  <!-- Our custom field -->
                  <control template="/org/alfresco/components/form/controls/textfield.ftl" />
               </field>
            </appearance>
         </form>
      </forms>
   </config>

   <!-- dl:dataList type (Editing Data Lists) -->
   <config evaluator="node-type" condition="acmedl:dataList">
      <forms>
         <!-- Data Lists: Edit Data List details -->
         <form>
            <field-visibility>
                 <!-- <show id="cm:title" force="true" /> -->
                <show id="dl:responsiblePerson" force="true" />     <!-- Our custom field -->
            </field-visibility>
            <edit-form template="../data-lists/forms/datalist-edit.ftl" />
            <appearance>
              <!-- <field id="cm:title" mandatory="true">
                  <control template="/org/alfresco/components/form/controls/textfield.ftl" />
               </field> -->
               <field id="dl:responsiblePerson" mandatory="true"> <!-- Our custom field -->
                  <control template="/org/alfresco/components/form/controls/textfield.ftl" />
               </field>

            </appearance>
         </form>
      </forms>
   </config>



    <!--
        acmedl:projectListItem type create form config
        -->
    <config evaluator="model-type" condition="acmedl:projectListItem">
        <forms>
            <!-- Create item form -->
            <form>
                <field-visibility>
                    <show id="acmedl:x1" />
                    <show id="acmedl:x2" />
                    <show id="acmedl:x3" />
                </field-visibility>
                <create-form template="../data-lists/forms/dataitem.ftl" />
                <appearance>
                </appearance>
            </form>
        </forms>
    </config>

    <!--
        acmedl:projectListItem type edit form config
    -->
    <config evaluator="node-type" condition="acmedl:projectListItem">
        <forms>
            <form>
                <field-visibility>
                    <show id="acmedl:x1" />
                    <show id="acmedl:x2" />
                    <show id="acmedl:x3" />
                </field-visibility>
                <edit-form template="../data-lists/forms/dataitem.ftl" />
                <appearance>
                </appearance>
            </form>
        </forms>
    </config>

Upvotes: 0

Views: 494

Answers (1)

After looking at this code, dataList is inherited from cm:folder. If you want to add any custom properties, first those properties should be part of dl:dataList, otherwise, you can't store the values into Repository. And I'm also not sure, how to custom properties into existing dataList. Let me ask this as a different question.

<!-- Data List - Container. DO NOT MODIFY -->
      <type name="dl:dataList">
         <title>Data List container type</title>
         <parent>cm:folder</parent>
         <properties>
            <property name="dl:dataListItemType">
               <title>List Item Type</title>
               <description>Determines which Data Dictionary type will be used when create new items within the Data List.</description>
               <type>d:text</type>
            </property>
         </properties>
      </type>

I added one few field called, Data List Owner (dl:responsiblePerson) into datalist model and Share side also. Based on this idea, I hope you can addd your own fields.

We assume, we manually added a custom property(dl:responsiblePerson) into dl:dataList, like below.

<type name="dl:dataList">
         <title>Data List container type</title>
         <parent>cm:folder</parent>
         <properties>
            <property name="dl:dataListItemType">
               <title>List Item Type</title>
               <description>Determines which Data Dictionary type will be used when create new items within the Data List.</description>
               <type>d:text</type>
            </property>
            <property name="dl:responsiblePerson">
               <title>Data List Owner</title>               
               <type>d:text</type>
            </property>
         </properties>
      </type>

And in Share side, use the below code snippet into share-config-custom.xml file. Always use cm:title property in the datalist creation form, otherwise you getting datalist name some alpha-number / GUID value.

<!-- dl:dataList type (Creating Data Lists) -->
   <config evaluator="model-type" condition="dl:dataList" replace="true">
      <forms>
         <!-- Data Lists: Create new Data List -->
         <form>
            <field-visibility>
                <show id="cm:title" force="true" />
               <show id="dl:responsiblePerson" force="true" />        <!-- Our custom field -->        
            </field-visibility>
            <create-form template="../data-lists/forms/datalist-new.ftl" />
            <appearance>
             <field id="cm:title" mandatory="true">
                  <control template="/org/alfresco/components/form/controls/textfield.ftl" />
               </field>
               <field id="dl:responsiblePerson" mandatory="true">  <!-- Our custom field -->
                  <control template="/org/alfresco/components/form/controls/textfield.ftl" />
               </field>
            </appearance>
         </form>
      </forms>
   </config>

   <!-- dl:dataList type (Editing Data Lists) -->
   <config evaluator="node-type" condition="dl:dataList">
      <forms>
         <!-- Data Lists: Edit Data List details -->
         <form>
            <field-visibility>
                 <show id="cm:title" force="true" />
                <show id="dl:responsiblePerson" force="true" />     <!-- Our custom field -->
            </field-visibility>
            <edit-form template="../data-lists/forms/datalist-edit.ftl" />
            <appearance>
              <field id="cm:title" mandatory="true">
                  <control template="/org/alfresco/components/form/controls/textfield.ftl" />
               </field>
               <field id="dl:responsiblePerson" mandatory="true"> <!-- Our custom field -->
                  <control template="/org/alfresco/components/form/controls/textfield.ftl" />
               </field>

            </appearance>
         </form>
      </forms>
   </config>

Data List Creation

Upvotes: 2

Related Questions