diff --git a/.prettierignore b/.prettierignore index 2de6ff9137..df350adef7 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,7 +1,7 @@ -app/assets/stylesheets/rails_admin/aristo -app/assets/stylesheets/rails_admin/themes/cerulean coverage spec/dummy_app/public spec/dummy_app/tmp spec/support/jquery.simulate.drag-sortable.js +src/rails_admin/styles/aristo +src/rails_admin/styles/themes/cerulean vendor diff --git a/app/assets/javascripts/rails_admin/custom/ui.js b/app/assets/javascripts/rails_admin/custom/ui.js deleted file mode 100644 index 9d6e5c7cb2..0000000000 --- a/app/assets/javascripts/rails_admin/custom/ui.js +++ /dev/null @@ -1 +0,0 @@ -// override this file in your application to add custom behaviour diff --git a/app/assets/javascripts/rails_admin/jquery-ui.js b/app/assets/javascripts/rails_admin/jquery-ui.js deleted file mode 100644 index 2f31d7f9d9..0000000000 --- a/app/assets/javascripts/rails_admin/jquery-ui.js +++ /dev/null @@ -1,3 +0,0 @@ -//= require 'jquery-ui/effect' -//= require 'jquery-ui/widgets/sortable' -//= require 'jquery-ui/widgets/autocomplete' diff --git a/app/assets/javascripts/rails_admin/ra.i18n.js b/app/assets/javascripts/rails_admin/ra.i18n.js deleted file mode 100644 index 527cdbadd9..0000000000 --- a/app/assets/javascripts/rails_admin/ra.i18n.js +++ /dev/null @@ -1,26 +0,0 @@ -(function () { - var Locale; - - this.RailsAdmin || (this.RailsAdmin = {}); - - this.RailsAdmin.I18n = Locale = (function () { - function Locale() {} - - Locale.init = function (locale, translations) { - this.locale = locale; - this.translations = translations; - moment.locale(this.locale); - if (typeof this.translations === "string") { - this.translations = JSON.parse(this.translations); - } - }; - - Locale.t = function (key) { - var humanize; - humanize = key.charAt(0).toUpperCase() + key.replace(/_/g, " ").slice(1); - return this.translations[key] || humanize; - }; - - return Locale; - })(); -}.call(this)); diff --git a/app/assets/stylesheets/rails_admin/aristo/images/bg_fallback.png b/app/assets/stylesheets/rails_admin/aristo/images/bg_fallback.png deleted file mode 100644 index 155ebd7e93..0000000000 Binary files a/app/assets/stylesheets/rails_admin/aristo/images/bg_fallback.png and /dev/null differ diff --git a/app/assets/stylesheets/rails_admin/aristo/images/icon_sprite.png b/app/assets/stylesheets/rails_admin/aristo/images/icon_sprite.png deleted file mode 100644 index 0b376bf66c..0000000000 Binary files a/app/assets/stylesheets/rails_admin/aristo/images/icon_sprite.png and /dev/null differ diff --git a/app/assets/stylesheets/rails_admin/aristo/images/progress_bar.gif b/app/assets/stylesheets/rails_admin/aristo/images/progress_bar.gif deleted file mode 100644 index c3d43fa40b..0000000000 Binary files a/app/assets/stylesheets/rails_admin/aristo/images/progress_bar.gif and /dev/null differ diff --git a/app/assets/stylesheets/rails_admin/aristo/images/slider_handles.png b/app/assets/stylesheets/rails_admin/aristo/images/slider_handles.png deleted file mode 100644 index 872eaac305..0000000000 Binary files a/app/assets/stylesheets/rails_admin/aristo/images/slider_handles.png and /dev/null differ diff --git a/app/assets/stylesheets/rails_admin/aristo/images/ui-icons_222222_256x240.png b/app/assets/stylesheets/rails_admin/aristo/images/ui-icons_222222_256x240.png deleted file mode 100644 index 664494d838..0000000000 Binary files a/app/assets/stylesheets/rails_admin/aristo/images/ui-icons_222222_256x240.png and /dev/null differ diff --git a/app/assets/stylesheets/rails_admin/aristo/images/ui-icons_454545_256x240.png b/app/assets/stylesheets/rails_admin/aristo/images/ui-icons_454545_256x240.png deleted file mode 100644 index 8cccf85760..0000000000 Binary files a/app/assets/stylesheets/rails_admin/aristo/images/ui-icons_454545_256x240.png and /dev/null differ diff --git a/app/assets/stylesheets/rails_admin/custom/mixins.scss b/app/assets/stylesheets/rails_admin/custom/mixins.scss deleted file mode 100644 index 70921182fa..0000000000 --- a/app/assets/stylesheets/rails_admin/custom/mixins.scss +++ /dev/null @@ -1,11 +0,0 @@ -/* - Customize Sass mixins from Twitter-Bootstrap/RailsAdmin theme or add new ones for your own use. - Copy this file to your app/assets/rails_admin/custom/mixins.scss, leave this one untouched - Don't require it in your application.rb - - Available mixins to use/override: - - https://github.com/twbs/bootstrap-sass/tree/master/assets/stylesheets/bootstrap/mixins - https://github.com/railsadminteam/rails_admin/blob/master/app/assets/stylesheets/rails_admin/base/mixins.scss - Plus the ones from your theme. -*/ diff --git a/app/assets/stylesheets/rails_admin/custom/theming.scss b/app/assets/stylesheets/rails_admin/custom/theming.scss deleted file mode 100644 index 72ca4ecae0..0000000000 --- a/app/assets/stylesheets/rails_admin/custom/theming.scss +++ /dev/null @@ -1,13 +0,0 @@ -/* - Customize RailsAdmin theme here. - Copy this file to your app/assets/stylesheets/rails_admin/custom/theming.scss, leave this one untouched - Don't require it in your application.rb - - Look at the markup in RailsAdmin and go there to get inspiration from: - - http://getbootstrap.com - - Test me: (actual color should be the one defined in variables.scss if you did) - - body { background-color: $link-color; } -*/ diff --git a/app/assets/stylesheets/rails_admin/custom/variables.scss b/app/assets/stylesheets/rails_admin/custom/variables.scss deleted file mode 100644 index 4e19047169..0000000000 --- a/app/assets/stylesheets/rails_admin/custom/variables.scss +++ /dev/null @@ -1,15 +0,0 @@ -/* - Customize Sass variables from Twitter-Bootstrap/RailsAdmin theme or add new ones for your own use. - Copy this file to your app/assets/rails_admin/custom/variables.scss, leave this one untouched - Don't require it in your application.rb - - Available variables to use/override: - - https://github.com/twbs/bootstrap-sass/blob/master/assets/stylesheets/bootstrap/_variables.scss - https://github.com/railsadminteam/rails_admin/blob/master/app/assets/stylesheets/rails_admin/base/variables.scss - Plus the ones from your themes. - - Test me: pink links - - $link-color: #F0F; -*/ diff --git a/spec/dummy_app/app/javascript/packs/rails_admin.js b/spec/dummy_app/app/javascript/packs/rails_admin.js index 913ce15e62..63c31b5973 100644 --- a/spec/dummy_app/app/javascript/packs/rails_admin.js +++ b/spec/dummy_app/app/javascript/packs/rails_admin.js @@ -1,2 +1,2 @@ -import "rails_admin/src/base"; +import "rails_admin/src/rails_admin/base"; import "../stylesheets/rails_admin.scss"; diff --git a/spec/dummy_app/app/javascript/stylesheets/rails_admin.scss b/spec/dummy_app/app/javascript/stylesheets/rails_admin.scss index 927a8bb6ae..6ec27d11b3 100644 --- a/spec/dummy_app/app/javascript/stylesheets/rails_admin.scss +++ b/spec/dummy_app/app/javascript/stylesheets/rails_admin.scss @@ -1 +1 @@ -@import "~rails_admin/src/styles/base.scss"; +@import "~rails_admin/src/rails_admin/styles/base.scss"; diff --git a/src/rails_admin/base.js b/src/rails_admin/base.js new file mode 100644 index 0000000000..930147d54a --- /dev/null +++ b/src/rails_admin/base.js @@ -0,0 +1,21 @@ +import Rails from "@rails/ujs"; +import jQuery from "jquery"; +import moment from "moment"; +import "./vendor/jquery.pjax"; +import "./vendor/jquery_nested_form"; +import "bootstrap"; +import "moment/min/locales.js"; +import "eonasdan-bootstrap-datetimepicker"; + +import "./filter-box"; +import "./filtering-multiselect"; +import "./filtering-select"; +import "./nested-form-hooks"; +import "./remote-form"; +import "./sidescroll"; +import "./ui"; +import "./widgets"; + +Rails.start(); +window.$ = window.jQuery = jQuery; +window.moment = moment; diff --git a/app/assets/javascripts/rails_admin/ra.filter-box.js b/src/rails_admin/filter-box.js similarity index 89% rename from app/assets/javascripts/rails_admin/ra.filter-box.js rename to src/rails_admin/filter-box.js index 522b9249f7..c5cca7c902 100644 --- a/app/assets/javascripts/rails_admin/ra.filter-box.js +++ b/src/rails_admin/filter-box.js @@ -1,3 +1,7 @@ +import jQuery from "jquery"; +import moment from "moment"; +import I18n from "./i18n"; + (function ($) { var filters; @@ -25,22 +29,22 @@ .append( $('') .prop("selected", field_value == "true") - .text(RailsAdmin.I18n.t("true")) + .text(I18n.t("true")) ) .append( $('') .prop("selected", field_value == "false") - .text(RailsAdmin.I18n.t("false")) + .text(I18n.t("false")) ); if (!required) { control.append([ '', $('') .prop("selected", field_value == "_present") - .text(RailsAdmin.I18n.t("is_present")), + .text(I18n.t("is_present")), $('') .prop("selected", field_value == "_blank") - .text(RailsAdmin.I18n.t("is_blank")), + .text(I18n.t("is_blank")), ]); } break; @@ -59,31 +63,29 @@ '' ) .prop("selected", field_operator == "default") - .text( - RailsAdmin.I18n.t(field_type == "time" ? "time" : "date") - ) + .text(I18n.t(field_type == "time" ? "time" : "date")) ) .append( $( '' ) .prop("selected", field_operator == "between") - .text(RailsAdmin.I18n.t("between_and_")) + .text(I18n.t("between_and_")) ); if (field_type != "time") { control.append([ $('') .prop("selected", field_operator == "today") - .text(RailsAdmin.I18n.t("today")), + .text(I18n.t("today")), $('') .prop("selected", field_operator == "yesterday") - .text(RailsAdmin.I18n.t("yesterday")), + .text(I18n.t("yesterday")), $('') .prop("selected", field_operator == "this_week") - .text(RailsAdmin.I18n.t("this_week")), + .text(I18n.t("this_week")), $('') .prop("selected", field_operator == "last_week") - .text(RailsAdmin.I18n.t("last_week")), + .text(I18n.t("last_week")), ]); } if (!required) { @@ -91,10 +93,10 @@ '', $('') .prop("selected", field_operator == "_not_null") - .text(RailsAdmin.I18n.t("is_present")), + .text(I18n.t("is_present")), $('') .prop("selected", field_operator == "_null") - .text(RailsAdmin.I18n.t("is_blank")), + .text(I18n.t("is_blank")), ]); } additional_control = $.map( @@ -139,10 +141,10 @@ : [ $('') .prop("selected", field_value == "_present") - .text(RailsAdmin.I18n.t("is_present")), + .text(I18n.t("is_present")), $('') .prop("selected", field_value == "_blank") - .text(RailsAdmin.I18n.t("is_blank")), + .text(I18n.t("is_blank")), '', ] ) @@ -179,45 +181,45 @@ '' ) .prop("selected", field_operator == "like") - .text(RailsAdmin.I18n.t("contains")) + .text(I18n.t("contains")) ) .append( $( '' ) .prop("selected", field_operator == "not_like") - .text(RailsAdmin.I18n.t("does_not_contain")) + .text(I18n.t("does_not_contain")) ) .append( $( '' ) .prop("selected", field_operator == "is") - .text(RailsAdmin.I18n.t("is_exactly")) + .text(I18n.t("is_exactly")) ) .append( $( '' ) .prop("selected", field_operator == "starts_with") - .text(RailsAdmin.I18n.t("starts_with")) + .text(I18n.t("starts_with")) ) .append( $( '' ) .prop("selected", field_operator == "ends_with") - .text(RailsAdmin.I18n.t("ends_with")) + .text(I18n.t("ends_with")) ); if (!required) { control.append([ '', $('') .prop("selected", field_operator == "_present") - .text(RailsAdmin.I18n.t("is_present")), + .text(I18n.t("is_present")), $('') .prop("selected", field_operator == "_blank") - .text(RailsAdmin.I18n.t("is_blank")), + .text(I18n.t("is_blank")), ]); } additional_control = $( @@ -244,24 +246,24 @@ '' ) .prop("selected", field_operator == "default") - .text(RailsAdmin.I18n.t("number")) + .text(I18n.t("number")) ) .append( $( '' ) .prop("selected", field_operator == "between") - .text(RailsAdmin.I18n.t("between_and_")) + .text(I18n.t("between_and_")) ); if (!required) { control.append([ '', $('') .prop("selected", field_operator == "_not_null") - .text(RailsAdmin.I18n.t("is_present")), + .text(I18n.t("is_present")), $('') .prop("selected", field_operator == "_null") - .text(RailsAdmin.I18n.t("is_blank")), + .text(I18n.t("is_blank")), ]); } additional_control = $( @@ -331,7 +333,7 @@ $content.find(".date, .datetime").each(function () { $(this).datetimepicker({ date: moment($(this).siblings("[type=hidden]").val()), - locale: RailsAdmin.I18n.locale, + locale: I18n.locale, showTodayButton: true, format: options["datetimepicker_format"], }); @@ -365,7 +367,7 @@ $(document).on("click", "#filters_box .delete", function (e) { e.preventDefault(); - form = $(this).parents("form"); + var form = $(this).parents("form"); $(this).parents(".filter").remove(); !$("#filters_box").children().length && $("hr.filters_box:visible").hide("slow"); @@ -387,7 +389,8 @@ "#filters_box .switch-additional-fieldsets", function (e) { var selected_option = $(this).find("option:selected"); - if ((klass = $(selected_option).data("additional-fieldset"))) { + var klass = $(selected_option).data("additional-fieldset"); + if (klass) { $(this) .siblings(".additional-fieldset:not(." + klass + ")") .hide("slow"); diff --git a/app/assets/javascripts/rails_admin/ra.filtering-multiselect.js b/src/rails_admin/filtering-multiselect.js similarity index 97% rename from app/assets/javascripts/rails_admin/ra.filtering-multiselect.js rename to src/rails_admin/filtering-multiselect.js index 208103d669..a9dc7cb9b1 100644 --- a/app/assets/javascripts/rails_admin/ra.filtering-multiselect.js +++ b/src/rails_admin/filtering-multiselect.js @@ -1,14 +1,7 @@ -/* - * RailsAdmin filtering multiselect @VERSION - * - * License - * - * http://www.railsadmin.org - * - * Depends: - * jquery.ui.core.js - * jquery.ui.widget.js - */ +import jQuery from "jquery"; +import "jquery-ui/ui/widget"; +import I18n from "./i18n"; + (function ($) { $.widget("ra.filteringMultiselect", { _cache: {}, @@ -152,10 +145,10 @@ this.element.css({ display: "none" }); this.tooManyObjectsPlaceholder = $('