Skip to content

Latest commit

 

History

History
101 lines (77 loc) · 2.81 KB

UPGRADING_to_v2.md

File metadata and controls

101 lines (77 loc) · 2.81 KB

Upgrade existing application to chaltron v2

1 Upgrade to the last v1 version and ensure it's all working

You should re-run rails generator chaltron:install to keep all updated.

Sometimes it's easier to manually follow the generator, to update what is needed. Don't forget to add the last migration!

class AddEnabledToUsers < ActiveRecord::Migration[5.2]
  def change
      add_column :users, :enabled, :boolean, default: true
  end
end

2 Install chaltron v2

Just update your bundle

2.1 Update Gemfile

Add the following gems before chaltron

gem 'devise'
gem 'omniauth'
gem 'omniauth-rails_csrf_protection'
gem 'gitlab_omniauth-ldap'
gem 'cancancan'

gem 'bootstrap'
gem 'autoprefixer-rails'
gem 'font-awesome-sass'

gem 'jquery-rails'
gem 'jquery-datatables'
gem 'ajax-datatables-rails'

gem 'bootstrap_form'
gem 'nprogress-rails'
gem 'simple-navigation'
gem 'rails-i18n'

Note that chaltron gem must be declared after devise, because both of them change the view paths

2.2 Update app/assets/javascripts/application.js

Add the following dependencies, replacing //= require chaltron

//= require jquery
//= require popper
//= require bootstrap
//= require datatables/jquery.dataTables
//= require datatables/dataTables.bootstrap4
//= require datatables/extensions/Responsive/dataTables.responsive
//= require datatables/extensions/Responsive/responsive.bootstrap4
//= require nprogress
//= require nprogress-turbolinks
//= require nprogress-ajax
//= require chaltron

And (at the bottom)

document.addEventListener('DOMContentLoaded', function(event) {
  Chaltron.locale = $('body').data('locale');
});

NProgress.configure({
  showSpinner: false,
});
2.3 Update stylesheets

Copy chaltron_custom.scss and datatables.scss into app/assets/stylesheets/

2.4 Fix localization

In app/views/layouts/application.html.erb add the following data field to your body

<%= content_tag :body, data: { locale: I18n.locale } do %>
...
<% end %>
2.5 Fix javascript

Remove app/assets/javascripts/localization.js (or any other reference to Chaltron.prototype.lang)

The current language is now retrieved with

Chaltron.locale

Remove any reference to Chaltron.locales

DataTables objects are localized with the following options

language: Chaltron.translate('datatables')