Action Disable

Having trouble installing <oXygen/>? Got a bug to report? Post it all here.
Konstantin
Posts: 61
Joined: Tue Oct 27, 2015 11:49 am

Action Disable

Post by Konstantin » Wed May 11, 2016 6:13 pm

Hello !

I use WebApp 18.0.0

I need disable action when there is changes in editor.
Actions does not have property Enable.
I tried write something like this, but it not works:

Code: Select all

goog.events.listen(workspace, sync.api.Workspace.EventType.EDITOR_LOADED, function(e) {
window.editor = e.editor;

goog.events.listen(window.editor, sync.api.Editor.EventTypes.DIRTY_STATUS_CHANGED, function(e) {
CheckInAction.isEnabled = function() {
return !e.isDirty;
};
});
});
How could I do this?

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

Re: Action Disable

Post by cristi_talau » Wed May 11, 2016 6:27 pm

Hello,

The status (enabled or disabled) of the actions is not updated automatically. You should call the "refreshActionsStatus" method of the actions manager to trigger a status refresh.

Best,
Cristian

[1] https://www.oxygenxml.com/maven/com/oxy ... ionsStatus

Konstantin
Posts: 61
Joined: Tue Oct 27, 2015 11:49 am

Re: Action Disable

Post by Konstantin » Thu May 12, 2016 11:38 am

I did as you said but it does not work. Could you correct me

I signed to Editor after editor load.

Code: Select all

goog.events.listen(workspace, sync.api.Workspace.EventType.EDITOR_LOADED, function(e) {
window.editor = e.editor;
});
I created new action.

Code: Select all

CheckInAction = function(editor, docId, problemReporter) {
this.editor = editor;
this.docId = docId;
this.problemReporter = problemReporter;
};
Then I override method isEnabled

Code: Select all

CheckInAction.prototype.isEnabled = function() {
return !this.editor.isDirty();
};
Then I added the action to toolbar

Code: Select all

goog.events.listen(workspace,
sync.api.Workspace.EventType.BEFORE_EDITOR_LOADED, function(e) {
var editor = e.editor;
var preventLeave = e.preventLeave;
var docId = e.docId;
var problemReporter = e.problemReporter;
// Register the newly created action.
editor.getActionsManager().registerAction('checkIn.action',
new CheckInAction(editor, docId, problemReporter));
addToDitaToolbar(editor, 'checkIn.action');
});
Then I try refresh status action by Click on button or by Changing content in editor but nothing happen.

Code: Select all

CheckInAction.prototype.actionPerformed = function(callback) {

this.actionsManager.refreshActionsStatus(["checkIn.action"]);

......
};

goog.events.listen(window.editor, sync.api.Editor.EventTypes.DIRTY_STATUS_CHANGED, function(e) {
this.actionsManager.refreshActionsStatus(["checkIn.action"]);-
});
By click button the refresh does nothing.
And listener does not called.

Konstantin
Posts: 61
Joined: Tue Oct 27, 2015 11:49 am

Re: Action Disable

Post by Konstantin » Thu May 12, 2016 12:00 pm

All right
I found error for button click (not right scope of variables)
Thanks )

Post Reply