forms-angular 0.12.0-beta.205 → 0.12.0-beta.207

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.
@@ -47,7 +47,6 @@ class FormsAngular {
47
47
  }
48
48
  }
49
49
  const search = 'search/', schema = 'schema/', report = 'report/', resourceName = ':resourceName', id = '/:id', formName = '/:formName', newClarifier = '/new';
50
- ;
51
50
  this.app.get.apply(this.app, processArgs(this.options, ['models', this.models()]));
52
51
  this.app.get.apply(this.app, processArgs(this.options, [search + resourceName, this.search()]));
53
52
  this.app.get.apply(this.app, processArgs(this.options, [schema + resourceName, this.schema()]));
@@ -199,11 +198,14 @@ class FormsAngular {
199
198
  addResource(resourceName, model, options) {
200
199
  let resource = {
201
200
  resourceName: resourceName,
201
+ resourceNameLower: resourceName.toLowerCase(),
202
202
  options: options || {}
203
203
  };
204
204
  if (!resource.options.suppressDeprecatedMessage) {
205
205
  console.log('addResource is deprecated - see https://github.com/forms-angular/forms-angular/issues/39');
206
206
  }
207
+ // Check all the synonyms are lower case
208
+ resource.options.synonyms?.forEach(s => { s.name = s.name.toLowerCase(); });
207
209
  if (typeof model === 'function') {
208
210
  resource.model = model;
209
211
  }
@@ -355,7 +357,7 @@ class FormsAngular {
355
357
  }
356
358
  for (let i = 0; i < resourceCount; i++) {
357
359
  let resource = resourcesToSearch[i];
358
- if (resourceCount === 1 || (resource.options.searchImportance !== false && (!collectionName || collectionName === resource.resourceName || resource.options?.synonyms?.find(s => s.name?.toLowerCase() === collectionNameLower)))) {
360
+ if (resourceCount === 1 || (resource.options.searchImportance !== false && (!collectionName || collectionNameLower === resource.resourceNameLower || resource.options?.synonyms?.find(s => s.name === collectionNameLower)))) {
359
361
  let schema = resource.model.schema;
360
362
  let indexedFields = [];
361
363
  for (let j = 0; j < schema._indexes.length; j++) {
@@ -1539,11 +1541,11 @@ class FormsAngular {
1539
1541
  if (resource.options.dependents === undefined) {
1540
1542
  resource.options.dependents = that.resources.reduce(function (acc, r) {
1541
1543
  function searchPaths(schema, prefix) {
1542
- var fldList = [];
1543
- for (var fld in schema.paths) {
1544
+ let fldList = [];
1545
+ for (let fld in schema.paths) {
1544
1546
  if (schema.paths.hasOwnProperty(fld)) {
1545
- var parts = fld.split('.');
1546
- var schemaType = schema.tree;
1547
+ const parts = fld.split('.');
1548
+ let schemaType = schema.tree;
1547
1549
  while (parts.length > 0) {
1548
1550
  schemaType = schemaType[parts.shift()];
1549
1551
  }
@@ -88,6 +88,7 @@ declare module fngServer {
88
88
 
89
89
  interface Resource extends ResourceExport {
90
90
  resourceName: string;
91
+ resourceNameLower: string;
91
92
  }
92
93
 
93
94
  interface ListParams {
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "author": "Mark Chapman <support@forms-angular.org>",
4
4
  "description": "A form builder that sits on top of Angular.js, Twitter Bootstrap, jQuery UI, Angular-UI, Express and Mongoose. Opinionated or what?",
5
5
  "homepage": "http://forms-angular.org",
6
- "version": "0.12.0-beta.205",
6
+ "version": "0.12.0-beta.207",
7
7
  "engines": {
8
8
  "node": ">=8.x",
9
9
  "npm": ">=5.x"