Skip to content

form '*' generate only remain keys from schema #748

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

Closed
wants to merge 3 commits into from
Closed
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
27 changes: 27 additions & 0 deletions src/services/schema-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,33 @@ angular.module('schemaForm').provider('schemaForm',

var stdForm = service.defaults(schema, ignore, options);

//simple case, we have a "...", just put the stdFormRemains there
var idRest = form.indexOf('...');
if (idRest !== -1) {
var formKeys = form.map(function(obj) {
if (typeof obj === 'string'){
return obj;
} else if (obj.key) {
return obj.key;
}
}).filter(function(element) {
return element !== undefined;
});

var stdFormRemains = stdForm.form.map(function(obj) {
isInside = formKeys.indexOf(obj.key[0]) !== -1;
if (!isInside) {
return obj;
}
}).filter(function(element) {
return element !== undefined;
});

form = form.slice(0, idRest)
.concat(stdFormRemains)
.concat(form.slice(idRest + 1));
}

//simple case, we have a "*", just put the stdForm there
var idx = form.indexOf('*');
if (idx !== -1) {
Expand Down