Browse files

Merge branch 'devel' of github.com:htgt/LIMS2-WebApp into devel

  • Loading branch information...
2 parents 4406679 + 186392a commit 0f976e408cecdc3d44acb6825a02e30d90de1588 @sajp sajp committed Sep 10, 2014
View
4 Changes
@@ -1,5 +1,9 @@
{{$NEXT}}
+0.238 2014-09-10 09:25:52 Europe/London
+
+ Added Project Efforts, under the Genes tab
+
0.237 2014-09-02 14:50:23 Europe/London
Add interface to link crispr groups to designs
View
1 ddl/versions/72/audit-up.sql
@@ -0,0 +1 @@
+ALTER TABLE audit.projects ADD COLUMN effort_concluded BOOLEAN NOT NULL DEFAULT FALSE;
View
1 ddl/versions/72/fixtures.sql
@@ -0,0 +1 @@
+INSERT INTO schema_versions(version) VALUES (72);
View
1 ddl/versions/72/up.sql
@@ -0,0 +1 @@
+ALTER TABLE projects ADD COLUMN effort_concluded BOOLEAN NOT NULL DEFAULT FALSE;
View
67 lib/LIMS2/Model/Plugin/Project.pm
@@ -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__
View
28 lib/LIMS2/Model/Schema/Result/Project.pm
@@ -77,6 +77,12 @@ __PACKAGE__->table("projects");
data_type: 'integer'
is_nullable: 1
+=head2 effort_concluded
+
+ data_type: 'boolean'
+ default_value: false
+ is_nullable: 0
+
=cut
__PACKAGE__->add_columns(
@@ -99,6 +105,8 @@ __PACKAGE__->add_columns(
{ data_type => "text", is_nullable => 1 },
"htgt_project_id",
{ data_type => "integer", is_nullable => 1 },
+ "effort_concluded",
+ { data_type => "boolean", default_value => \"false", is_nullable => 0 },
);
=head1 PRIMARY KEY
@@ -169,8 +177,24 @@ __PACKAGE__->belongs_to(
);
-# Created by DBIx::Class::Schema::Loader v0.07022 @ 2014-02-07 16:49:17
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:NWx1GMZQcu6KlFq2s3dSaA
+# Created by DBIx::Class::Schema::Loader v0.07022 @ 2014-09-02 15:28:38
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:E+p0emXyULopBYB1vFws9A
+
+
+sub as_hash {
+ my $self = shift;
+
+ return {
+ "id" => $self->id,
+ "sponsor_id" => $self->sponsor_id,
+ "allele_request" => $self->allele_request,
+ "gene_id" => $self->gene_id,
+ "targeting_type" => $self->targeting_type,
+ "species_id" => $self->species_id,
+ "htgt_project_id" => $self->htgt_project_id,
+ "effort_concluded" => $self->effort_concluded,
+ }
+}
# You can replace this text with custom code or comments, and it will be preserved on regeneration
View
43 lib/LIMS2/WebApp/Controller/API/Project.pm
@@ -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;
View
112 lib/LIMS2/WebApp/Controller/User/Projects.pm
@@ -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;
View
3 root/lib/navigation.tt
@@ -20,6 +20,9 @@
<li>
<a href="[% c.uri_for( '/user/sponsor_report' ) %]">Sponsor Report</a>
</li>
+ <li>
+ <a href="[% c.uri_for( '/user/projects' ) %]">Project Efforts</a>
+ </li>
</ul>
</li>
View
60 root/site/user/projects/index.tt
@@ -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 %]
View
19 root/site/user/report/generic_report_grid.tt
@@ -1,4 +1,7 @@
<script type="text/javascript" charset="utf-8">
+
+ var grid;
+
Ext.onReady( function() {
Ext.define('Report', {
@@ -9,6 +12,8 @@
[%#- for now, deisgn ids need to be treated as integers for sorting, not strings %]
[%- IF col.match( '[Dd]esign[_\- ][Ii][Dd]' ) %]
{ name: '[%- col %]', type: 'int' },
+ [%- ELSIF col.match( 'concluded\?' ) %]
+ { name: '[%- col %]', type: 'boolean' },
[%- ELSE %]
{ name: '[%- col %]', type: 'string' },
[%- END %]
@@ -70,6 +75,7 @@
[% hidden = {
"gene id" = 1
"row id" = 1
+ "id" = 1
} %]
var columns = [
@@ -88,11 +94,19 @@
[%- ELSE %]
sortable: true,
[%- END %]
+ [%- IF col.match( 'concluded\?' ) %]
+ xtype: 'checkcolumn',
+ listeners: {
+ checkchange: function (column, recordIndex, checked) {
+ var record = grid.store.getAt(recordIndex);
+ $.getJSON( "[% c.uri_for('/api/project_toggle') %]", {id:record.get('id')}, function(data){record.commit()})
+ }
+ },
+ [%- END %]
dataIndex: '[%- col %]'
},
[%- END %]
];
-
function lims2_action_button_json(val) {
@@ -119,7 +133,8 @@
return Ext.String.format('<div id="{0}"></div>', id);
};
- var grid = Ext.create('Ext.grid.Panel', {
+
+ grid = Ext.create('Ext.grid.Panel', {
height: 750,
width: 1200,
store: store,

0 comments on commit 0f976e4

Please sign in to comment.