fixed div id
[sgn.git] / mason / phenome / assign_owner.mas
blob34dce09d39ec7a1e10cda051d46760260304684d
3 <%doc>
5 =head1 NAME
7 /phenome/assign_owner.mas - a component for printing assign locus owner form
9 =head1 DESCRIPTION
12 Parameters:
14 =over 6
16 =item object_id
18 object  id
20 =item  object_type
22 the type of the object (e.g. 'locus', 'stock')
24 =item show_form
25 must be logged in as a curator. Defaults to 0
27 =item sp_person_autocomplete_uri
28 defaults to  '/ajax/people/autocomplete'
30 =item owners_div
31 defaults to 'object_owners'
33 =item owner_add_uri
34 must pass this param
36 =back
38 =head1 AUTHOR
40 Naama Menda <nm249@cornell.edu>
42 =cut
44 </%doc>
46 <%args>
48   $object_id
49   $object_type
50   $sp_person_autocomplete_uri => '/ajax/people/autocomplete/1'
51   $owner_add_uri
52   $show_form => 0
53   $owners_div => 'object_owners'
54 </%args>
56 <script language="javascript">
58   jQuery(function() {
59      jQuery("#sp_person").autocomplete({
60          source: '<% $sp_person_autocomplete_uri %>'
61      });
62   });
64   function submit_owner_form() {
65        var sp_person = jQuery("#sp_person").val();
66          jQuery.ajax({
67            dataType: "json",
68            url: "<% $owner_add_uri %>" ,
69            type:"POST",
70            data: 'object_id='+<% $object_id %>+'&sp_person='+sp_person ,
71            success: function(response) {
72                var error = response.error;
73                if (error) { alert(error) ; }
74                display_owners( "<% $owners_div %>" );
76            }
77        } );
78   }
80   function display_owners(owners_div) {
81     jQuery.ajax( { url: "/<% $object_type %>/<% $object_id %>/owners" , dataType: "json",
82       success: function(response) {
83          jQuery("#"+owners_div).html(response.html);
84       }
85     } );
86   }
88 </script>
91 % if ($show_form) {
93  <&| /page/optional_show.mas, title => "Assign owner" &>
95 <div id="associate_owner_form">
96   Notice: 'user' account will be updated to 'submitter'
97   <div id="person_search" >
98     <form name="owner_form" >
99       <input type="text" style="width: 70%" id="sp_person" name="sp_person" value = "type first or last name"/>
100       <input type="hidden" id="object_id" name="object_id" value="<% $object_id %>" />
101        <input
102          type="button"
103          name = "assign_owner"
104          onclick="javascript:submit_owner_form()"
105          value = "Assign owner" />
106     </form>
107   </div>
108 </div>
110 </&>
112 % }