Save button state refresh

Having trouble deploying Oxygen XML Web Author? Got a bug to report? Post it all here.
Johann
Posts: 198
Joined: Wed Jun 17, 2015 12:46 pm

Save button state refresh

Post by Johann »

Hello,

I am using Author web 25.0.0.0 but I have the same behaviour in 24 version.

When I open a document for the first time, the "Save" button is disabled.

If I put the cursor in a text node and I add another character, the "Save" button stays disabled.

In order to make the "Save" button enabled, I have to :
- Add a second character
OR
- Put my cursor at another place in the editor

Why does the "Save" button become enabled after the second character added and not from the first one ?

In the same way, when I save the document (after a change) by clicking the "Save" button or with CTRL + S, the save button remains enabled.
It becomes disabled when I click in the editor view.

Thank you for your help,

Johann
Bogdan Dumitru
Site Admin
Posts: 142
Joined: Tue Mar 20, 2018 5:28 pm

Re: Save button state refresh

Post by Bogdan Dumitru »

Hello Johann,
Why does the "Save" button become enabled after the second character added and not from the first one ?
It doesn't, or at least it shouldn't.

Unfortunately, we don't reproduce the issue you're describing.
What would help us to reproduce the problem or at least to better understand it:
  1. What is your environment?
    • what browser are you using?
    • do you have any browser extensions installed?
    • what OS are you using?
    • do you use or have installed any IME?
  2. Do you reproduce on our public demo server too?
Bogdan Dumitru
http://www.oxygenxml.com
Johann
Posts: 198
Joined: Wed Jun 17, 2015 12:46 pm

Re: Save button state refresh

Post by Johann »

Hello Bogdan,

Indeed it works on your demo server.

There is an important difference in my framework that explains this difference in behaviour.
I needed to customize the toolbars displayed in Author web so I first "deleted" the "Builtin" toolbar in javascript:

Code: Select all

var builtinToolbar=null;
if(actionsConfig.toolbars){
    for(vari=0;i<actionsConfig.toolbars.length;i++){
        vartoolbar=actionsConfig.toolbars[i];
        if(toolbar.name==="Builtin"){
            builtinToolbar=toolbar;
        }
    }
}

if(builtinToolbar){
    builtinToolbar.children=[];
}
Then I added in my framework file the "Save" button:

Code: Select all

<field name="toolbarDescriptor">
	<toolbar>
		<field name="id">
			<String>author_xml_switch_toolbar</String>
		</field>
		<field name="type">
			<Integer>2</Integer>
		</field>
		<field name="toolbarEntriesDescriptorList">
			<toolbarEntry-array>
				<toolbarItem>
					<field name="actionID">
						<String>Author/ShowXML</String>
					</field>
				</toolbarItem>
			</toolbarEntry-array>
		</field>
	</toolbar>
</field>
<field name="additionalToolbarsDescriptors">
	<toolbar-array>
		<toolbar>
			<field name="id">
				<String>author_core_actions_toolbar</String>
			</field>
			<field name="type">
				<Integer>2</Integer>
			</field>
			<field name="toolbarEntriesDescriptorList">
				<toolbarEntry-array>
					<toolbarItem>
						<field name="actionID">
							<String>Author/Undo</String>
						</field>
					</toolbarItem>
					<toolbarItem>
						<field name="actionID">
							<String>Author/Redo</String>
						</field>
					</toolbarItem>
					<toolbarItem>
						<field name="actionID">
							<String>Author/Save</String>
						</field>
					</toolbarItem>
				</toolbarEntry-array>
			</field>
		</toolbar>
	</toolbar-array>
</field>

If I go back to the "Builtin" toolbar I actually don't have the problem anymore.

Why doesn't the Save button react the same way when added manually in the toolbars?

Thank you,

Johann
Bogdan Dumitru
Site Admin
Posts: 142
Joined: Tue Mar 20, 2018 5:28 pm

Re: Save button state refresh

Post by Bogdan Dumitru »

Hi Johann,

Looking at the code snippet you sent, it seems that you removed with no mercy all of the actions from Web Author's application toolbar (the black one).
If you wanted to hide the app bar, there is another way to do this, see "workspace.getViewManager().hideAppBar()" from the Integrating Web Author in a CMS or Another Application topic.

Would it suffice to use the "hideAppBar()" method?
Bogdan Dumitru
http://www.oxygenxml.com
Johann
Posts: 198
Joined: Wed Jun 17, 2015 12:46 pm

Re: Save button state refresh

Post by Johann »

Hello,

I think there is another issue because when I remove my javascript code to remove the "Builtin" toolbar and I let the framework part :

Code: Select all

<field name="toolbarDescriptor">
	<toolbar>
		<field name="id">
			<String>author_xml_switch_toolbar</String>
		</field>
		<field name="type">
			<Integer>2</Integer>
		</field>
		<field name="toolbarEntriesDescriptorList">
			<toolbarEntry-array>
				<toolbarItem>
					<field name="actionID">
						<String>Author/ShowXML</String>
					</field>
				</toolbarItem>
			</toolbarEntry-array>
		</field>
	</toolbar>
</field>
<field name="additionalToolbarsDescriptors">
	<toolbar-array>
		<toolbar>
			<field name="id">
				<String>author_core_actions_toolbar</String>
			</field>
			<field name="type">
				<Integer>2</Integer>
			</field>
			<field name="toolbarEntriesDescriptorList">
				<toolbarEntry-array>
					<toolbarItem>
						<field name="actionID">
							<String>Author/Undo</String>
						</field>
					</toolbarItem>
					<toolbarItem>
						<field name="actionID">
							<String>Author/Redo</String>
						</field>
					</toolbarItem>
					<toolbarItem>
						<field name="actionID">
							<String>Author/Save</String>
						</field>
					</toolbarItem>
				</toolbarEntry-array>
			</field>
		</toolbar>
	</toolbar-array>
</field>
I get two "Save" buttons, the "builtin" one et the one added thanks to the framework but they do not have the same behaviour.

The "builtin" one becomes enabled after one character hit.
The one added with the framework becomes enabled after two character hits.

Regards,

Johann
Bogdan Dumitru
Site Admin
Posts: 142
Joined: Tue Mar 20, 2018 5:28 pm

Re: Save button state refresh

Post by Bogdan Dumitru »

Hello Johann,

You use the sync.api.Editor.EventTypes.ACTIONS_LOADED API in a very creative way and I guess that even the creator of the API didn't consider it. The API was designed to allow users to extend the toolbars by contributing actions or toolbars in "actionsConfig.toolbars", and wasn't designed with the need to remove the application's toolbar in mind.
Anyway, at a first glance, we don't see an instant solution to your problem.

Please help us to understand in-depth what you want to achieve so that can we guide you to a solution that overcomes the problem you encountered.
Please answer the following questions:
  • What is your use case (what do you want to achieve and also why)?
  • Why do you want to remove actions from the application's bar?
  • Why don't you remove the application's bar by using "workspace.getViewManager().hideAppBar()"?
Bogdan Dumitru
http://www.oxygenxml.com
Bogdan Dumitru
Site Admin
Posts: 142
Joined: Tue Mar 20, 2018 5:28 pm

Re: Save button state refresh

Post by Bogdan Dumitru »

Hi,

Indeed, there is a problem with the activation state if you put the Save action inside a custom toolbar.
To overcome it you have to manually refresh the action status when editor's dirty status changes:

Code: Select all

    editor.listen(sync.api.Editor.EventTypes.DIRTY_STATUS_CHANGED,
        () => {
            setTimeout(() =>  {
                editor.getActionsManager().refreshActionsStatus("Author/Save");
            })
        });
Bogdan Dumitru
http://www.oxygenxml.com
Johann
Posts: 198
Joined: Wed Jun 17, 2015 12:46 pm

Re: Save button state refresh

Post by Johann »

Hello Bogdan,

The quick fix works well until the real correction is made ;)

Thank you,

Johann
Post Reply