Class: Releaf::I18nDatabase::TranslationsController
- Inherits:
-
ActionController
- Object
- ActionController
- Releaf::I18nDatabase::TranslationsController
- Defined in:
- app/controllers/releaf/i18n_database/translations_controller.rb
Class Method Summary collapse
Instance Method Summary collapse
- #action_features ⇒ Object
- #action_views ⇒ Object
- #build_breadcrumbs ⇒ Object
- #edit ⇒ Object
- #export ⇒ Object
- #features ⇒ Object
- #import ⇒ Object
- #import_view ⇒ Object
- #resources ⇒ Object
-
#search(lookup_string) ⇒ Object
overwrite search here.
- #update ⇒ Object
Class Method Details
.resource_class ⇒ Object
2 3 4 |
# File 'app/controllers/releaf/i18n_database/translations_controller.rb', line 2 def self.resource_class Releaf::I18nDatabase::I18nEntry end |
Instance Method Details
#action_features ⇒ Object
87 88 89 |
# File 'app/controllers/releaf/i18n_database/translations_controller.rb', line 87 def action_features {index: :index}.with_indifferent_access end |
#action_views ⇒ Object
83 84 85 |
# File 'app/controllers/releaf/i18n_database/translations_controller.rb', line 83 def action_views super.merge(import: :edit) end |
#build_breadcrumbs ⇒ Object
22 23 24 25 26 27 28 |
# File 'app/controllers/releaf/i18n_database/translations_controller.rb', line 22 def super if %w[edit update].include?(params[:action]) && !params.has_key?(:import) @breadcrumbs << { name: I18n.t("Edit translations", scope: controller_scope_name), url: url_for(action: :edit, search: params[:search]) } end end |
#edit ⇒ Object
6 7 8 9 |
# File 'app/controllers/releaf/i18n_database/translations_controller.rb', line 6 def edit @collection = resources search(params[:search]) end |
#export ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'app/controllers/releaf/i18n_database/translations_controller.rb', line 11 def export @collection = resources search(params[:search]) respond_to do |format| format.xlsx do response.headers['Content-Disposition'] = "attachment; filename=\"#{export_file_name}\"" end end end |
#features ⇒ Object
79 80 81 |
# File 'app/controllers/releaf/i18n_database/translations_controller.rb', line 79 def features [:index, :search] end |
#import ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'app/controllers/releaf/i18n_database/translations_controller.rb', line 59 def import if File.exist?(import_file_path) begin @collection = Releaf::I18nDatabase::ParseSpreadsheetTranslations.call(file_path: import_file_path, extension: import_file_extension) import_view render :edit rescue Releaf::I18nDatabase::ParseSpreadsheetTranslations::UnsupportedFileFormatError flash["error"] = { "id" => "resource_status", "message" => I18n.t("Unsupported file format", scope: notice_scope_name) } redirect_to action: :index end else redirect_to action: :index end end |
#import_view ⇒ Object
74 75 76 77 |
# File 'app/controllers/releaf/i18n_database/translations_controller.rb', line 74 def import_view @import = true @breadcrumbs << { name: I18n.t("import", scope: controller_scope_name) } end |
#resources ⇒ Object
50 51 52 |
# File 'app/controllers/releaf/i18n_database/translations_controller.rb', line 50 def resources Releaf::I18nDatabase::TranslationsUtilities.include_localizations(super).order(:key) end |
#search(lookup_string) ⇒ Object
overwrite search here
55 56 57 |
# File 'app/controllers/releaf/i18n_database/translations_controller.rb', line 55 def search(lookup_string) @collection = Releaf::I18nDatabase::TranslationsUtilities.search(@collection, lookup_string, params[:only_blank].present?) end |
#update ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'app/controllers/releaf/i18n_database/translations_controller.rb', line 30 def update @collection = [] @translations_to_save = [] valid = build_updatables(params[:translations]) import_view if params.has_key?(:import) respond_to do |format| format.html do if valid process_updatables update_response_success else render_notification false, now: true render action: :edit end end end end |