Skip to content
Snippets Groups Projects
Commit dc8a12d8 authored by pabois's avatar pabois
Browse files

wip exports

parent 33c58881
No related branches found
No related tags found
No related merge requests found
class Admin::Communication::Extranets::ContactsController < Admin::Communication::Extranets::ApplicationController class Admin::Communication::Extranets::ContactsController < Admin::Communication::Extranets::ApplicationController
def index def index
@persons = current_university.people.ordered.page params[:persons_page] @persons = current_university.people.ordered
@organizations = current_university.organizations.ordered.page params[:organizations_page] @organizations = current_university.organizations.ordered
respond_to do |format|
format.html {
@persons = @persons.page params[:persons_page]
@organizations = @organizations.page params[:organizations_page]
}
format.xlsx {
@export = params['export']
filename = "#{@export}-#{Time.now.strftime("%Y%m%d%H%M%S")}.xlsx"
response.headers['Content-Disposition'] = "attachment; filename=#{filename}"
render @export
}
end
breadcrumb breadcrumb
add_breadcrumb Communication::Extranet.human_attribute_name(:feature_contacts) add_breadcrumb Communication::Extranet.human_attribute_name(:feature_contacts)
end end
...@@ -26,4 +40,4 @@ class Admin::Communication::Extranets::ContactsController < Admin::Communication ...@@ -26,4 +40,4 @@ class Admin::Communication::Extranets::ContactsController < Admin::Communication
object_id = params[:objectId] object_id = params[:objectId]
@object = object_type.constantize.find object_id @object = object_type.constantize.find object_id
end end
end end
\ No newline at end of file
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<%= render 'admin/communication/extranets/sidebar' do %> <%= render 'admin/communication/extranets/sidebar' do %>
<% action = link_to t('export'), <% action = link_to t('export'),
admin_communication_extranet_contacts_path(extranet_id: @extranet.id, export: 'persons'), admin_communication_extranet_contacts_path(extranet_id: @extranet.id, export: 'persons', format: :xlsx),
class: button_classes('ms-1') if can?(:show, University::Person) %> class: button_classes('ms-1') if can?(:show, University::Person) %>
<%= osuny_panel University::Person.model_name.human(count: 2), action: action do %> <%= osuny_panel University::Person.model_name.human(count: 2), action: action do %>
<div class="table-responsive"> <div class="table-responsive">
...@@ -40,7 +40,10 @@ ...@@ -40,7 +40,10 @@
</div> </div>
<%= paginate @persons, theme: 'bootstrap-5', param_name: :persons_page %> <%= paginate @persons, theme: 'bootstrap-5', param_name: :persons_page %>
<% end %> <% end %>
<%= osuny_panel University::Organization.model_name.human(count: 2) do %> <% action = link_to t('export'),
admin_communication_extranet_contacts_path(extranet_id: @extranet.id, export: 'organizations', format: :xlsx),
class: button_classes('ms-1') if can?(:show, University::Person) %>
<%= osuny_panel University::Organization.model_name.human(count: 2), action: action do %>
<div class="table-responsive"> <div class="table-responsive">
<table class="<%= table_classes%>"> <table class="<%= table_classes%>">
<tbody> <tbody>
......
@users ||= users
wb = xlsx_package.workbook
wb.add_worksheet(name: "index") do |sheet|
headers = User::xls_header_for(current_brand)
# for headers types are always :string (because those are labels)
sheet.add_row headers[:labels], types: Array.new(headers[:types].length) { |_| :string }
@users.each do |user|
sheet.add_row user.xls_basic_row, types: headers[:types]
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment