alchemymvc 1.3.2 → 1.3.3-alpha

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.
@@ -1503,7 +1503,7 @@ Select.setMethod(function addAssociation(name) {
1503
1503
  this.requireFieldForQuery(info.options.localKey);
1504
1504
  }
1505
1505
  } catch (err) {
1506
- console.warn('Failed to find "' + name + '" association for ' + this.criteria.model.modelName);
1506
+ console.warn('Failed to find "' + name + '" association for ' + this.criteria.model.model_name);
1507
1507
  }
1508
1508
 
1509
1509
  return this.associations[name];
@@ -218,6 +218,10 @@ Validator.setMethod(async function validateDocument(root, context, schema) {
218
218
 
219
219
  fields_with_value = field.getDocumentValues(root);
220
220
 
221
+ if (!fields_with_value?.length) {
222
+ continue;
223
+ }
224
+
221
225
  violation = await this.validateFieldValue(fields_with_value);
222
226
 
223
227
  if (violation) {
@@ -645,31 +645,26 @@ Document.setMethod(['populate', 'addAssociatedData'], function addAssociatedData
645
645
  /**
646
646
  * Get the display field value
647
647
  *
648
- * @author Jelle De Loecker <jelle@develry.be>
648
+ * @author Jelle De Loecker <jelle@elevenways.be>
649
649
  * @since 0.3.0
650
- * @version 1.3.0
650
+ * @version 1.3.3
651
651
  *
652
652
  * @param {Object} options
653
653
  *
654
- * @return {String}
654
+ * @return {String|undefined}
655
655
  */
656
- Document.setMethod(function getDisplayFieldValue(options) {
657
-
658
- var display_field,
659
- result,
660
- i;
661
-
662
- if (!options) {
663
- options = {};
664
- }
656
+ Document.setMethod(function getDisplayFieldValue(options = {}) {
665
657
 
666
- display_field = Array.cast(this.$model.display_field);
658
+ let display_field = Array.cast(this.$model.display_field);
667
659
 
668
660
  // If there are fields we prefer, check those first
669
661
  if (options.prefer) {
670
662
  display_field = Array.cast(options.prefer).concat(display_field);
671
663
  }
672
664
 
665
+ let result,
666
+ i;
667
+
673
668
  for (i = 0; i < display_field.length; i++) {
674
669
  result = this[display_field[i]];
675
670
 
@@ -682,8 +677,14 @@ Document.setMethod(function getDisplayFieldValue(options) {
682
677
  }
683
678
  }
684
679
 
680
+ let fallback_property = options.fallback ?? '_id';
681
+
682
+ if (!fallback_property) {
683
+ return;
684
+ }
685
+
685
686
  // If nothing was found, return the _id value
686
- return String(this._id);
687
+ return String(this[fallback_property]);
687
688
  });
688
689
 
689
690
  /**
@@ -281,7 +281,12 @@ Sitemap.setTypedMethod([Types.Alchemy.Route, Types.Object, Types.Alchemy.Criteri
281
281
  *
282
282
  * @author Jelle De Loecker <jelle@elevenways.be>
283
283
  * @since 1.3.0
284
- * @version 1.3.0
284
+ * @version 1.3.3
285
+ *
286
+ * @param {Route} route The route of which to add something to the map
287
+ * @param {Object} config Sitemap configuration for this route
288
+ * @param {Object} parameters The parameter object to use for generating the url
289
+ * @param {String} forced_prefix The optional prefix to use
285
290
  *
286
291
  * @return {Promise}
287
292
  */
@@ -290,6 +295,7 @@ Sitemap.setMethod(function addRouteWithParameters(route, config, parameters, for
290
295
  if (!parameters) {
291
296
  parameters = {};
292
297
  } else {
298
+ // Make an overlay object
293
299
  parameters = Object.create(parameters);
294
300
  }
295
301
 
@@ -319,7 +325,7 @@ Sitemap.setMethod(function addRouteWithParameters(route, config, parameters, for
319
325
  let route_config = Object.assign({}, config);
320
326
 
321
327
  if (parameters && parameters.getDisplayFieldValue) {
322
- route_config.title = parameters.getDisplayFieldValue({prefix});
328
+ route_config.title = parameters.getDisplayFieldValue({prefix, fallback: false});
323
329
  }
324
330
 
325
331
  if (!route_config.title) {
@@ -333,7 +339,9 @@ Sitemap.setMethod(function addRouteWithParameters(route, config, parameters, for
333
339
  }
334
340
 
335
341
  if (!route_config.title) {
336
- route_config.title = route.name;
342
+ // Skip this if no title was found.
343
+ // It's better to show nothing
344
+ continue;
337
345
  }
338
346
 
339
347
  this.addUrl(config.category, url, route_config, prefix);
@@ -311,7 +311,7 @@ Alchemy.setMethod(function sourcemapMiddleware(req, res, nextMiddleware) {
311
311
  *
312
312
  * @author Jelle De Loecker <jelle@develry.be>
313
313
  * @since 0.2.0
314
- * @version 1.2.7
314
+ * @version 1.3.3
315
315
  *
316
316
  * @param {String} path
317
317
  * @param {Object} options
@@ -434,7 +434,7 @@ Alchemy.setMethod(function minifyScript(path, options, callback) {
434
434
  }
435
435
  };
436
436
 
437
- if (alchemy.settings.debug && alchemy.settings.source_map !== false) {
437
+ if (alchemy.settings.debug && alchemy.settings.source_map) {
438
438
  minify_options.sourceMap = {
439
439
  url: 'inline'
440
440
  };
@@ -516,7 +516,7 @@ Alchemy.setMethod(function printLog(level, args, options) {
516
516
  *
517
517
  * @author Jelle De Loecker <jelle@develry.be>
518
518
  * @since 0.4.0
519
- * @version 1.1.6
519
+ * @version 1.3.3
520
520
  */
521
521
  Alchemy.setMethod(function loadSettings() {
522
522
 
@@ -689,6 +689,21 @@ Alchemy.setMethod(function loadSettings() {
689
689
  }
690
690
  }
691
691
 
692
+ if (settings.debug) {
693
+
694
+ if (settings.source_map === 'false') {
695
+ settings.source_map = false;
696
+ }
697
+
698
+ if (settings.source_map == null || settings.source_map) {
699
+ settings.source_map = true;
700
+ } else {
701
+ settings.source_map = false;
702
+ }
703
+ } else {
704
+ settings.source_map = false;
705
+ }
706
+
692
707
  if (settings.preload) {
693
708
  this.doPreload();
694
709
  }
@@ -744,7 +759,7 @@ Alchemy.setMethod(function ready(callback) {
744
759
  *
745
760
  * @author Jelle De Loecker <jelle@elevenways.be>
746
761
  * @since 1.1.2
747
- * @version 1.1.2
762
+ * @version 1.3.3
748
763
  */
749
764
  Alchemy.setMethod(async function doPreload() {
750
765
 
@@ -771,7 +786,7 @@ Alchemy.setMethod(async function doPreload() {
771
786
 
772
787
  Blast.getClientPath({
773
788
  modify_prototypes : true,
774
- create_source_map : alchemy.settings.debug,
789
+ create_source_map : alchemy.settings.source_map,
775
790
  enable_coverage : !!global.__coverage__
776
791
  });
777
792
  }
package/lib/stages.js CHANGED
@@ -183,9 +183,9 @@ alchemy.sputnik.add(function define_debug() {
183
183
  * The "hawkejsSetup" stage:
184
184
  * Initialize Hawkejs
185
185
  *
186
- * @author Jelle De Loecker <jelle@develry.be>
186
+ * @author Jelle De Loecker <jelle@elevenways.be>
187
187
  * @since 0.0.1
188
- * @version 1.1.0
188
+ * @version 1.3.3
189
189
  */
190
190
  alchemy.sputnik.add(function hawkejs_setup() {
191
191
 
@@ -201,7 +201,7 @@ alchemy.sputnik.add(function hawkejs_setup() {
201
201
  Blast.getClientPath({
202
202
  modify_prototypes : true,
203
203
  ua : req.conduit.headers.useragent,
204
- create_source_map : alchemy.settings.debug,
204
+ create_source_map : alchemy.settings.source_map,
205
205
  enable_coverage : !!global.__coverage__
206
206
  }).done(gotClientFile);
207
207
 
@@ -243,7 +243,7 @@ alchemy.sputnik.add(function hawkejs_setup() {
243
243
  refresh : true,
244
244
  modify_prototypes : true,
245
245
  ua : req.conduit.headers.useragent,
246
- create_source_map : alchemy.settings.debug,
246
+ create_source_map : alchemy.settings.source_map,
247
247
  }).done(gotClientFile);
248
248
  }
249
249
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "alchemymvc",
3
3
  "description": "MVC framework for Node.js",
4
- "version": "1.3.2",
4
+ "version": "1.3.3-alpha",
5
5
  "author": "Jelle De Loecker <jelle@elevenways.be>",
6
6
  "keywords": [
7
7
  "alchemy",
@@ -22,7 +22,7 @@
22
22
  "chokidar" : "~3.5.3",
23
23
  "formidable" : "~2.0.1",
24
24
  "graceful-fs" : "~4.2.9",
25
- "hawkejs" : "~2.3.2",
25
+ "hawkejs" : "~2.3.3",
26
26
  "jsondiffpatch" : "~0.4.1",
27
27
  "mime" : "~3.0.0",
28
28
  "minimist" : "~1.2.5",
@@ -31,7 +31,7 @@
31
31
  "mongodb" : "~3.6.6",
32
32
  "ncp" : "~2.0.0",
33
33
  "postcss" : "~8.4.6",
34
- "protoblast" : "~0.8.2",
34
+ "protoblast" : "~0.8.3",
35
35
  "semver" : "~7.3.5",
36
36
  "socket.io" : "~2.4.0",
37
37
  "@11ways/socket.io-stream" : "~0.9.2",