Skip to content

Commit

Permalink
download template
Browse files Browse the repository at this point in the history
  • Loading branch information
qinmingyuan committed Dec 5, 2023
1 parent 57aca0f commit 6961953
Show file tree
Hide file tree
Showing 11 changed files with 9 additions and 13 deletions.
2 changes: 0 additions & 2 deletions app/controllers/datum/panel/data_exports_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ def sync

def rebuild
@data_export.rebuild!

redirect_back fallback_location: data_exports_url
end

def just_run
Expand Down
7 changes: 3 additions & 4 deletions app/controllers/datum/panel/data_imports_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Datum
class Panel::DataImportsController < Panel::BaseController
before_action :set_data_import, only: [:show, :edit, :update, :rebuild, :destroy]
before_action :set_data_import, only: [:show, :edit, :update, :rebuild, :destroy, :template]

def index
q_params = {}
Expand All @@ -14,11 +14,10 @@ def sync

def rebuild
@data_import.rebuild!

redirect_back fallback_location: data_imports_url
end

def just_run
def template
send_data @data_import.template, filename: 'template.xlsx', type: 'application/xlsx'
end

private
Expand Down
2 changes: 0 additions & 2 deletions app/controllers/datum/panel/table_lists_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ def new
def create
@table_list = @data_list.table_lists.build(table_list_params)
@table_list.save

redirect_to data_list_table_lists_url(@data_list)
end

def direct
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<% if !defined?(rails_role_user) || rails_role_user.has_role?(controller_path: 'datum/panel/data_lists', action_name: 'read', id: model.id) %>
<tr id="tr_<%= model.id %>" data-controller="show" data-action="mouseenter->show#show mouseleave->show#hide">
<%= yield %>
<td>
Expand All @@ -15,4 +14,3 @@
</div>
</td>
</tr>
<% end %>
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<% if !defined?(rails_role_user) || rails_role_user.has_role?(controller_path: 'datum/panel/data_lists', action_name: 'read', id: model.id) %>
<tr id="tr_<%= model.id %>" data-controller="show" data-action="mouseenter->show#show mouseleave->show#hide">
<%= yield %>
<td>
<div data-show-target="item" style="visibility: hidden">
<%= button_to({ action: 'rebuild', id: model.id }, method: :patch, aria: { label: t('.rebuild'), turbo_confirm: t('.confirm') }, class: 'button is-small is-rounded is-light') do %>
<i class="fa-solid fa-recycle has-text-warning"></i>
<% end %>
<%= link_to({ action: 'template', id: model.id, format: 'xlsx' }, aria: { label: t('.template.title') }, class: 'button is-small is-rounded is-light') do %>
<i class="fa-solid fa-file-excel has-text-primary"></i>
<% end %>
<%= button_to({ action: 'edit', id: model.id }, aria: { label: t('.edit.title') }, class: 'button is-small is-rounded is-light') do %>
<i class="fa-solid fa-pencil has-text-link"></i>
<% end %>
Expand All @@ -15,4 +17,3 @@
</div>
</td>
</tr>
<% end %>
2 changes: 2 additions & 0 deletions config/locales/en.controller.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ en:
title: Imports
sync:
title: Sync
template:
title: Template
data_records:
index:
title: Reports
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
end
member do
patch :rebuild
match :template, via: [:get, :post]
get :template
end
end
resources :data_lists, only: [] do
Expand Down

0 comments on commit 6961953

Please sign in to comment.