cancel
Showing results for 
Search instead for 
Did you mean: 

Date notation on custom Aikau page

rhannink
Champ on-the-rise
Champ on-the-rise

Hello,

I have made a custom Aikau page showing all custom aspects of some documents in table form. Two of the custom aspects are of the type d:date. When I display the aspects on the Aikau page using the

alfresco/renderers/Property

widget, the date is showing as:

Zo 5 jun 2016 00:00:00

I would like to display the dates as 5 jun 2016 or 5-06-2016

I have already tried to change the share date notation in

common.properties

, but this was not helping. There also is a

renderDate

method within the

alfresco/renderers/Property

but Iam not sure how to call this method and Iam not sure it is working/implemented at all.

How can i change the date format on my custom Aikau page

With kind regards,

Remco

4 REPLIES 4

steven_okennedy
Star Contributor
Star Contributor
Hi,

It looks like you're not in luck here with the out of the box PropertyWidget, as although it provides a renderDate(date, format) function which is uses for rendering date values, it never uses the format argument and so doesn't give you the option of specifying a format preference.

Creating a custom widget that extends from Property that takes a date format configuration argument is probably your simplest solution, e.g. something like:


define(["dojo/_base/declare",
        "alfresco/renderers/Property"
        ],
        function(declare, Property) {

   return declare([Property], {

      requiredDateFormat: null,
     
      /**
       * Renders a date property using the either the format argument  or
       * requiredDateFormat as the date format.  requiredDateFormat will take
       * preference if set
       *
       * @instance
       */
      renderDate: function(date, format) {
        preferredFormat = (this.requiredDateFormat ? this.requiredDateFormat : format)
         return this.formatDate(this.fromISO8601(date), preferredFormat);
      }
   });
});


This just simply overrides the Property's renderDate method to use a config, requiredDateFormat, as the desired format.  To use it you just set your desired format in your JSON model as a config property when specifying your Property.

Note: I haven't tested this, run this, built this so it's intended as a direction you could go in, not a working solution (although it may be Smiley Happy)

Regards

Steven

ddraper
World-Class Innovator
World-Class Innovator

steven.okennedy _‌ is correct in that no version of Aikau supports what you require (at the time of writing the latest version available is 1.0.85 - if you're reading this any time after 15th Sept 2016 then you may want to check what is available in later releases!)

However, the preferred approach here would be for you to raise an issue on the GitHub project to make us aware of your requirement and then we can actually do something about it. Better yet, rather than just writing a custom widget yourself you could make updates to the existing widgets or add an entirely new widget and contribute it back to the project as a pull request. There is a new backwards compatibly Aikau release on a weekly basis so you wouldn't need to wait very long to take advantage of your contribution.

This ensures that others will also be able to benefit from the addition - it also means that Aikau team will need to support it going forwards which will ensure that your usage of the widget is future proof.

ddraper
World-Class Innovator
World-Class Innovator

I've created a blog post explaining how a feature like this can be contributed back. I've raised a PR and the solution should be available from Aikau 1.0.88

rhannink
Champ on-the-rise
Champ on-the-rise

Dave,

Thanks for your blog and your PR. I have installed Aikau 1.0.90 and used the format property. Ever things works fine now, I can totally control the format of date/time. Either bij keywords (isoDate, shortDate) or by variables (dd-mm-yy).

Thanks again.