Add minimal admin js setup

This commit is contained in:
Matt-Yorkley
2023-05-07 23:39:47 +01:00
parent c4bc0a7bbd
commit f181b35a90
5 changed files with 56 additions and 5 deletions

View File

@@ -0,0 +1,44 @@
// This is a manifest file that'll be compiled into including all the files listed below.
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
// be included in the compiled file accessible from http://example.com/assets/application.js
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
//= require jquery2
//= require admin/spree/spree-select2
//= require admin/spree/handlebar_extensions
//= require i18n/translations
//= require darkswarm/i18n.translate.js
//= require moment/min/moment.min.js
//= require moment/locale/ar.js
//= require moment/locale/ca.js
//= require moment/locale/de.js
//= require moment/locale/en-gb.js
//= require moment/locale/es.js
//= require moment/locale/fil.js
//= require moment/locale/fr.js
//= require moment/locale/it.js
//= require moment/locale/nb.js
//= require moment/locale/nl-be.js
//= require moment/locale/pt-br.js
//= require moment/locale/pt.js
//= require moment/locale/ru.js
//= require moment/locale/sv.js
//= require moment/locale/tr.js
//= require moment/locale/pl.js
//= require js-big-decimal/dist/web/js-big-decimal.min.js
window.angular = { module: function(noop){ return { value: function(){} } } }
document.addEventListener("ajax:beforeSend", (event) => {
window.Turbo.navigator.adapter.progressBar.setValue(0)
window.Turbo.navigator.adapter.progressBar.show()
})
document.addEventListener("ajax:complete", (event) => {
window.Turbo.navigator.adapter.progressBar.setValue(100)
window.Turbo.navigator.adapter.progressBar.hide()
})

View File

@@ -1,6 +1,8 @@
- content_for :page_title do
= t('.listing_orders')
- content_for :minimal_js, true
- content_for :page_actions do
%li
= button_link_to t('.new_order'), spree.new_admin_order_url, icon: 'icon-plus', id: 'admin_new_order'
@@ -42,7 +44,7 @@
%div.menu_item
%span.name{ "data-controller": "modal-link", "data-action": "click->modal-link#open", "data-modal-link-target-value": "cancel_orders" }
= t('.cancel_orders')
= render partial: 'admin/shared/angular_per_page_controls', locals: { position: "right", model: "orders" }
%table#listing_orders.index.responsive{width: "100%", 'ng-init' => 'initialise()', 'ng-show' => "!RequestMonitor.loading && orders.length > 0" }

View File

@@ -3,8 +3,6 @@
= csrf_meta_tags
= action_cable_meta_tag
= action_cable_meta_tag
%title
- if content_for? :html_title
= yield :html_title
@@ -16,7 +14,11 @@
= stylesheet_pack_tag 'admin-styles', media: "screen, print"
= render "layouts/bugsnag_js"
= javascript_include_tag 'admin/all'
- if content_for? :minimal_js
= javascript_include_tag 'admin_minimal'
- else
= javascript_include_tag 'admin/all'
= render "spree/admin/shared/translations"
= render "spree/admin/shared/routes"

View File

@@ -1,4 +1,7 @@
<script>
if (Spree === undefined) {
var Spree = {}
}
Spree.translations = <%==
{:flatpickr_date_format => Spree.t(:flatpickr_date_format,
:scope => 'date_picker',

View File

@@ -209,7 +209,7 @@ module Openfoodnetwork
# Instead, they must be explicitly included below
# http://stackoverflow.com/questions/8012434/what-is-the-purpose-of-config-assets-precompile
config.assets.initialize_on_precompile = true
config.assets.precompile += ['admin/*.js', 'admin/**/*.js']
config.assets.precompile += ['admin/*.js', 'admin/**/*.js', 'admin_minimal.js']
config.assets.precompile += ['web/all.js']
config.assets.precompile += ['darkswarm/all.js']
config.assets.precompile += ['shared/*']