Alfresco Custom Datalist

Creating a custom Datalist in Alfresco can be a helpful extension when it comes to tracking tasks, issues, or even just keeping a group of items all in one place.Screen Shot 2016-08-30 at 9.00.18 AM

This tutorial will focus on creating a new datalist model, and applying the custom datalist in Alfresco. The four main files, shown below, in the final product of what this datalist will look like, are the model file, the properties file, the context file, and the share-config-custom file. Screen Shot 2016-08-30 at 3.30.25 PM

The Model

First we need to create the datalist model which will define the datalist item type and its properties. Similar to our previous tutorial on creating custom metadata for Alfresco Records management the model will be kept in the alfresco/extension/ folder, only it will go one level deeper and be stored in a “model” folder which will help later on when we get to the context file, which will load the model. 

alfresco/extension/model/fikaDataListModel.xml

<?xml version="1.0" encoding="UTF-8"?>
<model name="fika:fikaDataListModel" xmlns="http://www.alfresco.org/model/dictionary/1.0">
	<description>Tutorial Task Datalist Model</description>
	<author>Sean Dumont</author>
	<version>1.0</version>
	<imports>
		<import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d" />
		<import uri="http://www.alfresco.org/model/content/1.0" prefix="cm" />
		<import uri="http://www.alfresco.org/model/datalist/1.0" prefix="dl" />
	</imports>
	<namespaces>
		<namespace uri="http://www.fikatechnologies.com/model/fikaDataListModel/1.0" prefix="fika" />
	</namespaces>

	<types>
		<type name="fika:fikatasklist">
			<title>Fika Task List</title>
			<parent>dl:dataListItem</parent>
			<properties>
				<property name="fika:startDate">
					<title>Task Start Date</title>
					<type>d:date</type>
				</property>
				<property name="fika:dueDate">
					<title>Task Due Date</title>
					<type>d:date</type>
				</property>
				<property name="fika:taskComments">
					<title>Comments</title>
					<type>d:text</type>
				</property>
			</properties>
			<associations>
				<association name="fika:taskAssignee">
					<title>Assignee</title>
					<source>
						<mandatory>false</mandatory>
						<many>true</many>
					</source>
					<target>
						<class>cm:person</class>
						<many>true</many>
					</target>
				</association>
			</associations>
			<overrides/>
			<mandatory-aspects>
				<aspect>fika:created</aspect>
				<aspect>cm:titled</aspect>
				<aspect>cm:attachable</aspect>
			</mandatory-aspects>
		</type>
	</types>
	<aspects>
		<aspect name="fika:created">
			<title>Task Submission Date</title>
			<parent>cm:auditable</parent>
			<overrides>
					<property name="cm:created">
					</property>
					<property name="cm:creator">
					</property>
			</overrides>
		</aspect>
	</aspects>
</model>

 

The Properties file

The properties file (displayed below) is the file that contains all the labels for the datalist’s properties, aspects, and other metadata. This file will be placed in a “messages” folder which helps differentiate it from the model itself and will be useful for the next step.

alfresco/extension/messages/fikaDataListModel.properties

fika_fikaDataListModel.type.fika_fikatasklist.title=Fika Task List
fika_fikaDataListModel.type.fika_fikatasklist.description=A simple task list including title, description, start date, due date, assignee, comments, and attachments.
fika_fikaDataListModel.property.fika_startDate.title=Start Date
fika_fikaDataListModel.property.fika_dueDate.title=Due Date
fika_fikaDataListModel.property.fika_taskComments.title=Comments
fika_fikaDataListModel.association.fika_taskAssignee.title=Assignee
fika_fikaDataListModel.property.cm_creator.title=Task Submitter

 

 

The Context File

The context file (displayed below) is the file that loads the model and its labels into Alfresco for it to be used. The file location of the context file will be outside of the model and messages file, so Alfresco can pick it up, it is important to note that the file requires the “-context” portion in order to be picked up.

alfresco/extension/fikaDataListModel-context.xml

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans
  PUBLIC '-//SPRING//DTD BEAN//EN'
  'http://www.springframework.org/dtd/spring-beans.dtd'>

<beans>
	<!-- This is filtered by Maven at build time, so that module name is single sourced. -->
    <bean depends-on="dictionaryBootstrap" id="fikaDataListModel.dictionaryBootstrap" parent="dictionaryModelBootstrap">
    	<property name="models">
    		<list>
    			<value>alfresco/extension/model/fikaDataListModel.xml</value>
    		</list>
    	</property>
    	<property name="labels">
    		<list>
    			<value>alfresco.extension.messages.fikaDataListModel</value>
    		</list>
    	</property>
    </bean>

</beans>

 

The Share Configuration

This file allows us to view our changes and additions in Alfresco Share, and will thus be changed on the Share side of things. This file will not be included in the tutorial, but screenshots will be provided below. 

alfresco/web-extension/share-config-custom.xml 

<!-- Task List Datalist Node -->
	<config evaluator="node-type" condition="fika:fikatasklist">
		<forms>
			<form>
				<field-visibility>
					<show id="cm:title" />
					<show id="cm:description" />
					<show id="fika:startDate" />
					<show id="fika:dueDate" />
					<show id="fika:taskAssignee" />
					<show id="fika:taskComments" />
					<show id="cm:attachments" />
				</field-visibility>
				<edit-form template="../data-lists/forms/dataitem.ftl" />
				<appearance>
					<field id="cm:title">
						<control template="/org/alfresco/components/form/controls/textfield.ftl"/>
					</field>
					<field id="fika:taskComments">
						<control template="/org/alfresco/components/form/controls/textarea.ftl"/>
					</field>
					<field id="cm:attachments">
						<control>
							<control-param name="startLocation">{doclib}</control-param>
						</control>
					</field>
				</appearance>
			</form>
		</forms>
	</config>

This above portion defines the node-type, which, upon editing the item, will show these fields in the form.

	<!-- Task List Datalist Model -->
	<config evaluator="model-type" condition="fika:fikatasklist">
		<forms>
			<form>
				<field-visibility>
					<show id="cm:title" />
					<show id="cm:description" />
					<show id="fika:startDate" />
					<show id="fika:dueDate" />
					<show id="fika:taskAssignee" />
					<show id="fika:taskComments" />
					<show id="cm:attachments" />
				</field-visibility>
				<create-form template="../data-lists/forms/dataitem.ftl" />
				<appearance>
					<field id="cm:title">
						<control template="/org/alfresco/components/form/controls/textfield.ftl"/>
					</field>
					<field id="fika:taskComments">
						<control template="/org/alfresco/components/form/controls/textarea.ftl"/>
					</field>
					<field id="cm:attachments">
						<control>
							<control-param name="startLocation">{doclib}</control-param>
						</control>
					</field>
				</appearance>
			</form>

			<form id="datagrid">
				<field-visibility>
					<show id="cm:title" />
					<show id="cm:creator" />
					<show id="cm:description" />
					<show id="fika:startDate" />
					<show id="fika:dueDate" />
					<show id="fika:taskAssignee" />
					<show id="fika:taskComments" />
					<show id="cm:attachments" />
				</field-visibility>
			</form>
		</forms>
	</config>

This above portion dictates how the form will look when a new datalist item is created, and the “<form id=”datagrid”>” portion allows you to choose which items are displayed on the datagrid when viewing the datalist portion of a site.

 

Test the Datalist

Now that everything is all created and in place we will test the newly created datalist.

First we navigate to a site, find and click the “create datalist” button, and find your datalist to give it a title and description. Screen Shot 2016-08-30 at 2.51.09 PMNext we will select the newly created datalist and create a new item by clicking on the “New Item” button.Screen Shot 2016-08-30 at 2.51.26 PM

A form will pop up (we configured this form in the share-config-custom file) and we will be able to fill out the fields.Screen Shot 2016-08-30 at 2.51.36 PM

Once completed our datalist will update and we can see the newly created datalist item.Screen Shot 2016-08-30 at 2.53.11 PM

Files from this tutorial are available for download below. Please leave your feedback, questions, or issues in the comments below. Happy extending!

view this tutorial on github!

6 Comments

  1. Ruben says

    HI,
    Thank you for sharing this information
    It has helped me a lot.
    I JUST HAVE ONE QUESTION.
    WHEN I PRESS THE EDIT BUTTON ONLY ALLOWS ME TO EDIT THE DATA SECTION ATTACHED. HOW CAN I EDIT OTHER FIELDS?
    thank you very much
    regards

      • Sean says

        Hi,

        Without knowing any other specific details to your request, one quick workaround to this issue would be to upload the files into your Alfresco repository first, and then when choosing an attachment you can reference the file you just uploaded. This is an additional step, but would create the desired effect of having your files attached to your Datalist Items.

        – cheers

    • Sean says

      Hi,

      In order to edit other fields, please ensure you’ve reviewed the “Share Configuration” section of the tutorial. The first portion in that section shows that the share configuration will allow you to decide which fields show up in the edit form as well as how they appear as well.

      Customizing the Datalist items and appearance can be tricky, and I’m afraid without more information I can’t get very detailed in my recommendations on how to address your issue.

      – cheers

  2. Lawrence says

    Hi,

    I have followed your tutorial, using your code exactly, and the model works very well. Many thanks for the information.

    However, in the data list and the forms I am getting meta-data fields that I don’t want, such as Date Created, Last Accessed Date etc. I don’t want these fields displayed.

    Any ideas please?

    Thanks and regards,

    Lawrence

    • Sean says

      Hi,

      If there are meta-data fields appearing in your Datalist view and in the forms that you don’t want, I would suggest reviewing your share configuration, and ensure that you’re only including the fields you want in the form and datagrid definitions in your share-custom-config.xml file.

      – cheers

Leave a Reply

Your email address will not be published. Required fields are marked *

From our Blog...

Configuring Alfresco SAML SSO Module with Okta IdP

Alfresco recently released a new patch for their SAML Single Sign On solution module. This module allows Alfresco user’s to configure their Alfresco installation with their Single Sign On (SSO) Identity Provider. In this tutorial, I’ll explain the process of configuring Okta to be used with the module. Note: This tutorial is assuming you’ve followed… Read more »

Read More

Content Migration: Being Prepared

Much like negotiating a treaty between two countries who do not share a common language, someone will be faced with the task of translating. If that translator is not properly prepared the outcome might create more problems than it solves.

Read More

Debugging and Integration Testing in Alfresco SDK 3.0

Alfresco has updated its SDK! See our articles here and here about the basics. In its current state, SDK 3.0 doesn’t support unit testing. It does, however, have a robust Integration Testing framework which, in many ways, covers the same ground and then some. In this article I’ll be going into the basics of Integration… Read more »

Read More