@fleetbase/fleetops-engine 0.0.5 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -74,7 +74,7 @@ export default class LeafletDrawControl extends BaseLayer {
74
74
  const { onDrawControlCreated, onDrawControlAddedToMap } = this.args;
75
75
  const showDrawingLayer = getWithDefault(this.args, 'showDrawingLayer', true);
76
76
 
77
- if (this.map && this._layer) {
77
+ if (this.map && this._layer && this.L.drawLocal) {
78
78
  this.options.edit = assign({ featureGroup: this._layer }, this.options.edit);
79
79
  this.options.draw = assign({}, this.L.drawLocal.draw, this.options.draw);
80
80
 
@@ -142,11 +142,14 @@ export default class LiveMapComponent extends Component {
142
142
 
143
143
  @action toggleDrawControlContextMenuItem() {
144
144
  const index = this.currentContextMenuItems.findIndex((options) => options.text?.includes('draw controls'));
145
- const options = this.currentContextMenuItems.objectAt(index);
146
-
147
- set(options, 'text', this.isDrawControlsVisible ? `Hide draw controls...` : `Enable draw controls...`);
148
145
 
149
146
  if (index > 0) {
147
+ const options = this.currentContextMenuItems.objectAt(index);
148
+
149
+ if (!isEmpty(options)) {
150
+ options.text = this.isDrawControlsVisible ? 'Hide draw controls...' : 'Enable draw controls...';
151
+ }
152
+
150
153
  this.leafletMap?.contextmenu?.removeItem(index);
151
154
  this.leafletMap?.contextmenu?.insertItem(options, index);
152
155
  }
@@ -0,0 +1,22 @@
1
+ export function initialize() {
2
+ const path = '/engines-dist/leaflet/';
3
+ const scripts = ['leaflet.contextmenu.js', 'leaflet.draw-src.js', 'leaflet.rotatedMarker.js'];
4
+ const stylesheets = ['leaflet.contextmenu.css', 'leaflet.draw.css'];
5
+
6
+ for (let i = 0; i < scripts.length; i++) {
7
+ const script = document.createElement('script');
8
+ script.src = path + scripts[i];
9
+ document.body.appendChild(script);
10
+ }
11
+
12
+ for (let i = 0; i < stylesheets.length; i++) {
13
+ const link = document.createElement('link');
14
+ link.rel = 'stylesheet';
15
+ link.href = path + stylesheets[i];
16
+ document.body.appendChild(link);
17
+ }
18
+ }
19
+
20
+ export default {
21
+ initialize,
22
+ };
@@ -29,7 +29,7 @@ export default class OperationsOrdersIndexRoute extends Route {
29
29
  this.controller?.resetView(transition);
30
30
  }
31
31
 
32
- model(params) {
32
+ @action model(params) {
33
33
  return this.store.query('order', params);
34
34
  }
35
35
  }
package/index.js CHANGED
@@ -1,8 +1,9 @@
1
1
  'use strict';
2
- const Funnel = require('broccoli-funnel');
3
- const MergeTrees = require('broccoli-merge-trees');
4
2
  const { buildEngine } = require('ember-engines/lib/engine-addon');
5
3
  const { name } = require('./package');
4
+ const Funnel = require('broccoli-funnel');
5
+ const MergeTrees = require('broccoli-merge-trees');
6
+ const resolve = require('resolve');
6
7
  const path = require('path');
7
8
 
8
9
  module.exports = buildEngine({
@@ -12,44 +13,51 @@ module.exports = buildEngine({
12
13
  enabled: true,
13
14
  },
14
15
 
15
- included: function () {
16
- this._super.included.apply(this, arguments);
17
-
18
- const importJs = (module, file, options) => {
19
- const modulePath = path.dirname(require.resolve(module));
20
- this.import(`${modulePath}/${file}`, options);
21
- };
22
-
23
- importJs('leaflet-rotatedmarker', 'leaflet.rotatedMarker.js');
24
- importJs('leaflet-draw', 'leaflet.draw-src.js');
25
- importJs('leaflet-contextmenu', 'leaflet.contextmenu.js');
26
-
27
- // import stylesheets
28
- this.import('node_modules/leaflet-contextmenu/dist/leaflet.contextmenu.css');
29
- this.import('node_modules/leaflet-draw/dist/leaflet.draw.css');
30
- },
31
-
32
16
  treeForPublic: function () {
33
17
  const publicTree = this._super.treeForPublic.apply(this, arguments);
34
-
35
- // Use a Funnel assets
36
18
  const leafletPath = path.dirname(require.resolve('leaflet'));
37
19
  const leafletImagesPath = path.join(leafletPath, 'images');
38
- const addonTree = [
20
+ const alwaysExclude = ['LICENSE', 'package.json', 'example.html'];
21
+ const leafletAddons = [
22
+ { package: 'leaflet', include: ['leaflet-src.js'], exclude: [...alwaysExclude], path: ['dist'] },
23
+ { package: 'leaflet-contextmenu', include: undefined, exclude: [...alwaysExclude], path: ['dist'] },
24
+ { package: 'leaflet-draw', include: undefined, exclude: [...alwaysExclude], path: ['dist'] },
25
+ { package: 'leaflet-rotatedmarker', include: undefined, exclude: [...alwaysExclude], path: [] },
26
+ ];
27
+ const trees = [];
28
+
29
+ for (let i = 0; i < leafletAddons.length; i++) {
30
+ const leafletAdddon = leafletAddons[i];
31
+ const leafletAddonDist = path.join(this.pathBase(leafletAdddon.package), ...leafletAdddon.path);
32
+
33
+ trees.push(
34
+ new Funnel(leafletAddonDist, {
35
+ destDir: 'leaflet',
36
+ include: leafletAdddon.include,
37
+ exclude: leafletAdddon.exclude,
38
+ })
39
+ );
40
+ }
41
+
42
+ trees.push(
39
43
  new Funnel(leafletImagesPath, {
40
44
  srcDir: '/',
41
45
  destDir: '/leaflet-images',
42
- }),
46
+ })
47
+ );
48
+ trees.push(
43
49
  new Funnel(path.join(__dirname, 'assets'), {
44
50
  destDir: '/',
45
- }),
46
- ];
51
+ })
52
+ );
47
53
 
48
54
  // Merge the addon tree with the existing tree
49
- return publicTree ? new MergeTrees([publicTree, ...addonTree], { overwrite: true }) : new MergeTrees([...addonTree], { overwrite: true });
55
+ return publicTree ? new MergeTrees([publicTree, ...trees], { overwrite: true }) : new MergeTrees([...trees], { overwrite: true });
50
56
  },
51
57
 
52
- _concatStyles: () => {},
58
+ pathBase(packageName) {
59
+ return path.dirname(resolve.sync(packageName + '/package.json', { basedir: __dirname }));
60
+ },
53
61
 
54
62
  isDevelopingAddon() {
55
63
  return true;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@fleetbase/fleetops-engine",
3
3
  "extension": "Fleet Ops",
4
4
  "icon": "route",
5
- "version": "0.0.5",
5
+ "version": "0.0.7",
6
6
  "priority": 0,
7
7
  "description": "Fleetbase Fleet-Ops extension provides a fleet management and last mile delivery operations system module.",
8
8
  "keywords": [
@@ -37,8 +37,8 @@
37
37
  },
38
38
  "dependencies": {
39
39
  "@fleetbase/ember-core": "^0.0.2",
40
- "@fleetbase/ember-ui": "^0.0.4",
41
- "@fleetbase/fleetops-data": "^0.0.1",
40
+ "@fleetbase/ember-ui": "^0.0.5",
41
+ "@fleetbase/fleetops-data": "^0.0.2",
42
42
  "@fleetbase/leaflet-routing-machine": "^3.2.15",
43
43
  "@fortawesome/ember-fontawesome": "^0.4.1",
44
44
  "@fortawesome/fontawesome-svg-core": "^6.4.0",
@@ -50,10 +50,10 @@
50
50
  "ember-cli-babel": "^7.26.11",
51
51
  "ember-cli-es6-transform": "^1.0.0",
52
52
  "ember-cli-htmlbars": "^6.1.0",
53
- "ember-leaflet": "^5.0.1",
53
+ "ember-leaflet": "^5.1.1",
54
54
  "ember-radio-button": "3.0.0-beta.1",
55
55
  "ember-wormhole": "^0.6.0",
56
- "leaflet": "^1.8.0",
56
+ "leaflet": "^1.9.4",
57
57
  "leaflet-contextmenu": "^1.4.0",
58
58
  "leaflet-draw": "^1.0.4",
59
59
  "leaflet-rotatedmarker": "^0.2.0",
@@ -102,6 +102,7 @@
102
102
  "prettier": "^2.7.1",
103
103
  "qunit": "^2.19.1",
104
104
  "qunit-dom": "^2.0.0",
105
+ "resolve": "^1.22.2",
105
106
  "webpack": "^5.74.0"
106
107
  },
107
108
  "peerDependencies": {