From 8c15cfe364c5f0420ea22fc5f70ab0314ffcaf41 Mon Sep 17 00:00:00 2001 From: Julien Portalier Date: Tue, 28 Nov 2023 20:24:21 +0100 Subject: [PATCH] Fix: downgrade knockoutjs and lodash + fix invalid ko code Fixes a couple issues found by Knockout 3.5 but still downgrade the library as it still doesn't work properly. Also vendors the asset file as the gem can't be installed along with rails 5 and the gem does nothing. Also downgrades lodash since there was error popping out. --- Gemfile | 3 +- Gemfile.lock | 7 +- app/views/layers/index.haml | 1 - plugins/alerts/views/thresholds/index.haml | 13 +- vendor/assets/javascripts/knockout.js | 5299 ++++++++++++++++++++ 5 files changed, 5308 insertions(+), 15 deletions(-) create mode 100644 vendor/assets/javascripts/knockout.js diff --git a/Gemfile b/Gemfile index 0ebd9b21a..8643a1b70 100644 --- a/Gemfile +++ b/Gemfile @@ -56,8 +56,7 @@ gem 'haml-magic-translations' # assets gem 'coffee-rails', '~> 4.1.1' -gem 'lodash-rails' -gem 'knockoutjs-rails', '~> 3.5.0' +gem 'lodash-rails', '~> 2.4.1' gem 'rails-assets-knockout-sortable', :source => 'https://rails-assets.org' gem 'sass-rails', '~> 5.0' gem 'uglifier', '>= 2.5.0' diff --git a/Gemfile.lock b/Gemfile.lock index b71902d17..7f1b4250c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -230,10 +230,8 @@ GEM aes_key_wrap bindata jwt (2.3.0) - knockoutjs-rails (3.5.1.1) - railties (>= 3.1) locale (2.1.3) - lodash-rails (4.17.21) + lodash-rails (2.4.1) railties (>= 3.1) loofah (2.20.0) crass (~> 1.0.2) @@ -488,8 +486,7 @@ DEPENDENCIES instedd_telemetry! intercom-rails jasmine (~> 2.7.0) - knockoutjs-rails (~> 3.5.0) - lodash-rails + lodash-rails (~> 2.4.1) loofah (= 2.20.0) machinist (= 1.0.6) mini_magick diff --git a/app/views/layers/index.haml b/app/views/layers/index.haml index 3fe7cdba5..e1e6c59cf 100644 --- a/app/views/layers/index.haml +++ b/app/views/layers/index.haml @@ -129,7 +129,6 @@ //ko %br/ - //ko - if current_user_snapshot.at_present? && collection_admin? /ko if: !savingLayer() diff --git a/plugins/alerts/views/thresholds/index.haml b/plugins/alerts/views/thresholds/index.haml index db0528173..4d5341ca6 100644 --- a/plugins/alerts/views/thresholds/index.haml +++ b/plugins/alerts/views/thresholds/index.haml @@ -240,14 +240,13 @@ .rightbuttons %button.cadd.right //ko - //ko -# New threshold link /ko if: fields().length - .box.grey.add{ ko(visible: 'state() == "listing"', click: 'showAddThreshold'), style: 'display:none'} - .toptitle - %span - Add Alert - .rightbuttons - %button.cadd.right + /.box.grey.add{ ko(visible: 'state() == "listing"', click: 'showAddThreshold'), style: 'display:none'} + / .toptitle + / %span + / Add Alert + / .rightbuttons + / %button.cadd.right //ko diff --git a/vendor/assets/javascripts/knockout.js b/vendor/assets/javascripts/knockout.js new file mode 100644 index 000000000..d6db670d1 --- /dev/null +++ b/vendor/assets/javascripts/knockout.js @@ -0,0 +1,5299 @@ +/*! + * Knockout JavaScript library v3.2.0 + * (c) Steven Sanderson - http://knockoutjs.com/ + * License: MIT (http://www.opensource.org/licenses/mit-license.php) + */ + +(function(){ +var DEBUG=true; +(function(undefined){ + // (0, eval)('this') is a robust way of getting a reference to the global object + // For details, see http://stackoverflow.com/questions/14119988/return-this-0-evalthis/14120023#14120023 + var window = this || (0, eval)('this'), + document = window['document'], + navigator = window['navigator'], + jQueryInstance = window["jQuery"], + JSON = window["JSON"]; +(function(factory) { + // Support three module loading scenarios + if (typeof require === 'function' && typeof exports === 'object' && typeof module === 'object') { + // [1] CommonJS/Node.js + var target = module['exports'] || exports; // module.exports is for Node.js + factory(target, require); + } else if (typeof define === 'function' && define['amd']) { + // [2] AMD anonymous module + define(['exports', 'require'], factory); + } else { + // [3] No module loader (plain