From aa6ef95d6c1cdd2daa81b725be7569e404251a77 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Sun, 21 Nov 2021 16:37:24 -0800 Subject: [PATCH] Switch templates from HAML to ERB Make RailsAdmin have fewer dependencies and so slightly reduce total installation size. Align the project with default upstream Rails practices. Starting a new Rails project includes ERB by default but not HAML. By switching, we don't pull in additional templating practices beyond what any default project is already using. The change may also help encourage contributors. While nearly all Rails developers have direct experience working with ERB, the same is not always true of HAML. This removes a small barrier. Fixes #3173 --- .rubocop_todo.yml | 1 - Appraisals | 3 - Gemfile | 1 - .../ra-twitter-bootstrap/_gap.html.erb | 5 + .../ra-twitter-bootstrap/_gap.html.haml | 2 - .../ra-twitter-bootstrap/_next_page.html.erb | 9 + .../ra-twitter-bootstrap/_next_page.html.haml | 4 - .../ra-twitter-bootstrap/_page.html.erb | 9 + .../ra-twitter-bootstrap/_page.html.haml | 4 - .../ra-twitter-bootstrap/_paginator.html.erb | 13 + .../ra-twitter-bootstrap/_paginator.html.haml | 9 - .../ra-twitter-bootstrap/_prev_page.html.erb | 9 + .../ra-twitter-bootstrap/_prev_page.html.haml | 4 - .../without_count/_next_page.html.erb | 9 + .../without_count/_next_page.html.haml | 4 - .../without_count/_paginator.html.erb | 6 + .../without_count/_paginator.html.haml | 4 - .../without_count/_prev_page.html.erb | 9 + .../without_count/_prev_page.html.haml | 4 - app/views/layouts/rails_admin/_head.html.erb | 7 + app/views/layouts/rails_admin/_head.html.haml | 7 - .../layouts/rails_admin/_navigation.html.erb | 21 ++ .../layouts/rails_admin/_navigation.html.haml | 12 - .../_secondary_navigation.html.erb | 24 ++ .../_secondary_navigation.html.haml | 10 - .../rails_admin/_sidebar_navigation.html.erb | 9 + .../rails_admin/_sidebar_navigation.html.haml | 3 - .../layouts/rails_admin/application.html.erb | 27 ++ .../layouts/rails_admin/application.html.haml | 16 -- app/views/layouts/rails_admin/modal.js.erb | 7 + app/views/layouts/rails_admin/modal.js.haml | 5 - app/views/layouts/rails_admin/pjax.html.erb | 20 ++ app/views/layouts/rails_admin/pjax.html.haml | 12 - .../main/_dashboard_history.html.erb | 45 ++++ .../main/_dashboard_history.html.haml | 21 -- .../rails_admin/main/_delete_notice.html.erb | 35 +++ .../rails_admin/main/_delete_notice.html.haml | 24 -- .../main/_form_action_text.html.erb | 7 + .../main/_form_action_text.html.haml | 7 - .../rails_admin/main/_form_boolean.html.erb | 16 ++ .../rails_admin/main/_form_boolean.html.haml | 10 - ...tor.html.haml => _form_ck_editor.html.erb} | 6 +- .../main/_form_code_mirror.html.erb | 9 + .../main/_form_code_mirror.html.haml | 9 - .../main/_form_colorpicker.html.erb | 1 + .../main/_form_colorpicker.html.haml | 1 - .../rails_admin/main/_form_datetime.html.erb | 9 + .../rails_admin/main/_form_datetime.html.haml | 6 - .../main/_form_enumeration.html.erb | 21 ++ .../main/_form_enumeration.html.haml | 19 -- .../rails_admin/main/_form_field.html.erb | 1 + .../rails_admin/main/_form_field.html.haml | 1 - .../main/_form_file_upload.html.erb | 17 ++ .../main/_form_file_upload.html.haml | 17 -- ...l => _form_filtering_multiselect.html.erb} | 20 +- ...l.haml => _form_filtering_select.html.erb} | 25 +- .../rails_admin/main/_form_froala.html.erb | 8 + .../rails_admin/main/_form_froala.html.haml | 8 - .../main/_form_multiple_file_upload.html.erb | 20 ++ .../main/_form_multiple_file_upload.html.haml | 16 -- .../main/_form_nested_many.html.erb | 21 ++ .../main/_form_nested_many.html.haml | 15 -- .../main/_form_nested_one.html.erb | 21 ++ .../main/_form_nested_one.html.haml | 17 -- ...=> _form_polymorphic_association.html.erb} | 16 +- .../rails_admin/main/_form_simple_mde.haml | 8 - .../main/_form_simple_mde.html.erb | 8 + .../rails_admin/main/_form_text.html.erb | 1 + .../rails_admin/main/_form_text.html.haml | 1 - .../rails_admin/main/_form_wysihtml5.html.erb | 8 + .../main/_form_wysihtml5.html.haml | 8 - .../rails_admin/main/_submit_buttons.html.erb | 25 ++ .../main/_submit_buttons.html.haml | 16 -- .../rails_admin/main/bulk_delete.html.erb | 19 ++ .../rails_admin/main/bulk_delete.html.haml | 11 - app/views/rails_admin/main/dashboard.html.erb | 64 +++++ .../rails_admin/main/dashboard.html.haml | 34 --- app/views/rails_admin/main/delete.html.erb | 21 ++ app/views/rails_admin/main/delete.html.haml | 18 -- app/views/rails_admin/main/edit.html.erb | 3 + app/views/rails_admin/main/edit.html.haml | 2 - app/views/rails_admin/main/export.html.erb | 146 +++++++++++ app/views/rails_admin/main/export.html.haml | 92 ------- app/views/rails_admin/main/history.html.erb | 78 ++++++ app/views/rails_admin/main/history.html.haml | 51 ---- app/views/rails_admin/main/index.html.erb | 232 ++++++++++++++++++ app/views/rails_admin/main/index.html.haml | 133 ---------- app/views/rails_admin/main/new.html.erb | 3 + app/views/rails_admin/main/new.html.haml | 2 - app/views/rails_admin/main/show.html.erb | 28 +++ app/views/rails_admin/main/show.html.haml | 15 -- config/initializers/haml.rb | 5 - gemfiles/rails_6.0.gemfile | 1 - gemfiles/rails_6.1.gemfile | 1 - gemfiles/rails_7.0.gemfile | 1 - rails_admin.gemspec | 1 - .../dummy_app/app/views/players/show.html.erb | 1 + .../app/views/players/show.html.haml | 1 - 98 files changed, 1087 insertions(+), 709 deletions(-) create mode 100644 app/views/kaminari/ra-twitter-bootstrap/_gap.html.erb delete mode 100644 app/views/kaminari/ra-twitter-bootstrap/_gap.html.haml create mode 100644 app/views/kaminari/ra-twitter-bootstrap/_next_page.html.erb delete mode 100644 app/views/kaminari/ra-twitter-bootstrap/_next_page.html.haml create mode 100644 app/views/kaminari/ra-twitter-bootstrap/_page.html.erb delete mode 100644 app/views/kaminari/ra-twitter-bootstrap/_page.html.haml create mode 100644 app/views/kaminari/ra-twitter-bootstrap/_paginator.html.erb delete mode 100644 app/views/kaminari/ra-twitter-bootstrap/_paginator.html.haml create mode 100644 app/views/kaminari/ra-twitter-bootstrap/_prev_page.html.erb delete mode 100644 app/views/kaminari/ra-twitter-bootstrap/_prev_page.html.haml create mode 100644 app/views/kaminari/ra-twitter-bootstrap/without_count/_next_page.html.erb delete mode 100644 app/views/kaminari/ra-twitter-bootstrap/without_count/_next_page.html.haml create mode 100644 app/views/kaminari/ra-twitter-bootstrap/without_count/_paginator.html.erb delete mode 100644 app/views/kaminari/ra-twitter-bootstrap/without_count/_paginator.html.haml create mode 100644 app/views/kaminari/ra-twitter-bootstrap/without_count/_prev_page.html.erb delete mode 100644 app/views/kaminari/ra-twitter-bootstrap/without_count/_prev_page.html.haml create mode 100644 app/views/layouts/rails_admin/_head.html.erb delete mode 100644 app/views/layouts/rails_admin/_head.html.haml create mode 100644 app/views/layouts/rails_admin/_navigation.html.erb delete mode 100644 app/views/layouts/rails_admin/_navigation.html.haml create mode 100644 app/views/layouts/rails_admin/_secondary_navigation.html.erb delete mode 100644 app/views/layouts/rails_admin/_secondary_navigation.html.haml create mode 100644 app/views/layouts/rails_admin/_sidebar_navigation.html.erb delete mode 100644 app/views/layouts/rails_admin/_sidebar_navigation.html.haml create mode 100644 app/views/layouts/rails_admin/application.html.erb delete mode 100644 app/views/layouts/rails_admin/application.html.haml create mode 100644 app/views/layouts/rails_admin/modal.js.erb delete mode 100644 app/views/layouts/rails_admin/modal.js.haml create mode 100644 app/views/layouts/rails_admin/pjax.html.erb delete mode 100644 app/views/layouts/rails_admin/pjax.html.haml create mode 100644 app/views/rails_admin/main/_dashboard_history.html.erb delete mode 100644 app/views/rails_admin/main/_dashboard_history.html.haml create mode 100644 app/views/rails_admin/main/_delete_notice.html.erb delete mode 100644 app/views/rails_admin/main/_delete_notice.html.haml create mode 100644 app/views/rails_admin/main/_form_action_text.html.erb delete mode 100644 app/views/rails_admin/main/_form_action_text.html.haml create mode 100644 app/views/rails_admin/main/_form_boolean.html.erb delete mode 100644 app/views/rails_admin/main/_form_boolean.html.haml rename app/views/rails_admin/main/{_form_ck_editor.html.haml => _form_ck_editor.html.erb} (57%) create mode 100644 app/views/rails_admin/main/_form_code_mirror.html.erb delete mode 100644 app/views/rails_admin/main/_form_code_mirror.html.haml create mode 100644 app/views/rails_admin/main/_form_colorpicker.html.erb delete mode 100644 app/views/rails_admin/main/_form_colorpicker.html.haml create mode 100644 app/views/rails_admin/main/_form_datetime.html.erb delete mode 100644 app/views/rails_admin/main/_form_datetime.html.haml create mode 100644 app/views/rails_admin/main/_form_enumeration.html.erb delete mode 100644 app/views/rails_admin/main/_form_enumeration.html.haml create mode 100644 app/views/rails_admin/main/_form_field.html.erb delete mode 100644 app/views/rails_admin/main/_form_field.html.haml create mode 100644 app/views/rails_admin/main/_form_file_upload.html.erb delete mode 100644 app/views/rails_admin/main/_form_file_upload.html.haml rename app/views/rails_admin/main/{_form_filtering_multiselect.html.haml => _form_filtering_multiselect.html.erb} (67%) rename app/views/rails_admin/main/{_form_filtering_select.html.haml => _form_filtering_select.html.erb} (53%) create mode 100644 app/views/rails_admin/main/_form_froala.html.erb delete mode 100644 app/views/rails_admin/main/_form_froala.html.haml create mode 100644 app/views/rails_admin/main/_form_multiple_file_upload.html.erb delete mode 100644 app/views/rails_admin/main/_form_multiple_file_upload.html.haml create mode 100644 app/views/rails_admin/main/_form_nested_many.html.erb delete mode 100644 app/views/rails_admin/main/_form_nested_many.html.haml create mode 100644 app/views/rails_admin/main/_form_nested_one.html.erb delete mode 100644 app/views/rails_admin/main/_form_nested_one.html.haml rename app/views/rails_admin/main/{_form_polymorphic_association.html.haml => _form_polymorphic_association.html.erb} (58%) delete mode 100644 app/views/rails_admin/main/_form_simple_mde.haml create mode 100644 app/views/rails_admin/main/_form_simple_mde.html.erb create mode 100644 app/views/rails_admin/main/_form_text.html.erb delete mode 100644 app/views/rails_admin/main/_form_text.html.haml create mode 100644 app/views/rails_admin/main/_form_wysihtml5.html.erb delete mode 100644 app/views/rails_admin/main/_form_wysihtml5.html.haml create mode 100644 app/views/rails_admin/main/_submit_buttons.html.erb delete mode 100644 app/views/rails_admin/main/_submit_buttons.html.haml create mode 100644 app/views/rails_admin/main/bulk_delete.html.erb delete mode 100644 app/views/rails_admin/main/bulk_delete.html.haml create mode 100644 app/views/rails_admin/main/dashboard.html.erb delete mode 100644 app/views/rails_admin/main/dashboard.html.haml create mode 100644 app/views/rails_admin/main/delete.html.erb delete mode 100644 app/views/rails_admin/main/delete.html.haml create mode 100644 app/views/rails_admin/main/edit.html.erb delete mode 100644 app/views/rails_admin/main/edit.html.haml create mode 100644 app/views/rails_admin/main/export.html.erb delete mode 100644 app/views/rails_admin/main/export.html.haml create mode 100644 app/views/rails_admin/main/history.html.erb delete mode 100644 app/views/rails_admin/main/history.html.haml create mode 100644 app/views/rails_admin/main/index.html.erb delete mode 100644 app/views/rails_admin/main/index.html.haml create mode 100644 app/views/rails_admin/main/new.html.erb delete mode 100644 app/views/rails_admin/main/new.html.haml create mode 100644 app/views/rails_admin/main/show.html.erb delete mode 100644 app/views/rails_admin/main/show.html.haml delete mode 100644 config/initializers/haml.rb create mode 100644 spec/dummy_app/app/views/players/show.html.erb delete mode 100644 spec/dummy_app/app/views/players/show.html.haml diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 13b8e9ec77..f7d4637528 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -302,7 +302,6 @@ Style/IdenticalConditionalBranches: # Cop supports --auto-correct. Style/IfUnlessModifier: Exclude: - - "config/initializers/haml.rb" - "lib/rails_admin/adapters/active_record.rb" - "lib/rails_admin/adapters/mongoid.rb" - "lib/rails_admin/bootstrap-sass.rb" diff --git a/Appraisals b/Appraisals index 6623ee79f9..0c1522bc7f 100644 --- a/Appraisals +++ b/Appraisals @@ -1,6 +1,5 @@ appraise "rails-6.0" do gem 'rails', '~> 6.0.0' - gem 'haml' gem 'sassc-rails', '~> 2.1' gem 'devise', '~> 4.7' @@ -34,7 +33,6 @@ end appraise "rails-6.1" do gem 'rails', '~> 6.1.0' - gem 'haml' gem 'sassc-rails', '~> 2.1' gem 'devise', '~> 4.7' @@ -68,7 +66,6 @@ end appraise "rails-7.0" do gem 'rails', '~> 7.0.0.alpha2' - gem 'haml' gem 'sassc-rails', '~> 2.1' gem 'devise', '~> 4.7', github: 'strobilomyces/devise', branch: 'patch-1' diff --git a/Gemfile b/Gemfile index 99204a4112..39f9bccda3 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,6 @@ source 'https://rubygems.org' gem 'appraisal', '>= 2.0' gem 'rails' -gem 'haml' gem 'devise' gem 'webrick', '~> 1.7' diff --git a/app/views/kaminari/ra-twitter-bootstrap/_gap.html.erb b/app/views/kaminari/ra-twitter-bootstrap/_gap.html.erb new file mode 100644 index 0000000000..148427934e --- /dev/null +++ b/app/views/kaminari/ra-twitter-bootstrap/_gap.html.erb @@ -0,0 +1,5 @@ +
  • + + <%= raw(t 'admin.pagination.truncate') %> + +
  • diff --git a/app/views/kaminari/ra-twitter-bootstrap/_gap.html.haml b/app/views/kaminari/ra-twitter-bootstrap/_gap.html.haml deleted file mode 100644 index 719ad2725d..0000000000 --- a/app/views/kaminari/ra-twitter-bootstrap/_gap.html.haml +++ /dev/null @@ -1,2 +0,0 @@ -%li.disabled - %a{href: '#'}= raw(t 'admin.pagination.truncate') diff --git a/app/views/kaminari/ra-twitter-bootstrap/_next_page.html.erb b/app/views/kaminari/ra-twitter-bootstrap/_next_page.html.erb new file mode 100644 index 0000000000..4287f2840f --- /dev/null +++ b/app/views/kaminari/ra-twitter-bootstrap/_next_page.html.erb @@ -0,0 +1,9 @@ +<% if current_page.last? %> + +<% else %> + +<% end %> diff --git a/app/views/kaminari/ra-twitter-bootstrap/_next_page.html.haml b/app/views/kaminari/ra-twitter-bootstrap/_next_page.html.haml deleted file mode 100644 index b8f93c4e73..0000000000 --- a/app/views/kaminari/ra-twitter-bootstrap/_next_page.html.haml +++ /dev/null @@ -1,4 +0,0 @@ -- if current_page.last? - %li.next.disabled= link_to raw(t 'admin.pagination.next'), '#' -- else - %li.next= link_to raw(t 'admin.pagination.next'), url, class: (remote ? 'pjax' : '') diff --git a/app/views/kaminari/ra-twitter-bootstrap/_page.html.erb b/app/views/kaminari/ra-twitter-bootstrap/_page.html.erb new file mode 100644 index 0000000000..7b6f252e8a --- /dev/null +++ b/app/views/kaminari/ra-twitter-bootstrap/_page.html.erb @@ -0,0 +1,9 @@ +<% if page.current? %> +
  • + <%= link_to page, url, class: (remote ? 'pjax' : '') %> +
  • +<% else %> +
  • + <%= link_to page, url, class: (remote ? 'pjax' : '') %> +
  • +<% end %> diff --git a/app/views/kaminari/ra-twitter-bootstrap/_page.html.haml b/app/views/kaminari/ra-twitter-bootstrap/_page.html.haml deleted file mode 100644 index a92e5af158..0000000000 --- a/app/views/kaminari/ra-twitter-bootstrap/_page.html.haml +++ /dev/null @@ -1,4 +0,0 @@ -- if page.current? - %li.active= link_to page, url, class: (remote ? 'pjax' : '') -- else - %li= link_to page, url, class: (remote ? 'pjax' : '') diff --git a/app/views/kaminari/ra-twitter-bootstrap/_paginator.html.erb b/app/views/kaminari/ra-twitter-bootstrap/_paginator.html.erb new file mode 100644 index 0000000000..dcbf65973d --- /dev/null +++ b/app/views/kaminari/ra-twitter-bootstrap/_paginator.html.erb @@ -0,0 +1,13 @@ +<%= paginator.render do %> + +<% end %> diff --git a/app/views/kaminari/ra-twitter-bootstrap/_paginator.html.haml b/app/views/kaminari/ra-twitter-bootstrap/_paginator.html.haml deleted file mode 100644 index 47f2b27e95..0000000000 --- a/app/views/kaminari/ra-twitter-bootstrap/_paginator.html.haml +++ /dev/null @@ -1,9 +0,0 @@ -= paginator.render do - %ul.pagination - = prev_page_tag - - each_page do |page| - - if page.left_outer? or page.right_outer? or page.inside_window? - = page_tag page - - elsif !page.was_truncated? - = gap_tag - = next_page_tag diff --git a/app/views/kaminari/ra-twitter-bootstrap/_prev_page.html.erb b/app/views/kaminari/ra-twitter-bootstrap/_prev_page.html.erb new file mode 100644 index 0000000000..90ea46f8ea --- /dev/null +++ b/app/views/kaminari/ra-twitter-bootstrap/_prev_page.html.erb @@ -0,0 +1,9 @@ +<% if current_page.first? %> + +<% else %> + +<% end %> diff --git a/app/views/kaminari/ra-twitter-bootstrap/_prev_page.html.haml b/app/views/kaminari/ra-twitter-bootstrap/_prev_page.html.haml deleted file mode 100644 index 1b7f839fb4..0000000000 --- a/app/views/kaminari/ra-twitter-bootstrap/_prev_page.html.haml +++ /dev/null @@ -1,4 +0,0 @@ -- if current_page.first? - %li.prev.disabled= link_to raw(t 'admin.pagination.previous'), '#' -- else - %li.prev= link_to raw(t 'admin.pagination.previous'), url, class: (remote ? 'pjax' : '') diff --git a/app/views/kaminari/ra-twitter-bootstrap/without_count/_next_page.html.erb b/app/views/kaminari/ra-twitter-bootstrap/without_count/_next_page.html.erb new file mode 100644 index 0000000000..4287f2840f --- /dev/null +++ b/app/views/kaminari/ra-twitter-bootstrap/without_count/_next_page.html.erb @@ -0,0 +1,9 @@ +<% if current_page.last? %> + +<% else %> + +<% end %> diff --git a/app/views/kaminari/ra-twitter-bootstrap/without_count/_next_page.html.haml b/app/views/kaminari/ra-twitter-bootstrap/without_count/_next_page.html.haml deleted file mode 100644 index b8f93c4e73..0000000000 --- a/app/views/kaminari/ra-twitter-bootstrap/without_count/_next_page.html.haml +++ /dev/null @@ -1,4 +0,0 @@ -- if current_page.last? - %li.next.disabled= link_to raw(t 'admin.pagination.next'), '#' -- else - %li.next= link_to raw(t 'admin.pagination.next'), url, class: (remote ? 'pjax' : '') diff --git a/app/views/kaminari/ra-twitter-bootstrap/without_count/_paginator.html.erb b/app/views/kaminari/ra-twitter-bootstrap/without_count/_paginator.html.erb new file mode 100644 index 0000000000..cc8e5901d4 --- /dev/null +++ b/app/views/kaminari/ra-twitter-bootstrap/without_count/_paginator.html.erb @@ -0,0 +1,6 @@ +<%= paginator.render do %> + +<% end %> diff --git a/app/views/kaminari/ra-twitter-bootstrap/without_count/_paginator.html.haml b/app/views/kaminari/ra-twitter-bootstrap/without_count/_paginator.html.haml deleted file mode 100644 index dc2c17d399..0000000000 --- a/app/views/kaminari/ra-twitter-bootstrap/without_count/_paginator.html.haml +++ /dev/null @@ -1,4 +0,0 @@ -= paginator.render do - %ul.pagination - = prev_page_tag if !current_page.first? - = next_page_tag diff --git a/app/views/kaminari/ra-twitter-bootstrap/without_count/_prev_page.html.erb b/app/views/kaminari/ra-twitter-bootstrap/without_count/_prev_page.html.erb new file mode 100644 index 0000000000..90ea46f8ea --- /dev/null +++ b/app/views/kaminari/ra-twitter-bootstrap/without_count/_prev_page.html.erb @@ -0,0 +1,9 @@ +<% if current_page.first? %> + +<% else %> + +<% end %> diff --git a/app/views/kaminari/ra-twitter-bootstrap/without_count/_prev_page.html.haml b/app/views/kaminari/ra-twitter-bootstrap/without_count/_prev_page.html.haml deleted file mode 100644 index 1b7f839fb4..0000000000 --- a/app/views/kaminari/ra-twitter-bootstrap/without_count/_prev_page.html.haml +++ /dev/null @@ -1,4 +0,0 @@ -- if current_page.first? - %li.prev.disabled= link_to raw(t 'admin.pagination.previous'), '#' -- else - %li.prev= link_to raw(t 'admin.pagination.previous'), url, class: (remote ? 'pjax' : '') diff --git a/app/views/layouts/rails_admin/_head.html.erb b/app/views/layouts/rails_admin/_head.html.erb new file mode 100644 index 0000000000..68a133c78a --- /dev/null +++ b/app/views/layouts/rails_admin/_head.html.erb @@ -0,0 +1,7 @@ + + + + +<%= csrf_meta_tag %> +<%= stylesheet_link_tag "rails_admin/rails_admin.css", media: :all %> +<%= javascript_include_tag "rails_admin/rails_admin.js" %> diff --git a/app/views/layouts/rails_admin/_head.html.haml b/app/views/layouts/rails_admin/_head.html.haml deleted file mode 100644 index 12e92abc52..0000000000 --- a/app/views/layouts/rails_admin/_head.html.haml +++ /dev/null @@ -1,7 +0,0 @@ -%meta{content: "IE=edge", "http-equiv" => "X-UA-Compatible"} -%meta{content: "text/html; charset=utf-8", "http-equiv" => "Content-Type"} -%meta{content: "width=device-width, initial-scale=1", name: "viewport; charset=utf-8"} -%meta{content: "NONE,NOARCHIVE", name: "robots"} -= csrf_meta_tag -= stylesheet_link_tag "rails_admin/rails_admin.css", media: :all -= javascript_include_tag "rails_admin/rails_admin.js" diff --git a/app/views/layouts/rails_admin/_navigation.html.erb b/app/views/layouts/rails_admin/_navigation.html.erb new file mode 100644 index 0000000000..d9d3c426d0 --- /dev/null +++ b/app/views/layouts/rails_admin/_navigation.html.erb @@ -0,0 +1,21 @@ +
    + + +
    diff --git a/app/views/layouts/rails_admin/_navigation.html.haml b/app/views/layouts/rails_admin/_navigation.html.haml deleted file mode 100644 index 01c2b24a53..0000000000 --- a/app/views/layouts/rails_admin/_navigation.html.haml +++ /dev/null @@ -1,12 +0,0 @@ -.container-fluid - .navbar-header - %button.navbar-toggle.collapsed{ type: 'button', data: { toggle: 'collapse', target: '#secondary-navigation' } } - %span.sr-only= t('admin.toggle_navigation') - %span.icon-bar - %span.icon-bar - %span.icon-bar - %a.navbar-brand.pjax{href: dashboard_path} - = _get_plugin_name[0] || 'Rails' - %small= _get_plugin_name[1] || 'Admin' - .collapse.navbar-collapse#secondary-navigation - = render partial: 'layouts/rails_admin/secondary_navigation' diff --git a/app/views/layouts/rails_admin/_secondary_navigation.html.erb b/app/views/layouts/rails_admin/_secondary_navigation.html.erb new file mode 100644 index 0000000000..fd76c4b24b --- /dev/null +++ b/app/views/layouts/rails_admin/_secondary_navigation.html.erb @@ -0,0 +1,24 @@ + diff --git a/app/views/layouts/rails_admin/_secondary_navigation.html.haml b/app/views/layouts/rails_admin/_secondary_navigation.html.haml deleted file mode 100644 index 868c759507..0000000000 --- a/app/views/layouts/rails_admin/_secondary_navigation.html.haml +++ /dev/null @@ -1,10 +0,0 @@ -%ul.nav.navbar-nav.navbar-right.root_links - - actions(:root).select(&:show_in_navigation).each do |action| - %li{class: "#{action.action_name}_root_link"}= link_to wording_for(:menu, action), { action: action.action_name, controller: 'rails_admin/main' }, class: action.pjax? ? "pjax" : "" - - if main_app_root_path = (main_app.root_path rescue false) - %li= link_to t('admin.home.name'), main_app_root_path - - if _current_user - - if user_link = edit_user_link - %li.edit_user_root_link= user_link - - if logout_path.present? - %li= link_to content_tag('span', t('admin.misc.log_out'), class: 'label label-danger'), logout_path, method: logout_method diff --git a/app/views/layouts/rails_admin/_sidebar_navigation.html.erb b/app/views/layouts/rails_admin/_sidebar_navigation.html.erb new file mode 100644 index 0000000000..7630cc9996 --- /dev/null +++ b/app/views/layouts/rails_admin/_sidebar_navigation.html.erb @@ -0,0 +1,9 @@ + + + diff --git a/app/views/layouts/rails_admin/_sidebar_navigation.html.haml b/app/views/layouts/rails_admin/_sidebar_navigation.html.haml deleted file mode 100644 index e6a67037f5..0000000000 --- a/app/views/layouts/rails_admin/_sidebar_navigation.html.haml +++ /dev/null @@ -1,3 +0,0 @@ -%ul.nav.nav-pills.nav-stacked= main_navigation -%ul.nav.nav-pills.nav-stacked= root_navigation -%ul.nav.nav-pills.nav-stacked= static_navigation diff --git a/app/views/layouts/rails_admin/application.html.erb b/app/views/layouts/rails_admin/application.html.erb new file mode 100644 index 0000000000..44fa6c5981 --- /dev/null +++ b/app/views/layouts/rails_admin/application.html.erb @@ -0,0 +1,27 @@ + + + + <%= render "layouts/rails_admin/head" %> + + +
    " id="admin-js">
    + + +
    +
    + +
    +
    + <%= render template: 'layouts/rails_admin/pjax' %> +
    +
    +
    +
    + + diff --git a/app/views/layouts/rails_admin/application.html.haml b/app/views/layouts/rails_admin/application.html.haml deleted file mode 100644 index 0d6a938224..0000000000 --- a/app/views/layouts/rails_admin/application.html.haml +++ /dev/null @@ -1,16 +0,0 @@ -!!! 5 -%html{lang: I18n.locale} - %head - = render "layouts/rails_admin/head" - %body.rails_admin - #admin-js{:'data-i18n-options' => I18n.t("admin.js").to_json} - #loading.label.label-warning{style: 'display:none; position:fixed; right:20px; bottom:20px; z-index:100000'}= t('admin.loading') - %nav.navbar.navbar-default.navbar-fixed-top - = render "layouts/rails_admin/navigation" - .container-fluid - .row - .col-sm-3.col-md-2.sidebar-nav - = render "layouts/rails_admin/sidebar_navigation" - .col-sm-9.col-sm-offset-3.col-md-10.col-md-offset-2 - .content{:'data-pjax-container' => true} - = render template: 'layouts/rails_admin/pjax' diff --git a/app/views/layouts/rails_admin/modal.js.erb b/app/views/layouts/rails_admin/modal.js.erb new file mode 100644 index 0000000000..15659d37f3 --- /dev/null +++ b/app/views/layouts/rails_admin/modal.js.erb @@ -0,0 +1,7 @@ +<% flash && flash.each do |key, value| %> +
    + + <%= value %> +
    +<% end %> +<%= yield %> diff --git a/app/views/layouts/rails_admin/modal.js.haml b/app/views/layouts/rails_admin/modal.js.haml deleted file mode 100644 index 0b26511ac8..0000000000 --- a/app/views/layouts/rails_admin/modal.js.haml +++ /dev/null @@ -1,5 +0,0 @@ -- flash && flash.each do |key, value| - .alert.alert-dismissible{class: flash_alert_class(key)} - %button.close{type: 'button', :'data-dismiss' => "alert"} × - = value -= yield diff --git a/app/views/layouts/rails_admin/pjax.html.erb b/app/views/layouts/rails_admin/pjax.html.erb new file mode 100644 index 0000000000..5e007d5e5b --- /dev/null +++ b/app/views/layouts/rails_admin/pjax.html.erb @@ -0,0 +1,20 @@ + + <%= "#{@abstract_model.try(:pretty_name) || @page_name} | #{[_get_plugin_name[0] || 'Rails', _get_plugin_name[1] || 'Admin'].join(' ')}" %> + + +<% flash && flash.each do |key, value| %> +
    + + <%= value %> +
    +<% end %> +<%= breadcrumb %> + +<%= yield %> diff --git a/app/views/layouts/rails_admin/pjax.html.haml b/app/views/layouts/rails_admin/pjax.html.haml deleted file mode 100644 index 4edbc350ec..0000000000 --- a/app/views/layouts/rails_admin/pjax.html.haml +++ /dev/null @@ -1,12 +0,0 @@ -%title= "#{@abstract_model.try(:pretty_name) || @page_name} | #{[_get_plugin_name[0] || 'Rails', _get_plugin_name[1] || 'Admin'].join(' ')}" -.page-header{data: {model: @abstract_model.to_param}} - %h1= @page_name -- flash && flash.each do |key, value| - .alert.alert-dismissible{class: flash_alert_class(key)} - %button.close{type: 'button', :'data-dismiss' => "alert"} × - = value -= breadcrumb -%ul.nav.nav-tabs - = menu_for((@abstract_model ? (@object.try(:persisted?) ? :member : :collection) : :root), @abstract_model, @object) - = content_for :contextual_tabs -= yield diff --git a/app/views/rails_admin/main/_dashboard_history.html.erb b/app/views/rails_admin/main/_dashboard_history.html.erb new file mode 100644 index 0000000000..e11a81c0de --- /dev/null +++ b/app/views/rails_admin/main/_dashboard_history.html.erb @@ -0,0 +1,45 @@ + + + + + + + + + + <% @history.each do |t| %> + <% abstract_model = RailsAdmin.config(t.table).abstract_model %> + + + <% if o = abstract_model.try(:get, t.item) %> + <% label = o.send(abstract_model.config.object_label_method) %> + <% if show_action = action(:show, abstract_model, o) %> + + <% else %> + + <% end %> + <% else %> + <% label = Object.const_defined?(t.table) ? t.table.constantize.model_name.human : t.table %> + + <% end %> + + + <% end %> + +
    + <%= t("admin.table_headers.username") %> + + <%= t("admin.table_headers.item") %> + + <%= t("admin.table_headers.changes") %> +
    + <%= t.try :username %> + + <%= link_to(label, url_for(action: show_action.action_name, model_name: abstract_model.to_param, id: o.id), class: 'pjax') %> + + <%= label %> + + <%= "#{label} ##{t.item}" %> + + <%= t.message %> +
    diff --git a/app/views/rails_admin/main/_dashboard_history.html.haml b/app/views/rails_admin/main/_dashboard_history.html.haml deleted file mode 100644 index d2d56eaad3..0000000000 --- a/app/views/rails_admin/main/_dashboard_history.html.haml +++ /dev/null @@ -1,21 +0,0 @@ -%table.table.table-condensed.table-striped.table-hover - %thead - %tr - %th.shrink.user= t("admin.table_headers.username") - %th.shrink.items= t("admin.table_headers.item") - %th.changes= t("admin.table_headers.changes") - %tbody - - @history.each do |t| - - abstract_model = RailsAdmin.config(t.table).abstract_model - %tr - %td= t.try :username - - if o = abstract_model.try(:get, t.item) - - label = o.send(abstract_model.config.object_label_method) - - if show_action = action(:show, abstract_model, o) - %td= link_to(label, url_for(action: show_action.action_name, model_name: abstract_model.to_param, id: o.id), class: 'pjax') - - else - %td= label - - else - - label = Object.const_defined?(t.table) ? t.table.constantize.model_name.human : t.table - %td= "#{label} ##{t.item}" - %td= t.message diff --git a/app/views/rails_admin/main/_delete_notice.html.erb b/app/views/rails_admin/main/_delete_notice.html.erb new file mode 100644 index 0000000000..31136af908 --- /dev/null +++ b/app/views/rails_admin/main/_delete_notice.html.erb @@ -0,0 +1,35 @@ +<% object = delete_notice %> +
  • + + <%= @abstract_model.pretty_name %> + + <% wording = object.send(@model_config.object_label_method) %> + <% if show_action = action(:show, @abstract_model, object) %> + <%= link_to(wording, url_for(action: show_action.action_name, model_name: @abstract_model.to_param, id: object.id), class: 'pjax') %> + <% else %> + <%= wording %> + <% end %> + +
  • diff --git a/app/views/rails_admin/main/_delete_notice.html.haml b/app/views/rails_admin/main/_delete_notice.html.haml deleted file mode 100644 index da1facfba7..0000000000 --- a/app/views/rails_admin/main/_delete_notice.html.haml +++ /dev/null @@ -1,24 +0,0 @@ -- object = delete_notice - -%li{style: 'display:block; margin-top:10px'} - %span.label.label-default= @abstract_model.pretty_name - - wording = object.send(@model_config.object_label_method) - - if show_action = action(:show, @abstract_model, object) - = link_to(wording, url_for(action: show_action.action_name, model_name: @abstract_model.to_param, id: object.id), class: 'pjax') - - else - = wording - %ul - - @abstract_model.each_associated_children(object) do |association, children| - - humanized_association = @abstract_model.model.human_attribute_name association.name - - limit = children.count > 12 ? 10 : children.count - - children.first(limit).each do |child| - = content_tag :li, class: dom_class(child) do - - child_config = RailsAdmin.config(child) - = humanized_association.singularize - - wording = child.send(child_config.object_label_method) - - if child.id && (show_action = action(:show, child_config.abstract_model, child)) - = link_to(wording, url_for(action: show_action.action_name, model_name: child_config.abstract_model.to_param, id: child.id), class: 'pjax') - - else - = wording - - if children.count > limit - %li= t('admin.misc.more', count: children.count - limit, models_name: humanized_association) diff --git a/app/views/rails_admin/main/_form_action_text.html.erb b/app/views/rails_admin/main/_form_action_text.html.erb new file mode 100644 index 0000000000..1d6f9f3bf0 --- /dev/null +++ b/app/views/rails_admin/main/_form_action_text.html.erb @@ -0,0 +1,7 @@ +<% + js_data = { + csspath: field.css_location, + jspath: field.js_location + } +%> +<%= form.rich_text_area field.method_name, field.html_attributes.reverse_merge(data: { options: js_data.to_json }) %> diff --git a/app/views/rails_admin/main/_form_action_text.html.haml b/app/views/rails_admin/main/_form_action_text.html.haml deleted file mode 100644 index f3a9ac4ec7..0000000000 --- a/app/views/rails_admin/main/_form_action_text.html.haml +++ /dev/null @@ -1,7 +0,0 @@ -:ruby - js_data = { - csspath: field.css_location, - jspath: field.js_location - } - -= form.rich_text_area field.method_name, field.html_attributes.reverse_merge(data: { options: js_data.to_json }) diff --git a/app/views/rails_admin/main/_form_boolean.html.erb b/app/views/rails_admin/main/_form_boolean.html.erb new file mode 100644 index 0000000000..88a99babd3 --- /dev/null +++ b/app/views/rails_admin/main/_form_boolean.html.erb @@ -0,0 +1,16 @@ +<% if field.nullable? %> +
    + <% {'1': true, '0': false, '': nil}.each do |text, value| %> + + <% end %> +
    +<% else %> +
    + +
    +<% end %> diff --git a/app/views/rails_admin/main/_form_boolean.html.haml b/app/views/rails_admin/main/_form_boolean.html.haml deleted file mode 100644 index a258192d0f..0000000000 --- a/app/views/rails_admin/main/_form_boolean.html.haml +++ /dev/null @@ -1,10 +0,0 @@ -- if field.nullable? - .btn-group{'data-toggle': 'buttons'} - - {'1': true, '0': false, '': nil}.each do |text, value| - %label.btn.btn-default{class: [field.css_classes[value], ("active" if field.form_value == value)]} - = form.radio_button field.method_name, text, field.html_attributes.reverse_merge({ checked: field.form_value == value, required: field.required}) - = field.labels[value].html_safe -- else - .checkbox - %label{ style: 'display: block;' } - = form.send field.view_helper, field.method_name, field.html_attributes.reverse_merge({ value: field.form_value, checked: field.form_value.in?([true, '1']), required: field.required}) diff --git a/app/views/rails_admin/main/_form_ck_editor.html.haml b/app/views/rails_admin/main/_form_ck_editor.html.erb similarity index 57% rename from app/views/rails_admin/main/_form_ck_editor.html.haml rename to app/views/rails_admin/main/_form_ck_editor.html.erb index f5fa2a8d39..61fd226ff9 100644 --- a/app/views/rails_admin/main/_form_ck_editor.html.haml +++ b/app/views/rails_admin/main/_form_ck_editor.html.erb @@ -1,4 +1,4 @@ -:ruby +<% js_data = { jspath: field.location ? field.location : field.base_location + "ckeditor.js", base_location: field.base_location, @@ -6,5 +6,5 @@ customConfig: field.config_js ? field.config_js : field.base_location + "config.js" } } - -= form.text_area field.method_name, field.html_attributes.reverse_merge(data: { richtext: 'ckeditor', options: js_data.to_json }).reverse_merge({ value: field.form_value }) +%> +<%= form.text_area field.method_name, field.html_attributes.reverse_merge(data: { richtext: 'ckeditor', options: js_data.to_json }).reverse_merge({ value: field.form_value }) %> diff --git a/app/views/rails_admin/main/_form_code_mirror.html.erb b/app/views/rails_admin/main/_form_code_mirror.html.erb new file mode 100644 index 0000000000..e18cf862d8 --- /dev/null +++ b/app/views/rails_admin/main/_form_code_mirror.html.erb @@ -0,0 +1,9 @@ +<% + js_data = { + csspath: field.css_location, + jspath: field.js_location, + options: field.config, + locations: field.assets + } +%> +<%= form.text_area field.method_name, field.html_attributes.reverse_merge(data: { richtext: 'codemirror', options: js_data.to_json }).reverse_merge({ value: field.form_value }) %> diff --git a/app/views/rails_admin/main/_form_code_mirror.html.haml b/app/views/rails_admin/main/_form_code_mirror.html.haml deleted file mode 100644 index 8b07c8d16b..0000000000 --- a/app/views/rails_admin/main/_form_code_mirror.html.haml +++ /dev/null @@ -1,9 +0,0 @@ -:ruby - js_data = { - csspath: field.css_location, - jspath: field.js_location, - options: field.config, - locations: field.assets - } - -= form.text_area field.method_name, field.html_attributes.reverse_merge(data: { richtext: 'codemirror', options: js_data.to_json }).reverse_merge({ value: field.form_value }) diff --git a/app/views/rails_admin/main/_form_colorpicker.html.erb b/app/views/rails_admin/main/_form_colorpicker.html.erb new file mode 100644 index 0000000000..0dd24d4027 --- /dev/null +++ b/app/views/rails_admin/main/_form_colorpicker.html.erb @@ -0,0 +1 @@ +<%= form.send field.view_helper, field.method_name, field.html_attributes.reverse_merge({class: 'form-control', value: field.form_value}) %> diff --git a/app/views/rails_admin/main/_form_colorpicker.html.haml b/app/views/rails_admin/main/_form_colorpicker.html.haml deleted file mode 100644 index 99725e60bd..0000000000 --- a/app/views/rails_admin/main/_form_colorpicker.html.haml +++ /dev/null @@ -1 +0,0 @@ -= form.send field.view_helper, field.method_name, field.html_attributes.reverse_merge({class: 'form-control', value: field.form_value}) diff --git a/app/views/rails_admin/main/_form_datetime.html.erb b/app/views/rails_admin/main/_form_datetime.html.erb new file mode 100644 index 0000000000..f482fede31 --- /dev/null +++ b/app/views/rails_admin/main/_form_datetime.html.erb @@ -0,0 +1,9 @@ +
    +
    + <%= form.hidden_field(field.method_name, id: nil, value: field.form_value) %> + <%= form.text_field field.method_name, field.html_attributes.reverse_merge({class: 'form-control', data: {datetimepicker: true, options: field.datepicker_options.to_json}, name: nil, value: nil}) %> + <%= form.label(field.method_name, class: 'input-group-addon') do %> + + <% end %> +
    +
    diff --git a/app/views/rails_admin/main/_form_datetime.html.haml b/app/views/rails_admin/main/_form_datetime.html.haml deleted file mode 100644 index 091688d1f2..0000000000 --- a/app/views/rails_admin/main/_form_datetime.html.haml +++ /dev/null @@ -1,6 +0,0 @@ -.form-inline - .input-group - = form.hidden_field(field.method_name, id: nil, value: field.form_value) - = form.text_field field.method_name, field.html_attributes.reverse_merge({class: 'form-control', data: {datetimepicker: true, options: field.datepicker_options.to_json}, name: nil, value: nil}) - = form.label(field.method_name, class: 'input-group-addon') do - %i.fa.fa-fw.fa-calendar diff --git a/app/views/rails_admin/main/_form_enumeration.html.erb b/app/views/rails_admin/main/_form_enumeration.html.erb new file mode 100644 index 0000000000..09ad016a20 --- /dev/null +++ b/app/views/rails_admin/main/_form_enumeration.html.erb @@ -0,0 +1,21 @@ +<% unless field.multiple? %> + <%= form.select field.method_name, field.enum, { include_blank: true }.reverse_merge({ selected: field.form_value }), field.html_attributes.reverse_merge({ data: { enumeration: true }, placeholder: t('admin.misc.search') }) %> +<% else %> + <% + js_data = { + xhr: false, + sortable: false, + cacheAll: true, + regional: { + add: t("admin.misc.add_new"), + chooseAll: t("admin.misc.chose_all"), + clearAll: t("admin.misc.clear_all"), + down: t("admin.misc.down"), + remove: t("admin.misc.remove"), + search: t("admin.misc.search"), + up: t("admin.misc.up") + } + } + %> + <%= form.select field.method_name, field.enum, { selected: field.form_value, object: form.object }, field.html_attributes.reverse_merge({data: { filteringmultiselect: true, options: js_data.to_json }, multiple: true}) %> +<% end %> diff --git a/app/views/rails_admin/main/_form_enumeration.html.haml b/app/views/rails_admin/main/_form_enumeration.html.haml deleted file mode 100644 index 3ebe30f4e2..0000000000 --- a/app/views/rails_admin/main/_form_enumeration.html.haml +++ /dev/null @@ -1,19 +0,0 @@ -- unless field.multiple? - = form.select field.method_name, field.enum, { include_blank: true }.reverse_merge({ selected: field.form_value }), field.html_attributes.reverse_merge({ data: { enumeration: true }, placeholder: t('admin.misc.search') }) -- else - :ruby - js_data = { - xhr: false, - sortable: false, - cacheAll: true, - regional: { - add: t("admin.misc.add_new"), - chooseAll: t("admin.misc.chose_all"), - clearAll: t("admin.misc.clear_all"), - down: t("admin.misc.down"), - remove: t("admin.misc.remove"), - search: t("admin.misc.search"), - up: t("admin.misc.up") - } - } - = form.select field.method_name, field.enum, { selected: field.form_value, object: form.object }, field.html_attributes.reverse_merge({data: { filteringmultiselect: true, options: js_data.to_json }, multiple: true}) diff --git a/app/views/rails_admin/main/_form_field.html.erb b/app/views/rails_admin/main/_form_field.html.erb new file mode 100644 index 0000000000..8115e24d8a --- /dev/null +++ b/app/views/rails_admin/main/_form_field.html.erb @@ -0,0 +1 @@ +<%= form.send field.view_helper, field.method_name, field.html_attributes.reverse_merge({ value: field.form_value, class: 'form-control', required: field.required}) %> diff --git a/app/views/rails_admin/main/_form_field.html.haml b/app/views/rails_admin/main/_form_field.html.haml deleted file mode 100644 index 205da46a82..0000000000 --- a/app/views/rails_admin/main/_form_field.html.haml +++ /dev/null @@ -1 +0,0 @@ -= form.send field.view_helper, field.method_name, field.html_attributes.reverse_merge({ value: field.form_value, class: 'form-control', required: field.required}) diff --git a/app/views/rails_admin/main/_form_file_upload.html.erb b/app/views/rails_admin/main/_form_file_upload.html.erb new file mode 100644 index 0000000000..a29b729882 --- /dev/null +++ b/app/views/rails_admin/main/_form_file_upload.html.erb @@ -0,0 +1,17 @@ +<% file = field.value %> +<% if field.cache_method %> + <%= form.hidden_field(field.cache_method, value: field.cache_value) %> +<% end %> +
    + <% if value = field.pretty_value %> + <%= value %> + <% end %> + <%= form.file_field(field.name, field.html_attributes.reverse_merge({ data: { fileupload: true }})) %> +
    +<% if field.optional? && field.errors.blank? && file && field.delete_method %> + + + <%= I18n.t('admin.actions.delete.link', object_label: field.label) %> + + <%= form.check_box(field.delete_method, style: 'display:none;') %> +<% end %> diff --git a/app/views/rails_admin/main/_form_file_upload.html.haml b/app/views/rails_admin/main/_form_file_upload.html.haml deleted file mode 100644 index 2a33721629..0000000000 --- a/app/views/rails_admin/main/_form_file_upload.html.haml +++ /dev/null @@ -1,17 +0,0 @@ -- file = field.value - -- if field.cache_method - = form.hidden_field(field.cache_method, value: field.cache_value) - -.toggle{style: ('display:none;' if file && field.delete_method && form.object.send(field.delete_method) == '1')} - - if value = field.pretty_value - = value - - = form.file_field(field.name, field.html_attributes.reverse_merge({ data: { fileupload: true }})) - -- if field.optional? && field.errors.blank? && file && field.delete_method - %a.btn.btn-info.btn-remove-image{href: '#', :'data-toggle' => 'button', role: 'button'} - %i.fas.fa-trash - = I18n.t('admin.actions.delete.link', object_label: field.label) - - = form.check_box(field.delete_method, style: 'display:none;') diff --git a/app/views/rails_admin/main/_form_filtering_multiselect.html.haml b/app/views/rails_admin/main/_form_filtering_multiselect.html.erb similarity index 67% rename from app/views/rails_admin/main/_form_filtering_multiselect.html.haml rename to app/views/rails_admin/main/_form_filtering_multiselect.html.erb index 2be172aaaf..090ada252c 100644 --- a/app/views/rails_admin/main/_form_filtering_multiselect.html.haml +++ b/app/views/rails_admin/main/_form_filtering_multiselect.html.erb @@ -1,4 +1,4 @@ -:ruby +<% related_id = params[:associations] && params[:associations][field.name.to_s] config = field.associated_model_config source_abstract_model = RailsAdmin.config(form.object.class).abstract_model @@ -38,12 +38,12 @@ up: t('admin.misc.up') } } - -%input{name: form.dom_name(field), type: "hidden", value: ""} - -- selected_ids = (hdv = field.form_default_value).nil? ? selected_ids : hdv -= form.select field.method_name, collection, { selected: selected_ids, object: form.object }, field.html_attributes.reverse_merge({data: { filteringmultiselect: true, options: js_data.to_json }, multiple: true}) -- if authorized?(:new, config.abstract_model) && field.inline_add - - path_hash = { model_name: config.abstract_model.to_param, modal: true } - - path_hash.merge!({ associations: { field.inverse_of => (form.object.persisted? ? form.object.id : 'new') } }) if field.inverse_of - = link_to " ".html_safe + wording_for(:link, :new, config.abstract_model), '#', data: { link: new_path(path_hash) }, class: "create btn btn-info", style: 'margin-left:10px' +%> + +<% selected_ids = (hdv = field.form_default_value).nil? ? selected_ids : hdv %> +<%= form.select field.method_name, collection, { selected: selected_ids, object: form.object }, field.html_attributes.reverse_merge({data: { filteringmultiselect: true, options: js_data.to_json }, multiple: true}) %> +<% if authorized?(:new, config.abstract_model) && field.inline_add %> + <% path_hash = { model_name: config.abstract_model.to_param, modal: true } %> + <% path_hash.merge!({ associations: { field.inverse_of => (form.object.persisted? ? form.object.id : 'new') } }) if field.inverse_of %> + <%= link_to " ".html_safe + wording_for(:link, :new, config.abstract_model), '#', data: { link: new_path(path_hash) }, class: "create btn btn-info", style: 'margin-left:10px' %> +<% end %> diff --git a/app/views/rails_admin/main/_form_filtering_select.html.haml b/app/views/rails_admin/main/_form_filtering_select.html.erb similarity index 53% rename from app/views/rails_admin/main/_form_filtering_select.html.haml rename to app/views/rails_admin/main/_form_filtering_select.html.erb index 7cf053af49..41506a09b9 100644 --- a/app/views/rails_admin/main/_form_filtering_select.html.haml +++ b/app/views/rails_admin/main/_form_filtering_select.html.erb @@ -1,4 +1,4 @@ -:ruby +<% config = field.associated_model_config related_id = params[:associations] && params[:associations][field.name.to_s] source_abstract_model = RailsAdmin.config(form.object.class).abstract_model @@ -24,14 +24,15 @@ xhr: xhr, remote_source: index_path(config.abstract_model.to_param, source_object_id: form.object.id, source_abstract_model: source_abstract_model.to_param, associated_collection: field.name, current_action: current_action, compact: true) } - -- selected_id = (hdv = field.form_default_value).nil? ? selected_id : hdv -= form.select field.method_name, collection, { selected: selected_id, include_blank: true }, field.html_attributes.reverse_merge({ data: { filteringselect: true, options: js_data.to_json }, placeholder: t('admin.misc.search'), style: "float: left" }) - -- if authorized?(:new, config.abstract_model) && field.inline_add - - path_hash = { model_name: config.abstract_model.to_param, modal: true } - - path_hash.merge!({ associations: { field.inverse_of => (form.object.persisted? ? form.object.id : 'new') } }) if field.inverse_of - = link_to " ".html_safe + wording_for(:link, :new, config.abstract_model), '#', data: { link: new_path(path_hash) }, class: "btn btn-info create", style: 'margin-left:10px' - -- if edit_url.present? && field.inline_edit - = link_to " ".html_safe + wording_for(:link, :edit, config.abstract_model), '#', data: { link: edit_url }, class: "btn btn-info update #{field.value.nil? && 'disabled'}", style: 'margin-left:10px' +%> + +<% selected_id = (hdv = field.form_default_value).nil? ? selected_id : hdv %> +<%= form.select field.method_name, collection, { selected: selected_id, include_blank: true }, field.html_attributes.reverse_merge({ data: { filteringselect: true, options: js_data.to_json }, placeholder: t('admin.misc.search'), style: "float: left" }) %> +<% if authorized?(:new, config.abstract_model) && field.inline_add %> + <% path_hash = { model_name: config.abstract_model.to_param, modal: true } %> + <% path_hash.merge!({ associations: { field.inverse_of => (form.object.persisted? ? form.object.id : 'new') } }) if field.inverse_of %> + <%= link_to " ".html_safe + wording_for(:link, :new, config.abstract_model), '#', data: { link: new_path(path_hash) }, class: "btn btn-info create", style: 'margin-left:10px' %> +<% end %> +<% if edit_url.present? && field.inline_edit %> + <%= link_to " ".html_safe + wording_for(:link, :edit, config.abstract_model), '#', data: { link: edit_url }, class: "btn btn-info update #{field.value.nil? && 'disabled'}", style: 'margin-left:10px' %> +<% end %> diff --git a/app/views/rails_admin/main/_form_froala.html.erb b/app/views/rails_admin/main/_form_froala.html.erb new file mode 100644 index 0000000000..4107677637 --- /dev/null +++ b/app/views/rails_admin/main/_form_froala.html.erb @@ -0,0 +1,8 @@ +<% + js_data = { + csspath: field.css_location, + jspath: field.js_location, + config_options: field.config_options.to_json + } +%> +<%= form.text_area field.method_name, field.html_attributes.reverse_merge(data: { richtext: 'froala-wysiwyg', options: js_data.to_json }).reverse_merge({ value: field.form_value }) %> diff --git a/app/views/rails_admin/main/_form_froala.html.haml b/app/views/rails_admin/main/_form_froala.html.haml deleted file mode 100644 index 7ad8570c0d..0000000000 --- a/app/views/rails_admin/main/_form_froala.html.haml +++ /dev/null @@ -1,8 +0,0 @@ -:ruby - js_data = { - csspath: field.css_location, - jspath: field.js_location, - config_options: field.config_options.to_json - } - -= form.text_area field.method_name, field.html_attributes.reverse_merge(data: { richtext: 'froala-wysiwyg', options: js_data.to_json }).reverse_merge({ value: field.form_value }) diff --git a/app/views/rails_admin/main/_form_multiple_file_upload.html.erb b/app/views/rails_admin/main/_form_multiple_file_upload.html.erb new file mode 100644 index 0000000000..183018e2da --- /dev/null +++ b/app/views/rails_admin/main/_form_multiple_file_upload.html.erb @@ -0,0 +1,20 @@ +<% field.attachments.each_with_index do |attachment, i| %> +
    + <%= attachment.pretty_value %> + <% if field.delete_method || field.keep_method %> + + + <%= I18n.t('admin.form.delete_file', field_label: field.label, number: i + 1) %> + + <% if field.keep_method %> + <%= form.check_box(field.keep_method, {multiple:true, checked: true, style: 'display:none;'}, attachment.keep_value, nil) %> + <% elsif field.delete_method %> + <%= form.check_box(field.delete_method, {multiple:true, style: 'display:none;'}, attachment.delete_value, nil) %> + <% end %> + <% end %> +
    +<% end %> +<%= form.file_field(field.name, field.html_attributes.reverse_merge({ data: { :"multiple-fileupload" => true }, multiple: true })) %> +<% if field.cache_method %> + <%= form.hidden_field(field.cache_method) %> +<% end %> diff --git a/app/views/rails_admin/main/_form_multiple_file_upload.html.haml b/app/views/rails_admin/main/_form_multiple_file_upload.html.haml deleted file mode 100644 index 869712fc1b..0000000000 --- a/app/views/rails_admin/main/_form_multiple_file_upload.html.haml +++ /dev/null @@ -1,16 +0,0 @@ -- field.attachments.each_with_index do |attachment, i| - .toggle{class: field.reorderable? ? 'sortables' : ''} - = attachment.pretty_value - - if field.delete_method || field.keep_method - %a.btn.btn-info.btn-remove-image{href: '#', :'data-toggle' => 'button', role: 'button'} - %i.fas.fa-trash - = I18n.t('admin.form.delete_file', field_label: field.label, number: i + 1) - - if field.keep_method - = form.check_box(field.keep_method, {multiple:true, checked: true, style: 'display:none;'}, attachment.keep_value, nil) - - elsif field.delete_method - = form.check_box(field.delete_method, {multiple:true, style: 'display:none;'}, attachment.delete_value, nil) - -= form.file_field(field.name, field.html_attributes.reverse_merge({ data: { :"multiple-fileupload" => true }, multiple: true })) - -- if field.cache_method - = form.hidden_field(field.cache_method) diff --git a/app/views/rails_admin/main/_form_nested_many.html.erb b/app/views/rails_admin/main/_form_nested_many.html.erb new file mode 100644 index 0000000000..3a77eea570 --- /dev/null +++ b/app/views/rails_admin/main/_form_nested_many.html.erb @@ -0,0 +1,21 @@ +
    +
    + + + + <% unless field.nested_form[:update_only] || !field.inline_add %> + <%= form.link_to_add " #{wording_for(:link, :new, field.associated_model_config.abstract_model)}".html_safe, field.name, { class: 'btn btn-info' } %> + <% end %> +
    + <%= form.errors_for(field) %> + <%= form.help_for(field) %> + +
    +
    + <%= form.fields_for field.name do |nested_form| %> + <% if field.nested_form[:allow_destroy] || nested_form.options[:child_index] == "new_#{field.name}" %> + <%= nested_form.link_to_remove ''.html_safe %> + <% end %> + <%= nested_form.generate({action: :nested, model_config: field.associated_model_config, nested_in: field }) %> + <% end %> +
    diff --git a/app/views/rails_admin/main/_form_nested_many.html.haml b/app/views/rails_admin/main/_form_nested_many.html.haml deleted file mode 100644 index eb98345710..0000000000 --- a/app/views/rails_admin/main/_form_nested_many.html.haml +++ /dev/null @@ -1,15 +0,0 @@ -.controls.col-sm-10{data: { nestedmany: true }} - .btn-group - %a.btn.btn-info.toggler{:'data-toggle' => "button", :'data-target' => "#{form.jquery_namespace(field)} > .tab-content, #{form.jquery_namespace(field)} > .controls > .nav", class: (field.active? ? 'active' : '')} - %i.fas - - unless field.nested_form[:update_only] || !field.inline_add - = form.link_to_add " #{wording_for(:link, :new, field.associated_model_config.abstract_model)}".html_safe, field.name, { class: 'btn btn-info' } - = form.errors_for(field) - = form.help_for(field) - %ul.nav.nav-tabs - -.tab-content - = form.fields_for field.name do |nested_form| - - if field.nested_form[:allow_destroy] || nested_form.options[:child_index] == "new_#{field.name}" - = nested_form.link_to_remove ''.html_safe - = nested_form.generate({action: :nested, model_config: field.associated_model_config, nested_in: field }) diff --git a/app/views/rails_admin/main/_form_nested_one.html.erb b/app/views/rails_admin/main/_form_nested_one.html.erb new file mode 100644 index 0000000000..fdaa9dbbb7 --- /dev/null +++ b/app/views/rails_admin/main/_form_nested_one.html.erb @@ -0,0 +1,21 @@ +
    + +
    + + + + <% unless field.nested_form[:update_only] || !field.inline_add %> + <%= form.link_to_add " #{wording_for(:link, :new, field.associated_model_config.abstract_model)}".html_safe, field.name, { class: 'btn btn-info', :'data-add-label' => " #{wording_for(:link, :new, field.associated_model_config.abstract_model)}".gsub("\n", "") } %> + <% end %> +
    + <%= form.errors_for(field) %> + <%= form.help_for(field) %> +
    +
    + <%= form.fields_for field.name do |nested_form| %> + <% if field.nested_form[:allow_destroy] %> + <%= nested_form.link_to_remove ''.html_safe %> + <% end %> + <%= nested_form.generate({action: :nested, model_config: field.associated_model_config, nested_in: field }) %> + <% end %> +
    diff --git a/app/views/rails_admin/main/_form_nested_one.html.haml b/app/views/rails_admin/main/_form_nested_one.html.haml deleted file mode 100644 index 08f840445f..0000000000 --- a/app/views/rails_admin/main/_form_nested_one.html.haml +++ /dev/null @@ -1,17 +0,0 @@ -.controls.col-sm-10{data: { nestedone: true }} - %ul.nav{style: 'margin-bottom:0px; display:none'} - .btn-group - %a.btn.btn-info.toggler{:'data-toggle' => "button", :'data-target' => "#{form.jquery_namespace(field)} > .tab-content", class: (field.active? ? 'active' : '') } - %i.fas - - unless field.nested_form[:update_only] || !field.inline_add - = form.link_to_add " #{wording_for(:link, :new, field.associated_model_config.abstract_model)}".html_safe, - field.name, - { class: 'btn btn-info', :'data-add-label' => " #{wording_for(:link, :new, field.associated_model_config.abstract_model)}".gsub("\n", "") } - = form.errors_for(field) - = form.help_for(field) - -.tab-content - = form.fields_for field.name do |nested_form| - - if field.nested_form[:allow_destroy] - = nested_form.link_to_remove ''.html_safe - = nested_form.generate({action: :nested, model_config: field.associated_model_config, nested_in: field }) diff --git a/app/views/rails_admin/main/_form_polymorphic_association.html.haml b/app/views/rails_admin/main/_form_polymorphic_association.html.erb similarity index 58% rename from app/views/rails_admin/main/_form_polymorphic_association.html.haml rename to app/views/rails_admin/main/_form_polymorphic_association.html.erb index 8a712c46f4..92bf937e04 100644 --- a/app/views/rails_admin/main/_form_polymorphic_association.html.haml +++ b/app/views/rails_admin/main/_form_polymorphic_association.html.erb @@ -1,4 +1,4 @@ -:ruby +<% type_collection = field.polymorphic_type_collection type_column = field.association.foreign_type.to_s selected_type = field.bindings[:object].send(type_column) @@ -17,9 +17,11 @@ float_left: false }) end - -.form-inline - - js_data.each do |model, value| - %div{id: "#{model}-js-options", data: { options: value.to_json } } - = form.select type_column, type_collection, {include_blank: true, selected: selected_type}, class: "form-control", id: column_type_dom_id, data: { polymorphic: true, urls: field.polymorphic_type_urls.to_json }, style: "float: left; margin-right: 10px;" - = form.select field.method_name, collection, {include_blank: true, selected: selected.try(:id)}, class: "form-control", data: { filteringselect: true, options: js_data[selected_type.try(:downcase)] || default_options }, placeholder: 'Search' +%> +
    + <% js_data.each do |model, value| %> +
    + <% end %> + <%= form.select type_column, type_collection, {include_blank: true, selected: selected_type}, class: "form-control", id: column_type_dom_id, data: { polymorphic: true, urls: field.polymorphic_type_urls.to_json }, style: "float: left; margin-right: 10px;" %> + <%= form.select field.method_name, collection, {include_blank: true, selected: selected.try(:id)}, class: "form-control", data: { filteringselect: true, options: js_data[selected_type.try(:downcase)] || default_options }, placeholder: 'Search' %> +
    diff --git a/app/views/rails_admin/main/_form_simple_mde.haml b/app/views/rails_admin/main/_form_simple_mde.haml deleted file mode 100644 index 99cd82d98c..0000000000 --- a/app/views/rails_admin/main/_form_simple_mde.haml +++ /dev/null @@ -1,8 +0,0 @@ -:ruby - js_data = { - js_location: field.js_location, - css_location: field.css_location, - instance_config: field.instance_config - } - -= form.text_area field.method_name, field.html_attributes.reverse_merge(data: { richtext: 'simplemde', options: js_data.to_json }).reverse_merge({ value: field.form_value }) diff --git a/app/views/rails_admin/main/_form_simple_mde.html.erb b/app/views/rails_admin/main/_form_simple_mde.html.erb new file mode 100644 index 0000000000..d86d5ee5ad --- /dev/null +++ b/app/views/rails_admin/main/_form_simple_mde.html.erb @@ -0,0 +1,8 @@ +<% + js_data = { + js_location: field.js_location, + css_location: field.css_location, + instance_config: field.instance_config + } +%> +<%= form.text_area field.method_name, field.html_attributes.reverse_merge(data: { richtext: 'simplemde', options: js_data.to_json }).reverse_merge({ value: field.form_value }) %> diff --git a/app/views/rails_admin/main/_form_text.html.erb b/app/views/rails_admin/main/_form_text.html.erb new file mode 100644 index 0000000000..e478dc06ba --- /dev/null +++ b/app/views/rails_admin/main/_form_text.html.erb @@ -0,0 +1 @@ +<%= form.text_area field.method_name, field.html_attributes.reverse_merge(data: { richtext: false, options: {}.to_json }).reverse_merge({ value: field.form_value, class: 'form-control', required: field.required }) %> diff --git a/app/views/rails_admin/main/_form_text.html.haml b/app/views/rails_admin/main/_form_text.html.haml deleted file mode 100644 index fafc9b9b50..0000000000 --- a/app/views/rails_admin/main/_form_text.html.haml +++ /dev/null @@ -1 +0,0 @@ -= form.text_area field.method_name, field.html_attributes.reverse_merge(data: { richtext: false, options: {}.to_json }).reverse_merge({ value: field.form_value, class: 'form-control', required: field.required }) diff --git a/app/views/rails_admin/main/_form_wysihtml5.html.erb b/app/views/rails_admin/main/_form_wysihtml5.html.erb new file mode 100644 index 0000000000..d933be3181 --- /dev/null +++ b/app/views/rails_admin/main/_form_wysihtml5.html.erb @@ -0,0 +1,8 @@ +<% + js_data = { + csspath: field.css_location, + jspath: field.js_location, + config_options: field.config_options.to_json + } +%> +<%= form.text_area field.method_name, field.html_attributes.reverse_merge(data: { richtext: 'bootstrap-wysihtml5', options: js_data.to_json }).reverse_merge({ value: field.form_value }) %> diff --git a/app/views/rails_admin/main/_form_wysihtml5.html.haml b/app/views/rails_admin/main/_form_wysihtml5.html.haml deleted file mode 100644 index ae362f0f66..0000000000 --- a/app/views/rails_admin/main/_form_wysihtml5.html.haml +++ /dev/null @@ -1,8 +0,0 @@ -:ruby - js_data = { - csspath: field.css_location, - jspath: field.js_location, - config_options: field.config_options.to_json - } - -= form.text_area field.method_name, field.html_attributes.reverse_merge(data: { richtext: 'bootstrap-wysihtml5', options: js_data.to_json }).reverse_merge({ value: field.form_value }) diff --git a/app/views/rails_admin/main/_submit_buttons.html.erb b/app/views/rails_admin/main/_submit_buttons.html.erb new file mode 100644 index 0000000000..60e8317d95 --- /dev/null +++ b/app/views/rails_admin/main/_submit_buttons.html.erb @@ -0,0 +1,25 @@ +
    +
    + + + + <% if authorized? :new, @abstract_model %> + + <% end %> + <% if authorized? :edit, @abstract_model %> + + <% end %> + + +
    +
    diff --git a/app/views/rails_admin/main/_submit_buttons.html.haml b/app/views/rails_admin/main/_submit_buttons.html.haml deleted file mode 100644 index a4a4acf366..0000000000 --- a/app/views/rails_admin/main/_submit_buttons.html.haml +++ /dev/null @@ -1,16 +0,0 @@ -.form-group.form-actions - .col-sm-offset-2.col-sm-10 - %input{type: :hidden, name: 'return_to', value: (params[:return_to].presence || request.referer)} - %button.btn.btn-primary{type: "submit", name: "_save", :'data-disable-with' => t("admin.form.save")} - %i.fas.fa-check - = t("admin.form.save") - %span.extra_buttons - - if authorized? :new, @abstract_model - %button.btn.btn-info{type: "submit", name: "_add_another", :'data-disable-with' => t("admin.form.save_and_add_another")} - = t("admin.form.save_and_add_another") - - if authorized? :edit, @abstract_model - %button.btn.btn-info{type: "submit", name: "_add_edit", :'data-disable-with' => t("admin.form.save_and_edit")} - = t("admin.form.save_and_edit") - %button.btn.btn-default{type: "submit", name: "_continue", :'data-disable-with' => t("admin.form.cancel"), :formnovalidate => true} - %i.fas.fa-times - = t("admin.form.cancel") diff --git a/app/views/rails_admin/main/bulk_delete.html.erb b/app/views/rails_admin/main/bulk_delete.html.erb new file mode 100644 index 0000000000..24ba8e9aff --- /dev/null +++ b/app/views/rails_admin/main/bulk_delete.html.erb @@ -0,0 +1,19 @@ +

    + <%= I18n.t('admin.form.bulk_delete') %> +

    + +<%= form_tag bulk_delete_path(model_name: @abstract_model.to_param, bulk_ids: @objects.map(&:id)), method: :delete do %> +
    + + + +
    +<% end %> diff --git a/app/views/rails_admin/main/bulk_delete.html.haml b/app/views/rails_admin/main/bulk_delete.html.haml deleted file mode 100644 index 11028a3a00..0000000000 --- a/app/views/rails_admin/main/bulk_delete.html.haml +++ /dev/null @@ -1,11 +0,0 @@ -%h4= I18n.t('admin.form.bulk_delete') -%ul= render partial: "delete_notice", collection: @objects -= form_tag bulk_delete_path(model_name: @abstract_model.to_param, bulk_ids: @objects.map(&:id)), method: :delete do - .form-actions - %input{type: :hidden, name: 'return_to', value: (params[:return_to].presence || request.referer)} - %button.btn.btn-danger{type: "submit", :'data-disable-with' => t("admin.form.confirmation")} - %i.fas.fa-check - = t("admin.form.confirmation") - %button.btn{type: "submit", name: "_continue", :'data-disable-with' => t("admin.form.cancel")} - %i.fas.fa-times - = t("admin.form.cancel") diff --git a/app/views/rails_admin/main/dashboard.html.erb b/app/views/rails_admin/main/dashboard.html.erb new file mode 100644 index 0000000000..b223897028 --- /dev/null +++ b/app/views/rails_admin/main/dashboard.html.erb @@ -0,0 +1,64 @@ +<% if @abstract_models %> + + + + + + + + + + + <% @abstract_models.each do |abstract_model| %> + <% if authorized? :index, abstract_model %> + <% index_path = index_path(model_name: abstract_model.to_param) %> + <% row_class = "#{cycle("odd", "even")}#{" link" if index_path} #{abstract_model.param_key}_links" %> + + <% last_created = @most_recent_created[abstract_model.model.name] %> + <% active = last_created.try(:today?) %> + + + + + + <% end %> + <% end %> + +
    + <%= t "admin.table_headers.model_name" %> + + <%= t "admin.table_headers.last_created" %> + + <%= t "admin.table_headers.records" %> +
    + + <%= link_to abstract_model.config.label_plural, index_path, class: 'pjax' %> + + + <% if last_created %> + <%= t "admin.misc.time_ago", time: time_ago_in_words(last_created), default: "#{time_ago_in_words(last_created)} #{t("admin.misc.ago")}" %> + <% end %> + + <% count = @count[abstract_model.model.name] %> + <% percent = count > 0 ? (@max <= 1 ? count : ((Math.log(count+1) * 100.0) / Math.log(@max+1)).to_i) : -1 %> +
    +
    + <%= @count[abstract_model.model.name] %> +
    +
    +
    +<% end %> +<% if @auditing_adapter && authorized?(:history_index) %> +
    +
    +

    + <%= t("admin.actions.history_index.menu") %> +

    + <%= render partial: 'rails_admin/main/dashboard_history' %> +
    +
    +<% end %> diff --git a/app/views/rails_admin/main/dashboard.html.haml b/app/views/rails_admin/main/dashboard.html.haml deleted file mode 100644 index 1e976cf71e..0000000000 --- a/app/views/rails_admin/main/dashboard.html.haml +++ /dev/null @@ -1,34 +0,0 @@ -- if @abstract_models - %table.table.table-condensed.table-striped.table-hover - %thead - %tr - %th.shrink.model-name= t "admin.table_headers.model_name" - %th.shrink.last-created= t "admin.table_headers.last_created" - %th.records= t "admin.table_headers.records" - %th.shrink.controls - %tbody - - @abstract_models.each do |abstract_model| - - if authorized? :index, abstract_model - - index_path = index_path(model_name: abstract_model.to_param) - - row_class = "#{cycle("odd", "even")}#{" link" if index_path} #{abstract_model.param_key}_links" - %tr{class: row_class, :"data-link" => index_path} - - last_created = @most_recent_created[abstract_model.model.name] - - active = last_created.try(:today?) - %td - %span.show= link_to abstract_model.config.label_plural, index_path, class: 'pjax' - %td - - if last_created - = t "admin.misc.time_ago", time: time_ago_in_words(last_created), default: "#{time_ago_in_words(last_created)} #{t("admin.misc.ago")}" - %td - - count = @count[abstract_model.model.name] - - percent = count > 0 ? (@max <= 1 ? count : ((Math.log(count+1) * 100.0) / Math.log(@max+1)).to_i) : -1 - .progress{style: "margin-bottom:0px", class: "progress-#{get_indicator(percent)} #{active && 'active progress-striped'}" } - .progress-bar.animate-width-to{:class => "progress-bar-#{get_indicator(percent)}", :'data-animate-length' => ([1.0, percent].max.to_i * 20), :'data-animate-width-to' => "#{[2.0, percent].max.to_i}%", style: "width:2%"} - = @count[abstract_model.model.name] - %td.links - %ul.inline.list-inline= menu_for :collection, abstract_model, nil, true -- if @auditing_adapter && authorized?(:history_index) - #block-tables.block - .content - %h2= t("admin.actions.history_index.menu") - = render partial: 'rails_admin/main/dashboard_history' diff --git a/app/views/rails_admin/main/delete.html.erb b/app/views/rails_admin/main/delete.html.erb new file mode 100644 index 0000000000..6d1eb44342 --- /dev/null +++ b/app/views/rails_admin/main/delete.html.erb @@ -0,0 +1,21 @@ +

    + <%= t("admin.form.are_you_sure_you_want_to_delete_the_object", model_name: @abstract_model.pretty_name.downcase) %> + “<%= @model_config.with(object: @object).object_label %>” + <%= t("admin.form.all_of_the_following_related_items_will_be_deleted") %> +

    + +<%= form_for(@object, url: delete_path(model_name: @abstract_model.to_param, id: @object.id), html: {method: "delete"}) do %> + +
    + + +
    +<% end %> diff --git a/app/views/rails_admin/main/delete.html.haml b/app/views/rails_admin/main/delete.html.haml deleted file mode 100644 index dae756597c..0000000000 --- a/app/views/rails_admin/main/delete.html.haml +++ /dev/null @@ -1,18 +0,0 @@ -%h4 - = t("admin.form.are_you_sure_you_want_to_delete_the_object", model_name: @abstract_model.pretty_name.downcase) - “ - %strong>= @model_config.with(object: @object).object_label - \” - %span> - = t("admin.form.all_of_the_following_related_items_will_be_deleted") - -%ul= render partial: "delete_notice", object: @object -= form_for(@object, url: delete_path(model_name: @abstract_model.to_param, id: @object.id), html: {method: "delete"}) do - %input{type: :hidden, name: 'return_to', value: (params[:return_to].presence || request.referer)} - .form-actions - %button.btn.btn-danger{type: "submit", :'data-disable-with' => t("admin.form.confirmation")} - %i.fas.fa-check - = t("admin.form.confirmation") - %button.btn{type: "submit", name: "_continue", :'data-disable-with' => t("admin.form.cancel")} - %i.fas.fa-times - = t("admin.form.cancel") diff --git a/app/views/rails_admin/main/edit.html.erb b/app/views/rails_admin/main/edit.html.erb new file mode 100644 index 0000000000..9fd974bb30 --- /dev/null +++ b/app/views/rails_admin/main/edit.html.erb @@ -0,0 +1,3 @@ +<%= rails_admin_form_for @object, url: edit_path(@abstract_model, @object.id), as: @abstract_model.param_key, html: { method: "put", multipart: true, class: "form-horizontal denser", data: { title: @page_name } } do |form| %> + <%= form.generate action: :update %> +<% end %> diff --git a/app/views/rails_admin/main/edit.html.haml b/app/views/rails_admin/main/edit.html.haml deleted file mode 100644 index 33fe61581b..0000000000 --- a/app/views/rails_admin/main/edit.html.haml +++ /dev/null @@ -1,2 +0,0 @@ -= rails_admin_form_for @object, url: edit_path(@abstract_model, @object.id), as: @abstract_model.param_key, html: { method: "put", multipart: true, class: "form-horizontal denser", data: { title: @page_name } } do |form| - = form.generate action: :update diff --git a/app/views/rails_admin/main/export.html.erb b/app/views/rails_admin/main/export.html.erb new file mode 100644 index 0000000000..44a304e37e --- /dev/null +++ b/app/views/rails_admin/main/export.html.erb @@ -0,0 +1,146 @@ +<% params = request.params.except(:action, :controller, :utf8, :page, :per_page, :format, :authenticity_token) %> +<% visible_fields = @model_config.export.with(view: self, object: @abstract_model.model.new, controller: self.controller).visible_fields %> +<%= form_tag export_path(params.merge(all: true)), method: 'post', class: 'form-horizontal' do %> + / +
    + + + <%= t('admin.export.select') %> + +
    +
    +
    + +
    +
    +
    +
    +
    +
    + + <%= t('admin.export.fields_from', name: @model_config.label_plural.downcase) %> + +
    +
    +
    + <% visible_fields.select{ |f| !f.association? || f.association.polymorphic? }.each do |field| %> + <% list = field.virtual? ? 'methods' : 'only' %> +
    + <% if field.association? && field.association.polymorphic? %> + + <% polymorphic_type_column_name = @abstract_model.properties.detect {|p| field.association.foreign_type == p.name }.name %> + + <% else %> + + <% end %> +
    + <% end %> +
    +
    +
    +
    + <% visible_fields.select{ |f| f.association? && !f.association.polymorphic? }.each do |field| %> + <% fields = field.associated_model_config.export.with(controller: self.controller, view: self, object: (associated_model = field.associated_model_config.abstract_model.model).new).visible_fields.select{ |f| !f.association? } %> +
    +
    +
    + + <%= t('admin.export.fields_from_associated', name: field.label.downcase) %> + +
    +
    +
    + <% fields.each do |associated_model_field| %> + <% list = associated_model_field.virtual? ? 'methods' : 'only' %> +
    + +
    + <% end %> +
    +
    +
    +
    + <% end %> +
    +
    + + + <%= t('admin.export.options_for', name: 'csv') %> + +
    + <% guessed_encoding = @abstract_model.encoding %> + +
    + <% # from http://books.google.com/support/partner/bin/answer.py?answer=30990 : %> + <%= select_tag 'csv_options[encoding_to]', options_for_select(Encoding.name_list.sort), include_blank: true, placeholder: t('admin.misc.search'), :'data-enumeration' => true %> +

    + <%= t('admin.export.csv.encoding_to_help', name: guessed_encoding) %> +

    +
    +
    +
    + +
    +
    + +
    +

    + <%= t('admin.export.csv.skip_header_help') %> +

    +
    +
    +
    + +
    + <%= select_tag 'csv_options[generator][col_sep]', options_for_select({ '' => t('admin.export.csv.default_col_sep'), " ','" => ',', " ';'" => ';', '' => "'\t'" }), placeholder: t('admin.misc.search'), :'data-enumeration' => true %> +

    + <%= t('admin.export.csv.col_sep_help', value: t('admin.export.csv.default_col_sep')) %> +

    +
    +
    +
    +
    +
    + + + + + +
    +
    +<% end %> diff --git a/app/views/rails_admin/main/export.html.haml b/app/views/rails_admin/main/export.html.haml deleted file mode 100644 index 7594273d2f..0000000000 --- a/app/views/rails_admin/main/export.html.haml +++ /dev/null @@ -1,92 +0,0 @@ -- params = request.params.except(:action, :controller, :utf8, :page, :per_page, :format, :authenticity_token) -- visible_fields = @model_config.export.with(view: self, object: @abstract_model.model.new, controller: self.controller).visible_fields - -= form_tag export_path(params.merge(all: true)), method: 'post', class: 'form-horizontal' do - - %input{name: "send_data", type: "hidden", value: "true"}/ - %fieldset{id: 'fields_to_export'} - %legend - %i.fas.fa-chevron-down - = t('admin.export.select') - .form-group.control-group - .col-sm-12 - .checkbox - %label{for: 'check_all'} - = check_box_tag 'all', 'all', true, { id: 'check_all' } - %b= t('admin.export.select_all_fields') - .form-group.control-group - .col-sm-12 - .well.well-sm.reverse-selection{rel: 'tooltip', title: t('admin.export.click_to_reverse_selection'), style: 'margin: 0; cursor: pointer;'} - %b= t('admin.export.fields_from', name: @model_config.label_plural.downcase) - .controls - .row - - visible_fields.select{ |f| !f.association? || f.association.polymorphic? }.each do |field| - - list = field.virtual? ? 'methods' : 'only' - .checkbox.col-sm-3 - - if field.association? && field.association.polymorphic? - %label{for: "schema_#{list}_#{field.method_name}"} - = check_box_tag "schema[#{list}][]", field.method_name, true, { id: "schema_#{list}_#{field.method_name}" } - = field.label + " [id]" - - polymorphic_type_column_name = @abstract_model.properties.detect {|p| field.association.foreign_type == p.name }.name - %label{for: "schema_#{list}_#{polymorphic_type_column_name}"} - = check_box_tag "schema[#{list}][]", polymorphic_type_column_name, true, { id: "schema_#{list}_#{polymorphic_type_column_name}" } - = field.label + " [type]" - - else - %label{for: "schema_#{list}_#{field.name}"} - = check_box_tag "schema[#{list}][]", field.name, true, { id: "schema_#{list}_#{field.name}" } - = field.label - - - visible_fields.select{ |f| f.association? && !f.association.polymorphic? }.each do |field| - - fields = field.associated_model_config.export.with(controller: self.controller, view: self, object: (associated_model = field.associated_model_config.abstract_model.model).new).visible_fields.select{ |f| !f.association? } - .form-group.control-group - .col-sm-12 - .well.well-sm.reverse-selection{rel: 'tooltip', title: t('admin.export.click_to_reverse_selection'), style: 'margin: 0; cursor: pointer;'} - %b= t('admin.export.fields_from_associated', name: field.label.downcase) - .controls - .row - - fields.each do |associated_model_field| - - list = associated_model_field.virtual? ? 'methods' : 'only' - .checkbox.col-sm-3 - %label{for: "schema_include_#{field.name}_#{list}_#{associated_model_field.name}"} - = check_box_tag "schema[include][#{field.name}][#{list}][]", associated_model_field.name, true, { id: "schema_include_#{field.name}_#{list}_#{associated_model_field.name}" } - = associated_model_field.label - - %fieldset - %legend - %i.fas.fa-chevron-down - = t('admin.export.options_for', name: 'csv') - .form-group.control-group - - guessed_encoding = @abstract_model.encoding - %label.col-sm-2.control-label{for: "csv_options_encoding_to"}= t('admin.export.csv.encoding_to') - .col-sm-10.controls - -# from http://books.google.com/support/partner/bin/answer.py?answer=30990 : - = select_tag 'csv_options[encoding_to]', options_for_select(Encoding.name_list.sort), include_blank: true, placeholder: t('admin.misc.search'), :'data-enumeration' => true - %p.help-block= t('admin.export.csv.encoding_to_help', name: guessed_encoding) - - .form-group.control-group - %label.col-sm-2.control-label{for: "csv_options_skip_header"}= t('admin.export.csv.skip_header') - .col-sm-10.controls - .checkbox - %label{style: 'display: block;' } - = check_box_tag 'csv_options[skip_header]', 'true' - %p.help-block= t('admin.export.csv.skip_header_help') - - .form-group.control-group - %label.col-sm-2.control-label{for: "csv_options_generator_col_sep"}= t('admin.export.csv.col_sep') - .col-sm-10.controls - = select_tag 'csv_options[generator][col_sep]', options_for_select({ '' => t('admin.export.csv.default_col_sep'), " ','" => ',', " ';'" => ';', '' => "'\t'" }), placeholder: t('admin.misc.search'), :'data-enumeration' => true - %p.help-block= t('admin.export.csv.col_sep_help', value: t('admin.export.csv.default_col_sep')) - - .form-group.form-actions - .col-sm-offset-2.col-sm-10 - %input{type: :hidden, name: 'return_to', value: (params[:return_to].presence || request.referer)} - %button.btn.btn-primary{type: "submit", name: 'csv'} - %i.fas.fa-check - = t("admin.export.confirmation", name: 'csv') - %button.btn.btn-info{type: "submit", name: 'json'} - = t("admin.export.confirmation", name: 'json') - %button.btn.btn-info{type: "submit", name: 'xml'} - = t("admin.export.confirmation", name: 'xml') - %button.btn{type: "submit", name: "_continue"} - %i.fas.fa-times - = t("admin.form.cancel") diff --git a/app/views/rails_admin/main/history.html.erb b/app/views/rails_admin/main/history.html.erb new file mode 100644 index 0000000000..f932ac0991 --- /dev/null +++ b/app/views/rails_admin/main/history.html.erb @@ -0,0 +1,78 @@ +<% params = request.params.except(:action, :controller, :model_name) %> +<% query = params[:query] %> +<% filter = params[:filter] %> +<% sort = params[:sort] %> +<% sort_reverse = params[:sort_reverse] %> +<% path_method = params[:id] ? "history_show_path" : "history_index_path" %> +<%= form_tag("", method: "get", class: "search pjax-form form-inline") do %> +
    +
    + " type="search" value="<%= query %>"> + + + +
    +
    +<% end %> + + + + <% columns = [] %> + <% columns << { property_name: "created_at", css_class: "created_at",link_text: t('admin.table_headers.created_at') } %> + <% columns << { property_name: "username", css_class: "username", link_text: t('admin.table_headers.username') } %> + <% columns << { property_name: "item", css_class: "item", link_text: t('admin.table_headers.item') } if @general %> + <% columns << { property_name: "message", css_class: "message", link_text: t('admin.table_headers.message') } %> + <% columns.each do |column| %> + <% property_name = column[:property_name] %> + <% selected = (sort == property_name) %> + <% sort_direction = (sort_reverse ? "headerSortUp" : "headerSortDown" if selected) %> + <% sort_location = send(path_method, params.except("sort_reverse").merge(model_name: @abstract_model.to_param, sort: property_name).merge(selected && sort_reverse != "true" ? {sort_reverse: "true"} : {})) %> + + <% end %> + + + + <% @history.each_with_index do |object, index| %> + + <% unless object.created_at.nil? %> + + <% end %> + + <% if @general %> + <% if o = @abstract_model.get(object.item) %> + <% label = o.send(@abstract_model.config.object_label_method) %> + <% if show_action = action(:show, @abstract_model, o) %> + + <% else %> + + <% end %> + <% else %> + + <% end %> + <% end %> + + + <% end %> + +
    + <%= column[:link_text] %> +
    + <%= l(object.created_at, format: :long, default: l(object.created_at, format: :long)) %> + + <%= object.username %> + + <%= link_to(label, url_for(action: show_action.action_name, model_name: @abstract_model.to_param, id: o.id), class: 'pjax') %> + + <%= label %> + + <%= "#{@abstract_model.config.label} ##{object.item}" %> + + <%= object.message.in?(['delete', 'new']) ? t("admin.actions.#{object.message}.done").capitalize : object.message %> +
    +<% unless params[:all] || !@history.respond_to?(:current_page) %> + <%= paginate(@history, theme: 'ra-twitter-bootstrap', remote: true) %> + <%= link_to(t("admin.misc.show_all"), send(path_method, params.merge(all: true)), class: "show-all btn pjax") unless (tc = @history.total_count) <= @history.size || tc > 100 %> +<% end %> diff --git a/app/views/rails_admin/main/history.html.haml b/app/views/rails_admin/main/history.html.haml deleted file mode 100644 index 35a838ef42..0000000000 --- a/app/views/rails_admin/main/history.html.haml +++ /dev/null @@ -1,51 +0,0 @@ -- params = request.params.except(:action, :controller, :model_name) -- query = params[:query] -- filter = params[:filter] -- sort = params[:sort] -- sort_reverse = params[:sort_reverse] -- path_method = params[:id] ? "history_show_path" : "history_index_path" - -= form_tag("", method: "get", class: "search pjax-form form-inline") do - .well - .input-group - %input.form-control.input-small{name: "query", type: "search", value: query, placeholder: "#{t("admin.misc.filter")}", class: 'input-small'} - %span.input-group-btn - %button.btn.btn-primary{type: 'submit', :'data-disable-with' => ' '.html_safe + t('admin.misc.refresh')} - %i.fas.fa-sync - = t("admin.misc.refresh") -%table#history.table.table-condensed.table-striped.table-hover - %thead - %tr - - columns = [] - - columns << { property_name: "created_at", css_class: "created_at",link_text: t('admin.table_headers.created_at') } - - columns << { property_name: "username", css_class: "username", link_text: t('admin.table_headers.username') } - - columns << { property_name: "item", css_class: "item", link_text: t('admin.table_headers.item') } if @general - - columns << { property_name: "message", css_class: "message", link_text: t('admin.table_headers.message') } - - - columns.each do |column| - - property_name = column[:property_name] - - selected = (sort == property_name) - - sort_direction = (sort_reverse ? "headerSortUp" : "headerSortDown" if selected) - - sort_location = send(path_method, params.except("sort_reverse").merge(model_name: @abstract_model.to_param, sort: property_name).merge(selected && sort_reverse != "true" ? {sort_reverse: "true"} : {})) - %th{class: "header pjax #{column[:css_class]} #{sort_direction if selected}", :'data-href' => sort_location}= column[:link_text] - %tbody - - @history.each_with_index do |object, index| - %tr - - unless object.created_at.nil? - %td= l(object.created_at, format: :long, default: l(object.created_at, format: :long)) - %td= object.username - - if @general - - if o = @abstract_model.get(object.item) - - label = o.send(@abstract_model.config.object_label_method) - - if show_action = action(:show, @abstract_model, o) - %td= link_to(label, url_for(action: show_action.action_name, model_name: @abstract_model.to_param, id: o.id), class: 'pjax') - - else - %td= label - - else - %td= "#{@abstract_model.config.label} ##{object.item}" - %td= object.message.in?(['delete', 'new']) ? t("admin.actions.#{object.message}.done").capitalize : object.message - -- unless params[:all] || !@history.respond_to?(:current_page) - = paginate(@history, theme: 'ra-twitter-bootstrap', remote: true) - = link_to(t("admin.misc.show_all"), send(path_method, params.merge(all: true)), class: "show-all btn pjax") unless (tc = @history.total_count) <= @history.size || tc > 100 - diff --git a/app/views/rails_admin/main/index.html.erb b/app/views/rails_admin/main/index.html.erb new file mode 100644 index 0000000000..a1a4a387b8 --- /dev/null +++ b/app/views/rails_admin/main/index.html.erb @@ -0,0 +1,232 @@ +<% + query = params[:query] + params = request.params.except(:authenticity_token, :action, :controller, :utf8, :bulk_export, :_pjax) + params.delete(:query) if params[:query].blank? + params.delete(:sort_reverse) unless params[:sort_reverse] == 'true' + sort_reverse = params[:sort_reverse] + sort = params[:sort] + params.delete(:sort) if params[:sort] == @model_config.list.sort_by.to_s + export_action = RailsAdmin::Config::Actions.find(:export, { controller: self.controller, abstract_model: @abstract_model }) + export_action = nil unless export_action && authorized?(export_action.authorization_key, @abstract_model) + description = RailsAdmin.config(@abstract_model.model_name).description + properties = @model_config.list.with(controller: self.controller, view: self, object: @abstract_model.model.new).visible_fields + checkboxes = @model_config.list.checkboxes? + # columns paginate + unless (frozen_columns = @model_config.list.sidescroll_frozen_columns) + sets = get_column_sets(properties) + properties = sets[params[:set].to_i] || [] + other_left = ((params[:set].to_i - 1) >= 0) && sets[params[:set].to_i - 1].present? + other_right = sets[params[:set].to_i + 1].present? + end + table_table_header_count = begin + count = checkboxes ? 1 : 0 + count = count + properties.count + end +%> + +<% content_for :contextual_tabs do %> + <% if checkboxes %> + <%= bulk_menu %> + <% end %> + <% if filterable_fields.present? %> + + <% end %> +<% end %> + + + +
    + <%= form_tag(index_path(params.except(*%w[page f query])), method: :get, class: "pjax-form form-inline") do %> +
    + +
    +
    + " type="search" value="<%= query %>"> + + + + +
    + <% if export_action %> + + <%= link_to wording_for(:link, export_action), export_path(params.except('set').except('page')), class: 'btn btn-info' %> + + <% end %> +
    + <% end %> + <% unless @model_config.list.scopes.empty? %> + + <% end %> + <%= form_tag bulk_action_path(model_name: @abstract_model.to_param), method: :post, id: "bulk_form", class: ["form", frozen_columns ? 'ra-sidescroll' : nil], data: (frozen_columns ? {ra_sidescroll: frozen_columns} : {}) do %> + <%= hidden_field_tag :bulk_action %> + <% if description.present? %> +

    + + <%= description %> + +

    + <% end %> + + + + <% if checkboxes %> + + <% end %> + <% if frozen_columns %> + + <% end %> + <% if other_left %> + + <% end %> + <% properties.each do |property| %> + <% selected = (sort == property.name.to_s) %> + <% if property.sortable %> + <% sort_location = index_path params.except('sort_reverse').except('page').merge(sort: property.name).merge(selected && sort_reverse != "true" ? {sort_reverse: "true"} : {}) %> + <% sort_direction = (sort_reverse == 'true' ? "headerSortUp" : "headerSortDown" if selected) %> + <% end %> + + <% end %> + <% if other_right %> + + <% end %> + <% unless frozen_columns %> + + <% end %> + + + + <% @objects.each do |object| %> + + <% if checkboxes %> + + <% end %> + <% if frozen_columns %> + + <% end %> + <% if @other_left_link ||= other_left && index_path(params.except('set').merge(params[:set].to_i != 1 ? {set: (params[:set].to_i - 1)} : {})) %> + + <% end %> + <% properties.map{ |property| property.bind(:object, object) }.each do |property| %> + <% value = property.pretty_value %> + + <% end %> + <% if @other_right_link ||= other_right && index_path(params.merge(set: (params[:set].to_i + 1))) %> + + <% end %> + <% unless frozen_columns %> + + <% end %> + + <% end %> + <% if @objects.empty? %> + + + + <% end %> + +
    + + + <%= "..." %> + " data-href="<%= property.sortable && sort_location %>" rel="tooltip" title="<%= property.hint %>"> + <%= property.label %> + + <%= "..." %> +
    + <%= check_box_tag "bulk_ids[]", object.id, false %> + + <%= link_to "...", @other_left_link, class: 'pjax' %> + + <%= value %> + + <%= link_to "...", @other_right_link, class: 'pjax' %> +
    + <%= I18n.t('admin.actions.index.no_records') %> +
    + <% if @model_config.list.limited_pagination %> +
    +
    + <%= paginate(@objects, theme: 'ra-twitter-bootstrap/without_count', total_pages: Float::INFINITY, remote: true) %> +
    +
    + <% elsif @objects.respond_to?(:total_count) %> + <% total_count = @objects.total_count.to_i %> +
    +
    + <%= paginate(@objects, theme: 'ra-twitter-bootstrap', remote: true) %> +
    +
    +
    +
    + <%= link_to(t("admin.misc.show_all"), index_path(params.merge(all: true)), class: "show-all btn btn-default clearfix pjax") unless total_count > 100 || total_count <= @objects.to_a.size %> +
    +
    +
    + <%= "#{total_count} #{@model_config.pluralize(total_count).downcase}" %> +
    + <% else %> +
    + <%= "#{@objects.size} #{@model_config.pluralize(@objects.size).downcase}" %> +
    + <% end %> + <% end %> +
    diff --git a/app/views/rails_admin/main/index.html.haml b/app/views/rails_admin/main/index.html.haml deleted file mode 100644 index d63086c995..0000000000 --- a/app/views/rails_admin/main/index.html.haml +++ /dev/null @@ -1,133 +0,0 @@ -:ruby - query = params[:query] - params = request.params.except(:authenticity_token, :action, :controller, :utf8, :bulk_export, :_pjax) - params.delete(:query) if params[:query].blank? - params.delete(:sort_reverse) unless params[:sort_reverse] == 'true' - sort_reverse = params[:sort_reverse] - sort = params[:sort] - params.delete(:sort) if params[:sort] == @model_config.list.sort_by.to_s - export_action = RailsAdmin::Config::Actions.find(:export, { controller: self.controller, abstract_model: @abstract_model }) - export_action = nil unless export_action && authorized?(export_action.authorization_key, @abstract_model) - description = RailsAdmin.config(@abstract_model.model_name).description - properties = @model_config.list.with(controller: self.controller, view: self, object: @abstract_model.model.new).visible_fields - checkboxes = @model_config.list.checkboxes? - # columns paginate - unless (frozen_columns = @model_config.list.sidescroll_frozen_columns) - sets = get_column_sets(properties) - properties = sets[params[:set].to_i] || [] - other_left = ((params[:set].to_i - 1) >= 0) && sets[params[:set].to_i - 1].present? - other_right = sets[params[:set].to_i + 1].present? - end - table_table_header_count = begin - count = checkboxes ? 1 : 0 - count = count + properties.count - end - -- content_for :contextual_tabs do - - if checkboxes - = bulk_menu - - if filterable_fields.present? - %li.dropdown{style: 'float:right'} - %a.dropdown-toggle{href: '#', :'data-toggle' => "dropdown"} - = t('admin.misc.add_filter') - %b.caret - %ul.dropdown-menu#filters{style: 'left:auto; right:0;'} - - filterable_fields.each do |field| - - field_options = case field.type - - when :enum - - options_for_select(field.with(object: @abstract_model.model.new).enum) - - else - - '' - %li - %a{href: '#', :"data-field-label" => field.label, :"data-field-name" => field.name, :"data-field-operator" => field.default_filter_operator, :"data-field-options" => field_options.html_safe, :"data-field-required" => field.required.to_s, :"data-field-type" => field.type, :"data-field-value" => "", :"data-field-datetimepicker-format" => field.try(:momentjs_format)}= field.label - -%style - - properties.select{ |p| p.column_width.present? }.each do |property| - = "#list th.#{property.css_class} { width: #{property.column_width}px; min-width: #{property.column_width}px; }" - = "#list td.#{property.css_class} { max-width: #{property.column_width}px; }" - -#list - = form_tag(index_path(params.except(*%w[page f query])), method: :get, class: "pjax-form form-inline") do - .well - %span#filters_box{data: {options: ordered_filter_options.to_json}} - %hr.filters_box{style: "display:#{ordered_filters.empty? ? 'none' : 'block'}"} - .input-group - %input.form-control.input-small{name: "query", type: "search", value: query, placeholder: t("admin.misc.filter")} - %span.input-group-btn - %button.btn.btn-primary{type: 'submit', :'data-disable-with' => ' '.html_safe + t('admin.misc.refresh')} - %i.fas.fa-sync - = t('admin.misc.refresh') - %button#remove_filter.btn.btn-info{title: t('admin.misc.reset_filters')} - %i.fas.fa-times - - if export_action - %span{style: 'float:right'}= link_to wording_for(:link, export_action), export_path(params.except('set').except('page')), class: 'btn btn-info' - - - unless @model_config.list.scopes.empty? - %ul.nav.nav-tabs#scope_selector - - @model_config.list.scopes.each_with_index do |scope, index| - - scope = '_all' if scope.nil? - %li{class: "#{'active' if scope.to_s == params[:scope] || (params[:scope].blank? && index == 0)}"} - %a{href: index_path(params.merge(scope: scope, page: nil)), class: 'pjax'}= I18n.t("admin.scopes.#{@abstract_model.to_param}.#{scope}", default: I18n.t("admin.scopes.#{scope}", default: scope.to_s.titleize)) - - = form_tag bulk_action_path(model_name: @abstract_model.to_param), method: :post, id: "bulk_form", class: ["form", frozen_columns ? 'ra-sidescroll' : nil], data: (frozen_columns ? {ra_sidescroll: frozen_columns} : {}) do - = hidden_field_tag :bulk_action - - if description.present? - %p - %strong= description - - %table.table.table-condensed.table-striped.table-hover - %thead - %tr - - if checkboxes - %th.shrink - %input.toggle{type: "checkbox"} - - if frozen_columns - %th.last.shrink - - if other_left - %th.other.left.shrink= "..." - - properties.each do |property| - - selected = (sort == property.name.to_s) - - if property.sortable - - sort_location = index_path params.except('sort_reverse').except('page').merge(sort: property.name).merge(selected && sort_reverse != "true" ? {sort_reverse: "true"} : {}) - - sort_direction = (sort_reverse == 'true' ? "headerSortUp" : "headerSortDown" if selected) - %th{class: "#{property.sortable && "header pjax" || nil} #{sort_direction if property.sortable && sort_direction} #{property.css_class} #{property.type_css_class}", :'data-href' => (property.sortable && sort_location), rel: "tooltip", title: "#{property.hint}"}= property.label - - if other_right - %th.other.right.shrink= "..." - - unless frozen_columns - %th.last.shrink - %tbody - - @objects.each do |object| - %tr{class: "#{@abstract_model.param_key}_row #{@model_config.list.with(object: object).row_css_class}"} - - if checkboxes - %td= check_box_tag "bulk_ids[]", object.id, false - - if frozen_columns - %td.last.links - %ul.inline.list-inline= menu_for :member, @abstract_model, object, true - - if @other_left_link ||= other_left && index_path(params.except('set').merge(params[:set].to_i != 1 ? {set: (params[:set].to_i - 1)} : {})) - %td.other.left= link_to "...", @other_left_link, class: 'pjax' - - properties.map{ |property| property.bind(:object, object) }.each do |property| - - value = property.pretty_value - %td{class: "#{property.css_class} #{property.type_css_class}", title: strip_tags(value.to_s)}= value - - if @other_right_link ||= other_right && index_path(params.merge(set: (params[:set].to_i + 1))) - %td.other.right= link_to "...", @other_right_link, class: 'pjax' - - unless frozen_columns - %td.last.links - %ul.inline.list-inline= menu_for :member, @abstract_model, object, true - - if @objects.empty? - %tr{class: "empty_row"} - %td{colspan: table_table_header_count} - = I18n.t('admin.actions.index.no_records') - - if @model_config.list.limited_pagination - .row - .col-md-6= paginate(@objects, theme: 'ra-twitter-bootstrap/without_count', total_pages: Float::INFINITY, remote: true) - - - elsif @objects.respond_to?(:total_count) - - total_count = @objects.total_count.to_i - .row - .col-md-6= paginate(@objects, theme: 'ra-twitter-bootstrap', remote: true) - .row - .col-md-6= link_to(t("admin.misc.show_all"), index_path(params.merge(all: true)), class: "show-all btn btn-default clearfix pjax") unless total_count > 100 || total_count <= @objects.to_a.size - .clearfix.total-count= "#{total_count} #{@model_config.pluralize(total_count).downcase}" - - - else - .clearfix.total-count= "#{@objects.size} #{@model_config.pluralize(@objects.size).downcase}" diff --git a/app/views/rails_admin/main/new.html.erb b/app/views/rails_admin/main/new.html.erb new file mode 100644 index 0000000000..a7386af981 --- /dev/null +++ b/app/views/rails_admin/main/new.html.erb @@ -0,0 +1,3 @@ +<%= rails_admin_form_for @object, url: new_path(model_name: @abstract_model.to_param), as: @abstract_model.param_key, html: { multipart: true, class: "form-horizontal denser", data: { title: @page_name } } do |form| %> + <%= form.generate action: :create %> +<% end %> diff --git a/app/views/rails_admin/main/new.html.haml b/app/views/rails_admin/main/new.html.haml deleted file mode 100644 index dee547032d..0000000000 --- a/app/views/rails_admin/main/new.html.haml +++ /dev/null @@ -1,2 +0,0 @@ -= rails_admin_form_for @object, url: new_path(model_name: @abstract_model.to_param), as: @abstract_model.param_key, html: { multipart: true, class: "form-horizontal denser", data: { title: @page_name } } do |form| - = form.generate action: :create diff --git a/app/views/rails_admin/main/show.html.erb b/app/views/rails_admin/main/show.html.erb new file mode 100644 index 0000000000..eb904e4ff6 --- /dev/null +++ b/app/views/rails_admin/main/show.html.erb @@ -0,0 +1,28 @@ +<% @model_config.show.with(object: @object, view: self, controller: self.controller).visible_groups.each do |fieldset| %> + <% unless (fields = fieldset.with(object: @object, view: self, controller: self.controller).visible_fields).empty? %> + <% unless (fields = fields.reject{ |f| RailsAdmin::config.compact_show_view && (f.formatted_value.nil? || f.formatted_value == '') }).empty? %> +
    +

    + <%= fieldset.label %> +

    + <% if fieldset.help %> +

    + <%= fieldset.help %> +

    + <% end %> +
    + <% fields.each_with_index do |field, index| %> +
    + + <%= field.label %> + +
    +
    + <%= field.pretty_value %> +
    + <% end %> +
    +
    + <% end %> + <% end %> +<% end %> diff --git a/app/views/rails_admin/main/show.html.haml b/app/views/rails_admin/main/show.html.haml deleted file mode 100644 index f86de0e3fe..0000000000 --- a/app/views/rails_admin/main/show.html.haml +++ /dev/null @@ -1,15 +0,0 @@ -- @model_config.show.with(object: @object, view: self, controller: self.controller).visible_groups.each do |fieldset| - - unless (fields = fieldset.with(object: @object, view: self, controller: self.controller).visible_fields).empty? - - unless (fields = fields.reject{ |f| RailsAdmin::config.compact_show_view && (f.formatted_value.nil? || f.formatted_value == '') }).empty? - .fieldset - %h4 - = fieldset.label - - if fieldset.help - %p= fieldset.help - %dl - - fields.each_with_index do |field, index| - %dt - %span.label.label-info{class: "#{field.type_css_class} #{field.css_class}"} - = field.label - %dd.well - = field.pretty_value diff --git a/config/initializers/haml.rb b/config/initializers/haml.rb deleted file mode 100644 index 26884716c9..0000000000 --- a/config/initializers/haml.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'haml' -require 'haml/template' -if Haml::Options.buffer_option_keys.include?(:ugly) - Haml::Template.options[:ugly] = true -end diff --git a/gemfiles/rails_6.0.gemfile b/gemfiles/rails_6.0.gemfile index 3bad56eedd..463bdfaab9 100644 --- a/gemfiles/rails_6.0.gemfile +++ b/gemfiles/rails_6.0.gemfile @@ -4,7 +4,6 @@ source "https://rubygems.org" gem "appraisal", ">= 2.0" gem "rails", "~> 6.0.0" -gem "haml" gem "devise", "~> 4.7" gem "webrick", "~> 1.7" gem "sassc-rails", "~> 2.1" diff --git a/gemfiles/rails_6.1.gemfile b/gemfiles/rails_6.1.gemfile index 6a4d438690..6951c9290e 100644 --- a/gemfiles/rails_6.1.gemfile +++ b/gemfiles/rails_6.1.gemfile @@ -4,7 +4,6 @@ source "https://rubygems.org" gem "appraisal", ">= 2.0" gem "rails", "~> 6.1.0" -gem "haml" gem "devise", "~> 4.7" gem "webrick", "~> 1.7" gem "sassc-rails", "~> 2.1" diff --git a/gemfiles/rails_7.0.gemfile b/gemfiles/rails_7.0.gemfile index e29e02dc1f..bed1f5b064 100644 --- a/gemfiles/rails_7.0.gemfile +++ b/gemfiles/rails_7.0.gemfile @@ -4,7 +4,6 @@ source "https://rubygems.org" gem "appraisal", ">= 2.0" gem "rails", "~> 7.0.0.alpha2" -gem "haml" gem "devise", "~> 4.7", github: "strobilomyces/devise", branch: "patch-1" gem "webrick", "~> 1.7" gem "sassc-rails", "~> 2.1" diff --git a/rails_admin.gemspec b/rails_admin.gemspec index 696eacf733..cd5e08f9a9 100644 --- a/rails_admin.gemspec +++ b/rails_admin.gemspec @@ -6,7 +6,6 @@ require 'rails_admin/version' Gem::Specification.new do |spec| # If you add a dependency, please maintain alphabetical order spec.add_dependency 'builder', '~> 3.1' - spec.add_dependency 'haml', '>= 4.0', '< 6' spec.add_dependency 'jquery-rails', ['>= 3.0', '< 5'] spec.add_dependency 'jquery-ui-rails', ['>= 6.0', '< 7'] spec.add_dependency 'kaminari', '>= 0.14', '< 2.0' diff --git a/spec/dummy_app/app/views/players/show.html.erb b/spec/dummy_app/app/views/players/show.html.erb new file mode 100644 index 0000000000..8264030c8f --- /dev/null +++ b/spec/dummy_app/app/views/players/show.html.erb @@ -0,0 +1 @@ +

    <%= @player.name %>

    diff --git a/spec/dummy_app/app/views/players/show.html.haml b/spec/dummy_app/app/views/players/show.html.haml deleted file mode 100644 index 99dc395d57..0000000000 --- a/spec/dummy_app/app/views/players/show.html.haml +++ /dev/null @@ -1 +0,0 @@ -%h1=@player.name