fng-ui-select 0.12.0-beta.192b → 0.12.0-beta.194
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.
|
@@ -8,14 +8,14 @@ describe('Lists', function () {
|
|
|
8
8
|
});
|
|
9
9
|
it('Creates a new record with multiple shelves', function () {
|
|
10
10
|
cy.visit('/#/k_referencing_self_collection/new');
|
|
11
|
-
cy.get('#f_warehouse_name').type("m"
|
|
11
|
+
cy.get('#f_warehouse_name').type("m".concat(unique, " Warehouse"));
|
|
12
12
|
cy.get('#add_f_shelves_btn').click().click().click();
|
|
13
|
-
cy.get('#
|
|
14
|
-
cy.get('#
|
|
15
|
-
cy.get('#
|
|
13
|
+
cy.get('#f_shelves_location_0').type('Top');
|
|
14
|
+
cy.get('#f_shelves_location_1').type('Middle');
|
|
15
|
+
cy.get('#f_shelves_location_2').type('Bottom');
|
|
16
16
|
cy.get('#add_f_items_btn').click();
|
|
17
|
-
cy.get('#
|
|
18
|
-
cy.get('#
|
|
17
|
+
cy.get('#f_items_description_0').type('Item 1');
|
|
18
|
+
cy.get('#f_items_shelf_0').select('Middle');
|
|
19
19
|
cy.get('#add_f_cleanedShelves').click().click();
|
|
20
20
|
cy.get('#f_cleanedShelves_0').select('Middle');
|
|
21
21
|
cy.get('#f_cleanedShelves_1').select('Top');
|
|
@@ -24,12 +24,12 @@ describe('Lists', function () {
|
|
|
24
24
|
});
|
|
25
25
|
it('Creates a new record with a single shelf', function () {
|
|
26
26
|
cy.visit('/#/k_referencing_self_collection/new');
|
|
27
|
-
cy.get('#f_warehouse_name').type("s"
|
|
27
|
+
cy.get('#f_warehouse_name').type("s".concat(unique, " Warehouse"));
|
|
28
28
|
cy.get('#add_f_shelves_btn').click();
|
|
29
|
-
cy.get('#
|
|
29
|
+
cy.get('#f_shelves_location_0').type('Only');
|
|
30
30
|
cy.get('#add_f_items_btn').click();
|
|
31
|
-
cy.get('#
|
|
32
|
-
cy.get('#
|
|
31
|
+
cy.get('#f_items_description_0').type('Item 1');
|
|
32
|
+
cy.get('#f_items_shelf_0').select('Only');
|
|
33
33
|
cy.get('#add_f_cleanedShelves').click();
|
|
34
34
|
cy.get('#f_cleanedShelves_0').select('Only');
|
|
35
35
|
cy.get('#f_favouriteShelf').select('Only');
|
|
@@ -39,7 +39,7 @@ describe('Lists', function () {
|
|
|
39
39
|
cy.visit('/#/l_referencing_list_in_other_document/new');
|
|
40
40
|
cy.get('#f_description').type('An item in multi');
|
|
41
41
|
cy.get('.select2-arrow > b').click();
|
|
42
|
-
cy.get('.ui-select-search').type("m"
|
|
42
|
+
cy.get('.ui-select-search').type("m".concat(unique));
|
|
43
43
|
cy.get('.select2-result-label > .ng-binding').click();
|
|
44
44
|
cy.get('#f_shelf').select('Top');
|
|
45
45
|
});
|
|
@@ -47,7 +47,7 @@ describe('Lists', function () {
|
|
|
47
47
|
cy.visit('/#/l_referencing_list_in_other_document/new');
|
|
48
48
|
cy.get('#f_description').type('An item in single');
|
|
49
49
|
cy.get('.select2-arrow > b').click();
|
|
50
|
-
cy.get('.ui-select-search').type("s"
|
|
50
|
+
cy.get('.ui-select-search').type("s".concat(unique));
|
|
51
51
|
cy.get('.select2-result-label > .ng-binding').click();
|
|
52
52
|
cy.get('#f_shelf').select('Only');
|
|
53
53
|
});
|
|
@@ -12,12 +12,12 @@ describe('Lists', function () {
|
|
|
12
12
|
cy.visit('/#/k_referencing_self_collection/new');
|
|
13
13
|
cy.get('#f_warehouse_name').type(`m${unique} Warehouse`);
|
|
14
14
|
cy.get('#add_f_shelves_btn').click().click().click();
|
|
15
|
-
cy.get('#
|
|
16
|
-
cy.get('#
|
|
17
|
-
cy.get('#
|
|
15
|
+
cy.get('#f_shelves_location_0').type('Top');
|
|
16
|
+
cy.get('#f_shelves_location_1').type('Middle');
|
|
17
|
+
cy.get('#f_shelves_location_2').type('Bottom');
|
|
18
18
|
cy.get('#add_f_items_btn').click();
|
|
19
|
-
cy.get('#
|
|
20
|
-
cy.get('#
|
|
19
|
+
cy.get('#f_items_description_0').type('Item 1');
|
|
20
|
+
cy.get('#f_items_shelf_0').select('Middle');
|
|
21
21
|
cy.get('#add_f_cleanedShelves').click().click();
|
|
22
22
|
cy.get('#f_cleanedShelves_0').select('Middle');
|
|
23
23
|
cy.get('#f_cleanedShelves_1').select('Top');
|
|
@@ -29,10 +29,10 @@ describe('Lists', function () {
|
|
|
29
29
|
cy.visit('/#/k_referencing_self_collection/new');
|
|
30
30
|
cy.get('#f_warehouse_name').type(`s${unique} Warehouse`);
|
|
31
31
|
cy.get('#add_f_shelves_btn').click();
|
|
32
|
-
cy.get('#
|
|
32
|
+
cy.get('#f_shelves_location_0').type('Only');
|
|
33
33
|
cy.get('#add_f_items_btn').click();
|
|
34
|
-
cy.get('#
|
|
35
|
-
cy.get('#
|
|
34
|
+
cy.get('#f_items_description_0').type('Item 1');
|
|
35
|
+
cy.get('#f_items_shelf_0').select('Only');
|
|
36
36
|
cy.get('#add_f_cleanedShelves').click();
|
|
37
37
|
cy.get('#f_cleanedShelves_0').select('Only');
|
|
38
38
|
cy.get('#f_favouriteShelf').select('Only');
|
package/package.json
CHANGED
package/src/fng-ui-select.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
var uiSelectModule = angular.module('fng.uiSelect', ['ui.select']);
|
|
5
5
|
|
|
6
|
-
uiSelectModule.factory('uiSelectHelper', ['$rootScope', '$q', 'SubmissionsService', function ($rootScope, $q, SubmissionsService) {
|
|
6
|
+
uiSelectModule.factory('uiSelectHelper', ['$rootScope', '$q', 'recordHandler', 'SubmissionsService', function ($rootScope, $q, recordHandler, SubmissionsService) {
|
|
7
7
|
var lastW, lastH;
|
|
8
8
|
const localLookups = {};
|
|
9
9
|
// this ultra-simple cache stores { [id: string]: stringValue } as a means of avoiding unnecessary network round-trips, and the UI refresh
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
function useCacheOrLookItUp(resourceName, id, cb) {
|
|
25
25
|
if (valueCache[id]) {
|
|
26
26
|
cb(valueCache[id]);
|
|
27
|
-
} else
|
|
27
|
+
} else {
|
|
28
28
|
var text;
|
|
29
29
|
SubmissionsService.getListAttributes(resourceName, id)
|
|
30
30
|
.then((response) => {
|
|
@@ -37,7 +37,9 @@
|
|
|
37
37
|
cb(text);
|
|
38
38
|
valueCache[id] = text;
|
|
39
39
|
})
|
|
40
|
+
}
|
|
40
41
|
}
|
|
42
|
+
|
|
41
43
|
return {
|
|
42
44
|
windowChanged: function (w, h) {
|
|
43
45
|
var result = false;
|
|
@@ -57,11 +59,7 @@
|
|
|
57
59
|
lookupFunc: function (value, formSchema, cb) {
|
|
58
60
|
if (formSchema.array) {
|
|
59
61
|
const promises = value.map((value) => {
|
|
60
|
-
|
|
61
|
-
// if it's already been converted, throw away the result of the previous conversion
|
|
62
|
-
if (id && id.id) {
|
|
63
|
-
id = id.id;
|
|
64
|
-
}
|
|
62
|
+
const id = value.x?.id || value.x; // if it's already been converted, throw away the result of the previous conversion
|
|
65
63
|
if (!id) {
|
|
66
64
|
return $q.resolve({ data: { list: ""} }); // nothing to convert
|
|
67
65
|
} else if (valueCache[id]) {
|
|
@@ -89,11 +87,18 @@
|
|
|
89
87
|
cb(formSchema, value); // already converted
|
|
90
88
|
} else if (formSchema.fngUiSelect.deriveOptions) {
|
|
91
89
|
const obj = localLookups[formSchema.fngUiSelect.deriveOptions].find((test) => test.id === value);
|
|
92
|
-
cb(formSchema, { id: value, text: obj
|
|
90
|
+
cb(formSchema, { id: value, text: obj?.text || "" });
|
|
93
91
|
} else {
|
|
94
92
|
useCacheOrLookItUp(formSchema.ref, value, (text) => { cb(formSchema, { id: value, text }) });
|
|
95
93
|
}
|
|
96
94
|
},
|
|
95
|
+
doOwnConversion: function(scope, processedAttrs, ref) {
|
|
96
|
+
var id = recordHandler.getData(scope.record, processedAttrs.info.name, scope.$index);
|
|
97
|
+
if (id) {
|
|
98
|
+
id = id.id || id; // in case it's already been converted
|
|
99
|
+
useCacheOrLookItUp(ref, id, (text) => { recordHandler.setData(scope.record, processedAttrs.info.name, scope.$index, { id, text }) });
|
|
100
|
+
}
|
|
101
|
+
}
|
|
97
102
|
};
|
|
98
103
|
}]);
|
|
99
104
|
|
|
@@ -103,7 +108,8 @@
|
|
|
103
108
|
$scope.uiSelect = $scope.uiSelect || [];
|
|
104
109
|
|
|
105
110
|
$scope.windowResizeUiSelect = function (checkResize) {
|
|
106
|
-
// This is to stop the resize firing too often. Really horrible way of doing it caused by some very regrettable
|
|
111
|
+
// This is to stop the resize firing too often. Really horrible way of doing it caused by some very regrettable
|
|
112
|
+
// design choices which will be factored out later
|
|
107
113
|
// Actually not choices - just not knowing any better
|
|
108
114
|
if (!checkResize || uiSelectHelper.windowChanged($window.innerWidth, $window.innerHeight)) {
|
|
109
115
|
for (var i = 0; i < $scope.uiSelect.length; i++) {
|
|
@@ -134,7 +140,10 @@
|
|
|
134
140
|
$scope[id + '_options'] = [];
|
|
135
141
|
} else {
|
|
136
142
|
var promise;
|
|
137
|
-
if (elem.filter && elem.filter[0] ===
|
|
143
|
+
if (elem.filter && typeof elem.filter === "string" && elem.filter[0] === "/") {
|
|
144
|
+
if (elem.filter.startsWith("/api/")) {
|
|
145
|
+
console.log("WARNING! fng-ui-select is using an /api/ endpoint to refresh options - this is likely to cause security authorisation problems");
|
|
146
|
+
}
|
|
138
147
|
// HACK We want to pass the existing record in e, but we can fall foul of 431 errors if it is large, so we test for that
|
|
139
148
|
// using an arbitrary number and if so just send the _id (on the assumption that large records won't be new so will have an _id).
|
|
140
149
|
// According to https://stackoverflow.com/questions/57431355/how-to-fix-431-request-header-fields-too-large-in-react-redux-app the limit is 8KB
|
|
@@ -191,12 +200,12 @@
|
|
|
191
200
|
$timeout($scope.windowResizeUiSelect);
|
|
192
201
|
}]);
|
|
193
202
|
|
|
194
|
-
uiSelectModule.directive('fngUiSelect', ['$compile', '
|
|
195
|
-
function ($compile,
|
|
203
|
+
uiSelectModule.directive('fngUiSelect', ['$compile', 'pluginHelper', 'cssFrameworkService', 'uiSelectHelper', '$timeout',
|
|
204
|
+
function ($compile, pluginHelper, cssFrameworkService, uiSelectHelper, $timeout) {
|
|
196
205
|
return {
|
|
197
206
|
restrict: 'E',
|
|
198
207
|
controller: 'FngUISelectCtrl',
|
|
199
|
-
link: function (scope, element,
|
|
208
|
+
link: function (scope, element, attrs) {
|
|
200
209
|
|
|
201
210
|
function addToConversions(path, options) {
|
|
202
211
|
if (Object.keys(options).length > 0) {
|
|
@@ -214,18 +223,20 @@
|
|
|
214
223
|
}
|
|
215
224
|
}
|
|
216
225
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
226
|
+
const processedAttrs = pluginHelper.extractFromAttr(attrs, 'fngUiSelect');
|
|
227
|
+
const id = processedAttrs.info.id;
|
|
228
|
+
const uniqueId = scope.$index !== undefined ? processedAttrs.info.id + "_" + scope.$index : id;
|
|
229
|
+
const elemScope = angular.extend({selectId: uniqueId}, processedAttrs.directiveOptions);
|
|
230
|
+
const multi = processedAttrs.info.array;
|
|
231
|
+
let elementHtml;
|
|
232
|
+
let input = '';
|
|
222
233
|
|
|
223
234
|
scope.uiSelect.push(elemScope);
|
|
224
|
-
addToConversions(
|
|
235
|
+
addToConversions(processedAttrs.info.name, processedAttrs.directiveOptions);
|
|
225
236
|
|
|
226
237
|
// Sort out the theme, defaulting to select2 (so old users won't see the change). Bootstrap theme only works with Bootstrap 3
|
|
227
238
|
// and not with animate (see https://github.com/angular-ui/ui-select/issues/1731 and others)
|
|
228
|
-
var theme =
|
|
239
|
+
var theme = processedAttrs.directiveOptions.theme || 'select2';
|
|
229
240
|
if (theme === 'bootstrap') {
|
|
230
241
|
if (cssFrameworkService.framework() !== 'bs3') {
|
|
231
242
|
theme = 'select2';
|
|
@@ -242,10 +253,10 @@
|
|
|
242
253
|
|
|
243
254
|
var multiControl = false;
|
|
244
255
|
var multiStr = '';
|
|
245
|
-
if (multi && (
|
|
256
|
+
if (multi && (processedAttrs.directiveOptions.fngajax || processedAttrs.directiveOptions.forcemultiple)) {
|
|
246
257
|
// We need the array to be an array of objects with a x property. This tells forms-angular to convert it by
|
|
247
258
|
// adding an attribute to the schema.
|
|
248
|
-
pluginHelper.findIdInSchemaAndFlagNeedX(scope.baseSchema(),
|
|
259
|
+
pluginHelper.findIdInSchemaAndFlagNeedX(scope.baseSchema(), id);
|
|
249
260
|
multiControl = true;
|
|
250
261
|
} else {
|
|
251
262
|
multiStr = multi ? 'multiple close-on-select reset-search-input ' : '';
|
|
@@ -253,38 +264,45 @@
|
|
|
253
264
|
|
|
254
265
|
var requiredStr = '';
|
|
255
266
|
var allowClearStr = '';
|
|
256
|
-
if (
|
|
267
|
+
if (processedAttrs.info.required) {
|
|
257
268
|
requiredStr = ' ng-required="true"';
|
|
269
|
+
} else if (processedAttrs.directiveOptions.ngrequired) {
|
|
270
|
+
requiredStr = ` ng-required="${processedAttrs.directiveOptions.ngrequired}"`;
|
|
258
271
|
} else {
|
|
259
272
|
allowClearStr = ' allow-clear';
|
|
260
273
|
}
|
|
261
|
-
|
|
262
|
-
if (processedAttr.directiveOptions.ngdisabled) {
|
|
263
|
-
disabledStr = ` ng-disabled="${processedAttr.directiveOptions.ngdisabled}"`
|
|
264
|
-
} else {
|
|
265
|
-
disabledStr = ' ng-disabled="disabled"';
|
|
266
|
-
}
|
|
274
|
+
let disabledStr = pluginHelper.genIdAndDisabledStr(scope, processedAttrs, "", { forceNg: true });
|
|
267
275
|
|
|
268
276
|
// First of all add a hidden input field which we will use to set the width of the select
|
|
269
|
-
if (!angular.element(
|
|
277
|
+
if (!angular.element(`#${uniqueId}_width-helper`).length > 0) {
|
|
270
278
|
var hiddenInputInfo = {
|
|
271
|
-
id:
|
|
272
|
-
name:
|
|
279
|
+
id: `${uniqueId}_width-helper`,
|
|
280
|
+
name: processedAttrs.info.name + '_width-helper',
|
|
273
281
|
label: ''
|
|
274
282
|
};
|
|
275
|
-
if (
|
|
276
|
-
hiddenInputInfo.size =
|
|
283
|
+
if (processedAttrs.info.size) {
|
|
284
|
+
hiddenInputInfo.size = processedAttrs.info.size;
|
|
277
285
|
}
|
|
278
|
-
input = pluginHelper.buildInputMarkup(
|
|
279
|
-
|
|
280
|
-
|
|
286
|
+
input = pluginHelper.buildInputMarkup(
|
|
287
|
+
scope,
|
|
288
|
+
attrs,
|
|
289
|
+
{
|
|
290
|
+
processedAttrs,
|
|
291
|
+
fieldInfoOverrides: hiddenInputInfo,
|
|
292
|
+
ignoreFieldInfoFromAttrs: true,
|
|
293
|
+
needsX: multiControl
|
|
294
|
+
},
|
|
295
|
+
function () {
|
|
296
|
+
return '<input id="' + hiddenInputInfo.id + '" type="text" class="form-control" disabled="" aria-label="unused input" style="position: absolute; left: -4200px;">';
|
|
297
|
+
}
|
|
298
|
+
);
|
|
281
299
|
input = input.replace('class="row', 'class="hidden-row row')
|
|
282
300
|
}
|
|
283
301
|
|
|
284
302
|
function optionsFromArray(multiControl, multi, array, arrayGetter) {
|
|
285
303
|
var isObjects = scope[array] && (scope[array].isObjects || typeof scope[array][0] === "object");
|
|
286
304
|
if (isObjects) {
|
|
287
|
-
addToConversions(
|
|
305
|
+
addToConversions(processedAttrs.info.name, {fngajax: uiSelectHelper.lookupFunc});
|
|
288
306
|
uiSelectHelper.addClientLookup(arrayGetter, scope[array]);
|
|
289
307
|
}
|
|
290
308
|
var select = '';
|
|
@@ -299,54 +317,96 @@
|
|
|
299
317
|
return select;
|
|
300
318
|
}
|
|
301
319
|
|
|
302
|
-
elementHtml = pluginHelper.buildInputMarkup(
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
if (processedAttr.directiveOptions.fngajax !== true) {
|
|
315
|
-
elemScope.filter = processedAttr.directiveOptions.fngajax;
|
|
320
|
+
elementHtml = pluginHelper.buildInputMarkup(
|
|
321
|
+
scope,
|
|
322
|
+
attrs,
|
|
323
|
+
{
|
|
324
|
+
processedAttrs,
|
|
325
|
+
addButtons: multiControl,
|
|
326
|
+
needsX: multiControl,
|
|
327
|
+
},
|
|
328
|
+
function (buildingBlocks) {
|
|
329
|
+
var defaultPlaceholder = 'Select an option...';
|
|
330
|
+
if (processedAttrs.directiveOptions.fngajax) {
|
|
331
|
+
defaultPlaceholder = 'Start typing...'
|
|
316
332
|
}
|
|
317
|
-
//
|
|
318
|
-
|
|
319
|
-
//
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
333
|
+
// set up the ui-select directives
|
|
334
|
+
// hack here. buildingBlocks.common will almost certainly contain 'id="xxxx"', but we don't want this because the
|
|
335
|
+
// id will already be in disabledStr. remove it.
|
|
336
|
+
// the right solution here would be to include an option in the params that are passed to buildInputMarkup which
|
|
337
|
+
// specifies whether or not the buildingBlocks that it creates should include the id or not.
|
|
338
|
+
const idIdx = buildingBlocks.common.indexOf('id="');
|
|
339
|
+
if (idIdx > -1) {
|
|
340
|
+
const endIdIdx = buildingBlocks.common.indexOf('"', idIdx+4);
|
|
341
|
+
if (endIdIdx > -1) {
|
|
342
|
+
buildingBlocks.common = buildingBlocks.common.substring(0, idIdx) + buildingBlocks.common.substring(endIdIdx + 1);
|
|
343
|
+
}
|
|
328
344
|
}
|
|
329
|
-
select
|
|
330
|
-
select += '<ui-select-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
345
|
+
var select = '<ui-select ' + multiStr + buildingBlocks.common + requiredStr + disabledStr + ' theme="' + theme + '" style="min-width:18em;">'
|
|
346
|
+
select += '<ui-select-match' + allowClearStr + ' placeholder="' + (processedAttrs.info.placeholder || defaultPlaceholder) + '">';
|
|
347
|
+
|
|
348
|
+
if (processedAttrs.directiveOptions.fngajax) {
|
|
349
|
+
// Stash any filters
|
|
350
|
+
if (processedAttrs.directiveOptions.fngajax !== true) {
|
|
351
|
+
elemScope.filter = processedAttrs.directiveOptions.fngajax;
|
|
352
|
+
}
|
|
353
|
+
// if we have a hard-coded ref (processedAttrs.info.ref), forms-angular can perform the lookup conversion for us.
|
|
354
|
+
// where processedAttrs.directiveOptions.refprop is being used instead, the ref is 'variable' - it comes from a property of scope.record, and
|
|
355
|
+
// in this case, we'll need to handle the conversions ourselves.
|
|
356
|
+
addToConversions(processedAttrs.info.name, {fngajax: uiSelectHelper.lookupFunc, noconvert: !!processedAttrs.directiveOptions.refprop});
|
|
357
|
+
if (processedAttrs.directiveOptions.refprop) {
|
|
358
|
+
// the property that we'll be getting the ref from may not be populated yet, and might conceivably change at any time, so we
|
|
359
|
+
// need to $watch it. buildingBlocks.modelString will be something like "record.<array>[$index].<field>". replacing <field>
|
|
360
|
+
// with the value of refprop will give us a suitable watch expression.
|
|
361
|
+
const watchStr = buildingBlocks.modelString.substring(0, buildingBlocks.modelString.lastIndexOf(".") + 1) + processedAttrs.directiveOptions.refprop;
|
|
362
|
+
scope.$watch(watchStr, (newValue) => {
|
|
363
|
+
if (newValue && elemScope.ref !== newValue) {
|
|
364
|
+
elemScope.ref = newValue;
|
|
365
|
+
uiSelectHelper.doOwnConversion(scope, processedAttrs, elemScope.ref);
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
// we also need to re-do the conversion if the user cancels changes. this event does fire on more than just user cancellation,
|
|
369
|
+
// so this is slightly wasteful. but with the caching implemented by uiSelectHelper, this is no big deal.
|
|
370
|
+
scope.$on("fngCancel", () => {
|
|
371
|
+
$timeout(() => {
|
|
372
|
+
if (elemScope.ref) {
|
|
373
|
+
uiSelectHelper.doOwnConversion(scope, processedAttrs, elemScope.ref);
|
|
374
|
+
}
|
|
375
|
+
});
|
|
376
|
+
});
|
|
377
|
+
} else {
|
|
378
|
+
elemScope.ref = processedAttrs.info.ref;
|
|
379
|
+
}
|
|
380
|
+
scope[`${uniqueId}_options`] = [];
|
|
381
|
+
if (multiControl) {
|
|
382
|
+
select += '{{$select.selected.text}}';
|
|
383
|
+
} else if (processedAttrs.options.subschema) {
|
|
384
|
+
select += '{{' + attrs.model + '.' + processedAttrs.info.name.replace(processedAttrs.options.subschemaroot, processedAttrs.options.subschemaroot + '[$index]') + '.text}}';
|
|
385
|
+
} else {
|
|
386
|
+
select += '{{' + buildingBlocks.modelString + '.text}}';
|
|
387
|
+
}
|
|
388
|
+
select += '</ui-select-match>';
|
|
389
|
+
select += `<ui-select-choices repeat="option in (${uniqueId}_options) track by $index" `;
|
|
390
|
+
select += `refresh="refreshOptions($select.search, '${uniqueId}')" `;
|
|
391
|
+
select += 'refresh-delay="400"> ';
|
|
392
|
+
select += '<div ng-bind-html="option.text" ng-attr-title="{{ option.text }}"></div>';
|
|
393
|
+
} else if (processedAttrs.directiveOptions.deriveoptions) {
|
|
394
|
+
if (typeof scope[processedAttrs.directiveOptions.deriveoptions] === "function") {
|
|
395
|
+
select += optionsFromArray(multiControl, multi, scope[processedAttrs.directiveOptions.deriveoptions](), processedAttrs.directiveOptions.deriveoptions);
|
|
396
|
+
} else {
|
|
397
|
+
throw new Error("In fng-ui-select " + processedAttrs.directiveOptions.deriveoptions + " is not a function on the scope");
|
|
398
|
+
}
|
|
399
|
+
} else if (processedAttrs.info.options) {
|
|
400
|
+
// Simple case - enumerated options on the form scope
|
|
401
|
+
select += optionsFromArray(multiControl, multi, processedAttrs.info.options);
|
|
337
402
|
} else {
|
|
338
|
-
throw new Error(
|
|
403
|
+
throw new Error('fng-ui-select has no means of populating select');
|
|
339
404
|
}
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
select
|
|
343
|
-
} else {
|
|
344
|
-
throw new Error('fng-ui-select has no means of populating select');
|
|
405
|
+
select += '</ui-select-choices>';
|
|
406
|
+
select += '</ui-select>';
|
|
407
|
+
return select;
|
|
345
408
|
}
|
|
346
|
-
|
|
347
|
-
select += '</ui-select>';
|
|
348
|
-
return select;
|
|
349
|
-
});
|
|
409
|
+
);
|
|
350
410
|
element.append($compile(input + elementHtml)(scope));
|
|
351
411
|
}
|
|
352
412
|
}
|