AnsweredAssumed Answered

How to properly configure the form for editing metadata?

Question asked by Aleksey Bykov on Jun 9, 2018
Latest reply on Jun 10, 2018 by Aleksey Bykov

Hi,

 

I forgot the basics a bit - I was working on another project a long time.

 

The problem. I need to show my custom controls on the screen for editing metadata. Then I will do some JavaScript-logic of interaction between these controls.

 

Here is my share-config-custom.xml:

<alfresco-config>

   <config evaluator="string-compare" condition="DocumentLibrary">
      <types>
                 <type name="cm:content">
                <subtype name="firm:doc" />
                <subtype name="firm:incomingDoc" />
             </type>
             <type name="firm:doc">
                <subtype name="firm:incomingDoc" />
             </type>
      </types>
   </config>
  
   <config replace="true" evaluator="string-compare" condition="AdvancedSearch">
      <advanced-search>
         <forms>
            <form labelId="search.form.label.cm_content" descriptionId="search.form.desc.cm_content">cm:content</form>
            <form labelId="search.form.label.cm_folder" descriptionId="search.form.desc.cm_folder">cm:folder</form>           
            <form labelId="type.firm_incomingDoc" descriptionId="search.form.desc.firm_incomingDoc">firm:incomingDoc</form>
         </forms>
      </advanced-search>
   </config>

   <config evaluator="node-type" condition="firm:incomingDoc">
      <forms>
         <form>
            <field-visibility>
               <show id="cm:name" />
               <show id="cm:title" force="true" />
               <show id="cm:description" force="true" />
               <show id="cm:author" force="true" />
               <show id="size" for-mode="view" />
               <show id="cm:creator" for-mode="view" />
               <show id="cm:created" for-mode="view" />
               <show id="cm:modifier" for-mode="view" />
               <show id="cm:modified" for-mode="view" />
              
               <!-- cm:dublincore aspect -->
               <show id="cm:publisher"/>
               <show id="cm:contributor"/>
               <show id="cm:type"/>
               <show id="cm:identifier"/>
               <show id="cm:dcsource"/>
               <show id="cm:coverage"/>
               <show id="cm:rights"/>
               <show id="cm:subject"/>
              
               <!-- cm:complianceable aspect -->
               <show id="cm:removeAfter" />
              
               <!-- cm:effectivity aspect -->
               <show id="cm:from"/>
               <show id="cm:to"/>
              
               <!--  cm:summarizable aspect -->
               <show id="cm:summary" />
              
               <!-- cm:translatable aspect -->
               <show id="cm:translations" />
              
               <!-- cm:localizable aspect -->
               <show id="cm:locale" />
              
               <!-- cm:ownable aspect -->
               <show id="cm:owner" />
              
               <!-- cm:attachable aspect -->
               <show id="cm:attachments" />
              
               <!-- cm:indexControl aspect -->
               <show id="cm:isIndexed" />
               <show id="cm:isContentIndexed" />
              
               <!-- sc:doc -->
               <show id="firm:relatedDocuments" />
              
               <!-- sc:marketingDoc -->
               <show id="firm:documentState" />
                  <show id="firm:documentTheme" />
                  <show id="firm:documentState" />
                  <show id="firm:documentCreationDate" />
                  <show id="firm:documentType" />
                  <show id="firm:documentSubType" />
                  <show id="firm:documentTheme" />
                  <show id="firm:documentNumber" />
                  <show id="firm:documentAutoCreation" />
                  <show id="firm:documentOutcomingNumber" />
                  <show id="firm:documentDate" />
                  <show id="firm:documentOrganization" />
                  <show id="firm:documentDeliveryMethod" />
                  <show id="firm:documentAdditionalInformation" />
                 
            </field-visibility>
            <appearance>
               <field id="cm:name">
                 <control>
                    <control-param name="maxLength">255</control-param>
                 </control>
               </field>
               <field id="cm:title">
                  <control template="/org/alfresco/components/form/controls/textfield.ftl" />
               </field>
               <field id="cm:description">
                  <control>
                     <control-param name="activateLinks">true</control-param>
                  </control>
               </field>
               <field id="size">
                  <control template="/org/alfresco/components/form/controls/size.ftl" />
               </field>
               <field id="cm:originator" read-only="true" />
               <field id="cm:addressee" read-only="true" />
               <field id="cm:addressees" read-only="true" />
               <field id="cm:sentdate" read-only="true" />
               <field id="cm:subjectline" read-only="true" />
               <field id="firm:relatedDocuments" label-id="assoc.firm_relatedDocuments" />
               <field id="firm:documentState" label-id="prop.firm_documentState" read-only="true"/>
                  <field id="firm:documentTheme" label-id="prop.firm_documentTheme"/>
                  <field id="firm:documentCreationDate" label-id="prop.firm_documentCreationDate"/>
                  <field id="firm:documentType" label-id="prop.firm_documentType"/>
                  <field id="firm:documentSubType" label-id="prop.firm_documentSubType"/>
                  <field id="firm:documentTheme" label-id="prop.firm_documentTheme"/>
                  <field id="firm:documentNumber" label-id="prop.firm_documentNumber"/>
                  <field id="firm:documentAutoCreation" label-id="prop.firm_documentAutoCreation"/>
                  <field id="firm:documentOutcomingNumber" label-id="prop.firm_documentOutcomingNumber"/>
                  <field id="firm:documentDate" label-id="prop.firm_documentDate"/>
                  <field id="firm:documentOrganization" label-id="prop.firm_documentOrganization"/>
                  <field id="firm:documentDeliveryMethod" label-id="prop.firm_documentDeliveryMethod"/>
                  <field id="firm:documentAdditionalInformation" label-id="prop.firm_documentAdditionalInformation"/>
              
            </appearance>
         </form>

         <form id="doclib-simple-metadata">
            <field-visibility>
               <show id="cm:name" />
               <show id="cm:title" force="true" />
               <show id="cm:description" force="true" />
               <!-- sc:doc -->
               <show id="firm:documentState" read-only="true"/>
                  <show id="firm:documentTheme" />
                  <show id="firm:documentCreationDate" />
                  <show id="firm:documentType" />
                  <show id="firm:documentSubType" />
                  <show id="firm:documentTheme" />
                  <show id="firm:documentNumber" />
                  <show id="firm:documentAutoCreation" force="true"/>
                  <show id="firm:documentOutcomingNumber" />
                  <show id="firm:documentDate" />
                  <show id="firm:documentOrganization" />
                  <show id="firm:documentDeliveryMethod" />
                  <show id="firm:documentAdditionalInformation" />
            </field-visibility>
            <edit-form template="../documentlibrary/forms/doclib-simple-metadata.ftl" />
            <appearance>
               <field id="cm:name">
                 <control>
                    <control-param name="maxLength">255</control-param>
                 </control>
               </field>
               <field id="cm:title">
                  <control template="/org/alfresco/components/form/controls/textfield.ftl" />
               </field>
               <field id="cm:description">
                  <control>
                     <control-param name="activateLinks">true</control-param>
                  </control>
               </field>
               <field id="firm:relatedDocuments" label-id="assoc.firm_relatedDocuments" />
               <field id="firm:documentState" label-id="prop.firm_documentState" read-only="true"/>
                  <field id="firm:documentTheme" label-id="prop.firm_documentTheme"/>
                  <field id="firm:documentCreationDate" label-id="prop.firm_documentCreationDate"/>

                  <field id="firm:documentType" label-id="prop.firm_documentType"/>
                  <field id="firm:documentSubType" label-id="prop.firm_documentSubType"/>
                 
                  <field id="firm:documentTheme" label-id="prop.firm_documentTheme"/>
                  <field id="firm:documentNumber" label-id="prop.firm_documentNumber"/>
                 
                  <field id="firm:documentAutoCreation" label-id="prop.firm_documentAutoCreation">
                  <control template="/com/firm/components/form/controls/firm_checkbox.ftl" />
               </field>
                 
                  <field id="firm:documentOutcomingNumber" label-id="prop.firm_documentOutcomingNumber"/>
                  <field id="firm:documentDate" label-id="prop.firm_documentDate"/>
                  <field id="firm:documentOrganization" label-id="prop.firm_documentOrganization"/>
                  <field id="firm:documentDeliveryMethod" label-id="prop.firm_documentDeliveryMethod"/>
                  <field id="firm:documentAdditionalInformation" label-id="prop.firm_documentAdditionalInformation"/>
            </appearance>
         </form>
        
         <form id="doclib-inline-edit">
            <field-visibility>
               <show id="cm:name" />
               <show id="cm:title" force="true" />
               <show id="cm:description" force="true" />
               <!-- sc:doc -->
               <show id="firm:documentState" />
                  <show id="firm:documentTheme" />
                  <show id="firm:documentState" />
                  <show id="firm:documentCreationDate" />
                  <show id="firm:documentType" />
                  <show id="firm:documentSubType" />
                  <show id="firm:documentTheme" />
                  <show id="firm:documentNumber" />
                  <show id="firm:documentAutoCreation" />
                  <show id="firm:documentOutcomingNumber" />
                  <show id="firm:documentDate" />
                  <show id="firm:documentOrganization" />
                  <show id="firm:documentDeliveryMethod" />
                  <show id="firm:documentAdditionalInformation" />
            </field-visibility>
            <appearance>
               <field id="cm:name">
                 <control>
                    <control-param name="maxLength">255</control-param>
                 </control>
               </field>
               <field id="cm:title">
                  <control template="/org/alfresco/components/form/controls/textfield.ftl" />
               </field>
               <field id="cm:description">
                  <control>
                     <control-param name="activateLinks">true</control-param>
                  </control>
               </field>
               <field id="firm:relatedDocuments" label-id="assoc.firm_relatedDocuments" />
               <field id="firm:documentState" label-id="prop.firm_documentState" read-only="true"/>
                  <field id="firm:documentTheme" label-id="prop.firm_documentTheme"/>
                  <field id="firm:documentCreationDate" label-id="prop.firm_documentCreationDate"/>

                  <field id="firm:documentType" label-id="prop.firm_documentType"/>
                  <field id="firm:documentSubType" label-id="prop.firm_documentSubType"/>
                 
                  <field id="firm:documentTheme" label-id="prop.firm_documentTheme"/>
                  <field id="firm:documentNumber" label-id="prop.firm_documentNumber"/>
                 
                  <field id="firm:documentAutoCreation" label-id="prop.firm_documentAutoCreation">
                  <control template="/com/firm/components/form/controls/firm_checkbox.ftl" />
               </field>
                 
                  <field id="firm:documentOutcomingNumber" label-id="prop.firm_documentOutcomingNumber"/>
                  <field id="firm:documentDate" label-id="prop.firm_documentDate"/>
                  <field id="firm:documentOrganization" label-id="prop.firm_documentOrganization"/>
                  <field id="firm:documentDeliveryMethod" label-id="prop.firm_documentDeliveryMethod"/>
                  <field id="firm:documentAdditionalInformation" label-id="prop.firm_documentAdditionalInformation"/>
              
              
               <field id="cm:content">
                  <control>
                     <control-param name="editorAppearance">explorer</control-param>
                     <control-param name="forceEditor">true</control-param>
                  </control>
               </field>
            </appearance>
         </form>
        
      </forms>
   </config>
  
</alfresco-config>

 

In this case, I'm interested in this field:

 

<field id="firm:documentAutoCreation" label-id="prop.firm_documentAutoCreation">
  <control template="/com/firm/components/form/controls/firm_checkbox.ftl" />
</field>

 

In this configuration, as shown above, the form that I need appears only when I call the editor from the menu in the repository (where the items "Download", "View in browser", etc.). When I opened the document, and then clicked "Edit properties" - in this edit window I do not see my firm_checkbox.ftl ...

 

If I specify my control here:

 

   <config evaluator="node-type" condition="firm:incomingDoc">
      <forms>
         <form>
            <field-visibility>
                    <show id="firm:documentAutoCreation" />
                    ...    
               </field-visibility>
                    <appearance>
                         <field id="firm:documentAutoCreation" label-id="prop.firm_documentAutoCreation">
                           <control template="/com/firm/components/form/controls/firm_checkbox.ftl" />
                        </field>
                        
                        
                         ...

 

Then my control appears on the form of editing metadata, but it also appears in the properties panel, where it should not be.

 

How to properly configure the form for editing metadata?

 

I would be very grateful for the information. Thanks to all.

Outcomes