fng-ui-select 0.12.0-beta.204 → 0.12.0-beta.206

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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "fng-ui-select",
3
3
  "author": "Mark Chapman <support@forms-angular.org>",
4
- "version": "0.12.0-beta.204",
4
+ "version": "0.12.0-beta.206",
5
5
  "description": "angular-ui-select plugin for forms-angular",
6
6
  "repository": {
7
7
  "type": "git",
@@ -58,31 +58,44 @@
58
58
  },
59
59
  lookupFunc: function (value, formSchema, cb) {
60
60
  if (formSchema.array) {
61
- const promises = value.map((value) => {
62
- const id = value.x ? (value.x.id || value.x) : undefined; // if it's already been converted, throw away the result of the previous conversion
63
- if (!id) {
64
- return $q.resolve({ data: { list: ""} }); // nothing to convert
65
- } else if (valueCache[id]) {
66
- return $q.resolve({ data: { list: valueCache[id] }}); // already cached
67
- } else {
68
- return SubmissionsService.getListAttributes(formSchema.ref, id); // need to look it up
69
- }
70
- });
71
- // TODO: no error handling here
72
- // TODO: perform lookups of cache misses using a single round-trip
73
- $q.all(promises).then((responses) => {
74
- const results = responses.map((response) => {
75
- let id = value.shift().x;
76
- id = id.id || id; // in case it's already been converted
77
- const text = response.data.list
78
- valueCache[id] = text; // cache it for next time
79
- return { id, text }
61
+ if (formSchema.fngUiSelect.deriveOptions) {
62
+ const results = value.map((value) => {
63
+ const obj = localLookups[formSchema.fngUiSelect.deriveOptions].find((test) => test.id === value);
64
+ return { id: value, text: obj ? obj.text : "" };
80
65
  });
81
66
  cb(formSchema, results);
82
- setTimeout(function () {
83
- $rootScope.$digest();
67
+ if (results.length > 0) {
68
+ setTimeout(function () {
69
+ $rootScope.$digest();
70
+ });
71
+ }
72
+ } else {
73
+ const promises = value.map((value) => {
74
+ const id = value.x ? (value.x.id || value.x) : value; // if it's already been converted, throw away the result of the previous conversion
75
+ if (!id) {
76
+ return $q.resolve({ data: { list: ""} }); // nothing to convert
77
+ } else if (valueCache[id]) {
78
+ return $q.resolve({ data: { list: valueCache[id] }}); // already cached
79
+ } else {
80
+ return SubmissionsService.getListAttributes(formSchema.ref, id); // need to look it up
81
+ }
84
82
  });
85
- });
83
+ // TODO: no error handling here
84
+ // TODO: perform lookups of cache misses using a single round-trip
85
+ $q.all(promises).then((responses) => {
86
+ const results = responses.map((response) => {
87
+ let id = value.shift().x;
88
+ id = id.id || id; // in case it's already been converted
89
+ const text = response.data.list
90
+ valueCache[id] = text; // cache it for next time
91
+ return { id, text }
92
+ });
93
+ cb(formSchema, results);
94
+ setTimeout(function () {
95
+ $rootScope.$digest();
96
+ });
97
+ });
98
+ }
86
99
  } else if (typeof value !== "string") {
87
100
  cb(formSchema, value); // already converted
88
101
  } else if (formSchema.fngUiSelect.deriveOptions) {
@@ -309,7 +322,7 @@
309
322
  if (multiControl) {
310
323
  select += '{{$select.selected' + (isObjects ? '.text' : '') + '}}';
311
324
  } else {
312
- select += multi ? '{{$item}}' : ('{{$select.selected' + (isObjects ? '.text' : '') + '}}');
325
+ select += multi ? '{{$item' + (isObjects ? '.text' : '') + '}}' : ('{{$select.selected' + (isObjects ? '.text' : '') + '}}');
313
326
  }
314
327
  select += '</ui-select-match>';
315
328
  select += '<ui-select-choices repeat="option in ' + array + ' | filter:$select.search">';