Tech List

[index] [prev] [next] [options] [help]
See the Mailing Lists Page for how to subscribe and unsubscribe.

eprints_tech messages

Please note: this page shows emails that have been sent to the eprints_tech mailing list. Some of these may be spam emails we have failed to filter.

Re: [EP-tech] Condition in the workflow

From: Tim Brody <tdb01r AT ecs.soton.ac.uk>
Date: Thu, 09 Oct 2008 16:06:16 +0100


Threading: [EP-tech] Condition in the workflow from simone AT cib.unibo.it
      • This Message

*** http://www.eprints.org/tech.php/id/%3C48EE1DE8.80107%40ecs.soton.ac.uk%3E
*** EPrints community wiki - http://wiki.eprints.org/

Simone Sacchi wrote:
> *** 
http://www.eprints.org/tech.php/id/%3CEMEW-k988Lg0be70e4325a5c70b8fd868eeb6057ee3-200810090921.39443.simone%40cib.unibo.it%3E
> *** EPrints community wiki - http://wiki.eprints.org/
>
> Hi Tim,
>
> What I want to achieve is the following situation:
>
> 1) An author upload a document, and so he get the field 
"security" to be 
> selected.
>
> 2) The field "Security" (which is a nameset field) contains a 
value 
> called "Distribution List"
>
> 3) If the author select "Distribution List" I want the page to 
be reloaded and 
> a text field called "List name" should appear, to be filled with 
a value.
>
> I thought that the best way to do it was having some javascript on the 
select 
> to reload the page and submit the value, and have in the workflow a 
condition 
> that say 'only display the document field called "List name" if 
"security" is 
> set to "Distribution List".
>
> So I know that I should modify the InputForm/Upload.pm plugin....
>
> Maybe another solution could be to use javascript simply to hide/unhide 
that 
> field based on the selected value of "security"...
>   
The trouble is the workflow is executed in the context of the eprint - 
you can't conditionally operate on the document in the workflow.

I *think* your best bet is to include the field in the workflow then 
inject some javascript using the XHTML component.

I've thrown together some demonstration javascript:
    <component type="XHTML"><script 
type="text/javascript">
        // <![CDATA[
        var security_language_inputs = Array();
        function init_security_watch()
        {
            var languages = $$('select[name$="language"]');
            var securities = $$('select[name$="security"]');
            for(var i = 0; i < securities.length; ++i)
            {
                if( securities[i].value != 'public' )
                    languages[i].disabled = true;
                security_language_inputs[securities[i]] = languages[i];
                Element.observe(securities[i], 'change', (function() {
                    if( this.value == 'public' )
                        security_language_inputs[this].disabled = false;
                    else
                        security_language_inputs[this].disabled = true;
                }).bindAsEventListener(securities[i]));
            }
        }
        document.observe('dom:loaded', function () { 
init_security_watch(); });
        // ]]>
    </script></component>

(It would be better to put the javascript in a file in 
static/javascript/auto)

The selects look like this:

<select name="c4_doc5_language" id="c4_doc5_language" 
size="1">

The "c4" bit there is specific to the workflow, so difficult to work 
out 
(unless someone knows something I don't).

Phew :-)

All the best,
Tim.


[index] [prev] [next] [options] [help]