Commit 2fee87fc authored by Jerome Mariette's avatar Jerome Mariette
Browse files

hide/unhide/publish/unpublish ok

parent 122e9fbf
......@@ -77,16 +77,20 @@ class tx_nG6_pi1 extends tslib_pibase {
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/bootstrap-editable.min.js"></script>
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/bootstrap-datepicker.js"></script>
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jquery.url.packed.js"></script>
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jquery.venny.js"></script>
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/tx_nG6_pi1.js"></script>
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/tx_nG6_utils.js"></script>
<script type="text/javascript" src="typo3/md5.js"></script>
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/tx_nG6_pi1_analysis.js"></script>
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jquery.venny.js"></script>
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jquery.highcharts.js"></script>
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jquery.highcharts.exporting.js"></script>
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/tx_nG6_classes.js"></script>
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jquery.highcharts.exporting.js"></script>
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/jsphylosvg-min.js"></script>
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/raphael-min.js"></script>
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/unitip.js"></script>
<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'res/js/tx_nG6_table.js"></script>
<script type="text/javascript" src="typo3/md5.js"></script>
<link type="text/css" rel="stylesheet" media="screen" href="'.t3lib_extMgm::siteRelPath($this->extKey).'res/css/unitip.css"/>
<link type="text/css" rel="stylesheet" media="screen" href="'.t3lib_extMgm::siteRelPath($this->extKey).'res/css/bootstrap.min.css"/>
......
......@@ -266,34 +266,31 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
</thead>
<tbody>
{foreach from=$projects key=project_id item=project_values}
{assign var="public_attribute" value=""}
{assign var="public_class" value=""}
{assign var="classes" value=""}
{if $login_user && $project_values.public == 0 && $project_values.is_admin}
{assign var="public_attribute" value="tx-nG6-pi1-public"}
{assign var="public_class" value="class='$public_attribute'"}
{$classes = $classes|cat:"tx-nG6-pi1-public"}
{/if}
{if $project_values.hidden == 1}
{$classes = $classes|cat:" tx-nG6-pi1-hidden"}
{/if}
{if ($project_values.hidden == 1 && $project_values.is_admin) || $project_values.hidden == 0}
<tr id="tr_project_{$project_values.id}" {$public_class}>
<tr id="tr_project_{$project_values.id}" class="{$classes}">
{if $project_values.is_admin}
<td><center><input type="checkbox" id="chk_project_{$project_values.id}" value="project_{$project_values.id}"></center></td>
{elseif $is_at_least_admin_of_1_project}
<td></td>
{/if}
{assign var="hidden_attribute" value="tx-nG6-pi1-hidden"}
{if $project_values.hidden == 0}
{assign var="hidden_attribute" value=""}
{/if}
<td field=tx_nG6_project=name {$hidden_attribute}">{$project_values.href}</td>
<td field=tx_nG6_project=crdate {$hidden_attribute}">
<td> {$project_values.href}</td>
<td>
{if $project_values.is_admin}
<a href="#" class="editable-date field=tx_nG6_project=crdate {$hidden_attribute}" data-type="date" data-pk="1" data-url="/post" data-original-title="Select date">{$project_values.date|date_format:"%d/%m/%Y"}</a>
<a href="#" class="editable-date" data-type="date" data-pk="1" data-original-title="Select date">{$project_values.date|date_format:"%d/%m/%Y"}</a>
{else}
{$project_values.date|date_format:"%d/%m/%Y"}
{/if}
</td>
<td field=tx_nG6_project=description {$hidden_attribute}">
<td>
{if $project_values.is_admin}
<a href="#" class="editable field=tx_nG6_project=description {$hidden_attribute}" data-type="textarea" data-pk="1" data-original-title="Enter description">
<a href="#" class="editable" data-type="textarea" data-pk="1" data-original-title="Enter description">
{$project_values.description}
</a>
{else}
......
......@@ -36,7 +36,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<tbody>
{foreach from=$runs key=run_id item=run_values}
{if ($run_values.hidden == 1 && $run_values.is_admin) || $run_values.hidden == 0}
<tr id="tr_run_{$run_values.id}" >
{assign var="classes" value=""}
{if $run_values.hidden == 1}
{$classes = $classes|cat:" tx-nG6-pi1-hidden"}
{/if}
<tr id="tr_run_{$run_values.id}" class="{$classes}">
{assign var="editable" value=""}
{if $run_values.is_admin}
<td><center><input type="checkbox" id="chk_run_{$run_values.id}" value="run_{$run_values.id}"></center></td>
......@@ -44,22 +48,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
{elseif $is_at_least_admin_of_1_run}
<td></td>
{/if}
{assign var="hidden_attribute" value="tx-nG6-pi1-hidden"}
{assign var="hidden_class" value="class='$hidden_attribute'"}
{if $run_values.hidden == 0}
{assign var="hidden_class" value=""}
{assign var="hidden_attribute" value=""}
{/if}
<td class="{$editable} field=tx_nG6_run=name {$hidden_attribute}">{$run_values.href}</td>
<td {$hidden_class}>{$run_values.project_name}</td>
<td class="{$editable} field=tx_nG6_run=date {$hidden_attribute}">{$run_values.date|date_format:"%d-%m-%y"}</td>
<td class="{$editable} field=tx_nG6_run=species {$hidden_attribute}">{$run_values.species}</td>
<td class="{$editable} field=tx_nG6_run=data_nature {$hidden_attribute}">{$run_values.data_nature}</td>
<td class="{$editable} field=tx_nG6_run=type {$hidden_attribute}">{$run_values.type}</td>
<td {$hidden_class}>{$run_values.nb_sequences|number_format:0:' ':' '}</td>
<td {$hidden_class}>{$run_values.full_seq_size|number_format:0:' ':' '}</td>
<td class="{$editable} field=tx_nG6_run=description {$hidden_attribute}">{$run_values.description}</td>
<td class="{$editable} field=tx_nG6_run=sequencer {$hidden_attribute}">{$run_values.sequencer}</td>
<td class="{$editable} field=tx_nG6_run=name">{$run_values.href}</td>
<td>{$run_values.project_name}</td>
<td class="{$editable} field=tx_nG6_run=date">{$run_values.date|date_format:"%d-%m-%y"}</td>
<td class="{$editable} field=tx_nG6_run=species">{$run_values.species}</td>
<td class="{$editable} field=tx_nG6_run=data_nature">{$run_values.data_nature}</td>
<td class="{$editable} field=tx_nG6_run=type">{$run_values.type}</td>
<td>{$run_values.nb_sequences|number_format:0:' ':' '}</td>
<td>{$run_values.full_seq_size|number_format:0:' ':' '}</td>
<td class="{$editable} field=tx_nG6_run=description">{$run_values.description}</td>
<td class="{$editable} field=tx_nG6_run=sequencer">{$run_values.sequencer}</td>
</tr>
{/if}
{/foreach}
......
This diff is collapsed.
......@@ -109,5 +109,155 @@ $(function () {
"bJQueryUI": true
});
});
var get_sort_behaviour = function(table) {
var columns_behaviour ;
switch (table.attr('id')) {
case 'fastqc_resume' :
// If table contains sample name (12 columns)
if( table.find("tbody tr td.sample_name").size() > 0 ) {
columns_behaviour = [
null,
null,
null,
null,
null,
{ "sType": "formatted-num" },
null,
{ "sType": "formatted-num" },
{ "sType": "formatted-num" },
null,
null,
null] ;
}
// If table contains sample name (11 columns)
else {
columns_behaviour = [
null,
null,
null,
null,
{ "sType": "formatted-num" },
null,
{ "sType": "formatted-num" },
{ "sType": "formatted-num" },
null,
null,
null] ;
}
break;
}
return( columns_behaviour );
} ;
/* Analyze_table */
$('table.analyze_table').dataTable({
"aoColumns": get_sort_behaviour($('table.analyze_table')),
"sScrollX": "100%",
//"sPaginationType": "full_numbers",
"iDisplayLength": $('table.analyze_table tbody tr').size()
//"bJQueryUI": true
});
/*
* Return an HTMLTableCellElement from the document table with class analyze_table.
* @return HTMLTableCellElement - The table.
*/
function getTxNG6TableFromDatatable() {
var html_table = document.createElement('table') ;
html_table.setAttribute('class', 'tx-nG6-pi1-listrow');
// Add the nodes of rows to html_table
var table_header = $('table.analyze_table').get()[0].getElementsByTagName('thead')[0].cloneNode(true) ;
var tr_header = table_header.getElementsByTagName('tr') ;
for( var i=0 ; i < tr_header.length ; i++ ) {
// Remove icons of sort
var span_nodes = tr_header[i].getElementsByTagName('span') ;
for( var j=0 ; j < span_nodes.length ; j++ ) {
span_nodes[j].parentNode.removeChild(span_nodes[j]);
j-- ;
}
// Remove dataTable class
var th_nodes = tr_header[i].getElementsByTagName('th') ;
for( var j=0 ; j < th_nodes.length ; j++ ) {
th_nodes[j].className = '';
}
// Add the row
html_table.appendChild(tr_header[i].cloneNode(true)) ;
}
var table_body = $('table.analyze_table').get()[1].getElementsByTagName('tbody')[0].cloneNode(true) ;
var tr_body = table_body.getElementsByTagName('tr') ;
for( var i=0 ; i < tr_body.length ; i++ ) {
// Remove dataTable class
var td_nodes = tr_body[i].getElementsByTagName('td') ;
for( var j=0 ; j < td_nodes.length ; j++ ) {
td_nodes[j].className = '';
}
tr_body[i].className = '';
html_table.appendChild(tr_body[i].cloneNode(true)) ;
}
// Create an tx_nG6_HTMLtable
var ng6_tab = new tx_nG6_HTMLtable( html_table ) ;
return ng6_tab ;
}
/* Opens a window that contains all the images available in the table */
$("#img_extract").click(function() {
// Create an tx_nG6_HTMLtable
var ng6_tab = getTxNG6TableFromDatatable() ;
// Delete columns without images
ng6_tab.filter('<a[^>]+class="[^"]*imglink') ;
// Replace markup of link in markup of image
ng6_tab.replace('<a[^>]+class="[^"]*imglink[^"]*"[^>]+href="(fileadmin\/data\/analyze\/[^"]+)', '<img src="', '" onload="resize(this, 0.5)">' ) ;
// Display images table
$("#table_dialog").html('') ;
$("#table_dialog").dialog("option", "title", "nG6 - images view");
$("#table_dialog").append(ng6_tab.getModel()).dialog("open");
}) ;
/* Opens a window that all the element in the selected column */
$("#column_extract").click(function() {
// Create an tx_nG6_HTMLtable
var ng6_tab = getTxNG6TableFromDatatable() ;
// Replace markup of link in markup of image
ng6_tab.replace('<a[^>]+class="[^"]*imglink[^"]*"[^>]+href="(fileadmin\/data\/analyze\/[^"]+)', '<img src="', '">' ) ;
// Filter columns
// List columns to keep
var selected_columns = new Array() ;
$("input[name='rad_col_selection']:checked").each(function(){
selected_columns.push($(this).attr('value')) ;
});
// Keep title column
if( $(this).attr('value') == "has_title_col" ) {
selected_columns.push("0") ;
}
// List columns to delete
var unselected_columns = new Array() ;
var nb_col = ng6_tab.getDimensions()[1] ;
for( var i=0 ; i < nb_col ; i++ ) {
if( jQuery.inArray( i+"", selected_columns ) == -1 ) {
unselected_columns.push(i) ;
}
}
unselected_columns.sort(function(a,b){return a - b}) ;
// Delete columns
ng6_tab.deleteColumns(unselected_columns) ;
// Display images table
$("#table_dialog").html('') ;
$("#table_dialog").dialog("option", "title", "nG6 - images view");
$("#table_dialog").append(ng6_tab.getModel()).dialog("open");
}) ;
});
/***************************************************************
* Copyright notice
*
* (c) 2009 PF genomique de Toulouse <>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Plugin 'nG6' for the 'nG6' extension.
*
* @author PF genomique de Toulouse <>
*/
function tx_nG6_HTMLtable( HTML_model )
{
/**
* HTML Table.
* @type HTMLTableCellElement
*/
var model = HTML_model ;
/**
* Number of rows and columns. The merging cells are as much individuals cells.
* @type Array(2)
*/
var dimensions ;
/**
* Location of the virtual cells. Example : the second column of a <td> with colspan.
* @type Array(n,n)
*/
var virtualOccupation ;
/**
* Separator of columns in CSV.
* @type Char
*/
var csv_separator = ';' ;
/**
* Removes the columns listed in the table. Column numbers reflect colspan.
* @param columns_list Array(n) - List of number of columns to remove.
*/
this.deleteColumns = function( columns_list ) {
// Retrieve rows
var rows = model.getElementsByTagName('tr') ;
// For each rows
for( var row_number = 0 ; row_number < rows.length ; row_number++ )
{
col_number = 0 ;
// Retrieve columns
var columns = rows[row_number].getElementsByTagName('td') ;
if( columns.length == 0 )
{
columns = rows[row_number].getElementsByTagName('th') ;
}
var td_number = 0 ;
// For each columns
for( var col_number = 0 ; col_number < dimensions[1] ; col_number++ )
{
// If this is not a virtual cell
if( !virtualOccupation[row_number][col_number] )
{
// Retrieve the number of virtualy occupied columns by current cell
var colspan_value = columns[td_number].getAttribute("colspan") ;
if( colspan_value != null )
{
for( var i = 0 ; i < colspan_value ; i++ )
{
if( in_array((col_number + i), columns_list) )
{
var old_colspan = columns[td_number].getAttribute("colspan") ;
// If the cell was removed
if( (old_colspan - 1) == 0 )
{
columns[td_number].removeAttribute("colspan") ;
}
// Otherwise (colspan >= 1)
else
{
columns[td_number].setAttribute("colspan", (old_colspan - 1)) ;
}
}
// If after the elimination of colspan, there are not column
if( columns[td_number].getAttribute("colspan") == null )
{
// Remove cell
var delete_node = columns[td_number] ;
rows[row_number].removeChild(delete_node) ;
td_number-- ;
}
}
}
// The cell does not contain colspan
else
{
// If the column is in the columns to remove
if( in_array(col_number, columns_list) )
{
// Remove cell
var delete_node = columns[td_number] ;
rows[row_number].removeChild(delete_node) ;
td_number-- ;
}
}
td_number++ ;
}
}
}
//Update dimensions and virtualOccupation
processTableDim() ;
processVirtualOccupation() ;
}
/**
* Remove any columns whose value matches the pattern.
* @param pattern String - valid pattern.
* @param filter_first Boolean - the first column should it be filtered ?
*/
this.filter = function( pattern, filter_first ) {
var pattern_regexp = new RegExp( pattern ) ;
var conserv_col = new Array() ;
// By default it keeps the first column
if( filter_first == null || !filter_first )
{
conserv_col["c0"] = true ;
}
// List the columns to keep
var rows = model.getElementsByTagName('tr') ;
for( var row_number = 0 ; row_number < rows.length ; row_number++ )
{
col_number = 0 ;
// Retrieve columns
var columns = rows[row_number].getElementsByTagName('td') ;
// It is only interested in values (skip titles)
if( columns.length != 0 )
{
var td_number = 0 ;
// For each columns
for( var col_number = 0 ; col_number < dimensions[1] ; col_number++ )
{
// If this is not a virtual cell
if( !virtualOccupation[row_number][col_number] )
{
// If cell contain the pattern
if( pattern_regexp.test(columns[td_number].innerHTML) )
{
// Keep the column
conserv_col["c"+col_number] = true ;
}
td_number++ ;
}
}
}
}
// List the columns to remove
var elim_columns = new Array() ;
for(var col = 0 ; col < dimensions[1] ; col++)
{
// If the column does not exist in the list of column to maintain
if( conserv_col["c"+col] === undefined )
{
elim_columns.push(col) ;
}
}
// Remove the columns
this.deleteColumns(elim_columns) ;
}
/**
* Return the dimensions without merge.
* @return Array(2) - The number of rows and columns.
*/
this.getDimensions = function() {
return dimensions ;
}
/**
* Return the HTML table.
* @return HTMLTableCellElement - The HTML table.
*/
this.getModel = function() {
return model ;
}
/**
* Set/Update the attribute dimensions.
*/
var processTableDim = function() {
var row_number = 0 ;
var col_number = 0 ;
// Retrieve all table's rows
var rows = model.getElementsByTagName('tr') ;
// For each row in the table
for( var tr_number = 0 ; tr_number < rows.length ; tr_number++ )
{
var nb_col_on_row = 0 ;
// Add one to the row number
row_number++ ;
// Retrieve columns
var columns = rows[tr_number].getElementsByTagName('td') ;
if( columns.length == 0 )
{
columns = rows[tr_number].getElementsByTagName('th') ;
}
// For each column
for( var td_number = 0 ; td_number < columns.length ; td_number++ )
{
var colspan_value = columns[td_number].getAttribute("colspan") ;
// If the value is on more than one column
if( colspan_value == null )
{
nb_col_on_row += 1 ;
}
// Otherwise
else
{
nb_col_on_row += parseInt(colspan_value) ;
}
}
// Keep only the maximum number of column in the table
if( col_number < nb_col_on_row )
{
col_number = nb_col_on_row ;
}
}
// Update the attribute dimensions
dimensions = new Array(2) ;
dimensions[0] = row_number ;
dimensions[1] = col_number ;
}
/**
* Set/Update the attribute virtualOccupation.
*/
var processVirtualOccupation = function() {
virtualOccupation = new Array( dimensions[0] ) ;
// Init the virtualOccupation matrice
for( var i = 0 ; i < dimensions[0] ; i++ )
{
virtualOccupation[i] = new Array( dimensions[1] ) ;
for( var j = 0 ; j < dimensions[1] ; j++ )
{
virtualOccupation[i][j] = false ;
}
}
// Load the virtualOccupation matrice
var rows = model.getElementsByTagName('tr') ;
for( var row_number = 0 ; row_number < rows.length ; row_number++ )
{
col_number = 0 ;
// Retrieve columns
var columns = rows[row_number].getElementsByTagName('td') ;
if( columns.length == 0 )
{
columns = rows[row_number].getElementsByTagName('th') ;
}
var td_number = 0 ;
// For each column
for( var col_number = 0 ; col_number < dimensions[1] ; col_number++ )
{
// If this is not a virtual cell
if( !virtualOccupation[row_number][col_number] )
{
var virtual_rows = 0 ;
var virtual_col = 0 ;
// Retrieve the number of virtualy occupied rows by current cell
var rowspan_value = columns[td_number].getAttribute("rowspan") ;
if( rowspan_value != null )
{
virtual_rows = rowspan_value - 1 ;
}
// Retrieve the number of virtualy occupied columns by current cell
var colspan_value = columns[td_number].getAttribute("colspan") ;
if( colspan_value != null )
{
virtual_col = colspan_value - 1 ;