Last active
August 29, 2015 14:21
-
-
Save jamiepollock/ef88e50570d6033e62e5 to your computer and use it in GitHub Desktop.
JavaScript to get the number of enabled fieldsets from a nested archtype
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ""; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"javascript": [ | |
"~/App_Plugins/ArchetypeLabelTemplates/ContactDetailsGroupBuilderTemplate.js" | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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