Alfresco Share form field visibility depending on other field value

It’s not a common scenario, but sometimes user requirements include dynamic field control visibility depending on a value stored in other field from the same fieldset.

Let’s imagine that we have to show a field named cm:comment only if the field named cm:title includes the sentence Including comments.

Declaring the Share Form Control configuration for our custom form control named my-textfield.ftl should include required parameters.

<config evaluator="node-type" condition="cm:content">
  <forms>
    <form>
      <appearance>
        <field id="cm:comment" label="Comments">
          <control template="/my-textfield.ftl">
		    <control-param name="visibilityField">cm_title</control-param>
		    <control-param name="visibilityCondition">Including comments</control-param>
          </control>
        </field>
      </appearance>
    </form>
  </forms>
</config>

In the my-textfield.ftl Share form control implementation, these values can be handled to show or hide the DIV containing the HTML control.

<!-- Naming field DIV to control visibility -->
<div class="form-field" id="${fieldHtmlId}-control-div">
   <#if form.mode == "view">
      <div class="viewmode-field">
         <span class="viewmode-label">${field.label?html}:</span>
         <span class="viewmode-value">${field.value?html}</span>
      </div>
   <#else>
      <label for="${fieldHtmlId}">${field.label?html}:<#if field.mandatory><span class="mandatory-indicator">*</span></#if></label>
      <input id="${fieldHtmlId}" type="text" name="${field.name}" value="${field.value}" 
            <#if field.disabled>disabled="true"</#if> />
   </#if>
</div>

<!-- Checking conditions when rendering field -->
<script type="text/javascript">//<![CDATA[

	<#if field.control.params.visibilityCondition??>
	YAHOO.util.Event.onContentReady("${fieldHtmlId}", function ()
	{
	
	       // Find value for field "visibilityField"
	       var value = "";
	       <#list form.fields?keys as formfield>
			  <#if formfield == "prop_" + field.control.params.visibilityField?js_string>
			      value = "${form.fields[formfield].value}";
			  </#if>
	       </#list>
	       
	       // Set value coming from control parameters
	       var targetValue = "${field.control.params.visibilityCondition}";
	       
	       // Hide full DIV if values are equal
	       if (value == targetValue) {
	           YAHOO.util.Dom.get("${fieldHtmlId}-control-div").style.display = 'none';
	       }
	       
	}, this);
	</#if>

//]]></script>

Sometimes Alfresco Share can be challenging when trying to find the right way to produce a new feature, but everything is easier than expected in the end!

Alfresco 6, restoring browser basic auth popup for remote APIs

Recently I’ve found another small and undocumented change in Alfresco 6 to be considered before upgrading.

From alfresco-remote-api.6.3, web browser will not present basic auth popup by default, so operations like CMIS Browsing will not be allowed from browser.

In order to restore previous behaviour, a new property has to be added to alfresco-global.properties

alfresco.restApi.basicAuthScheme=true

Main problem is that once this behaviour has been restored, ADF apps show also basic auth popup in login page before login in, what it’s not so user friendly.

Probably for organisations using both CMIS Browsing and ADF applications a patch will be required.

How to use Docker Composition to develop with Alfresco 5/6

Alfresco 5 can be installed in many different ways:

However, since Alfresco 6, the company has started with a new distribution approach based only in Docker for Kubernetes. Currently Alfresco 6 is only at beta stage, so things can change in the future.

Product strategy is to deliver different dockerizations for Enterprise and Community versions:

  • ACS Enterprise
    • Docker images for “micro-services” will only be available under subscription
    • Currently libreoffice, imagemagick & alfresco-pdf-renderer are included only in Enterprise but it looks like in the future they will split the product in many more services
    • Other services and products (from partners or from Alfresco itself) will be included in this private catalog to be used only with Alfresco Enterprise
    • It’s designed to provide native K8s deployment, so Helm charts can be also provided only for Enterprise customers
  • ACS Community
    • This composition delivers a more monolithic approach, providing only big blocks like alfresco, share and solr
    • There is no official deployment guide by now, but I made a simple approach to share with the Community

Additionally, Alfresco ADF applications have also started to deliver docker compositions for development and testing from 2.0.0 release.

Since there are some guides to develop single modules with Docker for Alfresco 6, there is no specification on how to build a unified integration testing environment. Below a sample Docker Composition derived from our internal projects is described.

Required components

  • Database (PostgreSQL or MariaDB)
  • Alfresco repository web application
  • SOLR indexer web application
  • Share web application
  • ADF web application
  • LibreOffice transformation server
  • Web Server like Apache HTTPd or Nginx

Database

Official images from PostgreSQL and MariaDB can be used directly in our composition.

One Docker volume for data storage is required in order to provide persistence.

Alfresco repository

As we are using Alfresco 5.2 by now, we are starting with keensoft templates, but Alfresco will provide a basic image for repository from Alfresco 6 officially.

Configuration is provided by using an external alfresco-global.properties file included in the assets folder and injected during image building process.

Modules can be installed by using AMP or JAR packaging. The files can be copied to amps and jars folders to be deployed in alfresco.war during image building process.

One Docker volume for data storage is required in order to provide persistence.

SOLR

Alfresco started to deliver Docker images for SOLR 6, so they can be used directly in our composition.

One Docker volume for data storage is required in order to provide persistence.

Share

As we are using Alfresco 5.2 by now, we are starting with keensoft templates, but Alfresco will provide a basic image for Share from Alfresco 6 officially.

Configuration is provided by using an external share-config-custom.xml file included in the assets folder and injected during image building process.

Modules can be installed by using AMP or JAR packaging. The files can be copied to amps_share and jars folders to be deployed in share.war during image building process.

No persistent storage is required.

ADF

Alfresco does not provide any official application based in ADF to be installed as main users UI. However, you can find a Docker image for Alfresco Content Application (the reference sample application).

Anyway as every ADF sample application provided by Alfresco is using the root path out of the box, it’s required to modify packaging instructions at package.json to produce a web application able to be deployed in a different base href.

No persistent storage is required.

LibreOffice

Alfresco is releasing an official LibreOffice image, but it looks like this image will work only with Enterprise. This is why we are including our image from keensoft templates

No persistent storage is required.

Web Server

Alfresco is not including any configuration to run all componentes together, as they are aiming to deploy the whole thing in K8s. We are using an approach based in Apache HTTPd to configure a simple proxy delivering all these services by plain HTTP port 80.

Operations

Following operations are supported by this configuration:

  • Modules deployment in repository
  • Modules deployment in Share
  • Repository configuration
  • Share configuration
  • ADF application updating
  • Docker rebooting with persistent storage

Recap

Sample project including a reference Docker Composition and some instructions is available at https://github.com/angelborroy/alfresco-docker-201707-GA

Alfresco 6 will require more work from the Community in order to be adopted by small companies, but building a common base could be helpful for everyone.