Merge pull request #3313 from solgenomics/topic/add_pedigree_upload_header_check
[sgn.git] / mason / genefamily / manual / add_locus.mas
blob85db2e94e2b57ccdb49feb7c2a869eae736ed9f4
1 <%doc>
3 =head1 NAME
5 /genefamily/manual/add_locus.mas - a component for adding a locus to a locusgroup
7 =head1 DESCRIPTION
10 Parameters:
12 =over 1
14 =item locusgroup_id
17 a database id
21 =back
23 =head1 AUTHOR
25 Naama Menda <nm249@cornell.edu>
27 =cut
30 </%doc>
32 <%args>
34 $locusgroup_id
35 $add_locus_uri => '/ajax/genefamily/manual/add'
36 $members_div => 'locusgroup_members'
37 $locus_autocomplete_uri => '/ajax/locus/autocomplete'
38 </%args>
41 <script language="javascript">
43  jQuery(function() {
44        var common_name = jQuery('#organism_select option:selected').attr("value");
45        jQuery("#locus").autocomplete({
46              source: '<% $locus_autocomplete_uri %>' + "?common_name=" + common_name + "&mode=no_alleles",
47              autoFocus: true,
48              minLength: 2,
49              select: function(event, ui) {
50                       Ontology.populateEvidence( 'locus_evidence_code_select', '/ajax/cvterm/evidence');
51                }
52           });
54        jQuery("#organism_select").change(function(){
55              common_name = jQuery('#organism_select option:selected').attr("value");
56              jQuery("#locus").autocomplete('option', 'source', '<% $locus_autocomplete_uri %>' + "?mode=no_alleles" + "&common_name=" + common_name  );
57        });
59   });
61   function update_references() {
62            var locus_info = jQuery("#locus").val();
63            var mySplitResult = locus_info.split("|");
64            var locus_id = mySplitResult[2];
65             Ontology.populateEvidence('locus_reference_select', '/locus/'+locus_id+'/references');
66   }
68   function submit_add_locus_form() {
69     //make an AJAX request with the form params
70     var locus = jQuery("#locus").val();
71     var reference_id = jQuery("#locus_reference_select").val();
72     var evidence_code_id = jQuery("#locus_evidence_code_select").val();
73     jQuery.ajax({
74             url: "<% $add_locus_uri %>" ,
75             type:"POST",
76             data: 'locusgroup_id='+<% $locusgroup_id %>+'&locus='+locus +'&evidence_id='+evidence_code_id +'&reference_id=' + reference_id,
77             success: function(response) {
78                var error = response.error;
79                if (error) { alert(error) ; }
80                 Locus.displayMembers( "<% $members_div %>", "<% $locusgroup_id %>" );
81                 reset_form();
82              }
83      } );
84   }
86    function reset_form() {
87          Effects.hideElement('associateLocusForm');
88          jQuery("#locus_evidence_code_select").html();
89   }
91 </script>
93 <& /util/import_javascript.mas, classes=>[qw[ jqueryui popup CXGN.Phenome.Locus CXGN.AJAX.Ontology ] ]&>
96 <div id='associateLocusForm' style="display: none">
97   <div id='locus_search'>
98     <input type="text"
99            style="width: 50%"
100            id="locus"
101            name="locus" >
102     <select id = "organism_select"  onchange="jQuery('#locus').val('--type a locus name--');$('associate_locus_button').disabled=true""
103       </select>
104     </select>
106     <select id="locus_evidence_code_select" style="width: 50%"
107             onchange="$('associate_locus_button').disabled=false;javascript:update_references()">
108     </select>
109     <select id="locus_reference_select" style="width: 100%">
110     </select>
112   <input type="button"
113           id="associate_locus_button"
114           value="Associate locus"
115          disabled="true"
116          onclick="javascript:submit_add_locus_form();this.disabled=true;" />
117   </div>
118 </div>