Skip to content

Commit

Permalink
Merge pull request #73 from fleetbase/dev-v0.2.32
Browse files Browse the repository at this point in the history
fixed loading of leaflet, no more duplicate initializations
  • Loading branch information
roncodes authored Oct 2, 2024
2 parents bf51899 + 031d2a0 commit 0c1ff91
Show file tree
Hide file tree
Showing 4 changed files with 1,020 additions and 1,083 deletions.
22 changes: 7 additions & 15 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,23 +53,16 @@ module.exports = {
included: function (app) {
this._super.included.apply(this, arguments);

// Get host application
if (typeof this._findHost === 'function') {
app = this._findHost();
} else {
app = this._findHostFallback();
}

// PostCSS
// Get Application Host
app = this.findApplicationHost(app);

// PostCSS Options
app.options = app.options || {};
app.options.postcssOptions = postcssOptions;

// Import leaflet-src
if (!app.__leafletIncluded) {
app.__leafletIncluded = true;
this.import('node_modules/leaflet/dist/leaflet-src.js');
this.import('node_modules/leaflet/dist/leaflet.css');
}
this.import('node_modules/leaflet/dist/leaflet-src.js');
this.import('node_modules/leaflet/dist/leaflet.css');

// Import the `intlTelInput.min.css` file and append it to the parent application's `vendor.css`
this.import('node_modules/intl-tel-input/build/css/intlTelInput.min.css');
Expand Down Expand Up @@ -128,9 +121,8 @@ module.exports = {
return path.dirname(resolve.sync(packageName + '/package.json', { basedir: __dirname }));
},

_findHostFallback() {
findApplicationHost(app) {
let current = this;
let app = current;
do {
if (current.lazyLoading === true || (current.lazyLoading && current.lazyLoading.enabled === true)) {
app = current;
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fleetbase/ember-ui",
"version": "0.2.31",
"version": "0.2.32",
"description": "Fleetbase UI provides all the interface components, helpers, services and utilities for building a Fleetbase extension into the Console.",
"keywords": [
"fleetbase-ui",
Expand Down Expand Up @@ -89,7 +89,7 @@
"ember-file-upload": "8.4.0",
"ember-focus-trap": "^1.0.1",
"ember-get-config": "^2.1.1",
"ember-gridstack": "^4.0.0",
"ember-gridstack": "4.0.0",
"ember-inflector": "^4.0.2",
"ember-leaflet": "^5.1.3",
"ember-loading": "^2.0.0",
Expand Down Expand Up @@ -150,7 +150,6 @@
"eslint-plugin-prettier": "^5.0.1",
"eslint-plugin-qunit": "^8.0.1",
"loader.js": "^4.7.0",
"patch-package": "^8.0.0",
"prettier": "^3.0.3",
"qunit": "^2.20.0",
"qunit-dom": "^2.0.0",
Expand Down
62 changes: 23 additions & 39 deletions patches/[email protected]
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
diff --git a/index.js b/index.js
index 7361871adfe0b79c70a3699e38cc435f3741cb33..fe08a429d35283691de28f3dc73ef7ec8bec76cb 100644
index 7361871adfe0b79c70a3699e38cc435f3741cb33..e02f7e6d61605d8b770ed5c0454b6c905d538ff9 100644
--- a/index.js
+++ b/index.js
@@ -1,36 +1,18 @@
@@ -1,87 +1,5 @@
-'use strict';
-const resolve = require('resolve');
-const path = require('path');
-const mergeTrees = require('broccoli-merge-trees');
-const Funnel = require('broccoli-funnel');
-const fastbootTransform = require('fastboot-transform');
+'use strict'
+const resolve = require('resolve')
+const path = require('path')
+const mergeTrees = require('broccoli-merge-trees')
+const Funnel = require('broccoli-funnel')
+const fastbootTransform = require('fastboot-transform')

module.exports = {
name: require('./package').name,
- name: require('./package').name,
-
- treeForVendor() {
- let dist = path.join(this.pathBase('leaflet'), 'dist');
-
Expand All @@ -39,32 +34,26 @@ index 7361871adfe0b79c70a3699e38cc435f3741cb33..fe08a429d35283691de28f3dc73ef7ec
-
- included(app) {
- this._super.included.apply(this, arguments);
+ included (app) {
+ this._super.included.apply(this, arguments)

// Addon options from the apps ember-cli-build.js
-
- // Addon options from the apps ember-cli-build.js
- let options = app.options[this.name] || {};
+ let options = app.options[this.name] || {}

// If the addon has the _findHost() method (in ember-cli >= 2.7.0), we'll just
// use that.
@@ -42,46 +24,22 @@ module.exports = {
// method in ember-cli.
// Keep iterating upward until we don't have a grandparent.
// Has to do this grandparent check because at some point we hit the project.
-
- // If the addon has the _findHost() method (in ember-cli >= 2.7.0), we'll just
- // use that.
- // if (typeof this._findHost === 'function') {
- // app = this._findHost();
- // }
-
- // Otherwise, we'll use this implementation borrowed from the _findHost()
- // method in ember-cli.
- // Keep iterating upward until we don't have a grandparent.
- // Has to do this grandparent check because at some point we hit the project.
- let current = this;
+ let current = this
do {
- do {
- if (current.lazyLoading === true || (current.lazyLoading && current.lazyLoading.enabled === true)) {
- app = current;
- break;
+ if (
+ current.lazyLoading === true ||
+ (current.lazyLoading && current.lazyLoading.enabled === true)
+ ) {
+ app = current
+ break
}
- }
- app = current.app || app;
- } while (current.parent.parent && (current = current.parent));
-
Expand Down Expand Up @@ -96,16 +85,11 @@ index 7361871adfe0b79c70a3699e38cc435f3741cb33..fe08a429d35283691de28f3dc73ef7ec
- destDir: imagesDestDir
- });
- }
+ app = current.app || app
+ } while (current.parent.parent && (current = current.parent))
},

- },
-
- pathBase(packageName) {
- return path.dirname(resolve.sync(packageName + '/package.json', { basedir: __dirname }));
+ pathBase (packageName) {
+ return path.dirname(
+ resolve.sync(packageName + '/package.json', { basedir: __dirname })
+ )
}
- }
-};
+ name: require('./package').name
+}
Loading

0 comments on commit 0c1ff91

Please sign in to comment.