diff --git a/app/assets/javascripts/templates/admin/save_bar.html.haml b/app/assets/javascripts/templates/admin/save_bar.html.haml index aed3708f8b..e0ab0f437e 100644 --- a/app/assets/javascripts/templates/admin/save_bar.html.haml +++ b/app/assets/javascripts/templates/admin/save_bar.html.haml @@ -1,7 +1,7 @@ #save-bar.animate-show{ "ng-show": 'dirty || persist || StatusMessage.active()' } .container .seven.columns.alpha - %h5#status-message{ "ng-show": "StatusMessage.invalidMessage == ''", "ng-style": 'StatusMessage.statusMessage.style', data: { 'order-cycle-form-target': 'element' }, "ng-attr-data-type": "{{StatusMessage.statusMessage.type}}", "ng-attr-data-action-name": "{{StatusMessage.statusMessage.actionName}}" } + %h5#status-message{ "ng-show": "StatusMessage.invalidMessage == ''", "ng-style": 'StatusMessage.statusMessage.style', data: { 'order-cycle-form-target': 'statusMessage' }, "ng-attr-data-type": "{{StatusMessage.statusMessage.type}}", "ng-attr-data-action-name": "{{StatusMessage.statusMessage.actionName}}" } {{ StatusMessage.statusMessage.text || " " }} %h5#status-message{ style: 'color: #C85136', "ng-show": "StatusMessage.invalidMessage !== ''" } {{ StatusMessage.invalidMessage || " " }} diff --git a/app/controllers/admin/order_cycles_controller.rb b/app/controllers/admin/order_cycles_controller.rb index f87c46f8b5..a94fa8a9b7 100644 --- a/app/controllers/admin/order_cycles_controller.rb +++ b/app/controllers/admin/order_cycles_controller.rb @@ -310,8 +310,7 @@ module Admin def same_dates(date, string) false unless date && string - DateTime.parse(string).strftime('%Y-%m-%d %H:%M') == - date.to_datetime.strftime('%Y-%m-%d %H:%M') + DateTime.parse(string).to_fs(:short) == date.to_fs(:short) end end end diff --git a/app/webpacker/controllers/order_cycle_form_controller.js b/app/webpacker/controllers/order_cycle_form_controller.js index 03128c09d0..4215e8060c 100644 --- a/app/webpacker/controllers/order_cycle_form_controller.js +++ b/app/webpacker/controllers/order_cycle_form_controller.js @@ -1,19 +1,20 @@ import { Controller } from "stimulus"; export default class extends Controller { - static targets = ['element'] + static targets = ['statusMessage'] connect() { + console.log(this.statusMessageTarget) this.observer = new MutationObserver(this.updateCallback); this.observer.observe( - this.elementTarget, + this.statusMessageTarget, { attributes: true, attributeOldValue: true, attributeFilter: ['data-type'] } ); } // Callback to trigger warning modal updateCallback(mutationsList) { - const newDataType = $('#status-message').attr('data-type'); - const actionName = $('#status-message').attr('data-action-name'); + const newDataType = document.getElementById('status-message').getAttribute('data-type'); + const actionName = document.getElementById('status-message').getAttribute('data-action-name'); if(!actionName) return; for(let mutation of mutationsList) { @@ -21,10 +22,18 @@ export default class extends Controller { // Only trigger warning modal when notice display (notice) is preceeded by progress display (progress) if(mutation.oldValue === 'progress' && newDataType === 'notice') { // Hide all confirmation buttons in warning modal - $('#linked-order-warning-modal .modal-actions button.secondary').css({ display: 'none' }) + document.querySelectorAll( + '#linked-order-warning-modal .modal-actions button.secondary' + ).forEach((node) => { + node.style.display = 'none'; + }); // Show the appropriate confirmation button, open warning modal, and return - $(`#linked-order-warning-modal button[data-trigger-action=${actionName}]`).css({ display: 'block' }); - $('.warning-modal button.modal-target-trigger').trigger('click'); + document.querySelectorAll( + `#linked-order-warning-modal button[data-trigger-action=${actionName}]` + ).forEach((node) => { + node.style.display = 'block'; + }) + document.querySelector('.warning-modal button.modal-target-trigger').click(); } } }