From 2ebef0954152c993bc274fa81f5d7f385f71b5e3 Mon Sep 17 00:00:00 2001 From: nmenda Date: Mon, 22 Jan 2024 09:47:16 -0500 Subject: [PATCH 1/3] fix sp_person.disabled column name --- lib/SGN/Controller/AJAX/People.pm | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/lib/SGN/Controller/AJAX/People.pm b/lib/SGN/Controller/AJAX/People.pm index be72bf41a1..7ea570d404 100644 --- a/lib/SGN/Controller/AJAX/People.pm +++ b/lib/SGN/Controller/AJAX/People.pm @@ -6,7 +6,7 @@ backend for the sgn_people schema =head1 DESCRIPTION -REST interface for searching people, getting user data, etc. +REST interface for searching people, getting user data, etc. =head1 AUTHOR @@ -54,7 +54,7 @@ sub autocomplete_GET :Args(1) { $person =~ s/(^\s+|\s+)$//g; $person =~ s/\s+/ /g; my $q = "SELECT sp_person_id, first_name, last_name FROM sgn_people.sp_person - WHERE lower(first_name) like ? OR lower(last_name) like ? and censor =0 and disable IS NULL + WHERE lower(first_name) like ? OR lower(last_name) like ? and censor =0 and disabled IS NULL LIMIT 20"; my $sth = $c->dbc->dbh->prepare($q); @@ -107,7 +107,7 @@ sub roles :Chained('/') PathPart('ajax/roles') CaptureArgs(0) { my $c = shift; print STDERR "ajax/roles...\n"; - + $c->stash->{message} = "processing"; } @@ -128,20 +128,20 @@ sub list_roles :Chained('roles') PathPart('list') Args(0) { while (my $row = $rs1->next()) { $roles{$row->sp_role_id} = $row->name(); } - + my $rs2 = $schema->resultset("SpPerson")->search( { censor => 0, disabled => undef }, { join => 'sp_person_roles', '+select' => ['sp_person_roles.sp_role_id', 'sp_person_roles.sp_person_role_id' ], '+as' => ['sp_role_id', 'sp_person_role_id' ], order_by => 'sp_role_id' }); - + my @data; my %hash; my %role_colors = ( curator => 'red', submitter => 'orange', user => 'green' ); my $default_color = "#0275d8"; - + while (my $row = $rs2->next()) { my $person_name = $row->first_name." ".$row->last_name(); @@ -150,17 +150,17 @@ sub list_roles :Chained('roles') PathPart('list') Args(0) { if ($c->user()->has_role("curator")) { $delete_link = 'X'; } - + else { $delete_link = "X"; } - + $hash{$row->sp_person_id}->{userlink} = ''.$row->first_name()." ".$row->last_name().''; my $role_name = $roles{$row->get_column('sp_role_id')}; print STDERR "ROLE : $role_name\n"; - + if (! $c->user()->has_role("curator")) { # only show breeding programs if ($role_name !~ /curator|user|submitter/) { @@ -172,14 +172,14 @@ sub list_roles :Chained('roles') PathPart('list') Args(0) { $hash{$row->sp_person_id}->{userroles} .= ''. $delete_link."   ".$role_name.""; $hash{$row->sp_person_id}->{add_user_link} = $add_user_link; } - + } foreach my $k (keys %hash) { $hash{$k}->{userroles} .= $hash{$k}->{add_user_link}; push @data, [ $hash{$k}->{userlink}, $hash{$k}->{userroles} ]; } - + $c->stash->{rest} = { data => \@data }; } @@ -206,7 +206,7 @@ sub list_roles :Chained('roles') PathPart('list') Args(0) { # $c->stash->{rest} = { error => "You don't have the necessary privileges for maintaining user roles." }; # return; # } - + # } @@ -215,7 +215,7 @@ sub delete :Chained('roles') PathPart('delete/association') Args(1) { my $self = shift; my $c = shift; my $sp_person_role_id = shift; - + if (! $c->user()) { $c->stash->{rest} = { error => "You must be logged in to use this function." }; return; @@ -227,7 +227,7 @@ sub delete :Chained('roles') PathPart('delete/association') Args(1) { } my $schema = $c->dbic_schema("CXGN::People::Schema"); - + my $row = $schema->resultset("SpPersonRole")->find( { sp_person_role_id => $sp_person_role_id } ); if (!$row) { @@ -244,4 +244,3 @@ sub delete :Chained('roles') PathPart('delete/association') Args(1) { ### 1; - From e49364bd3d88de6b6c10c77f91ad9f8aa234eb32 Mon Sep 17 00:00:00 2001 From: nmenda Date: Mon, 22 Jan 2024 10:39:05 -0500 Subject: [PATCH 2/3] display new assigned locus owner --- mason/phenome/assign_owner.mas | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/mason/phenome/assign_owner.mas b/mason/phenome/assign_owner.mas index 1fbbe97b95..34dce09d39 100644 --- a/mason/phenome/assign_owner.mas +++ b/mason/phenome/assign_owner.mas @@ -72,17 +72,26 @@ Naama Menda var error = response.error; if (error) { alert(error) ; } display_owners( "<% $owners_div %>" ); + } } ); } + function display_owners(owners_div) { + jQuery.ajax( { url: "/<% $object_type %>/<% $object_id %>/owners" , dataType: "json", + success: function(response) { + jQuery("#"+owners_div).html(response.html); + } + } ); + } + % if ($show_form) { <&| /page/optional_show.mas, title => "Assign owner" &> - +
Notice: 'user' account will be updated to 'submitter'