Filling date field automatically

Post here questions and problems related to oXygen frameworks/document types.
mu258770
Posts: 150
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: 341
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: 341
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: 150
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: 341
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

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

Re: Filling date field automatically

Post by mu258770 » Tue May 11, 2021 9:12 am

Hi Cristian,

Thanks a lot for your quick response. This works good in Eclipse Oxygen. But as you said, in Oxygen Web Author, the ${author.name} does not work.

Is there any plan to support this in Oxygen Web Author?

Regards,
Shabeer

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

Re: Filling date field automatically

Post by cristi_talau » Tue May 11, 2021 10:14 am

Hello,

I already registered an issue for this environment variable. However, since it has an workaround (developing a custom AuthorOperation), it is not high priority for us.

If you want a faster solution, I can give you more details regarding the implementation of an AuthorOperation.

Best,
Cristian

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

Re: Filling date field automatically

Post by mu258770 » Tue May 11, 2021 5:15 pm

Hi Cristian,

Yes, if this can be implemented with less efforts, am really interested in implementing it.

We do support Eclipse Oxygen and Oxygen Web Author and we would really keep both in sync.

Regards,
Shabeer

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

Re: Filling date field automatically

Post by cristi_talau » Wed May 12, 2021 12:58 pm

Hello,

I created a plugin that provides an com.oxygenxml.username.InsertFragmentOperation that supports an ${user.name} editor variable (instead of the ${author.name} one supported in Oxygen XML Editor). You can find the plugin here: https://github.com/oxygenxml/web-author ... ion-plugin .

To have a solution that works in both applications you can use media queries in CSS to target a different platform: webapp (Web Author) vs standalone (Oxygen XML Editor): https://www.oxygenxml.com/doc/versions/ ... -type.html .

Best,
Cristian

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

Re: Filling date field automatically

Post by mu258770 » Wed May 12, 2021 3:56 pm

Hi Cristian,

Thanks a lot for the plugin :). I will check and come back to you.

Regards,
Shabeer

Post Reply