Skip to content

Commit

Permalink
Segments Filter: in revise default enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
riccio82 committed May 8, 2018
1 parent ebad171 commit 7d5e607
Show file tree
Hide file tree
Showing 7 changed files with 223 additions and 0 deletions.
69 changes: 69 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
module.exports = function(grunt) {

var es2015Preset = require('babel-preset-es2015');
var reactPreset = require('babel-preset-react');

grunt.initConfig( {
browserify: {
core: {
options: {
transform: [
[ 'babelify', { presets: [ es2015Preset, reactPreset ] } ]
],
browserifyOptions: {
paths: [ __dirname + '/node_modules' ]
}
},
src: [
'static/src/js/cat_source/microsoft-core.js',
'static/src/js/cat_source/microsoft-core.*.js'
],
dest: 'static/build/microsoft-core-build.js'
},
},
sass: {
dist: {
options: {
sourceMap: false,
includePaths: ['static/src/css/sass/']
},
src: [
'static/src/css/sass/microsoft-core.scss'
],
dest: 'static/build/microsoft-build.css'
}
},
replace: {
css: {
src: [
'static/build/*'
],
dest: 'static/build/',
replacements: [
{
from: 'url(../img',
to: 'url(../src/css/img'
}
]
}
}

});

grunt.loadNpmTasks('grunt-browserify');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-sass');
grunt.loadNpmTasks('grunt-text-replace');

// Define your tasks here
grunt.registerTask('default', ['bundle:js']);

grunt.registerTask('bundle:js', [
'browserify:core',
'sass',
'replace'
]);



};
23 changes: 23 additions & 0 deletions lib/Features/Microsoft/Decorator/CatDecorator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace Features\Microsoft\Decorator;


use AbstractDecorator;
use Features\Microsoft\Utils\Routes;

class CatDecorator extends AbstractDecorator {
/**
* @var \PHPTALWithAppend
*/
protected $template;

public function decorate() {
$this->template->append( 'footer_js', Routes::staticBuild( '/microsoft-core-build.js' ) );
$this->template->append( 'css_resources', Routes::staticBuild( '/microsoft-build.css' ) );

$this->template->segment_filter_size = '50' ;
$this->template->segment_filter_type = 'regular_intervals' ;
}

}
23 changes: 23 additions & 0 deletions lib/Features/Microsoft/Utils/Routes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

/**
* Created by PhpStorm.
* User: fregini
* Date: 3/21/16
* Time: 12:05 PM
*/
namespace Features\Microsoft\Utils;

class Routes {


public static function staticSrc( $file, $options=array() ) {
$host = \Routes::pluginsBase( $options );
return $host . "/microsoft/static/src/$file" ;
}

public static function staticBuild( $file, $options=array() ) {
$host = \Routes::pluginsBase( $options );
return $host . "/microsoft/static/build/$file" ;
}
}
26 changes: 26 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "matecat-microsoft-plugin",
"version": "1.0.0",
"description": "",
"main": "Gruntfile.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "MateCat Team",
"license": "LGPL",
"dependencies": {
"babel-preset-es2015": "^6.9.0",
"babel-preset-react": "^6.11.1",
"babelify": "^7.2.0",
"grunt": "~0.4.2",
"grunt-browserify": "^4.0.1",
"grunt-contrib-concat": "~0.5.1",
"grunt-contrib-watch": "~0.6.1",
"grunt-sass": "^2.0.0",
"grunt-string-replace": "~0.2.7",
"grunt-strip": "^0.2.1",
"grunt-text-replace": "^0.4.0",
"keymirror": "^0.1.1",
"node-sass": "^4.6.1"
}
}
19 changes: 19 additions & 0 deletions static/src/css/sass/microsoft-core.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

.advanced-filter-searchbox {
.filters-container {
display: none;
}

.search-settings {
display: none;
}

.data-sample-checkbox-container {
display: none;
}

#clear-filter {
display: none;
}

}
56 changes: 56 additions & 0 deletions static/src/js/cat_source/microsoft-core.extension.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@


(function(SF) {

let filte_size = '50';
let filter_type = 'regular_intervals';
$.extend(UI, {

});

$.extend(SF, {

closeFilter: function ( ) {
CatToolActions.closeSubHeader();
this.open = false;
}

});

function overrideSegmentsFilter( SegmentsFilter ) {
let originalComponentDidMount = SegmentsFilter.prototype.componentDidMount;
let originaldefaultState = SegmentsFilter.prototype.defaultState;
SegmentsFilter.prototype.componentDidMount = function ( ) {

let storedState = SegmentFilter.getStoredState();
if (config.isReview && !storedState.reactState) {
originalComponentDidMount.apply(this);
this.doSubmitFilter();
} else {
originalComponentDidMount.apply(this);
}
};

SegmentsFilter.prototype.defaultState = function ( ) {
let storedState = SegmentFilter.getStoredState();
if (config.isReview && !storedState.reactState) {
return {
searchSettingsOpen: false,
selectedStatus: '',
samplingEnabled: true,
samplingType: filter_type,
samplingSize: filte_size,
filtering: false,
filteredCount: 0,
segmentsArray: [],
moreFilters: this.moreFilters

}
} else {
return originaldefaultState.apply(this);
}
}
}
overrideSegmentsFilter(SegmentFilter);

})(SegmentFilter) ;
7 changes: 7 additions & 0 deletions static/src/js/cat_source/microsoft-core.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(function() {

$.extend(UI, {

});

})() ;

0 comments on commit 7d5e607

Please sign in to comment.