template: function(data, helpers) {
     var filters = data.attr('config').filters;
     if (!can.isEmptyObject(filters.attr())) { //There are some filters to render
         var html = '<div class="datagrid-filters">';
         filters.each(function(filter){
             html += '   <div class="form-group filter-'+filter.name+'" data-filter-type="' + filter.type + '">' + filter.getLabelTemplate() + filter.getTemplate();
             if (filter.name === 'search') {
                 html += '<button class="icon-search search-input-toggle"></button>';
             }
             html += '</div>'; //end of .form-group
         });
         html += '</div>'; //end of .datagrid-filters
         return can.stache(html)(data, helpers);
     } else {
         return ''; //No filters -> nothing to render
     }
 },
Beispiel #2
0
	_validate: function () {
		var validateOpts = getValidateFromCache.call(this);
		var processedOpts = {};
		var self = this;

		// Loop through validate options
		can.each(this.define, function (value, key) {
			if (value.validate) {
				processedOpts[key] = resolveComputes({key: key, value: self.attr(key)}, validateOpts[key]);
			}
		});
		var errors = can.validate.validate(this.serialize(), processedOpts);

		// Process errors if we got them
		// TODO: This creates a new instance every time.
		this.attr('errors', new ErrorsObj(errors));

		return can.isEmptyObject(errors);
	},
Beispiel #3
0
var initProperty = function (key, value) {
	var validateOpts;
	var mapValidateCache;
	var propIniting;

	// Creat shortcut to cache
	mapValidateCache = getValidateFromCache.call(this);

	// If validate options don't exist in cache for current prop, create them
	if (mapValidateCache[key] && !can.isEmptyObject(mapValidateCache[key])) {
		validateOpts = mapValidateCache[key];
		propIniting = false;
	} else {
		// Copy current prop's validation properties to cache
		validateOpts = can.extend({}, getPropDefineBehavior('validate', key, this.define));
		// Need to build computes in the next step
		propIniting = true;
	}

	// Do validate if prop has any validate options
	if (typeof validateOpts !== 'undefined') {
		//create validation computes only when initing the map
		if (propIniting) {
			validateOpts = can.extend({},
				defaultValidationOpts,
				validateOpts,
				// Find any functions, converts them to computes and returns
				// nice object for shim to use
				this._processValidateOpts({key: key, value: value}, validateOpts)
			);
			mapValidateCache[key] = validateOpts;
		}
		return true;
	}
	return false;
};
Beispiel #4
0
	hasErrors: function () {
		return !can.isEmptyObject(this.attr());
	}