diff --git a/app/assets/javascripts/server.js b/app/assets/javascripts/server.js new file mode 100644 index 0000000000000000000000000000000000000000..5cebd6b2a62553d9cbf32cf06c4e2f91cc33547b --- /dev/null +++ b/app/assets/javascripts/server.js @@ -0,0 +1,17 @@ +//= require activestorage +//= require popper +//= require bootstrap-sprockets +//= require jquery3 +//= require jquery_ujs +//= require notyf/notyf.min +//= require simple_form_bs5_file_input +//= require sortablejs/Sortable +//= require summernote/summernote-bs5 +//= require_self +//= require ./admin/commons/nav +//= require ./admin/commons/sso +//= require_tree ./application/plugins +//= require ./admin/plugins/sortable +//= require_tree ./server + +window.osuny = {}; diff --git a/app/assets/javascripts/server/websites.js b/app/assets/javascripts/server/websites.js new file mode 100644 index 0000000000000000000000000000000000000000..0ec3387304910fd9cfa3e9acbced07fc0d993ff8 --- /dev/null +++ b/app/assets/javascripts/server/websites.js @@ -0,0 +1 @@ +window.osuny.websites = {}; \ No newline at end of file diff --git a/app/assets/javascripts/server/websites/batch-sync-themes.js b/app/assets/javascripts/server/websites/batch-sync-themes.js new file mode 100644 index 0000000000000000000000000000000000000000..d0a0be0b948009d5a8ba817fee0f531e2c9317cb --- /dev/null +++ b/app/assets/javascripts/server/websites/batch-sync-themes.js @@ -0,0 +1,31 @@ +window.osuny.websites.batchSyncThemes = { + init: function () { + 'use strict'; + this.syncAllBtn = document.querySelector('.js-sync-all-theme-versions'); + this.syncBtns = document.querySelectorAll('.js-sync-theme-version'); + this.syncAllBtn.addEventListener('click', this.syncAll.bind(this)); + }, + + syncAll: function (e) { + 'use strict'; + var i; + e.preventDefault(); + for (i = 0; i < this.syncBtns.length; i += 1) { + this.syncBtns[i].click(); + } + }, + + invoke: function () { + 'use strict'; + return { + init: this.init.bind(this) + }; + } +}.invoke(); + +window.addEventListener('DOMContentLoaded', function () { + 'use strict'; + if (document.body.classList.contains('websites-manage_versions')) { + window.osuny.websites.batchSyncThemes.init(); + } +}); diff --git a/app/controllers/server/websites_controller.rb b/app/controllers/server/websites_controller.rb index c9e5f860e02af8b2e28fcdae197d8180279ad7e1..b118fd30615549eaf23fbd4b58f922667123ff9c 100644 --- a/app/controllers/server/websites_controller.rb +++ b/app/controllers/server/websites_controller.rb @@ -1,6 +1,6 @@ class Server::WebsitesController < Server::ApplicationController - before_action :load_websites, only: [:index, :manage_versions, :update_all_themes] - before_action :load_website, except: [:index, :manage_versions, :update_all_themes] + before_action :load_websites, only: [:index, :manage_versions, :clean_and_rebuild_all_websites] + before_action :load_website, except: [:index, :manage_versions, :clean_and_rebuild_all_websites] has_scope :for_theme_version has_scope :for_production @@ -19,11 +19,11 @@ class Server::WebsitesController < Server::ApplicationController add_breadcrumb "Gestion des versions" end - def update_all_themes + def clean_and_rebuild_all_websites @websites.find_each do |website| website.clean_and_rebuild end - redirect_back(fallback_location: manage_versions_server_websites_path, notice: t('server_admin.websites.update_all_themes_notice')) + redirect_back(fallback_location: manage_versions_server_websites_path, notice: t('server_admin.websites.clean_and_rebuild_all_websites_notice')) end def sync_theme_version diff --git a/app/views/server/layouts/application.html.erb b/app/views/server/layouts/application.html.erb index bf62d98d8f88685a9c49071148e1df3c34e2f7e4..9bcbe98a42613f1b8be404cb78c5572244d34a64 100644 --- a/app/views/server/layouts/application.html.erb +++ b/app/views/server/layouts/application.html.erb @@ -32,7 +32,7 @@ </main> <%= render "admin/layouts/themes/pure/commands" %> <%= render "admin/layouts/themes/pure/footer" %> - <%= javascript_include_tag 'admin/pure' %> + <%= javascript_include_tag 'server' %> <%= render 'bugsnag' %> </body> </html> diff --git a/app/views/server/websites/manage_versions.html.erb b/app/views/server/websites/manage_versions.html.erb index b993c8818c3be0961e81f5cf529bdc726baa69f6..90eb99a75a1f4cc5ee995d789233861b4c854603 100644 --- a/app/views/server/websites/manage_versions.html.erb +++ b/app/views/server/websites/manage_versions.html.erb @@ -44,7 +44,7 @@ sync_theme_version_server_website_path(website), method: :post, remote: true, - class: button_classes if website.url.present? && website.theme_version_url.present? %> + class: "#{button_classes} js-sync-theme-version" if website.url.present? && website.theme_version_url.present? %> <%= link_to t('server_admin.websites.buttons.theme.update'), update_theme_server_website_path(website), method: :post, @@ -58,8 +58,11 @@ </div> <% content_for :action_bar_left do %> + <%= link_to "Synchroniser toutes les versions de thème", + "#", + class: "#{button_classes} js-sync-all-theme-versions" %> <%= link_to "Tout mettre à jour", - update_all_themes_server_websites_path(current_scopes), + clean_and_rebuild_all_websites_server_websites_path(current_scopes), method: :post, class: button_classes %> <% end %> \ No newline at end of file diff --git a/config/locales/en.yml b/config/locales/en.yml index 6e2adf9f08597daeb482cfe73fda7ed6f7ad76c0..a8a3bc2e99f9cc444f2f67323b62cdb8060a0193 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -337,8 +337,8 @@ en: theme: sync: Sync version update: Update theme + clean_and_rebuild_all_websites_notice: All themes will be updated. This can take a few minutes. sync_theme_version_notice: The theme's version of %{website} has been synced - update_all_themes_notice: All themes will be updated. This can take a few minutes. update_theme_notice: The theme of %{website} will be updated in a moment seo: SEO simple_form: diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 9ec5a600cd89079b8e189db31e92810e784272f5..bcdc970a212f0b5a904b13e59dd923ffd8a34b30 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -144,7 +144,7 @@ fr: summary: label: Résumé hint: Un texte court, comme un chapô pour un article. Ne mettez pas tout le contenu ici, pour ça, il y a les blocs ! - translation: + translation: button: Traduire avec LibreTranslate done: Traduction effectuée ! Merci de relire avant d'enregistrer. running: Traduction en cours @@ -337,8 +337,8 @@ fr: theme: sync: Synchroniser la version update: Mettre à jour le thème + clean_and_rebuild_all_websites_notice: Tous les thèmes vont être mis à jour. Cela peut prendre quelques minutes. sync_theme_version_notice: La version du thème de %{website} a été synchronisée - update_all_themes_notice: Tous les thèmes vont être mis à jour. Cela peut prendre quelques minutes. update_theme_notice: Le thème de %{website} va être mis à jour dans quelques instants seo: SEO simple_form: diff --git a/config/routes/server.rb b/config/routes/server.rb index 311ba5d9080f9790206717f69ab425cb82deff34..daf21fe4a6077acedb4c2f115039b08af14a6c5a 100644 --- a/config/routes/server.rb +++ b/config/routes/server.rb @@ -4,7 +4,7 @@ namespace :server do resources :websites do collection do get :manage_versions - post :update_all_themes + post :clean_and_rebuild_all_websites end member do post :sync_theme_version