Skip to content

Commit 935ae77

Browse files
committed
Make plugin handle both name/value and name/text according to standard
Change examples into name/text Add deprecation notice in documentation
1 parent a38bd7c commit 935ae77

10 files changed

+42
-36
lines changed

README.md

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ Features:
1212
* Sync and Async callbacks
1313
* HTTP GET/POST convenience functions
1414

15+
<b>Note:<br />
16+
Since 0.3.3 value/name-pairs for drop down data is deprecated.<br />
17+
The correct way, and how the HTML select element actually works, is value/text.<br />
18+
The the add-on still supports both variants, but value/name will either be removed or<br />
19+
replaced by a mapping in a later major version.
20+
<b />
1521

1622
#Installation
1723

@@ -73,33 +79,33 @@ All settings are made in the form definition. Sehttp://gulpjs.com/e the app.js f
7379

7480

7581
### Single select from static list
76-
The selection is an array of value/name objects
82+
The selection is an array of value/text objects
7783

7884
{
7985
"key": 'select',
8086
"type": 'strapselect',
8187
"items": [
82-
{"value": 'value1', "name": 'label1'},
83-
{"value": 'value2', "name": 'label2'},
84-
{"value": 'value3', "name": 'label3'}
88+
{"value": 'value1', "text": 'label1'},
89+
{"value": 'value2', "text": 'label2'},
90+
{"value": 'value3', "text": 'label3'}
8591
]
8692
},
8793
8894
### Single select from static list
89-
The selection is an array of value/name objects
95+
The selection is an array of value/text objects
9096

9197
{
9298
"key": 'multiselect',
9399
"type": 'strapmultiselect',
94100
"items": [
95-
{"value": 'value1', "name": 'label1'},
96-
{"value": 'value2', "name": 'label2'},
97-
{"value": 'value3', "name": 'long very very long label3'}
101+
{"value": 'value1', "text": 'label1'},
102+
{"value": 'value2', "text": 'label2'},
103+
{"value": 'value3', "text": 'long very very long label3'}
98104
]
99105
},
100106
101107
### Single select from dynamically loaded list via synchronous callback function
102-
Callback must return an array of value/name objects (see static list above)
108+
Callback must return an array of value/text objects (see static list above)
103109

104110
{
105111
"key": "selectdynamic",
@@ -110,7 +116,7 @@ Callback must return an array of value/name objects (see static list above)
110116
},
111117
112118
### Multiple select from dynamically loaded list via synchronous callback function
113-
Callback must return an array of value/name objects.
119+
Callback must return an array of value/text objects.
114120

115121
{
116122
"key": "multiselectdynamic",
@@ -122,7 +128,7 @@ Callback must return an array of value/name objects.
122128

123129
### Multiple select from dynamically loaded list via http post
124130
Convenience function, makes a JSON post request passing the "parameter" as is, no need for callback.
125-
Expects the server to return a JSON array of value/name objects.
131+
Expects the server to return a JSON array of value/text objects.
126132

127133
{
128134
"key": "multiselectdynamic_http_post",
@@ -137,7 +143,7 @@ Expects the server to return a JSON array of value/name objects.
137143

138144
### Multiple select from dynamically loaded list via http get
139145
Convenience function, makes a get request, no need for callback.
140-
Expects the server to return a JSON array of value/name objects.
146+
Expects the server to return a JSON array of value/text objects.
141147

142148
{
143149
"key": "multiselectdynamic_http_get",
@@ -153,7 +159,7 @@ Expects the server to return a JSON array of value/name objects.
153159
Note that the "call" parameter is the only mandatory parameter, the "url" is for convenience.
154160
The point is that the "options" structure is passed to all callbacks, making it possible to use fever callback function,
155161
allowing for cleaner(or not) code.
156-
The callback shall return a http-style promise and the data must be a JSON array of value/name objects.
162+
The callback shall return a http-style promise and the data must be a JSON array of value/text objects.
157163

158164
{
159165
"key": "multiselectdynamic_async",

angular-schema-form-dynamic-select.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
angular.module("schemaForm").run(["$templateCache", function($templateCache) {$templateCache.put("directives/decorators/bootstrap/strap/strapmultiselect.html","<div class=\"form-group\" ng-class=\"{\'has-error\': hasError(), \'has-success\': hasSuccess()}\">\n <label class=\"control-label\" ng-show=\"showTitle()\">{{form.title}}</label>\n <div class=\"form-group\">\n <button type=\"button\" class=\"btn btn-default\" sf-changed=\"form\" ng-model=\"$$value$$\" schema-validate=\"form\"\n data-placeholder=\"{{form.placeholder || form.schema.placeholder || (\'placeholders.select\')}}\"\n data-multiple=\"1\" data-html=\"1\" ng-options=\"item.value as item.name for item in form.items\" bs-select>\n </button>\n <span class=\"help-block\">{{ (hasError() && errorMessage(schemaError())) || form.description}}</span>\n </div>\n</div>\n");
2-
$templateCache.put("directives/decorators/bootstrap/strap/strapmultiselectdynamic.html","<div class=\"form-group\" ng-class=\"{\'has-error\': hasError(), \'has-success\': hasSuccess()}\">\n <label class=\"control-label\" ng-show=\"showTitle()\">{{form.title}}</label>\n <div class=\"form-group\" ng-controller=\"StrapSelectController\" ng-init=\"fetchResult(form.options)\">\n <button type=\"button\" class=\"btn btn-default\" sf-changed=\"form\" ng-model=\"$$value$$\" schema-validate=\"form\"\n data-placeholder=\"{{form.placeholder || form.schema.placeholder || (\'placeholders.select\')}}\"\n data-multiple=\"1\" data-html=\"1\" ng-options=\"item.value as item.name for item in items\" bs-select>\n </button>\n <span class=\"help-block\">{{ (hasError() && errorMessage(schemaError())) || form.description}}</span>\n </div>\n</div>\n");
3-
$templateCache.put("directives/decorators/bootstrap/strap/strapselect.html","<div class=\"form-group\" ng-class=\"{\'has-error\': hasError(), \'has-success\': hasSuccess()}\">\n <label class=\"control-label\" ng-show=\"showTitle()\">{{form.title}}</label>\n <div class=\"form-group\">\n <button type=\"button\" class=\"btn btn-default\" sf-changed=\"form\" ng-model=\"$$value$$\" schema-validate=\"form\"\n data-placeholder=\"{{form.placeholder || form.schema.placeholder ||(\'placeholders.select\')}}\"\n data-html=\"1\" ng-options=\"item.value as item.name for item in form.items\" bs-select>\n </button>\n <span class=\"help-block\">{{ (hasError() && errorMessage(schemaError())) || form.description}}</span>\n </div>\n</div>\n");
4-
$templateCache.put("directives/decorators/bootstrap/strap/strapselectdynamic.html","<div class=\"form-group\" ng-class=\"{\'has-error\': hasError(), \'has-success\': hasSuccess()}\">\n <label class=\"control-label\" ng-show=\"showTitle()\">{{form.title}}</label>\n <div class=\"form-group\" ng-controller=\"StrapSelectController\" ng-init=\"fetchResult(form.options)\">\n <button type=\"button\" class=\"btn btn-default\" sf-changed=\"form\" ng-model=\"$$value$$\" schema-validate=\"form\"\n data-placeholder=\"{{form.placeholder || form.schema.placeholder ||(\'placeholders.select\')}}\"\n data-html=\"1\" ng-options=\"item.value as item.name for item in items\" bs-select>\n </button>\n <span class=\"help-block\">{{ (hasError() && errorMessage(schemaError())) || form.description}}</span>\n </div>\n</div>\n");}]);
1+
angular.module("schemaForm").run(["$templateCache", function($templateCache) {$templateCache.put("directives/decorators/bootstrap/strap/strapmultiselect.html","<div class=\"form-group\" ng-class=\"{\'has-error\': hasError(), \'has-success\': hasSuccess()}\">\n <label class=\"control-label\" ng-show=\"showTitle()\">{{form.title}}</label>\n <div class=\"form-group\">\n <button type=\"button\" class=\"btn btn-default\" sf-changed=\"form\" ng-model=\"$$value$$\" schema-validate=\"form\"\n data-placeholder=\"{{form.placeholder || form.schema.placeholder || (\'placeholders.select\')}}\"\n data-multiple=\"1\" data-html=\"1\" ng-options=\"item.value as (item.text == null ? item.name : item.text) for item in form.items\" bs-select>\n </button>\n <span class=\"help-block\">{{ (hasError() && errorMessage(schemaError())) || form.description}}</span>\n </div>\n</div>\n");
2+
$templateCache.put("directives/decorators/bootstrap/strap/strapmultiselectdynamic.html","<div class=\"form-group\" ng-class=\"{\'has-error\': hasError(), \'has-success\': hasSuccess()}\">\n <label class=\"control-label\" ng-show=\"showTitle()\">{{form.title}}</label>\n <div class=\"form-group\" ng-controller=\"StrapSelectController\" ng-init=\"fetchResult(form.options)\">\n <button type=\"button\" class=\"btn btn-default\" sf-changed=\"form\" ng-model=\"$$value$$\" schema-validate=\"form\"\n data-placeholder=\"{{form.placeholder || form.schema.placeholder || (\'placeholders.select\')}}\"\n data-multiple=\"1\" data-html=\"1\" ng-options=\"item.value as (item.text == null ? item.name : item.text) for item in items\" bs-select>\n </button>\n <span class=\"help-block\">{{ (hasError() && errorMessage(schemaError())) || form.description}}</span>\n </div>\n</div>\n");
3+
$templateCache.put("directives/decorators/bootstrap/strap/strapselect.html","<div class=\"form-group\" ng-class=\"{\'has-error\': hasError(), \'has-success\': hasSuccess()}\">\n <label class=\"control-label\" ng-show=\"showTitle()\">{{form.title}}</label>\n <div class=\"form-group\">\n <button type=\"button\" class=\"btn btn-default\" sf-changed=\"form\" ng-model=\"$$value$$\" schema-validate=\"form\"\n data-placeholder=\"{{form.placeholder || form.schema.placeholder ||(\'placeholders.select\')}}\"\n data-html=\"1\" ng-options=\"item.value as (item.text == null ? item.name : item.text) for item in form.items\" bs-select>\n </button>\n <span class=\"help-block\">{{ (hasError() && errorMessage(schemaError())) || form.description}}</span>\n </div>\n</div>\n");
4+
$templateCache.put("directives/decorators/bootstrap/strap/strapselectdynamic.html","<div class=\"form-group\" ng-class=\"{\'has-error\': hasError(), \'has-success\': hasSuccess()}\">\n <label class=\"control-label\" ng-show=\"showTitle()\">{{form.title}}</label>\n <div class=\"form-group\" ng-controller=\"StrapSelectController\" ng-init=\"fetchResult(form.options)\">\n <button type=\"button\" class=\"btn btn-default\" sf-changed=\"form\" ng-model=\"$$value$$\" schema-validate=\"form\"\n data-placeholder=\"{{form.placeholder || form.schema.placeholder ||(\'placeholders.select\')}}\"\n data-html=\"1\" ng-options=\"item.value as (item.text == null ? item.name : item.text) for item in items\" bs-select>\n </button>\n <span class=\"help-block\">{{ (hasError() && errorMessage(schemaError())) || form.description}}</span>\n </div>\n</div>\n");}]);
55
angular.module('schemaForm').config(
66
['schemaFormProvider', 'schemaFormDecoratorsProvider', 'sfPathProvider',
77
function(schemaFormProvider, schemaFormDecoratorsProvider, sfPathProvider) {

0 commit comments

Comments
 (0)