Merge pull request #4106 from solgenomics/topic/wishlist
[sgn.git] / mason / phenome / assign_owner.mas
blob1fbbe97b951ae19e2e24e1ade943e181a9c6ab6b
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 %>" );
75            }
76        } );
77   }
79 </script>
82 % if ($show_form) {
84  <&| /page/optional_show.mas, title => "Assign owner" &>
86 <div id="associate_owner_form">
87   Notice: 'user' account will be updated to 'submitter'
88   <div id="person_search" >
89     <form name="owner_form" >
90       <input type="text" style="width: 70%" id="sp_person" name="sp_person" value = "type first or last name"/>
91       <input type="hidden" id="object_id" name="object_id" value="<% $object_id %>" />
92        <input
93          type="button"
94          name = "assign_owner"
95          onclick="javascript:submit_owner_form()"
96          value = "Assign owner" />
97     </form>
98   </div>
99 </div>
101 </&>
103 % }