mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 18:11:40 -05:00
Using AutoForm.getFormSchema()
This commit is contained in:
parent
2d021cbf15
commit
49c034c6e1
1 changed files with 5 additions and 16 deletions
|
@ -6,18 +6,6 @@ var findAtts = function () {
|
|||
return c && c.atts;
|
||||
}
|
||||
|
||||
var getSchema = function () {
|
||||
var schema = AutoForm.find().ss._schema;
|
||||
|
||||
// decorate schema with key names
|
||||
schema = _.map(schema, function (field, key) {
|
||||
field.name = key;
|
||||
return field;
|
||||
});
|
||||
|
||||
return schema;
|
||||
}
|
||||
|
||||
var canEditField = function (field) {
|
||||
// show field only if user is admin or it's marked as editable
|
||||
return isAdmin(Meteor.user()) || !!field.atts.editable || (!!field.afFieldInputAtts && !!field.afFieldInputAtts.editable)
|
||||
|
@ -26,8 +14,9 @@ var canEditField = function (field) {
|
|||
Template[getTemplate('quickForm_telescope')].helpers({
|
||||
fieldsWithNoFieldset: function () {
|
||||
// get names of fields who don't have an autoform attribute or don't have a group, but are not omitted
|
||||
var fields = _.pluck(_.filter(getSchema(), function (field, key) {
|
||||
if (field.name.indexOf('$') !== -1) // filter out fields with "$" in their name
|
||||
var fields = _.pluck(_.filter(AutoForm.getFormSchema()._schema, function (field, key) {
|
||||
var fieldName = key;
|
||||
if (fieldName.indexOf('$') !== -1) // filter out fields with "$" in their name
|
||||
return false
|
||||
if (field.autoform && field.autoform.omit) // filter out fields with omit = true
|
||||
return false
|
||||
|
@ -38,7 +27,7 @@ Template[getTemplate('quickForm_telescope')].helpers({
|
|||
return fields;
|
||||
},
|
||||
afFieldsets: function () {
|
||||
var groups = _.compact(_.uniq(_.pluckDeep(getSchema(), 'autoform.group')));
|
||||
var groups = _.compact(_.uniq(_.pluckDeep(AutoForm.getFormSchema(), 'autoform.group')));
|
||||
|
||||
// if user is not admin, exclude "admin" group from fieldsets
|
||||
if (!isAdmin(Meteor.user()))
|
||||
|
@ -53,7 +42,7 @@ Template[getTemplate('quickForm_telescope')].helpers({
|
|||
var fieldset = this.toLowerCase();
|
||||
|
||||
// get names of fields whose group match the current fieldset
|
||||
var fields = _.pluck(_.filter(getSchema(), function (field, key) {
|
||||
var fields = _.pluck(_.filter(AutoForm.getFormSchema(), function (field, key) {
|
||||
return (field.name.indexOf('$') === -1) && field.autoform && field.autoform.group == fieldset;
|
||||
}), 'name');
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue