var ts = $scope.ts = CRM.ts('org.civicrm.afform_admin'),
ctrl = this;
- this.isCollapsible = function() {
- return afGui.hasClass(ctrl.node, 'af-collapsible');
- };
-
this.isCollapsed = function() {
- return afGui.hasClass(ctrl.node, 'af-collapsible af-collapsed');
- };
-
- this.toggleCollapsible = function() {
- // Node must have a title to be collapsible
- if (ctrl.isCollapsible() || !ctrl.node['af-title']) {
- afGui.modifyClasses(ctrl.node, 'af-collapsible af-collapsed');
- } else {
- afGui.modifyClasses(ctrl.node, null, 'af-collapsible');
- }
+ return !('open' in ctrl.node);
};
this.toggleCollapsed = function() {
if (ctrl.isCollapsed()) {
- afGui.modifyClasses(ctrl.node, 'af-collapsed');
+ ctrl.node.open = '';
} else {
- afGui.modifyClasses(ctrl.node, null, 'af-collapsed');
+ delete ctrl.node.open;
}
};
-<-- Show the following if Element dropdown is collapsible -->
-<a href ng-click="$ctrl.toggleCollapsed(); $event.stopPropagation();" class="btn btn-sm btn-default" ng-class="{invisible: !$ctrl.isCollapsible()}">
- <i class="crm-i fa-caret-{{ $ctrl.isCollapsed() ? 'right' : 'down' }}"></i>
- {{ $ctrl.isCollapsed() ? ts('Closed') : ts('Open') }}
-</a>
+<label ng-click="$ctrl.toggleCollapsed(); $event.stopPropagation();">
+ <i class="crm-i fa{{ $ctrl.isCollapsed() ? '-check' : '' }}-square-o"></i>
+ {{:: ts('Collapsed') }}
+</label>
</select>
</div>
</li>
+<li><af-gui-menu-item-collapsible ng-if="!block && $ctrl.node['#tag'] === 'details'" node="$ctrl.node" class="af-gui-field-select-in-dropdown form-inline"></af-gui-menu-item-collapsible></li>
<li ng-if="isRepeatable()" ng-click="$event.stopPropagation()">
<div class="af-gui-field-select-in-dropdown form-inline">
<label ng-click="$ctrl.toggleRepeat()">
</div>
</div>
</li>
-<li><af-gui-menu-item-collapsible ng-if="!block" node="$ctrl.node" class="af-gui-field-select-in-dropdown form-inline"></af-gui-menu-item-collapsible></li>
<li><af-gui-menu-item-style node="$ctrl.node"></af-gui-menu-item-style></li>
<li><af-gui-menu-item-border node="$ctrl.node"></af-gui-menu-item-border></li>
<li><af-gui-menu-item-background node="$ctrl.node"></af-gui-menu-item-background></li>
};
this.getCollapsibleIcon = function() {
- if (afGui.hasClass(ctrl.node, 'af-collapsible')) {
- return afGui.hasClass(ctrl.node, 'af-collapsed') ? 'fa-caret-right' : 'fa-caret-down';
+ if (ctrl.node['#tag'] === 'details') {
+ return 'open' in ctrl.node ? 'fa-caret-down' : 'fa-caret-right';
}
+ return '';
};
// Sets min value for af-repeat as a string, returns it as an int
ctrl.node['af-title'] = value;
} else {
delete ctrl.node['af-title'];
- // With no title, cannot be collapsible
- afGui.modifyClasses(ctrl.node, 'af-collapsible af-collapsed');
}
}
return ctrl.node['af-title'];
</select>
</div>
</li>
-<li><af-gui-menu-item-collapsible node="$ctrl.node" class="af-gui-field-select-in-dropdown form-inline"></af-gui-menu-item-collapsible></li>
+<li><af-gui-menu-item-collapsible ng-if="$ctrl.node['#tag'] === 'details'" node="$ctrl.node" class="af-gui-field-select-in-dropdown form-inline"></af-gui-menu-item-collapsible></li>
<li><af-gui-menu-item-style node="$ctrl.node"></af-gui-menu-item-style></li>
<li><af-gui-menu-item-border node="$ctrl.node"></af-gui-menu-item-border></li>
<li><af-gui-menu-item-background node="$ctrl.node"></af-gui-menu-item-background></li>