Skip to content

Commit 6548657

Browse files
committed
Update templates to work better with arrays
1 parent 98e28f7 commit 6548657

11 files changed

+45
-43
lines changed

dist/angular-schema-form-bootstrap-bundled.js

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ return /******/ (function(modules) { // webpackBootstrap
251251
/***/ function(module, exports) {
252252

253253
var path = 'bootstrap/fieldset.html';
254-
var html = "<fieldset ng-disabled=\"form.readonly\" class=\"schema-form-fieldset {{::form.htmlClass}}\">\r\n <legend ng-class=\"{'sr-only': !showTitle() }\">{{ form.title }}</legend>\r\n <div class=\"help-block\" ng-show=\"form.description\" ng-bind-html=\"form.description\"></div>\r\n</fieldset>\r\n";
254+
var html = "<fieldset ng-disabled=\"form.readonly\" class=\"schema-form-fieldset {{::form.htmlClass}}\" sf-key-controller sf-parent-key=\"[{{form.key.join('][')}}]\" sf-index=\"{{$index}}\">\r\n <legend ng-class=\"{'sr-only': !showTitle() }\">{{ form.title }}</legend>\r\n <div class=\"help-block\" ng-show=\"form.description\" ng-bind-html=\"form.description\"></div>\r\n</fieldset>\r\n";
255255
window.angular.module('ng').run(['$templateCache', function(c) { c.put(path, html) }]);
256256
module.exports = path;
257257

@@ -269,7 +269,7 @@ return /******/ (function(modules) { // webpackBootstrap
269269
/***/ function(module, exports) {
270270

271271
var path = 'bootstrap/radio-buttons.html';
272-
var html = "<div class=\"form-group schema-form-radiobuttons {{::form.htmlClass}}\"\r\n ng-class=\"{'has-error': form.disableErrorState !== true && hasError(), 'has-success': form.disableSuccessState !== true && hasSuccess()}\">\r\n <div>\r\n <label class=\"control-label {{::form.labelHtmlClass}}\" ng-show=\"showTitle()\">{{form.title}}</label>\r\n </div>\r\n <div class=\"btn-group\">\r\n <label sf-field-model=\"replaceAll\" class=\"btn {{ (item.value === $$value$$) ? form.style.selected || 'btn-default' : form.style.unselected || 'btn-default'; }}\"\r\n ng-class=\"{ active: item.value === $$value$$ }\"\r\n ng-repeat=\"item in form.titleMap\">\r\n <input type=\"radio\"\r\n class=\"{{::form.fieldHtmlClass}}\"\r\n sf-changed=\"form\"\r\n style=\"display: none;\"\r\n ng-disabled=\"form.readonly\"\r\n sf-field-model\r\n schema-validate=\"form\"\r\n ng-value=\"item.value\"\r\n name=\"{{form.key.join('.')}}\">\r\n <span ng-bind-html=\"item.name\"></span>\r\n </label>\r\n </div>\r\n <div class=\"help-block\" sf-message=\"form.description\"></div>\r\n</div>\r\n";
272+
var html = "<div class=\"form-group schema-form-radiobuttons {{::form.htmlClass}}\"\r\n ng-class=\"{'has-error': form.disableErrorState !== true && hasError(), 'has-success': form.disableSuccessState !== true && hasSuccess()}\">\r\n <div>\r\n <label class=\"control-label {{::form.labelHtmlClass}}\" ng-show=\"showTitle()\">{{form.title}}</label>\r\n </div>\r\n <div class=\"btn-group\">\r\n <label sf-field-model=\"replaceAll\" class=\"btn {{ (tm.value === $$value$$) ? form.style.selected || 'btn-default' : form.style.unselected || 'btn-default'; }}\"\r\n ng-class=\"{ active: tm.value === $$value$$ }\"\r\n ng-repeat=\"tm in form.titleMap\">\r\n <input type=\"radio\"\r\n class=\"{{::form.fieldHtmlClass}}\"\r\n sf-changed=\"form\"\r\n style=\"display: none;\"\r\n ng-disabled=\"form.readonly\"\r\n sf-field-model\r\n schema-validate=\"form\"\r\n ng-value=\"tm.value\"\r\n name=\"{{::fieldId(true, false)}}\">\r\n <span ng-bind-html=\"tm.name\"></span>\r\n </label>\r\n </div>\r\n <div class=\"help-block\" sf-message=\"form.description\"></div>\r\n</div>\r\n";
273273
window.angular.module('ng').run(['$templateCache', function(c) { c.put(path, html) }]);
274274
module.exports = path;
275275

@@ -278,7 +278,7 @@ return /******/ (function(modules) { // webpackBootstrap
278278
/***/ function(module, exports) {
279279

280280
var path = 'bootstrap/radios-inline.html';
281-
var html = "<div class=\"form-group schema-form-radios-inline {{::form.htmlClass}}\"\r\n ng-class=\"{'has-error': form.disableErrorState !== true && hasError(), 'has-success': form.disableSuccessState !== true && hasSuccess()}\">\r\n <label class=\"control-label {{::form.labelHtmlClass}}\"\r\n ng-show=\"showTitle()\" sf-field-model\r\n schema-validate=\"form\" >{{form.title}}</label>\r\n <div>\r\n <label class=\"radio-inline\" ng-repeat=\"item in form.titleMap\" >\r\n <input type=\"radio\"\r\n class=\"{{::form.fieldHtmlClass}}\"\r\n sf-changed=\"form\"\r\n ng-disabled=\"form.readonly\"\r\n sf-field-model\r\n ng-value=\"item.value\"\r\n name=\"{{form.key.join('.')}}\">\r\n <span ng-bind-html=\"item.name\"></span>\r\n </label>\r\n </div>\r\n <div class=\"help-block\" sf-message=\"form.description\"></div>\r\n</div>\r\n";
281+
var html = "<div class=\"form-group schema-form-radios-inline {{::form.htmlClass}}\"\r\n ng-class=\"{'has-error': form.disableErrorState !== true && hasError(), 'has-success': form.disableSuccessState !== true && hasSuccess()}\">\r\n <label class=\"control-label {{::form.labelHtmlClass}}\"\r\n ng-show=\"showTitle()\" sf-field-model\r\n schema-validate=\"form\" >{{form.title}}</label>\r\n <div>\r\n <label class=\"radio-inline\" ng-repeat=\"tm in form.titleMap\" >\r\n <input type=\"radio\"\r\n class=\"{{::form.fieldHtmlClass}}\"\r\n sf-changed=\"form\"\r\n ng-disabled=\"form.readonly\"\r\n sf-field-model\r\n ng-value=\"tm.value\"\r\n name=\"{{::fieldId(true, false)}}\">\r\n <span ng-bind-html=\"tm.name\"></span>\r\n </label>\r\n </div>\r\n <div class=\"help-block\" sf-message=\"form.description\"></div>\r\n</div>\r\n";
282282
window.angular.module('ng').run(['$templateCache', function(c) { c.put(path, html) }]);
283283
module.exports = path;
284284

@@ -287,7 +287,7 @@ return /******/ (function(modules) { // webpackBootstrap
287287
/***/ function(module, exports) {
288288

289289
var path = 'bootstrap/radios.html';
290-
var html = "<div class=\"form-group schema-form-radios {{::form.htmlClass}}\" ng-class=\"{'has-error': form.disableErrorState !== true && hasError(), 'has-success': form.disableSuccessState !== true && hasSuccess()}\">\r\n <label class=\"control-label {{::form.labelHtmlClass}}\"\r\n sf-field-model schema-validate=\"form\"\r\n ng-show=\"showTitle()\">{{form.title}}</label>\r\n <div class=\"radio\" ng-repeat=\"item in form.titleMap\">\r\n <label>\r\n <input type=\"radio\"\r\n class=\"{{::form.fieldHtmlClass}}\"\r\n sf-changed=\"form\"\r\n ng-disabled=\"form.readonly\"\r\n sf-field-model\r\n ng-value=\"item.value\"\r\n name=\"{{form.key.join('.')}}\">\r\n <span ng-bind-html=\"item.name\"></span>\r\n </label>\r\n </div>\r\n <div class=\"help-block\" sf-message=\"form.description\"></div>\r\n</div>\r\n";
290+
var html = "<div class=\"form-group schema-form-radios {{::form.htmlClass}}\" ng-class=\"{'has-error': form.disableErrorState !== true && hasError(), 'has-success': form.disableSuccessState !== true && hasSuccess()}\">\r\n <label class=\"control-label {{::form.labelHtmlClass}}\"\r\n sf-field-model schema-validate=\"form\"\r\n ng-show=\"showTitle()\">{{form.title}}</label>\r\n <div class=\"radio\" ng-repeat=\"tm in form.titleMap\">\r\n <label>\r\n <input type=\"radio\"\r\n class=\"{{::form.fieldHtmlClass}}\"\r\n sf-changed=\"form\"\r\n ng-disabled=\"form.readonly\"\r\n sf-field-model\r\n ng-value=\"tm.value\"\r\n name=\"{{::fieldId(true, false)}}\">\r\n <span ng-bind-html=\"tm.name\"></span>\r\n </label>\r\n </div>\r\n <div class=\"help-block\" sf-message=\"form.description\"></div>\r\n</div>\r\n";
291291
window.angular.module('ng').run(['$templateCache', function(c) { c.put(path, html) }]);
292292
module.exports = path;
293293

@@ -296,7 +296,7 @@ return /******/ (function(modules) { // webpackBootstrap
296296
/***/ function(module, exports) {
297297

298298
var path = 'bootstrap/section.html';
299-
var html = "<div class=\"schema-form-section {{::form.htmlClass}}\"></div>\r\n";
299+
var html = "<div class=\"schema-form-section {{::form.htmlClass}}\" sf-key-controller sf-parent-key=\"[{{form.key.join('][')}}]\" sf-index=\"{{$index}}\"></div>\r\n";
300300
window.angular.module('ng').run(['$templateCache', function(c) { c.put(path, html) }]);
301301
module.exports = path;
302302

@@ -686,7 +686,7 @@ return /******/ (function(modules) { // webpackBootstrap
686686
state.modelName = 'item';
687687
}
688688

689-
// Flag to the builder that where in an array.
689+
// Flag to the builder that we're in an array.
690690
// This is needed for compatabiliy if a "old" add-on is used that
691691
// hasn't been transitioned to the new builder.
692692
state.arrayCompatFlag = true;
@@ -3779,17 +3779,19 @@ return /******/ (function(modules) { // webpackBootstrap
37793779
return {
37803780
scope: true,
37813781
require: ['^^sfNewArray'],
3782-
link: function link(scope, element, attrs, ctrl) {
3783-
var currentKey = sfPath.parse(attrs.sfParentKey);
3784-
if (currentKey.length > 1) currentKey = currentKey.splice(-1);
3782+
link: {
3783+
pre: function pre(scope, element, attrs, ctrl) {
3784+
var currentKey = sfPath.parse(attrs.sfParentKey);
3785+
if (currentKey.length > 1) currentKey = currentKey.splice(-1);
37853786

3786-
scope.parentKey = scope.parentKey || [];
3787-
scope.parentKey = scope.parentKey.concat(currentKey, Number(attrs.sfIndex));
3787+
scope.parentKey = scope.parentKey || [];
3788+
scope.parentKey = scope.parentKey.concat(currentKey, Number(attrs.sfIndex));
37883789

3789-
scope.arrayIndex = Number(attrs.sfIndex);
3790-
scope.arrayIndices = scope.arrayIndices || [];
3791-
scope.arrayIndices = scope.arrayIndices.concat(scope.arrayIndex);
3792-
scope.$i = scope.arrayIndices;
3790+
scope.arrayIndex = Number(attrs.sfIndex);
3791+
scope.arrayIndices = scope.arrayIndices || [];
3792+
scope.arrayIndices = scope.arrayIndices.concat(scope.arrayIndex);
3793+
scope.$i = scope.arrayIndices;
3794+
}
37933795
}
37943796
};
37953797
};

dist/angular-schema-form-bootstrap-bundled.min.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/angular-schema-form-bootstrap.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ return /******/ (function(modules) { // webpackBootstrap
250250
/***/ function(module, exports) {
251251

252252
var path = 'bootstrap/fieldset.html';
253-
var html = "<fieldset ng-disabled=\"form.readonly\" class=\"schema-form-fieldset {{::form.htmlClass}}\">\r\n <legend ng-class=\"{'sr-only': !showTitle() }\">{{ form.title }}</legend>\r\n <div class=\"help-block\" ng-show=\"form.description\" ng-bind-html=\"form.description\"></div>\r\n</fieldset>\r\n";
253+
var html = "<fieldset ng-disabled=\"form.readonly\" class=\"schema-form-fieldset {{::form.htmlClass}}\" sf-key-controller sf-parent-key=\"[{{form.key.join('][')}}]\" sf-index=\"{{$index}}\">\r\n <legend ng-class=\"{'sr-only': !showTitle() }\">{{ form.title }}</legend>\r\n <div class=\"help-block\" ng-show=\"form.description\" ng-bind-html=\"form.description\"></div>\r\n</fieldset>\r\n";
254254
window.angular.module('ng').run(['$templateCache', function(c) { c.put(path, html) }]);
255255
module.exports = path;
256256

@@ -268,7 +268,7 @@ return /******/ (function(modules) { // webpackBootstrap
268268
/***/ function(module, exports) {
269269

270270
var path = 'bootstrap/radio-buttons.html';
271-
var html = "<div class=\"form-group schema-form-radiobuttons {{::form.htmlClass}}\"\r\n ng-class=\"{'has-error': form.disableErrorState !== true && hasError(), 'has-success': form.disableSuccessState !== true && hasSuccess()}\">\r\n <div>\r\n <label class=\"control-label {{::form.labelHtmlClass}}\" ng-show=\"showTitle()\">{{form.title}}</label>\r\n </div>\r\n <div class=\"btn-group\">\r\n <label sf-field-model=\"replaceAll\" class=\"btn {{ (item.value === $$value$$) ? form.style.selected || 'btn-default' : form.style.unselected || 'btn-default'; }}\"\r\n ng-class=\"{ active: item.value === $$value$$ }\"\r\n ng-repeat=\"item in form.titleMap\">\r\n <input type=\"radio\"\r\n class=\"{{::form.fieldHtmlClass}}\"\r\n sf-changed=\"form\"\r\n style=\"display: none;\"\r\n ng-disabled=\"form.readonly\"\r\n sf-field-model\r\n schema-validate=\"form\"\r\n ng-value=\"item.value\"\r\n name=\"{{form.key.join('.')}}\">\r\n <span ng-bind-html=\"item.name\"></span>\r\n </label>\r\n </div>\r\n <div class=\"help-block\" sf-message=\"form.description\"></div>\r\n</div>\r\n";
271+
var html = "<div class=\"form-group schema-form-radiobuttons {{::form.htmlClass}}\"\r\n ng-class=\"{'has-error': form.disableErrorState !== true && hasError(), 'has-success': form.disableSuccessState !== true && hasSuccess()}\">\r\n <div>\r\n <label class=\"control-label {{::form.labelHtmlClass}}\" ng-show=\"showTitle()\">{{form.title}}</label>\r\n </div>\r\n <div class=\"btn-group\">\r\n <label sf-field-model=\"replaceAll\" class=\"btn {{ (tm.value === $$value$$) ? form.style.selected || 'btn-default' : form.style.unselected || 'btn-default'; }}\"\r\n ng-class=\"{ active: tm.value === $$value$$ }\"\r\n ng-repeat=\"tm in form.titleMap\">\r\n <input type=\"radio\"\r\n class=\"{{::form.fieldHtmlClass}}\"\r\n sf-changed=\"form\"\r\n style=\"display: none;\"\r\n ng-disabled=\"form.readonly\"\r\n sf-field-model\r\n schema-validate=\"form\"\r\n ng-value=\"tm.value\"\r\n name=\"{{::fieldId(true, false)}}\">\r\n <span ng-bind-html=\"tm.name\"></span>\r\n </label>\r\n </div>\r\n <div class=\"help-block\" sf-message=\"form.description\"></div>\r\n</div>\r\n";
272272
window.angular.module('ng').run(['$templateCache', function(c) { c.put(path, html) }]);
273273
module.exports = path;
274274

@@ -277,7 +277,7 @@ return /******/ (function(modules) { // webpackBootstrap
277277
/***/ function(module, exports) {
278278

279279
var path = 'bootstrap/radios-inline.html';
280-
var html = "<div class=\"form-group schema-form-radios-inline {{::form.htmlClass}}\"\r\n ng-class=\"{'has-error': form.disableErrorState !== true && hasError(), 'has-success': form.disableSuccessState !== true && hasSuccess()}\">\r\n <label class=\"control-label {{::form.labelHtmlClass}}\"\r\n ng-show=\"showTitle()\" sf-field-model\r\n schema-validate=\"form\" >{{form.title}}</label>\r\n <div>\r\n <label class=\"radio-inline\" ng-repeat=\"item in form.titleMap\" >\r\n <input type=\"radio\"\r\n class=\"{{::form.fieldHtmlClass}}\"\r\n sf-changed=\"form\"\r\n ng-disabled=\"form.readonly\"\r\n sf-field-model\r\n ng-value=\"item.value\"\r\n name=\"{{form.key.join('.')}}\">\r\n <span ng-bind-html=\"item.name\"></span>\r\n </label>\r\n </div>\r\n <div class=\"help-block\" sf-message=\"form.description\"></div>\r\n</div>\r\n";
280+
var html = "<div class=\"form-group schema-form-radios-inline {{::form.htmlClass}}\"\r\n ng-class=\"{'has-error': form.disableErrorState !== true && hasError(), 'has-success': form.disableSuccessState !== true && hasSuccess()}\">\r\n <label class=\"control-label {{::form.labelHtmlClass}}\"\r\n ng-show=\"showTitle()\" sf-field-model\r\n schema-validate=\"form\" >{{form.title}}</label>\r\n <div>\r\n <label class=\"radio-inline\" ng-repeat=\"tm in form.titleMap\" >\r\n <input type=\"radio\"\r\n class=\"{{::form.fieldHtmlClass}}\"\r\n sf-changed=\"form\"\r\n ng-disabled=\"form.readonly\"\r\n sf-field-model\r\n ng-value=\"tm.value\"\r\n name=\"{{::fieldId(true, false)}}\">\r\n <span ng-bind-html=\"tm.name\"></span>\r\n </label>\r\n </div>\r\n <div class=\"help-block\" sf-message=\"form.description\"></div>\r\n</div>\r\n";
281281
window.angular.module('ng').run(['$templateCache', function(c) { c.put(path, html) }]);
282282
module.exports = path;
283283

@@ -286,7 +286,7 @@ return /******/ (function(modules) { // webpackBootstrap
286286
/***/ function(module, exports) {
287287

288288
var path = 'bootstrap/radios.html';
289-
var html = "<div class=\"form-group schema-form-radios {{::form.htmlClass}}\" ng-class=\"{'has-error': form.disableErrorState !== true && hasError(), 'has-success': form.disableSuccessState !== true && hasSuccess()}\">\r\n <label class=\"control-label {{::form.labelHtmlClass}}\"\r\n sf-field-model schema-validate=\"form\"\r\n ng-show=\"showTitle()\">{{form.title}}</label>\r\n <div class=\"radio\" ng-repeat=\"item in form.titleMap\">\r\n <label>\r\n <input type=\"radio\"\r\n class=\"{{::form.fieldHtmlClass}}\"\r\n sf-changed=\"form\"\r\n ng-disabled=\"form.readonly\"\r\n sf-field-model\r\n ng-value=\"item.value\"\r\n name=\"{{form.key.join('.')}}\">\r\n <span ng-bind-html=\"item.name\"></span>\r\n </label>\r\n </div>\r\n <div class=\"help-block\" sf-message=\"form.description\"></div>\r\n</div>\r\n";
289+
var html = "<div class=\"form-group schema-form-radios {{::form.htmlClass}}\" ng-class=\"{'has-error': form.disableErrorState !== true && hasError(), 'has-success': form.disableSuccessState !== true && hasSuccess()}\">\r\n <label class=\"control-label {{::form.labelHtmlClass}}\"\r\n sf-field-model schema-validate=\"form\"\r\n ng-show=\"showTitle()\">{{form.title}}</label>\r\n <div class=\"radio\" ng-repeat=\"tm in form.titleMap\">\r\n <label>\r\n <input type=\"radio\"\r\n class=\"{{::form.fieldHtmlClass}}\"\r\n sf-changed=\"form\"\r\n ng-disabled=\"form.readonly\"\r\n sf-field-model\r\n ng-value=\"tm.value\"\r\n name=\"{{::fieldId(true, false)}}\">\r\n <span ng-bind-html=\"tm.name\"></span>\r\n </label>\r\n </div>\r\n <div class=\"help-block\" sf-message=\"form.description\"></div>\r\n</div>\r\n";
290290
window.angular.module('ng').run(['$templateCache', function(c) { c.put(path, html) }]);
291291
module.exports = path;
292292

@@ -295,7 +295,7 @@ return /******/ (function(modules) { // webpackBootstrap
295295
/***/ function(module, exports) {
296296

297297
var path = 'bootstrap/section.html';
298-
var html = "<div class=\"schema-form-section {{::form.htmlClass}}\"></div>\r\n";
298+
var html = "<div class=\"schema-form-section {{::form.htmlClass}}\" sf-key-controller sf-parent-key=\"[{{form.key.join('][')}}]\" sf-index=\"{{$index}}\"></div>\r\n";
299299
window.angular.module('ng').run(['$templateCache', function(c) { c.put(path, html) }]);
300300
module.exports = path;
301301

dist/angular-schema-form-bootstrap.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/bootstrap-example.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ <h3>Schema</h3>
222222

223223
<!-- These are the main files that you must include along with Angular-->
224224
<script type="text/javascript" src="../bower_components/tv4/tv4.js"></script>
225-
<script type="text/javascript" src="../dist/angular-schema-form-bootstrap.js"></script>
225+
<script type="text/javascript" src="../dist/angular-schema-form-bootstrap-bundled.js"></script>
226226
<!-- /These were the main files that you must include along with Angular-->
227227

228228
<script type="text/javascript" src="../bower_components/angular-schema-form-datepicker/bootstrap-datepicker.min.js"></script>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-schema-form-bootstrap",
3-
"version": "1.0.0-alpha.1",
3+
"version": "1.0.0-alpha.2",
44
"description": "Bootstrap 3 decorator for Angular Schema Form",
55
"main": "dist/bootstrap-decorator.js",
66
"scripts": {

src/bootstrap/fieldset.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<fieldset ng-disabled="form.readonly" class="schema-form-fieldset {{::form.htmlClass}}">
1+
<fieldset ng-disabled="form.readonly" class="schema-form-fieldset {{::form.htmlClass}}" sf-key-controller sf-parent-key="[{{form.key.join('][')}}]" sf-index="{{$index}}">
22
<legend ng-class="{'sr-only': !showTitle() }">{{ form.title }}</legend>
33
<div class="help-block" ng-show="form.description" ng-bind-html="form.description"></div>
44
</fieldset>

0 commit comments

Comments
 (0)