Skip to content

Fix form.key issues #874

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 56 additions & 55 deletions dist/angular-schema-form.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*!
* angular-schema-form
* @version 1.0.0-alpha.5
* @date Wed, 26 Apr 2017 14:49:08 GMT
* @date Mon, 01 May 2017 08:39:39 GMT
* @link https://github.com/json-schema-form/angular-schema-form
* @license MIT
* Copyright (c) 2014-2017 JSON Schema Form
Expand All @@ -14,9 +14,9 @@
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
Expand Down Expand Up @@ -2729,33 +2729,34 @@ module.exports = __webpack_require__(4);
/***/ })
/******/ ]);
//# sourceMappingURL=json-schema-form-core.js.map

/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2), __webpack_require__(19).setImmediate))

/***/ }),
/* 2 */
/***/ (function(module, exports) {

var g;

// This works in non-strict mode
g = (function() {
return this;
})();

try {
// This works if eval is allowed (see CSP)
g = g || Function("return this")() || (1,eval)("this");
} catch(e) {
// This works if the window reference is available
if(typeof window === "object")
g = window;
}

// g can still be undefined, but nothing to do about it...
// We return undefined, instead of nothing here, so it's
// easier to handle this case. if(!global) { ...}

module.exports = g;
var g;
// This works in non-strict mode
g = (function() {
return this;
})();
try {
// This works if eval is allowed (see CSP)
g = g || Function("return this")() || (1,eval)("this");
} catch(e) {
// This works if the window reference is available
if(typeof window === "object")
g = window;
}
// g can still be undefined, but nothing to do about it...
// We return undefined, instead of nothing here, so it's
// easier to handle this case. if(!global) { ...}
module.exports = g;


/***/ }),
Expand Down Expand Up @@ -2842,7 +2843,7 @@ __WEBPACK_IMPORTED_MODULE_1_angular___default.a.module('schemaForm', deps)
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_angular___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_angular__);


/* harmony default export */ __webpack_exports__["a"] = function (sfValidator, $parse, sfSelect, $interpolate) {
/* harmony default export */ __webpack_exports__["a"] = (function (sfValidator, $parse, sfSelect, $interpolate) {
return {
restrict: 'A',
scope: false,
Expand Down Expand Up @@ -3032,7 +3033,7 @@ __WEBPACK_IMPORTED_MODULE_1_angular___default.a.module('schemaForm', deps)
};
}
};
};
});

/***/ }),
/* 6 */
Expand All @@ -3048,7 +3049,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
/**
* Directive that handles the model arrays
*/
/* harmony default export */ __webpack_exports__["a"] = function (sfSelect, sfPath, schemaForm) {
/* harmony default export */ __webpack_exports__["a"] = (function (sfSelect, sfPath, schemaForm) {
return {
scope: true,
controller: ['$scope', function SFArrayController($scope) {
Expand Down Expand Up @@ -3279,7 +3280,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
};
}
};
};
});

/***/ }),
/* 7 */
Expand All @@ -3297,7 +3298,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
* Takes the form definition as argument.
* If the form definition has a "onChange" defined as either a function or
*/
/* harmony default export */ __webpack_exports__["a"] = function () {
/* harmony default export */ __webpack_exports__["a"] = (function () {
return {
require: 'ngModel',
restrict: 'AC',
Expand Down Expand Up @@ -3325,7 +3326,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
}
}
};
};
});

/***/ }),
/* 8 */
Expand All @@ -3338,7 +3339,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol



/* harmony default export */ __webpack_exports__["a"] = function ($parse, $compile, $http, $templateCache, $interpolate, $q, sfErrorMessage, sfPath, sfSelect) {
/* harmony default export */ __webpack_exports__["a"] = (function ($parse, $compile, $http, $templateCache, $interpolate, $q, sfErrorMessage, sfPath, sfSelect) {

var keyFormat = {
COMPLETE: '*',
Expand Down Expand Up @@ -3383,17 +3384,17 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
if (scope.completeKey !== scope.form.key) {
if (typeof scope.$index === 'number') {
key = key.concat(scope.$index);
};
}

if (scope.form.key && scope.form.key.length) {
if (typeof key[key.length - 1] === 'number' && scope.form.key.length >= 1) {
var trim = scope.form.key.length - key.length;
scope.completeKey = key.concat(scope.form.key.slice(-trim));
scope.completeKey = trim > 0 ? key.concat(scope.form.key.slice(-trim)) : key;
} else {
scope.completeKey = scope.form.key.slice();
};
};
};
}
}
}

// If there is no key then there's nothing to return
if (!Array.isArray(scope.completeKey)) {
Expand Down Expand Up @@ -3659,7 +3660,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
}
}
};
};
});

/***/ }),
/* 9 */
Expand All @@ -3669,7 +3670,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
/**
* Directive that handles keys and array indexes
*/
/* harmony default export */ __webpack_exports__["a"] = function (schemaForm, sfPath) {
/* harmony default export */ __webpack_exports__["a"] = (function (schemaForm, sfPath) {
return {
scope: true,
require: ['?^^sfNewArray'],
Expand Down Expand Up @@ -3698,7 +3699,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
}
}
};
};;
});;

/***/ }),
/* 10 */
Expand All @@ -3709,7 +3710,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_angular___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_angular__);


/* harmony default export */ __webpack_exports__["a"] = function ($injector, sfErrorMessage) {
/* harmony default export */ __webpack_exports__["a"] = (function ($injector, sfErrorMessage) {

//Inject sanitizer if it exists
var $sanitize = $injector.has('$sanitize') ? $injector.get('$sanitize') : function (html) {
Expand Down Expand Up @@ -3802,7 +3803,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
});
}
};
};
});

/***/ }),
/* 11 */
Expand All @@ -3818,7 +3819,7 @@ FIXME: real documentation
<form sf-form="form" sf-schema="schema" sf-decorator="foobar"></form>
*/

/* harmony default export */ __webpack_exports__["a"] = function ($compile, $http, $templateCache, $q, schemaForm, schemaFormDecorators, sfSelect, sfPath, sfBuilder) {
/* harmony default export */ __webpack_exports__["a"] = (function ($compile, $http, $templateCache, $q, schemaForm, schemaFormDecorators, sfSelect, sfPath, sfBuilder) {

return {
scope: {
Expand Down Expand Up @@ -4032,7 +4033,7 @@ FIXME: real documentation
};
}
};
};
});

/***/ }),
/* 12 */
Expand All @@ -4043,7 +4044,7 @@ FIXME: real documentation
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_angular___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_angular__);


/* harmony default export */ __webpack_exports__["a"] = function ($compileProvider, sfPathProvider) {
/* harmony default export */ __webpack_exports__["a"] = (function ($compileProvider, sfPathProvider) {
var defaultDecorator = '';
var decorators = {};

Expand Down Expand Up @@ -4463,11 +4464,11 @@ FIXME: real documentation
* @param {string} name directive name (CamelCased)
* @param {Object} fields, an object that maps "type" => `{ template, builder, replace}`.
attributes `builder` and `replace` are optional, and replace defaults to true.
`template` should be the key of the template to load and it should be pre-loaded
`template` should be the key of the template to load and it should be pre-loaded
in `$templateCache`.
`builder` can be a function or an array of functions. They will be called in
`builder` can be a function or an array of functions. They will be called in
the order they are supplied.
`replace` (DEPRECATED) is for backwards compatability. If false the builder
`replace` (DEPRECATED) is for backwards compatability. If false the builder
will use the "old" way of building that form field using a <sf-decorator>
directive.
*/
Expand Down Expand Up @@ -4575,7 +4576,7 @@ FIXME: real documentation

//Create a default directive
createDirective('sfDecorator');
};;
});;

/***/ }),
/* 13 */
Expand All @@ -4593,7 +4594,7 @@ FIXME: real documentation
/**
* Schema form service.
*/
/* harmony default export */ __webpack_exports__["a"] = function () {
/* harmony default export */ __webpack_exports__["a"] = (function () {
var postProcessFn = function postProcessFn(form) {
return form;
};
Expand Down Expand Up @@ -4714,7 +4715,7 @@ FIXME: real documentation

return service;
};
};
});

/***/ }),
/* 14 */
Expand All @@ -4723,7 +4724,7 @@ FIXME: real documentation
"use strict";

// FIXME: type template (using custom builder)
/* harmony default export */ __webpack_exports__["a"] = function (sfPathProvider) {
/* harmony default export */ __webpack_exports__["a"] = (function (sfPathProvider) {

var SNAKE_CASE_REGEXP = /[A-Z]/g;
var snakeCase = function snakeCase(name, separator) {
Expand Down Expand Up @@ -5042,7 +5043,7 @@ FIXME: real documentation
internalBuild: _build
};
}];
};
});

/***/ }),
/* 15 */
Expand All @@ -5053,7 +5054,7 @@ FIXME: real documentation
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_angular___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_angular__);


/* harmony default export */ __webpack_exports__["a"] = function () {
/* harmony default export */ __webpack_exports__["a"] = (function () {

// The codes are tv4 error codes.
// Not all of these can actually happen in a field, but for
Expand Down Expand Up @@ -5179,7 +5180,7 @@ FIXME: real documentation

return service;
}];
};
});

/***/ }),
/* 16 */
Expand Down Expand Up @@ -5219,7 +5220,7 @@ var sfPathProviderClass = function () {
return sfPathProviderClass;
}();

/* harmony default export */ __webpack_exports__["a"] = sfPathProviderClass;
/* harmony default export */ __webpack_exports__["a"] = (sfPathProviderClass);

/***/ }),
/* 17 */
Expand Down
11 changes: 5 additions & 6 deletions dist/angular-schema-form.min.js

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ module.exports = function(config) {

// test results reporter to use
// possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
reporters: ['dots','progress','coverage','growler'],
reporters: ['mocha','coverage','growler'],

mochaReporter: {
showDiff: true
},

preprocessors: {
'src/**/*.js': ['coverage']
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,15 @@
"babel-polyfill": "^6.16.0",
"babel-preset-es2015": "^6.18.0",
"chai": "^3.5.0",
"diff": "^3.2.0",
"html-webpack-externals-plugin": "^2.1.2",
"karma": "^1.3.0",
"karma-babel-preprocessor": "^6.0.1",
"karma-chai-sinon": "^0.1.5",
"karma-coverage": "^1.1.1",
"karma-growler-reporter": "0.0.1",
"karma-mocha": "^1.3.0",
"karma-mocha-reporter": "^2.2.3",
"karma-phantomjs-launcher": "^1.0.2",
"karma-webpack": "^1.8.0",
"mocha": "^3.2.0",
Expand Down
14 changes: 7 additions & 7 deletions src/directives/sf-field.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,18 @@ sfPath, sfSelect) {
if(scope.completeKey !== scope.form.key) {
if (typeof scope.$index === 'number') {
key = key.concat(scope.$index);
};
}

if(scope.form.key && scope.form.key.length) {
if(typeof key[key.length-1] === 'number' && scope.form.key.length >= 1) {
let trim = scope.form.key.length - key.length;
scope.completeKey = key.concat(scope.form.key.slice(-trim));
}
else {
scope.completeKey =
trim > 0 ? key.concat(scope.form.key.slice(-trim)) : key;
} else {
scope.completeKey = scope.form.key.slice();
};
};
};
}
}
}

// If there is no key then there's nothing to return
if(!Array.isArray(scope.completeKey)) {
Expand Down
Loading