How to properly configure the form for editing metadata?

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
alekseybykov
Established Member II

How to properly configure the form for editing metadata?

Jump to solution

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.

1 Solution

Accepted Solutions
krutik_jayswal
Senior Member II

Re: How to properly configure the form for editing metadata?

Jump to solution

There are few things which needs to be considered, which you need to understand.

 

<config > Element

There are two attributed in config element. 

First is evaluator.If eveluator attribute is set to model-type, this means particular form configured inside this configuration will be opened when the type of object is created.Which mean form is opened in create mode(There is attribute called form.mode which should be create)

Second is condition, which is used for identification of type or object which is defined inside the content model.

There is one more form which can be configured by giving id in the <form> tag.If you give doclib-simple-metadata,then it will open that form in edit properties dialogue.

How to create custom form field in share

While creating custom form control,Inside the ftl file, You need to define an if..else condition for rendering the field in view mode and rendering it in edit mode.If you refer existing textfield.ftl or any other control , inside that there are sections for rendering field in view mode which is your property pane and edit mode, which is edit properties form.

In ftl this can be implemented like below

 <#if form.mode == "view">

//Code for viewing field value

<#else>

//Code for editing field value

</#if>

2 Replies
alekseybykov
Established Member II

Re: How to properly configure the form for editing metadata?

Jump to solution

Solved by the following way:

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

But now this property has disappeared from the properties panel ("read only").

krutik_jayswal
Senior Member II

Re: How to properly configure the form for editing metadata?

Jump to solution

There are few things which needs to be considered, which you need to understand.

 

<config > Element

There are two attributed in config element. 

First is evaluator.If eveluator attribute is set to model-type, this means particular form configured inside this configuration will be opened when the type of object is created.Which mean form is opened in create mode(There is attribute called form.mode which should be create)

Second is condition, which is used for identification of type or object which is defined inside the content model.

There is one more form which can be configured by giving id in the <form> tag.If you give doclib-simple-metadata,then it will open that form in edit properties dialogue.

How to create custom form field in share

While creating custom form control,Inside the ftl file, You need to define an if..else condition for rendering the field in view mode and rendering it in edit mode.If you refer existing textfield.ftl or any other control , inside that there are sections for rendering field in view mode which is your property pane and edit mode, which is edit properties form.

In ftl this can be implemented like below

 <#if form.mode == "view">

//Code for viewing field value

<#else>

//Code for editing field value

</#if>