Skip to content

Instantly share code, notes, and snippets.

@jamiepollock
Last active August 29, 2015 14:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamiepollock/ef88e50570d6033e62e5 to your computer and use it in GitHub Desktop.
Save jamiepollock/ef88e50570d6033e62e5 to your computer and use it in GitHub Desktop.
JavaScript to get the number of enabled fieldsets from a nested archtype
var ContactDetailsGroupBuilderTemplate = {};
ContactDetailsGroupBuilderTemplate.Helpers = {};
ContactDetailsGroupBuilderTemplate.Helpers.getNumberOfEnabledFieldsets = function (fieldsets) {
return fieldsets.filter(function (v) {
return v.disabled === false;
}).length;
}
ContactDetailsGroupBuilderTemplate.getCount = function (value, scope) {
if (value && value.fieldsets) {
return ContactDetailsGroupBuilderTemplate.Helpers.getNumberOfEnabledFieldsets(value.fieldsets);
}
return "";
};
{
"javascript": [
"~/App_Plugins/ArchetypeLabelTemplates/ContactDetailsGroupBuilderTemplate.js"
]
}
Usage
Include JavaScript via a package.manifest (example file included).
In the advanced config for the parent Archetype:
- In your advanced configuration: Reference the javascript file path.
- In the label template: include the following {{ContactDetailsGroupBuilderTemplate.getCount(x)}}, where x is the alias of your nested Archetype, where you'd like the count to appear.
- ????
- PROFIT!!!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment