Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MOL-25578 - Support string arrays is Css facet rules #142

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions lib/components/c_facets/Css.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ var miloCore = require('milo-core')
* depth: '->>' // defaults to '->>'
* },
* classes: {
* '.someModelProp': 'some-css-class', // Apply css class if the value of '.someModelProp' is truthy
* '.someModelProp': 'some-css-class' | Array<string>, // Apply css class if the value of '.someModelProp' is truthy
* '.someOtherModelProp': {
* 'value-1': 'some-css-class', // Apply if the value of '.someOtherModelProp' == 'value-1'
* 'value-2: 'some-other-css-class' // etc
* 'value-1': 'some-css-class' | Array<string>, // Apply if the value of '.someOtherModelProp' == 'value-1'
* 'value-2: 'some-other-css-class' | Array<string> // etc
* },
* '.anotherModelProp': function getCssClass(modelValue) { return ... } // Apply result of function
* '.oneMoreModelProp': 'my-$-class' // Template value of '.oneMoreModelProp' (By replacing $ character)
* '.oneMoreModelProp': 'my-$-class' | Array<string> // Template value of '.oneMoreModelProp' (By replacing $ character)
* }
* }
* ```
Expand Down Expand Up @@ -129,7 +129,7 @@ function CssFacet$del() {

_.eachKey(this.activeModelPaths, function(modelPaths, cssClass) {
modelPaths.clear();
classList.remove(cssClass);
classList.remove(...cssClass.split(','));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That will destory old projects but it's fine :P

});
}

Expand Down Expand Up @@ -172,19 +172,19 @@ function updateSimple(modelPath, cssClass, data) {
if (modelPaths.has(modelPath)) {
modelPaths.delete(modelPath);

if (modelPaths.size === 0) // Only remove the class if no other model path is applying it
classList.remove(cssClass);
if (modelPaths.size === 0) // Only remove the class(es) if no other model path is applying it
classList.remove(...cssClass.split(','));
}
});

// Apply new css class (cssClass / data can be null if this is a remove only operation)
if (cssClass && data) {
cssClass = data ? cssClass.replace(/\$/g, data) : cssClass; // Process any template characters ($) in class name
cssClass = data ? [].concat(cssClass).map(cls => cls.replace(/\$/g, data)) : cssClass; // Process any template characters ($) in class name

var modelPaths = this.activeModelPaths[cssClass] || (this.activeModelPaths[cssClass] = new Set());

modelPaths.add(modelPath);
classList.add(cssClass);
classList.add(...[].concat(cssClass));
}
}

Expand Down