How to raise a dialog from JavaScript?

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2008 01:19 PM
Hello there,
I'm new on Alfresco, so my question may look a little bit silly.
I intend to make a custom action which could be seen e.g. in the 'more actions' menu and which executes the following:
1. Copy the document to another folder;
2. Add an aspect to this copy;
3. Raise the 'Details Edit' dialog to motivate the user to fill in the added aspect properties;
I've successfully registered this action, it's visible in the menu, and it calls a script, which executes the copy and the addAspect. But I don't know how to raise the dialog. Is it possible to do this from JavaScript?
Or am I going a totally wrong way and there ist another, more common solution?
Thanks in advance
Markus
I'm new on Alfresco, so my question may look a little bit silly.
I intend to make a custom action which could be seen e.g. in the 'more actions' menu and which executes the following:
1. Copy the document to another folder;
2. Add an aspect to this copy;
3. Raise the 'Details Edit' dialog to motivate the user to fill in the added aspect properties;
I've successfully registered this action, it's visible in the menu, and it calls a script, which executes the copy and the addAspect. But I don't know how to raise the dialog. Is it possible to do this from JavaScript?
Or am I going a totally wrong way and there ist another, more common solution?
Thanks in advance
Markus
Labels:
- Labels:
-
Archive
7 REPLIES 7

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2008 05:11 PM
No, you can't launch the dialog from your script. The script you describe will be running on the server side (in the repository) and hence can not effect the client.
You could get the script to return some client side javascript which in turn can be used to call another action that launches the dialog.
Alternatively, you could create a custom action, with these you can define some UI, so you could collect the metadata before copy and add aspect is performed. Have a look at the following wiki pages:
http://wiki.alfresco.com/wiki/Custom_Actions
http://wiki.alfresco.com/wiki/Custom_Action_UI
You could get the script to return some client side javascript which in turn can be used to call another action that launches the dialog.
Alternatively, you could create a custom action, with these you can define some UI, so you could collect the metadata before copy and add aspect is performed. Have a look at the following wiki pages:
http://wiki.alfresco.com/wiki/Custom_Actions
http://wiki.alfresco.com/wiki/Custom_Action_UI

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2008 02:47 PM
Thanks for your answer, Gavin.
Unfortunately I'm not (yet) a Java programmer, therefore it's not the right thing for me to define my own action handler as described in the Wiki. And as far as I understand your response, it's not possible to do it just by configuration, right?
So it seems, that the only way for me is to try it with Javascript. Please, could you give some more hints how to return and automatically call the client side javascript?
Thanks in advance again
Markus
Unfortunately I'm not (yet) a Java programmer, therefore it's not the right thing for me to define my own action handler as described in the Wiki. And as far as I understand your response, it's not possible to do it just by configuration, right?
So it seems, that the only way for me is to try it with Javascript. Please, could you give some more hints how to return and automatically call the client side javascript?
Thanks in advance again
Markus

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2008 04:31 PM
Oh, I'm sorry: That's a clear (and as I know now: a nearly simple) Javascript issue. I think this forum is not the right place for that. :wink:
Greetings
Markus
Greetings
Markus
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2008 06:11 AM
hey markusd,
could you please post how you managed to configure that script execution. i am searching for exactly what you already managed to do. i want to create a javascript that allows a user to move a document and inform a specific user via email. and i want this script-execution action only to be available on spaces of my choice. i think you did something very similar. would be great if you could reveal how you did it…
greets benni
could you please post how you managed to configure that script execution. i am searching for exactly what you already managed to do. i want to create a javascript that allows a user to move a document and inform a specific user via email. and i want this script-execution action only to be available on spaces of my choice. i think you did something very similar. would be great if you could reveal how you did it…
greets benni

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2008 11:22 AM
Hi benni,
I did the following (modified for your needs):
Insert the following code to the web-client-config-custom.xml to define a new action:
I think this is the best point to manage the availability of the action, using the permissions. I don't know whether it's possible to make this action available only for certain spaces.
In the same <actions>-block, override the default menu configuration:
Then create the required MyJavaScript.js in the Data Dictionary inside the repository, something like this:
Till now I didn't try to email from a javascript, but there is a description about this in the wiki (lucky you, the mail service is out-of-the-box a registered and therefore scriptable action). Please look at the example in
http://wiki.alfresco.com/wiki/JavaScript_API
I hope this helps a little bit. If it's not detailed enough, your welcome to ask again.
Greetings
Markus
I did the following (modified for your needs):
Insert the following code to the web-client-config-custom.xml to define a new action:
<config> <actions> <action id="my_action"> <permissions> <permission allow="true">Write</permission> </permissions> <label>My Action</label> <image>/images/icons/submit.gif</image> <script>/Firmen Arbeitsbereich/Data Dictionary/Scripts/MyJavaScript.js</script> <params> <param name="noderef">#{actionContext.nodeRef}</param> </params> </action> </actions> </config>
I think this is the best point to manage the availability of the action, using the permissions. I don't know whether it's possible to make this action available only for certain spaces.
In the same <actions>-block, override the default menu configuration:
<action-group id="document_browse_menu"> <action idref="preview_doc" hide="true" /> <action idref="update_doc" hide="true" /> <action idref="cancelcheckout_doc" hide="true" /> <action idref="approve_doc" hide="true" /> <action idref="reject_doc" hide="true" /> <action idref="cut_node" hide="true" /> <action idref="copy_node" hide="true" /> <action idref="start_workflow" hide="true" /> <action idref="my_action" /> </action-group>
to insert this action in a menu with an icon of your choice. Please look at the web-client-config-actions.xml to find out more of the available menus.Then create the required MyJavaScript.js in the Data Dictionary inside the repository, something like this:
var noderef = args["noderef"];var document = search.findNode(noderef);var targetfolder = companyhome.childByNamePath("TargetFolderName");if ((document != null) && (targetfolder != null)){ // Copy current document to target folder var copy = document.copy(targetfolder); // Add aspect copy.addAspect("namespace:aspectname"); // To do: eMail to somebody} var goBack = "<script>history.back();</script>";goBack;
Till now I didn't try to email from a javascript, but there is a description about this in the wiki (lucky you, the mail service is out-of-the-box a registered and therefore scriptable action). Please look at the example in
http://wiki.alfresco.com/wiki/JavaScript_API
I hope this helps a little bit. If it's not detailed enough, your welcome to ask again.
Greetings
Markus

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2008 09:22 AM
To display the details page for your copied node try replacing
in you script with:
var goBack = "<script>history.back();</script>";
in you script with:
var goBack = "<script>window.location.replace('/alfresco/navigate/showDocDetails/workspace/SpacesStore/' + copy.id);</script>";

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2008 02:17 PM
To display the details page for your copied node try replacingvar goBack = "<script>history.back();</script>";
in you script with:var goBack = "<script>window.location.replace('/alfresco/navigate/showDocDetails/workspace/SpacesStore/' + copy.id);</script>";
Mike,
This works quite well. Is it possible to open the details page for editing? I've been using
"<script>alert('" + alertMessage + "');window.location.replace('/alfresco/navigate/showSpaceDetails/workspace/SpacesStore/" + dest.id + "');</script>";
but have been unable, as yet, to open the page in my javascript.
