-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'devel' of github.com:htgt/LIMS2-WebApp into devel
- Loading branch information
Showing
11 changed files
with
335 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1 @@ | |||
ALTER TABLE audit.projects ADD COLUMN effort_concluded BOOLEAN NOT NULL DEFAULT FALSE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1 @@ | |||
INSERT INTO schema_versions(version) VALUES (72); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1 @@ | |||
ALTER TABLE projects ADD COLUMN effort_concluded BOOLEAN NOT NULL DEFAULT FALSE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,67 @@ | |||
package LIMS2::Model::Plugin::Project; | |||
|
|||
use strict; | |||
use warnings FATAL => 'all'; | |||
|
|||
use Moose::Role; | |||
use Hash::MoreUtils qw( slice slice_def ); | |||
use TryCatch; | |||
use LIMS2::Exception; | |||
use namespace::autoclean; | |||
|
|||
requires qw( schema check_params throw retrieve log trace ); | |||
|
|||
|
|||
|
|||
sub pspec_retrieve_project { | |||
return { | |||
sponsor_id => { validate => 'non_empty_string' }, | |||
gene_id => { validate => 'non_empty_string' }, | |||
targeting_type => { validate => 'non_empty_string' }, | |||
species_id => { validate => 'existing_species' }, | |||
}; | |||
} | |||
|
|||
sub retrieve_project { | |||
my ( $self, $params ) = @_; | |||
|
|||
my $validated_params = $self->check_params( $params, $self->pspec_retrieve_project ); | |||
|
|||
my $project = $self->retrieve( Project => { slice_def $validated_params, qw( id sponsor_id gene_id targeting_type species_id ) } ); | |||
|
|||
return $project; | |||
} | |||
|
|||
sub pspec_retrieve_project_by_id { | |||
return { | |||
id => { validate => 'integer' }, | |||
}; | |||
} | |||
|
|||
sub retrieve_project_by_id { | |||
my ( $self, $params ) = @_; | |||
|
|||
my $validated_params = $self->check_params( $params, $self->pspec_retrieve_project_by_id ); | |||
|
|||
my $project = $self->retrieve( Project => { slice_def $validated_params, qw( id sponsor_id gene_id targeting_type species_id ) } ); | |||
|
|||
return $project; | |||
} | |||
|
|||
sub toggle_concluded_flag { | |||
my ( $self, $params ) = @_; | |||
|
|||
my $project = $self->retrieve_project_by_id($params); | |||
|
|||
if ($project->effort_concluded) { | |||
$project->update( { effort_concluded => 0 } ); | |||
} else { | |||
$project->update( { effort_concluded => 1 } ); | |||
}; | |||
|
|||
return $project; | |||
} | |||
|
|||
1; | |||
|
|||
__END__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,43 @@ | |||
package LIMS2::WebApp::Controller::API::Project; | |||
use Moose; | |||
use Hash::MoreUtils qw( slice_def ); | |||
use namespace::autoclean; | |||
|
|||
BEGIN {extends 'LIMS2::Catalyst::Controller::REST'; } | |||
|
|||
sub project : Path( '/api/project' ) : Args(0) : ActionClass( 'REST' ) { | |||
} | |||
|
|||
sub project_GET{ | |||
my ( $self, $c ) = @_; | |||
|
|||
$c->assert_user_roles('read'); | |||
|
|||
my $project = $c->model( 'Golgi' )->txn_do( | |||
sub { | |||
shift->retrieve_project_by_id( { id => $c->request->param( 'id' ) } ); | |||
} | |||
); | |||
|
|||
return $self->status_ok( $c, entity => $project->as_hash ); | |||
} | |||
|
|||
sub project_toggle : Path( '/api/project_toggle' ) : Args(0) : ActionClass( 'REST' ) { | |||
} | |||
|
|||
sub project_toggle_GET{ | |||
my ( $self, $c ) = @_; | |||
|
|||
$c->assert_user_roles('read'); | |||
|
|||
my $project = $c->model( 'Golgi' )->txn_do( | |||
sub { | |||
shift->toggle_concluded_flag( { id => $c->request->param( 'id' ) } ); | |||
} | |||
); | |||
|
|||
return $self->status_ok( $c, entity => $project->as_hash ); | |||
} | |||
|
|||
|
|||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,112 @@ | |||
package LIMS2::WebApp::Controller::User::Projects; | |||
use Moose; | |||
use LIMS2::WebApp::Pageset; | |||
use namespace::autoclean; | |||
|
|||
BEGIN {extends 'Catalyst::Controller'; } | |||
|
|||
=head1 NAME | |||
LIMS2::WebApp::Controller::User::Projects - Catalyst Controller | |||
=head1 DESCRIPTION | |||
Catalyst Controller. | |||
=head1 METHODS | |||
=cut | |||
|
|||
|
|||
=head2 index | |||
=cut | |||
|
|||
sub index :Path( '/user/projects' ) :Args(0) { | |||
my ( $self, $c ) = @_; | |||
|
|||
$c->assert_user_roles('read'); | |||
|
|||
my $params = $c->request->params; | |||
|
|||
my $species_id = $c->session->{selected_species}; | |||
|
|||
my @sponsors_rs = $c->model('Golgi')->schema->resultset('Project')->search( { | |||
species_id => $species_id | |||
},{ | |||
columns => [ qw/sponsor_id/ ], | |||
distinct => 1 | |||
} | |||
); | |||
|
|||
my @sponsors = map { $_->sponsor_id } @sponsors_rs; | |||
|
|||
my $columns = ['id', 'gene_id', 'gene_symbol', 'sponsor', 'targeting type', 'concluded?']; | |||
|
|||
my $sel_sponsor; | |||
|
|||
$c->stash( | |||
sponsor_id => [ map { $_->sponsor_id } @sponsors_rs ], | |||
effort_concluded => ['true', 'false'], | |||
title => 'Project Efforts', | |||
columns => $columns, | |||
sel_sponsor => $sel_sponsor, | |||
); | |||
|
|||
|
|||
return unless ( $params->{filter} || $params->{show_all} ); | |||
|
|||
if ($params->{show_all}) { | |||
$params->{sponsor_id} = ''; | |||
} | |||
|
|||
my $search = { | |||
species_id => $species_id, | |||
}; | |||
|
|||
if ($params->{sponsor_id}) { | |||
$search->{sponsor_id} = $params->{sponsor_id}; | |||
$sel_sponsor = $params->{sponsor_id}; | |||
} | |||
|
|||
my @projects_rs = $c->model('Golgi')->schema->resultset('Project')->search( $search ); | |||
|
|||
|
|||
my @project_genes = map { [ | |||
$_->id, | |||
$_->gene_id, | |||
$c->model('Golgi')->find_gene( { species => $species_id, search_term => $_->gene_id } )->{gene_symbol}, | |||
$_->sponsor_id, | |||
$_->targeting_type, | |||
$_->effort_concluded | |||
] } @projects_rs; | |||
|
|||
|
|||
$c->stash( | |||
sponsor_id => [ map { $_->sponsor_id } @sponsors_rs ], | |||
effort_concluded => ['true', 'false'], | |||
title => 'Project Efforts', | |||
columns => $columns, | |||
data => \@project_genes, | |||
get_grid => 1, | |||
sel_sponsor => $sel_sponsor, | |||
); | |||
|
|||
return; | |||
} | |||
|
|||
|
|||
=head1 AUTHOR | |||
Team 87 | |||
=head1 LICENSE | |||
This library is free software. You can redistribute it and/or modify | |||
it under the same terms as Perl itself. | |||
=cut | |||
|
|||
__PACKAGE__->meta->make_immutable; | |||
|
|||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,60 @@ | |||
|
|||
<div class="page-header"> | |||
<h1>[% title %]</h1> | |||
</div> | |||
|
|||
<form method="GET" action="[% c.uri_for( '/user/projects' ) %]" class="well"> | |||
<fieldset> | |||
<label for="sponsor_id">Sponsor:</label> | |||
<select name="sponsor_id"> | |||
<option[% IF ! selected_sponsor.defined %] selected="selected" [% END %]>[% sel_sponsor %]</option> | |||
[%- FOR sponsor IN sponsor_id %] | |||
<option[% IF sponsor == selected_sponsor %] selected="selected"[% END %]>[% sponsor %]</option> | |||
[%- END %] | |||
</select> | |||
<button name="filter" id="filter" type="submit" value="Filter" class="btn btn-primary"><i class="icon-filter icon-white"></i>Filter</button> | |||
<button name="show_all" id="show_all" type="submit" value="Show All" class="btn"><i class="icon-list-alt"></i>Show All</button> | |||
</fieldset> | |||
<span class="help-block"> | |||
You can browse for efforts and mark them as concluded by checking the box. | |||
</span> | |||
</form> | |||
|
|||
|
|||
|
|||
|
|||
<div id="my_results"></div> | |||
|
|||
|
|||
[%- MACRO linkify(v) BLOCK %] | |||
[%- IF v.match( '^https?:' ) %] | |||
<a href="[% v %]">Test result</a> | |||
[%- ELSIF v.match( '^custom:' ) %] | |||
[%- USE String%] | |||
[%- v_copy = String.new( text => v ) %] | |||
[%- CALL v_copy.shift('custom:') %] | |||
[%- FOREACH pair_val IN v_copy.split(';') %] | |||
[%- pair_string = String.new ( text => pair_val) %] | |||
[%- vals = pair_string.split('=', 2) %] | |||
[%- left = vals.shift %] | |||
[%- right = vals.shift %] | |||
[%- custom.$left = right %] | |||
[%- END %] | |||
[%- button_label = custom.button_label %] | |||
[%- tab_target = custom.browser_target %] | |||
[%- api_url = custom.api_url %] | |||
[%- custom.delete( 'button_label', 'api_url') -%] | |||
<a class="btn btn-info btn-small" <a href="[% c.uri_for( api_url, custom ) %]" target="[% tab_target %]">[% button_label %]</a> | |||
[%- ELSE %] | |||
[%- v %] | |||
[%- END %] | |||
[%- END %] | |||
|
|||
<link rel="stylesheet" type="text/css" href="[% c.uri_for('/static/extjs/resources/css/ext-all.css') %]" /> | |||
<link rel="stylesheet" type="text/css" href="[% c.uri_for('/static/css/lims2_extjs.css') %]" /> | |||
|
|||
<script type="text/javascript" src="[% c.uri_for('/static/extjs/ext-all.js') %]"></script> | |||
|
|||
[%- IF get_grid %] | |||
[% PROCESS 'user/report/generic_report_grid.tt' %] | |||
[%- END %] |
Oops, something went wrong.