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
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ module.exports = function(grunt) {
}

grunt.loadNpmTasks('grunt-browserify');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-uglify-es');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-mocha-test');
Expand Down
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
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@
"brfs": "^1.4.3",
"browserify": "^14.0.0",
"eslintify": "^3.1.0",
"grunt": "^1.0.1",
"grunt": "1.0.1",
"grunt-browserify": "^5.0.0",
"grunt-contrib-copy": "^1.0.0",
"grunt-contrib-uglify": "^2.0.0",
"grunt-contrib-uglify-es": "^3.3.0",
"grunt-contrib-watch": "^1.0.0",
"grunt-exorcise": "^2.1.1",
"grunt-istanbul": "^0.7.1",
Expand Down