Skip to content
Snippets Groups Projects
Commit e8a68451 authored by Kyle Doherty's avatar Kyle Doherty
Browse files

single filter working

parent 0c825fea
Branches
Tags
No related merge requests found
......@@ -1381,12 +1381,9 @@ CardControllers.controller('CardDetailNew', [
$scope.model.card.dataset_query.query.aggregation[1] = target;
$scope.model.inform();
},
updateFilter: function (value, filterIndex, listIndex) {
var filters = $scope.model.card.dataset_query.query.filter,
filterListIndex = listIndex || 0;
updateFilter: function (value, index, filterListIndex) {
var filters = $scope.model.card.dataset_query.query.filter
console.log(filters)
console.log(arguments)
// check to see if we need to add another item for
/*
scope.addFilter = function() {
......@@ -1418,8 +1415,12 @@ CardControllers.controller('CardDetailNew', [
return result;
};
*/
if(filterListIndex) {
filters[filterListIndex][index] = value
} else {
filters[index] = value
}
filters[filterListIndex][filterIndex] = value;
$scope.model.inform();
},
removeFilter: function (index) {
......@@ -1435,7 +1436,6 @@ CardControllers.controller('CardDetailNew', [
$scope.model.card.dataset_query.query.filter = [];
$scope.model.card.dataset_query.query.filter.push('AND');
$scope.model.card.dataset_query.query.filter.push(newFilters);
debugger
$scope.model.inform();
} else if(filter[0] == 'AND'){
pushFilterTemplate(filterLength)
......@@ -1446,7 +1446,6 @@ CardControllers.controller('CardDetailNew', [
}
function pushFilterTemplate(index) {
console.log('index', index)
if(index) {
filter[index] = [null, null, null]
} else {
......
......@@ -599,13 +599,36 @@ var FilterWidget = React.createClass({
// we always know the index will 2 for the value of a filter
this.props.updateFilter(value, 2, index)
},
_operatorList: function (open) {
return (
<div className="FilterSection">
<SelectionModule
placeholder="..."
items={this.props.operatorList}
display='verbose_name'
selectedValue={this.props.operator}
selectedKey='name'
index={0}
isInitiallyOpen={open}
parentIndex={this.props.index}
action={this.props.updateFilter}
/>
</div>
)
},
render: function () {
console.log('filter widget props', this.props)
var fieldListOpen = true,
operatorList,
operatorListHtml,
canShowOperatorList = false,
operatorListOpen = true,
valueHtml
var style = {
fill: '#ddd'
}
if(this.props.field != null) {
fieldListOpen = false,
canShowOperatorList = true
......@@ -616,25 +639,7 @@ var FilterWidget = React.createClass({
}
if(canShowOperatorList) {
operatorList = (
<div className="FilterSection">
<SelectionModule
placeholder="..."
items={this.props.operatorList}
display='verbose_name'
selectedValue={this.props.operator}
selectedKey='name'
index={0}
isInitiallyOpen={operatorListOpen}
parentIndex={this.props.index}
action={this.props.updateFilter}
/>
</div>
)
}
var style = {
fill: '#ddd'
operatorListHtml = this._operatorList(operatorListOpen)
}
if(this.props.valueFields) {
......@@ -715,7 +720,7 @@ var FilterWidget = React.createClass({
action={this.props.updateFilter}
/>
</div>
{operatorList}
{operatorListHtml}
<div className="FilterSection">
{valueHtml}
</div>
......@@ -770,9 +775,8 @@ var QueryBuilder = React.createClass({
value = filter[2],
operatorList = [],
valueFields
var filterFieldList = this._getFilterFields()
valueFields,
filterFieldList = this._getFilterFields()
// extract the real info
for(var fieldItem in filterFieldList) {
......@@ -793,8 +797,6 @@ var QueryBuilder = React.createClass({
}
}
debugger;
return (
<FilterWidget
placeholder="Item"
......@@ -820,15 +822,15 @@ var QueryBuilder = React.createClass({
var filters = this.props.model.card.dataset_query.query.filter
// if we have filters...
if(filters.length != 0) {
// if we have multiple filters, map through and return a filter widget
// and if we have multiple filters, map through and return a filter widget
if(filters[0] == 'AND') {
filterList = this.props.model.card.dataset_query.query.filter.map(function (filter, index) {
this._getFilterWidget(filter, index)
}.bind(this))
} else {
this._getFilterWidget(filters)
filterList = this._getFilterWidget(filters)
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment