mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 01:51:40 -05:00
simplifying dropdown component
This commit is contained in:
parent
a29987d7b2
commit
24537d6e6f
6 changed files with 15 additions and 32 deletions
|
@ -26,7 +26,7 @@ meteorhacks:fast-render
|
|||
meteorhacks:subs-manager
|
||||
meteorhacks:npm
|
||||
|
||||
aldeed:autoform@5.0.0
|
||||
aldeed:autoform@5.0.3
|
||||
aldeed:collection2
|
||||
aldeed:simple-schema
|
||||
aldeed:template-extension
|
||||
|
|
|
@ -5,7 +5,7 @@ accounts-password@1.1.0
|
|||
accounts-twitter@1.0.4
|
||||
accounts-ui@1.1.5
|
||||
accounts-ui-unstyled@1.1.7
|
||||
aldeed:autoform@5.0.2
|
||||
aldeed:autoform@5.0.3
|
||||
aldeed:collection2@2.3.2
|
||||
aldeed:simple-schema@1.3.1
|
||||
aldeed:template-extension@3.4.3
|
||||
|
|
|
@ -13,7 +13,6 @@ var canEditField = function (field) {
|
|||
|
||||
Template[getTemplate('quickForm_telescope')].helpers({
|
||||
fieldsWithNoFieldset: function () {
|
||||
console.log(AutoForm.getFormSchema(this.atts.id))
|
||||
// get names of fields who don't have an autoform attribute or don't have a group, but are not omitted
|
||||
// note: we need to _.map() first to assign the field key to the "name" property to preserve it.
|
||||
var fields = _.pluck(_.filter(_.map(AutoForm.getFormSchema()._schema, function (field, key) {
|
||||
|
@ -45,7 +44,6 @@ Template[getTemplate('quickForm_telescope')].helpers({
|
|||
},
|
||||
fieldsForFieldset: function () {
|
||||
var fieldset = this.toLowerCase();
|
||||
|
||||
// get names of fields whose group match the current fieldset
|
||||
var fields = _.pluck(_.filter(AutoForm.getFormSchema()._schema, function (field, key) {
|
||||
return (field.name.indexOf('$') === -1) && field.autoform && field.autoform.group == fieldset;
|
||||
|
|
|
@ -11,12 +11,6 @@ dropdownItems (Array)
|
|||
|
||||
dropdownLabel (String) [optional]
|
||||
|
||||
dropdownItemLabel (Function) [optional]
|
||||
(Will default to "label" property)
|
||||
|
||||
dropdownItemPath (Function) [optional]
|
||||
(Will default to "route" property)
|
||||
|
||||
-->
|
||||
|
||||
<template name="dropdownComponent">
|
||||
|
|
|
@ -20,32 +20,22 @@ Template[getTemplate('dropdownComponent')].helpers({
|
|||
return this.length > 3;
|
||||
},
|
||||
itemLabel: function () {
|
||||
var dropdown = Template.parentData(2);
|
||||
// case 1: if a dropdown label function is provided, use it
|
||||
if (!!dropdown.dropdownItemLabel) {
|
||||
return dropdown.dropdownItemLabel(this);
|
||||
}
|
||||
// case 2: if label is a String, return it
|
||||
// case 1: if label is a String, return it
|
||||
if (typeof this.label == "string") {
|
||||
return i18n.t(this.label);
|
||||
}
|
||||
// case 3: if label is a Function return its result
|
||||
// case 2: if label is a Function return its result
|
||||
if (typeof this.label == "function") {
|
||||
return this.label()
|
||||
}
|
||||
},
|
||||
itemPath: function () {
|
||||
var dropdown = Template.parentData(2);
|
||||
// case 1: if a dropdown path function is provided, use it
|
||||
if (!!dropdown.dropdownItemPath) {
|
||||
return dropdown.dropdownItemPath(this);
|
||||
}
|
||||
// case 2: if route is a String, apply Router.path() to it
|
||||
// case 1: if route is a String, apply Router.path() to it
|
||||
if (typeof this.route == "string") {
|
||||
return Router.path(this.route);
|
||||
}
|
||||
// case 3: if route is a Function return its result
|
||||
if (typeof this.route == "string") {
|
||||
// case 2: if route is a Function return its result
|
||||
if (typeof this.route == "function") {
|
||||
return this.route()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,13 +3,14 @@ Meteor.startup(function () {
|
|||
categoriesMenuData: function () {
|
||||
return {
|
||||
dropdownName: 'categories',
|
||||
dropdownItems: Categories.find({}, {sort: {order: 1, name: 1}}).fetch(),
|
||||
dropdownItemLabel: function (category) {
|
||||
return category.name;
|
||||
},
|
||||
dropdownItemPath: function (category) {
|
||||
return getCategoryUrl(category.slug);
|
||||
}
|
||||
dropdownItems: _.map(Categories.find({}, {sort: {order: 1, name: 1}}).fetch(), function (category) {
|
||||
return {
|
||||
route: function () {
|
||||
return getCategoryUrl(category.slug);
|
||||
},
|
||||
label: category.name
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue