cancel
Showing results for 
Search instead for 
Did you mean: 

Surf Extension - edit-metadata forms component override

loftux
Star Contributor
Star Contributor
In the edit-metadata page I want to use a special form if the document has a specific aspect applied. For what I can tell by mere forms config you cannot do this based on aspect, only on document type.
So instead looking into surf extension, if I can do something like

<extension>
   <modules>
      <module>
         <id>ReplaceForm</id>
         <description>Show edit metadata for specific form</description>
         <components>
            <component>
               <region-id>edit-metadata</region-id>
               <source-id>edit-metadata</source-id>
               <scope>template</scope>
               <sub-components>
                  <sub-component id="edit-metadata">
                     <evaluations>
                        <evaluation id="hide">
                           <render>false</render>
                        </evaluation>
                     </evaluations>
                  </sub-component>
                  <sub-component id="edit-metadata-new" index="25">
                     <url>/components/form</url>
                     <properties>
                        <itemKind>node</itemKind>
                        <itemId>{nodeRef}</itemId>
                        <formId>customformid</formId>
                        <mode>edit</mode>
                        <submitType>json</submitType>
                        <showCaption>true</showCaption>
                        <showCancelButton>true</showCancelButton>
                     </properties>
                  </sub-component>
               </sub-components>
            </component>
         </components>
      </module>
   </modules>
</extension>
and  with the new subcomponent adding <formId>customformid</formId> I think I can achieve what I want, using a special form.
But that means an evaluator that can evaluate on hasAspect. There is one org.alfresco.web.evaluator.HasAspectEvaluator but is this available in this context? Does Surf at this time now about the node, and can do evaluations based on that?
3 REPLIES 3

afaust
Legendary Innovator
Legendary Innovator
Hello,

the hasAspect evaluator is not a Surf evaluator but a Share Documentlibrary one - that is a huge difference. Surf requires a bean which is a SubComponentEvaluator type and registered via a Spring context - it would know the hasAspect evaluator, but that one is of a different type for a different purpose.

There currently is no Surf sub-component evaluator defined by default which can handle the nodeRef URL parameter and check that for a specific aspect. You would have to implement you own and properly register this in a Spring context file to be able to use it in Surf.

Regards
Axel

loftux
Star Contributor
Star Contributor
I came up with a solution that I wrote about in my blog
http://loftux.com/2012/05/04/select-metadata-edit-form-based-on-aspect/

afaust
Legendary Innovator
Legendary Innovator
A different approach made possible by the new flexibility in Share customization. Nice one…

Based on the use case you explained in your blog, you might have also used a form filter (and possibly a guard policy) on the Repository tier to ensure read-only behavior on a lower level, so to avoid URL-based hacks and partially redundant form configuration. But of course, as you stated, such type of security was not warranted in your case.