Class: Decidim::TermCustomizer::Admin::TranslationsController
- Inherits:
-
ApplicationController
- Object
- Admin::ApplicationController
- ApplicationController
- Decidim::TermCustomizer::Admin::TranslationsController
- Defined in:
- app/controllers/decidim/term_customizer/admin/translations_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #export ⇒ Object
- #import ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #new_import ⇒ Object
- #update ⇒ Object
Methods inherited from ApplicationController
Instance Method Details
#create ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/controllers/decidim/term_customizer/admin/translations_controller.rb', line 21 def create :create, :translation @form = form(TranslationForm).from_params( params, current_organization: current_organization, translation_set: set ) CreateTranslation.call(@form) do on(:ok) do flash[:notice] = I18n.t("translations.create.success", scope: "decidim.term_customizer.admin") redirect_to translation_set_translations_path(set) end on(:invalid) do flash.now[:alert] = I18n.t("translations.create.error", scope: "decidim.term_customizer.admin") render action: "new" end end end |
#destroy ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'app/controllers/decidim/term_customizer/admin/translations_controller.rb', line 68 def destroy :destroy, :translation, translation: translation # Destroy all locales of the translation key Decidim::TermCustomizer::Translation.where( translation_set: set, key: translation.key ).destroy_all flash[:notice] = I18n.t("translations.destroy.success", scope: "decidim.term_customizer.admin") redirect_to translation_set_translations_path(set) end |
#edit ⇒ Object
42 43 44 45 |
# File 'app/controllers/decidim/term_customizer/admin/translations_controller.rb', line 42 def edit :update, :translation, translation: translation @form = form(TranslationForm).from_model(translation) end |
#export ⇒ Object
82 83 84 85 86 87 88 89 90 91 |
# File 'app/controllers/decidim/term_customizer/admin/translations_controller.rb', line 82 def export :export, :translation_set, translation_set: set name = "set-translations" ExportJob.perform_later(current_user, set, name, params[:format] || "json") flash[:notice] = I18n.t("exports.notice", scope: "decidim.admin") redirect_to translation_set_translations_path(set) end |
#import ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'app/controllers/decidim/term_customizer/admin/translations_controller.rb', line 99 def import :import, :translation_set, translation_set: set @import = form(Admin::TranslationsImportForm).from_params(params) ImportSetTranslations.call(@import, set) do on(:ok) do flash[:notice] = I18n.t("translations.import.success", scope: "decidim.term_customizer.admin") redirect_to translation_set_translations_path(set) end on(:invalid) do flash.now[:alert] = I18n.t("translations.import.error", scope: "decidim.term_customizer.admin") render action: "new_import" end end end |
#index ⇒ Object
9 10 11 12 13 |
# File 'app/controllers/decidim/term_customizer/admin/translations_controller.rb', line 9 def index :read, :translation @translations = collection @directory = TranslationDirectory.new(current_locale) end |
#new ⇒ Object
15 16 17 18 19 |
# File 'app/controllers/decidim/term_customizer/admin/translations_controller.rb', line 15 def new :create, :translation @form = form(TranslationForm).from_model(Translation.new) end |
#new_import ⇒ Object
93 94 95 96 97 |
# File 'app/controllers/decidim/term_customizer/admin/translations_controller.rb', line 93 def new_import :import, :translation_set, translation_set: set @import = form(Admin::TranslationsImportForm).instance end |
#update ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'app/controllers/decidim/term_customizer/admin/translations_controller.rb', line 47 def update :update, :translation, translation: translation @form = form(TranslationForm).from_params( params, current_organization: current_organization, translation_set: set ) UpdateTranslation.call(@form, translation) do on(:ok) do flash[:notice] = I18n.t("translations.update.success", scope: "decidim.term_customizer.admin") redirect_to translation_set_translations_path(set) end on(:invalid) do flash.now[:alert] = I18n.t("translations.update.error", scope: "decidim.term_customizer.admin") render action: "edit" end end end |