app/views/organizations/_organization_projects.html.erb
<table id="table_list_1" class="table tablesorterPager table-striped table-bordered table-condensed">
<thead>
<tr>
<th class="text_left exportable"><%= I18n.t(:label_project_name) %></th>
<% selected_inline_columns = update_selected_inline_columns(Project) %>
<% selected_inline_columns.each do |column| %>
<%= column_header(column) %>
<% end %>
<!--<%# @organization.fields.each do |field| %>-->
<!--<th><%#= field.name %></th>-->
<!--<%# end %>-->
<th class="action"><%= I18n.t(:actions) %></th>
</tr>
</thead>
<tbody>
<% @projects.each do |project| %>
<% if can_see_estimation?(project) %>
<tr>
<td class="exportable">
<% if can_show_estimation?(project) %>
<%= link_to(project.title, dashboard_path(project), :class => 'button_attribute_tooltip pull-left') %>
<% else %>
<%= project.title %>
<% end %>
</td>
<% selected_inline_columns.each do |column| %>
<%= column_content(column, project) %>
<% end %>
<!--<%# @organization.fields.each do |field| %>-->
<!--<td class="project_field_text_overflow exportable">-->
<!--<%# if field.coefficient.nil? %>-->
<!----->
<!--<%# else %>-->
<!--<%# pf = ProjectField.where(field_id: field.id, project_id: project.id).first %>-->
<!--<%#= pf.nil? ? '-' : convert_with_precision(pf.value.to_f / field.coefficient.to_f, user_number_precision) %>-->
<!--<%# end %>-->
<!--</td>-->
<!--<%# end %>-->
<td style="min-width: 130px;">
<% if can_alter_estimation?(project) && can?(:alter_estimation_status, project) %>
<%= link_to('', main_app.add_comment_on_status_change_path(:project_id => project.id), :class => "fa fa-share pull-left", style: "color: black; margin-top:4px;", :title => "#{I18n.t(:button_commit_project)}" , :remote => true) %>
<% end %>
<% if can_show_estimation?(project) %>
<%= link_to('', main_app.add_comment_on_status_change_path(:project_id => project.id), :class => "icon-comment pull-left", :title => "#{I18n.t(:label_add_status_change_comment)}" , :remote => true) %> <!-- Link to comment the estimation status change add_comment_on_status_change -->
<% end %>
<% if can_alter_estimation?(project) && can?(:commit_project, project) %>
<%#= link_to('', {:controller => 'projects', :action => 'checkout', :project_id => project.id}, :class => 'fa fa-code-fork pull-left', style: "color: black; margin-top:4px;", :title => I18n.t('button_checkout_project'), :confirm => (I18n.t(:confirm_new_branch_project_checkout) unless project.is_childless?)) %>
<%= link_to('', set_checkout_version_path(:project_id => project.id), :class => 'fa fa-code-fork pull-left', style: "color: black; margin-top:4px;", :title => I18n.t('button_checkout_project'), remote: true, :confirm => (I18n.t(:confirm_new_branch_project_checkout) unless project.is_childless?)) %>
<% end %>
<%= link_to('', edit_project_path(project, :anchor => 'tabs-history'), :class => 'fa fa-film pull-left', style: "color: black; margin-top:4px;", :title => I18n.t('label_project_history')) %>
<%= link_to('', {:controller => 'projects', :action => 'find_use_project', :project_id => project.id}, :remote => true, 'data-project_id' => project.id, :class => 'fa fa-map-marker pull-left', style: "color: black; margin-top:4px;", :id => 'find_use_projects', :title => I18n.t('button_find_use')) %>
<% if can_show_estimation?(project) %>
<%= link_to('', edit_project_path(project, :anchor => 'tabs-1'), :class => 'fa fa-pencil pull-left', style: "color: black; margin-top:4px;", :title => I18n.t('edit')) %>
<% if can? :create_project_from_scratch, Project %>
<%= link_to('', main_app.duplicate_path(project, organization_id: @organization, action_name: "duplication"), :class => 'icon-copy pull-left', :title => I18n.t('button_duplicate_project')) %>
<% end %>
<% end %>
<% if (can? :delete_project, project) || (can? :manage, project) %>
<% if project.is_childless? && can_delete_estimation?(project) %>
<%= (link_to('', confirm_deletion_path(project.id), :class => 'icon-trash pull-left', :title => I18n.t('delete')) if can? :delete_project, project) %>
<% end %>
<% end %>
</td>
</tr>
<% end %>
<% end %>
</tbody>
<%= render :partial => 'layouts/footer_table' %>
</table>
<script>
<%= render :partial => 'layouts/sort_date', :handlers => [:erb], :formats => [:js]%>
</script>
<script>
$(document).ready(function () {
function exportTableToCSV($table, filename) {
var $rows = $table.find('tr:has(th), tr:has(td)').not(".filtered"),
// Temporary delimiter characters unlikely to be typed by keyboard
// This is to avoid accidentally splitting the actual contents
tmpColDelim = String.fromCharCode(11), // vertical tab character
tmpRowDelim = String.fromCharCode(0), // null character
// actual delimiter characters for CSV format
colDelim = '"<%= I18n.t(:general_csv_separator) %>"',
rowDelim = '"\r\n"',
// Grab text from table into CSV formatted string
csv = '"' + $rows.map(function (i, row) {
var $row = $(row),
$cols = $row.find('th.exportable, td.exportable');
return $cols.map(function (j, col) {
var $col = $(col), text = $col.text();
return text.replace('"', '""'); // escape double quotes
}).get().join(tmpColDelim);
}).get().join(tmpRowDelim)
.split(tmpRowDelim).join(rowDelim)
.split(tmpColDelim).join(colDelim) + '"',
// Data URI
csvData = 'data:application/csv;charset=utf-8,' + encodeURIComponent(csv);
$(this).attr({
'download': filename,
'href': csvData,
'target': '_blank'
});
}
// This must be a hyperlink
$(".export").on('click', function (event) {
// CSV
exportTableToCSV.apply(this, [$('#table_list_1'), 'RapportTableau.csv']);
// IF CSV, don't do event.preventDefault() or return false
// We actually need this to be a typical hyperlink
});
});
</script>