LT-253: Creating dynamic form components

This commit is contained in:
Bruno Alves de Faria authored and Erik Ziegler committed 2016-07-22 11:12:04 +02:00
1 parent 88f737644f
commit cb875b1913
72 files changed
+1169 -126

No files matched your search

-38
View File
@@ -1,38 +0,0 @@
// Return the current template instance
Template.registerHelper('instance', () => {
return Template.instance();
});
// Return the session value for the given key
Template.registerHelper('session', key => {
return Session.get(key);
});
// Create a new object and extends it with the argument objects
Template.registerHelper('extend', (...argsArray) => {
// Create the resulting object
const result = {};
// Extract the Spacebars kw hash
const kwHash = _.last(argsArray).hash;
// Extract the given objects
const objects = _.initial(argsArray);
// Iterate over the given objects
_.each(objects, current => {
// Stop here if the current argument is not an object
if (typeof current !== 'object') {
return;
}
// Extend the resulting object with the current argument object
_.extend(result, current);
});
// Extend the resulting object with the Spacebars kw hash
_.extend(result, kwHash);
// Return the resulting object
return result;
});
@@ -1,69 +0,0 @@
/**
* Global Blaze UI helpers to work with logical operations
*/
// Convert any value into a boolean value
Template.registerHelper('bool', value => {
return !!value;
});
// Check if two values are identical
Template.registerHelper('eq', (a, b) => {
return a === b;
});
// Check if two values are different
Template.registerHelper('ne', (a, b) => {
return a === b;
});
// Check if the first value is greater than the second one
Template.registerHelper('gt', (a, b) => {
return a > b;
});
// Check if the first value is lesser than the second one
Template.registerHelper('lt', (a, b) => {
return a < b;
});
// Check if the first value is greater than or equals the second one
Template.registerHelper('gte', (a, b) => {
return a >= b;
});
// Check if the first value is lesser than or equals the second one
Template.registerHelper('lte', (a, b) => {
return a <= b;
});
// Get the boolean negation for the given value
Template.registerHelper('not', value => {
return !value;
});
// Check if all the given values are true
Template.registerHelper('and', (...values) => {
let result = true;
_.each(_.initial(values, 1), value => value || (result = false));
return result;
});
// Check if one of the given values is true
Template.registerHelper('or', (...values) => {
let result = false;
_.each(_.initial(values, 1), value => value && (result = true));
return result;
});
// Choose the first truthy value in the given values
Template.registerHelper('choose', (...values) => {
let result;
_.each(_.initial(values, 1), value => value && (result = value));
return result;
});
// Check if the value is different from undefined
Template.registerHelper('isDefined', value => {
return typeof value !== 'undefined';
});