From 78cfcdb8c39249dcd2a54ca50977f5b5c5552a78 Mon Sep 17 00:00:00 2001 From: titima15 Date: Tue, 24 Sep 2024 17:41:50 -0400 Subject: [PATCH] modified autogenerated name method --- lib/SGN/Controller/AJAX/Transformation.pm | 1 + lib/SGN/Controller/Transformation.pm | 11 +++++++++++ .../transformation/add_transformant_names_dialog.mas | 20 ++++++++++++++------ mason/transformation/transformation.mas | 8 +++++--- 4 files changed, 31 insertions(+), 9 deletions(-) diff --git a/lib/SGN/Controller/AJAX/Transformation.pm b/lib/SGN/Controller/AJAX/Transformation.pm index 647b2c2b3..83a891fac 100644 --- a/lib/SGN/Controller/AJAX/Transformation.pm +++ b/lib/SGN/Controller/AJAX/Transformation.pm @@ -435,6 +435,7 @@ sub add_transformants_POST :Args(0){ my $transformation_stock_id = $c->req->param('transformation_stock_id'); my $new_name_count = $c->req->param('new_name_count'); my $last_number = $c->req->param('last_number'); + my $prefix = $c->req->param('last_prefix'); if (!$c->user()){ $c->stash->{rest} = {error => "You need to be logged in to add new transformants."}; diff --git a/lib/SGN/Controller/Transformation.pm b/lib/SGN/Controller/Transformation.pm index 7cf4a5f61..69c2974d4 100644 --- a/lib/SGN/Controller/Transformation.pm +++ b/lib/SGN/Controller/Transformation.pm @@ -74,6 +74,17 @@ sub transformation_page : Path('/transformation') Args(1) { print STDERR "NAME =".Dumper($project_name)."\n"; my $project_link = qq{$project_name}; + my $name_prefix_cvterm_id = SGN::Model::Cvterm->get_cvterm_row($schema, 'autogenerated_name_prefix', 'project_property')->cvterm_id(); + my $name_prefix_rs = $schema->resultset("Project::Projectprop")->find ({ + project_id => $project_id, + type_id => $name_prefix_cvterm_id + }); + + if($name_prefix_rs) { + my $prefix = $name_prefix_rs->value; + $c->stash->{prefix} = $prefix; + } + my $identifier_link; my $tracking_transformation = $c->config->{tracking_transformation}; if ($tracking_transformation) { diff --git a/mason/transformation/add_transformant_names_dialog.mas b/mason/transformation/add_transformant_names_dialog.mas index d1ff3a7f2..bb7463f5f 100644 --- a/mason/transformation/add_transformant_names_dialog.mas +++ b/mason/transformation/add_transformant_names_dialog.mas @@ -3,6 +3,7 @@ $transformation_id $transformation_name $next_new_transformant $last_number +$prefix <& /util/import_javascript.mas, classes => [ 'jquery', 'jquery.dataTables' ] &> @@ -19,17 +20,19 @@ $last_number
- +
- +
+
@@ -75,23 +78,28 @@ $last_number jQuery(document).ready(function(){ var last_number = "<% $last_number %>"; + var prefix = "<% $prefix %>"; jQuery('#add_new_transformants_link').click(function(){ - jQuery('#add_new_transformant_names_dialog').modal('show'); + if (prefix) { + jQuery('#add_new_transformant_names_dialog').modal('show'); + } else { + alert('Please set Prefix for autogenerated names for this project first. You can find Set Autogenerated Names link on the project page') + } }); jQuery('#new_transformants_submit').click(function(){ - var transformation_name = jQuery('#transformation_name').val(); var new_name_count = jQuery('#number_of_new_transformants').val(); jQuery.ajax({ url : '/ajax/transformation/add_transformants', dataType: "json", type: 'POST', data : { - 'transformation_name': transformation_name, + 'transformation_name': "<%$transformation_name%>", 'transformation_stock_id': "<%$transformation_id%>", + 'prefix': prefix; 'new_name_count': new_name_count, - 'last_number': last_number, +// 'last_number': last_number, }, beforeSend: function(response){ jQuery('#working_modal').modal('show'); diff --git a/mason/transformation/transformation.mas b/mason/transformation/transformation.mas index 282b49565..103d5c591 100644 --- a/mason/transformation/transformation.mas +++ b/mason/transformation/transformation.mas @@ -12,6 +12,7 @@ $updated_status_type => undef $updated_status_string => undef $identifier_link => undef $project_link +$prefix => undef <& /util/import_javascript.mas, classes => ["jquery", "jqueryui", "thickbox", "CXGN.Page.FormattingHelpers", "jquery.cookie", "CXGN.List", "jquery.dataTables"] &> @@ -31,7 +32,8 @@ $project_link Plant Material<%$plant_material%> Vector Construct<%$vector_construct%> Notes<%$transformation_notes%> - Project<%$project_link%> + Project<%$project_link%> + Prefix for Transformant Names<%$prefix%> %if ($updated_status_type) { Status<%$updated_status_type%> Updated Status Info<%$updated_status_string%> @@ -43,7 +45,7 @@ $project_link
%if (!$updated_status_type) { -
+
%}
@@ -76,7 +78,7 @@ $project_link -<& /transformation/add_transformant_names_dialog.mas, transformation_id => $transformation_id, transformation_name => $transformation_name, next_new_transformant => $next_new_transformant, last_number => $last_number &> +<& /transformation/add_transformant_names_dialog.mas, transformation_id => $transformation_id, transformation_name => $transformation_name, next_new_transformant => $next_new_transformant, last_number => $last_number, prefix => $prefix &> <& /transformation/add_transformants_using_list_dialog.mas, transformation_id => $transformation_id, transformation_name => $transformation_name &>