Filling date field automatically

Post here questions and problems related to oXygen frameworks/document types.
mu258770
Posts: 145
Joined: Mon Aug 18, 2014 4:11 pm

Filling date field automatically

Post by mu258770 » Wed Jun 20, 2018 11:21 am

Hi

Whether it is possible for Date field to be filled automatically.

Would it be possible to auto-insert the current date when item is inserted?

For example : '<change-completed>' in '<change-historylist>'.

Best Regards
Shabeer

cristi_talau
Posts: 327
Joined: Thu Sep 04, 2014 4:22 pm

Re: Filling date field automatically

Post by cristi_talau » Wed Jun 20, 2018 7:20 pm

Hello,

I will describe below a solution that will insert the current date whenever you insert a "change-completed" element using the content completion menu.

You can customize the DITA framework [1] to define an Author Action with the following details:
- Activation XPath: oxy:allows-child-element("change-completed")
- Operation: ro.sync.ecss.extensions.commons.operations.InsertFragmentOperation
- Fragment argument: <change-completed>${date('yyyy-MM-dd')}</change-completed>.

This action should be added to the content completion menu and the element change-completed should be removed from the content completion menu [2].

Best,
Cristian

[1] https://www.oxygenxml.com/doc/versions/ ... works.html
[2] https://www.oxygenxml.com/doc/versions/ ... n-tab.html

cristi_talau
Posts: 327
Joined: Thu Sep 04, 2014 4:22 pm

Re: Filling date field automatically

Post by cristi_talau » Wed Jun 27, 2018 10:40 am

Hello,

Here's another (simpler) solution for your use-case. Use CSS to add a button form-control on each empty "change-completed" element. Clicking this button would insert the current date in the existing element. Below is the relevant CSS snippet :

Code: Select all


change-completed:empty:after {
content: oxy_button(actionID, 'insert-current-date')
}
The action could be defined as "InsertFragmentOperation" using the same fragment as in the post above.

Best,
Cristian

mu258770
Posts: 145
Joined: Mon Aug 18, 2014 4:11 pm

Re: Filling date field automatically

Post by mu258770 » Fri May 07, 2021 2:13 pm

Hi Cristian,

We need a slightly different thing here,

We have defined a CSS button in Oxygen to insert <change-info> and its subelements. The CSS look like below,

Code: Select all

*[class~="relmgmt-d/change-item"]:after{
    content: oxy_button(
    action, oxy_action(
          name, '+',
		  description, 'Click to add one more Change item', 
		   arg-fragment, '<change-item><change-person/><change-request-reference><change-request-system/><change-request-id/></change-request-reference><change-completed></change-completed><change-summary/><data/></change-item>',
          operation, 'ro.sync.ecss.extensions.commons.operations.InsertFragmentOperation', 
          arg-insertLocation, '.',
          arg-insertPosition, 'After'
),showText, false);  
}


This works properly. With this when we click on the + button, it inserts all the subelements of change-info as we defined above.

But we need to extend this further that when these elements get inserted, we want the following element values auto-filled:

1) <change-person> - with the author name
2) <change-completed> - with the current date

How that can be done? Is it already supported in the existing Oxygen CSS?

Regards,
Shabeer

cristi_talau
Posts: 327
Joined: Thu Sep 04, 2014 4:22 pm

Re: Filling date field automatically

Post by cristi_talau » Mon May 10, 2021 1:26 pm

Hello,

To get this behavior, you can use Oxygen Editor Variables in the inserted fragment, such as:
  • ${author.name}
  • ${date(pattern)}
You can find more details here [1].
Currently, the ${author.name} variable is not supported in Oxygen XML Web Author . If you are interested in a solution for this product, you can implement your own Java sub-class of AuthorOperation [2] that inserts the author name in the right place.

Best,
Cristian

[1] https://www.oxygenxml.com/doc/versions/ ... ables.html
[2] https://www.oxygenxml.com/doc/versions/ ... HowTo.html

Post Reply