From 33f528a07acbc382224a9df9fb73db43ee8da10d Mon Sep 17 00:00:00 2001 From: Dannon Baker Date: Thu, 30 Jan 2020 18:25:15 -0500 Subject: [PATCH] parent fc713a3cd5f3398fa85f0c0502679a15027bdcef author Dannon Baker 1580426715 -0500 committer Dannon Baker 1581649360 -0500 Drop bower exclusion from babel-loader. We need to transpile bootstrap-vue, otherwise edge blows up. Edge can't handle two events on the same element (?!?!?!) and silently just doesn't fire change when there's also an input binding here? Update commentary for babel stage excludes Add IMask functionality for initial input masking (similar to previous functionality, but a little more robust). We may want to work on the regex here. Fix unused var/eslint Adjust karma's webpack config to completely ignore node-modules for transpilation, fixes it messing with bootstrap-vue and failing Client format... --- client/galaxy/scripts/mvc/ui/ui-slider.js | 30 +++++++++++++---------- client/karma/webpack.config.unittest.js | 5 ++++ client/webpack.config.js | 11 +++++---- 3 files changed, 28 insertions(+), 18 deletions(-) diff --git a/client/galaxy/scripts/mvc/ui/ui-slider.js b/client/galaxy/scripts/mvc/ui/ui-slider.js index f1050baf374..b60d956725b 100644 --- a/client/galaxy/scripts/mvc/ui/ui-slider.js +++ b/client/galaxy/scripts/mvc/ui/ui-slider.js @@ -1,4 +1,5 @@ import Backbone from "backbone"; +import IMask from "imask"; import Utils from "utils/utils"; @@ -23,20 +24,23 @@ const View = Backbone.View.extend({ this.$text = this.$(".ui-form-slider-text"); this.$slider = this.$(".ui-form-slider-element"); - // add text field event - this.$text - .on("change", e => { - this.value(e.currentTarget.value); - }) - .on("input", e => { - const input = e.currentTarget; - if (this._isParameter(input.value)) { - return; - } else if (!this.model.get("precise")) { - input.value = input.value.split(".")[0]; + IMask(this.$text[0], { + mask: value => { + if (this._isParameter(value)) { + return true; } - input.value = input.value.replace(/[^0-9eE.-]/g, ""); - }); + if (!this.model.get("precise")) { + if (value != value.split(".")[0]) { + return false; + } + } + return value == value.replace(/[^0-9eE.-]/g, ""); + } + }); + + this.$text[0].addEventListener("change", e => { + this.value(e.currentTarget.value); + }); // build slider, cannot be rebuild in render const opts = this.model.attributes; diff --git a/client/karma/webpack.config.unittest.js b/client/karma/webpack.config.unittest.js index b8df1e6ff0f..63466d2b093 100644 --- a/client/karma/webpack.config.unittest.js +++ b/client/karma/webpack.config.unittest.js @@ -36,9 +36,14 @@ module.exports = (env, argv) => { // Using babel-plugin-rewire to handle dependency mocking since webpack 4 // exports immutable bindings for ES modules but we still need a way to // overwrite dependencies during unit-testing. + // + // Additionally, set exclude for babel-loader to completely ignore *all* + // node-modules, without our exceptions to support IE as in parent webpack + // config. wpConfig.module.rules = wpConfig.module.rules.map(rule => { if (rule.loader == "babel-loader") { + rule.exclude = [/(node_modules\/)/] rule.options.plugins.push("rewire"); } return rule; diff --git a/client/webpack.config.js b/client/webpack.config.js index bd341ad0b4d..47d15f80b45 100644 --- a/client/webpack.config.js +++ b/client/webpack.config.js @@ -66,11 +66,12 @@ module.exports = (env = {}, argv = {}) => { }, { test: /\.js$/, - // Pretty sure we don't want anything except node_modules here - exclude: [ - /(node_modules\/(?!(handsontable)\/)|bower_components)/, - libsBase - ], + /* + * Babel transpile excludes for: + * - all node_modules except for handsontable, bootstrap-vue + * - statically included libs (like old jquery plugins, etc.) + */ + exclude: [/(node_modules\/(?!(handsontable|bootstrap-vue)\/))/, libsBase], loader: "babel-loader", options: { cacheDirectory: true,