Skip to content

Commit 275cd42

Browse files
committed
Fix typos and update examples
1 parent eab4f71 commit 275cd42

File tree

4 files changed

+40
-6
lines changed

4 files changed

+40
-6
lines changed

bower.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,8 @@
5050
"angular-ui-sortable": ">=0.12.11",
5151
"bootstrap-vertical-tabs": "~1.2.0",
5252
"angular-schema-form-bootstrap": "~0.1.1"
53+
},
54+
"resolutions": {
55+
"jquery": "~2.1.1"
5356
}
5457
}

dist/schema-form.js

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ return /******/ (function(modules) { // webpackBootstrap
391391
}
392392
};
393393

394-
var _build = function _build(items, decorator, templateFn, slots, path, state, lookup, index) {
394+
var _build = function _build(items, decorator, templateFn, slots, path, state, lookup) {
395395
state = state || {};
396396
state = state || {};
397397
lookup = lookup || Object.create(null);
@@ -444,8 +444,8 @@ return /******/ (function(modules) { // webpackBootstrap
444444
path: path + '[' + index + ']',
445445

446446
// Recursive build fn
447-
build: function build(items, path, state, index) {
448-
return _build(items, decorator, templateFn, slots, path, state, lookup, index);
447+
build: function build(items, path, state) {
448+
return _build(items, decorator, templateFn, slots, path, state, lookup);
449449
}
450450

451451
};
@@ -556,9 +556,16 @@ return /******/ (function(modules) { // webpackBootstrap
556556

557557
//Normalise names and ids
558558
scope.fieldId = function (prependFormName, omitArrayIndexes) {
559+
var key = scope.parentKey || [];
559560
if (scope.form.key) {
560-
var formName = prependFormName && formCtrl && formCtrl.$name ? formCtrl.$name : undefined;
561-
return sfPath.name(scope.form.key, '-', formName, omitArrayIndexes);
561+
if (typeof key[key.length - 1] === 'number') {
562+
var combinedKey = key.concat(scope.form.key.slice(-1));
563+
var formName = prependFormName && formCtrl && formCtrl.$name ? formCtrl.$name : undefined;
564+
return sfPath.name(combinedKey, '-', formName, omitArrayIndexes);
565+
} else {
566+
var formName = prependFormName && formCtrl && formCtrl.$name ? formCtrl.$name : undefined;
567+
return sfPath.name(scope.form.key, '-', formName, omitArrayIndexes);
568+
}
562569
} else {
563570
return '';
564571
}
@@ -2756,7 +2763,7 @@ return /******/ (function(modules) { // webpackBootstrap
27562763

27572764
//Normalise names and ids
27582765
scope.fieldId = function (prependFormName, omitArrayIndexes) {
2759-
var key = scope.parentKeyTest || [];
2766+
var key = scope.parentKey || [];
27602767
if (scope.form.key) {
27612768
if (typeof key[key.length - 1] === 'number') {
27622769
var combinedKey = key.concat(scope.form.key.slice(-1));
@@ -3384,6 +3391,15 @@ return /******/ (function(modules) { // webpackBootstrap
33843391
scope.arrayIndex = Number(attrs.sfIndex);
33853392
scope.arrayIndices = scope.arrayIndices || [];
33863393
scope.arrayIndices = scope.arrayIndices.concat(scope.arrayIndex);
3394+
scope.$i = scope.arrayIndices;
3395+
scope.path = function (modelPath) {
3396+
var i = -1;
3397+
modelPath = modelPath.replace(/\[\]/gi, function (matched) {
3398+
i++;
3399+
return scope.$i[i];
3400+
});
3401+
return modelPath;
3402+
};
33873403
}
33883404
};
33893405
};

examples/data/deep-array.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
},
5656
{
5757
"key": "users",
58+
"type": "tabarray",
5859
"add": "New",
5960
"style": {
6061
"add": "btn-success"
@@ -74,6 +75,11 @@
7475
{
7576
"key": "users[].comments[].tags[].tag",
7677
"type": "text"
78+
},
79+
{
80+
"condition": "model.users[$i[0]].name",
81+
"type": "string",
82+
"default": "Brad"
7783
}
7884
]
7985
}

src/directives/keyController.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@ export default function(schemaForm, sfPath) {
1515
scope.arrayIndex = Number(attrs.sfIndex);
1616
scope.arrayIndices = scope.arrayIndices || [];
1717
scope.arrayIndices = scope.arrayIndices.concat(scope.arrayIndex);
18+
scope.$i = scope.arrayIndices;
19+
scope.path = function(modelPath) {
20+
var i = -1;
21+
modelPath = modelPath.replace(/\[\]/gi, function(matched){
22+
i++;
23+
return scope.$i[i];
24+
});
25+
return modelPath;
26+
}
1827
}
1928
};
2029
};

0 commit comments

Comments
 (0)