Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

WCM-59 Hide category wrappers when filtering fields #19

Closed
wants to merge 1 commit into from

2 participants

Chema Balsas Julio Camarero
Chema Balsas

No description provided.

Julio Camarero

Just started reviewing :)

:octocat: Sent from GH.

Julio Camarero

merged! :dancer:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 21, 2014
  1. Chema Balsas
This page is out of date. Refresh to see the latest.
63 content-targeting-web/docroot/js/content_targeting/ct_form_builder.js
View
@@ -213,16 +213,65 @@ AUI.add(
},
_onItemFilterResults: function(event) {
- var instance = this;
+ var instance = this,
+ contentBox = instance.get('contentBox'),
+ availableFieldsContainer = contentBox.one('.diagram-builder-fields-container'),
+ categories = availableFieldsContainer.all('.category-wrapper'),
+ query = event.query;
- A.all('.diagram-builder-field').addClass('hide');
+ if (!instance._collapsedCategories) {
+ instance._collapsedCategories = [];
- A.Array.each(
- event.results,
- function(result) {
- result.raw.node.ancestor('.diagram-builder-field').removeClass('hide');
+ categories.each(
+ function(item, index) {
+ var header = item.one('.toggler-header');
+
+ if (header && header.hasClass('toggler-header-collapsed')) {
+ instance._collapsedCategories.push(item);
+ }
+ }
+ );
+ }
+
+ if (!query) {
+ availableFieldsContainer.all('.category-wrapper, .diagram-builder-field').removeClass('hide');
+
+ if (instance._collapsedCategories) {
+ A.each(
+ instance._collapsedCategories,
+ function(item, index) {
+ var categoryIndex = categories.indexOf(item);
+
+ var togglerItems = instance._togglerDelegate.items;
+
+ togglerItems[categoryIndex].collapse(
+ {
+ silent: true
+ }
+ );
+ }
+ );
+
+ instance._collapsedCategories = null;
}
- );
+ }
+ else {
+ availableFieldsContainer.all('.category-wrapper, .diagram-builder-field').addClass('hide');
+
+ A.Array.each(
+ event.results,
+ function(result) {
+ result.raw.node.ancestor('.diagram-builder-field').removeClass('hide');
+ result.raw.node.ancestor('.category-wrapper').removeClass('hide');
+ }
+ );
+
+ instance._togglerDelegate.expandAll(
+ {
+ silent: true
+ }
+ );
+ }
},
_parseFields: function() {
Something went wrong with that request. Please try again.