Skip to content

Commit e8e0a39

Browse files
committed
Merge remote-tracking branch 'origin/develop'
# Conflicts: # angular-schema-form-dynamic-select.js # angular-schema-form-dynamic-select.min.js # src/angular-schema-form-dynamic-select.js
2 parents e7b7d0d + a9e598e commit e8e0a39

File tree

4 files changed

+27
-6
lines changed

4 files changed

+27
-6
lines changed

README.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ Usage is straightforward, simply include and reference:
130130
<script src="bower_components/angular-schema-form/dist/schema-form.min.js"></script>
131131
<script src="bower_components/angular-schema-form/dist/bootstrap-decorator.min.js"></script>
132132
<script src="bower_components/angular-schema-form-dynamic-select/angular-schema-form-dynamic-select.js"></script>
133+
133134
```
134135
<i>Note: Make sure you load angular-schema-form-dynamic-select.js **after** loading angular schema form.</i>
135136

@@ -235,7 +236,7 @@ The asyncCallback must return a *http-style promise* and the data the promise pr
235236
},
236237
```
237238
Note that in this example, the reference to the callback is a string, meaning a callback in the using controller scope.
238-
Also note, again, because this is a common misunderstanding, that asyncCallback should *not* return the array of items, but a http-promise, like the one $http.get()/$http.post()
239+
Also note, again, because this is a common misunderstanding, that asyncCallback should *not* return the array of items, but a http-promise, like the one $http.get()/$http.post() or [jquery's deferred.promise](https://api.jquery.com/deferred.promise/).
239240
Returning the array would be a synchronous operation, see "callback" above.
240241

241242
### Multiple select from dynamically loaded list via http get
@@ -339,7 +340,7 @@ Example:
339340
"filterTriggers": ["model.select"],
340341
"filter" : "model.select==item.category"
341342
},
342-
"items": [
343+
"titleMap": [
343344
{"value": 'value1', "name": 'text1', "category": "value1"},
344345
{"value": 'value2', "name": 'text2', "category": "value1"},
345346
{"value": 'value3', "name": 'long very very long label3'}
@@ -459,12 +460,24 @@ The two kinds of callback mechanisms are:
459460
* the optional optionsCallback can be used to add to or change the options with information known in runtime.
460461
* httpPost-options has a "parameter"-property, that contains the JSON that will be POST:ed to the server.
461462

463+
### Handling errors from asynchronous callbacks
464+
For asyncCallback, httpGet and httpPost, there is an option, `onPopulationError`.
465+
466+
If set to a callback function, and in case of a http error, the callback is called.
467+
Its parameters are: the form of the field(where they key and options are), the data and the status.
468+
469+
See app.js for an example of its usage. Try and rename test/testdata.js and you'll see it being called.
470+
462471
## Statically setting the list items
463472

464473
This is done by either using the JSON-schema enum-property, or by manually setting form.titleMap.
465474

466475
# UI-Select
467-
The support for angular-ui-select was added in the 0.9.0-version, and is currently partial.
476+
The support for angular-ui-select was added in the 0.9.0-version, and is currently partial, but getting there.
477+
478+
The currently supported UI-select specific/native options are:
479+
* Single: tagging, taggingTokens, taggingLabel, refreshDelay, searchDescription, uiClass
480+
* Multiple select: refreshDelay, uiClass, groupBy(only multiple)
468481

469482
## Installation
470483

app.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ testApp.controller("appController", ["$scope", "$http", function ($scope, $http)
7272
return options;
7373
};
7474

75+
$scope.onPopulationError = function (form, data, status) {
76+
console.log("An error occurred when the " + form.key + "-fields drop down was to be populated! \n")
77+
console.log("The data: " + data.data.toString());
78+
console.log("The status: " + status);
79+
};
80+
7581
$scope.schema = {
7682
type: "object",
7783
title: "Select",
@@ -303,6 +309,7 @@ testApp.controller("appController", ["$scope", "$http", function ($scope, $http)
303309
"options": {
304310
"multiple": "true",
305311
"asyncCallback": $scope.callBackMSDAsync,
312+
"onPopulationError": "onPopulationError",
306313
"urlOrWhateverOptionIWant": "test/testdata.json"
307314
}
308315
},

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"angular-schema-form": ">= 0.8.0",
2626
"angular-strap": ">= 2.2.2",
2727
"bootstrap": "^3.2.0",
28-
"ui-select": "^0.11.0"
28+
"ui-select": "^0.12.0"
2929
},
3030
"main": "angular-schema-form-dynamic-select.js",
3131
"repository": {

src/uiselectmultiple.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
<ui-select-match placeholder="{{form.placeholder || form.schema.placeholder || ('placeholders.select' | translate)}}">{{$item.name}}</ui-select-match>
1010
<ui-select-choices repeat="item in form.titleMap | propsFilter: {name: $select.search}"
1111
refresh="populateTitleMap(form, $select.search)"
12-
refresh-delay="form.options.refreshDelay">
12+
refresh-delay="form.options.refreshDelay"
13+
group-by="form.options.groupBy">
1314
<div ng-bind-html="item.name | highlight: $select.search"></div>
1415
</ui-select-choices>
1516
</ui-select>
@@ -20,4 +21,4 @@
2021
ng-show="(hasError() && errorMessage(schemaError())) || form.description"
2122
ng-bind-html="(hasError() && errorMessage(schemaError())) || form.description"></div>
2223
</div>
23-
</div>
24+
</div>

0 commit comments

Comments
 (0)