[build][s]: regular build.
This commit is contained in:
parent
970e4d41ea
commit
5d4166263e
12
dist/recline.css
vendored
12
dist/recline.css
vendored
@ -395,6 +395,18 @@ div.data-table-cell-content-numeric > a.data-table-cell-edit {
|
||||
width: 175px;
|
||||
}
|
||||
|
||||
.recline-filter-editor input {
|
||||
margin-top: 0.5em;
|
||||
}
|
||||
|
||||
.recline-filter-editor .add-filter {
|
||||
margin-top: 1em;
|
||||
margin-bottom: 2em;
|
||||
}
|
||||
|
||||
.recline-filter-editor .update-filter {
|
||||
margin-top: 1em;
|
||||
}
|
||||
|
||||
/**********************************************************
|
||||
* Fields Widget
|
||||
|
||||
142
dist/recline.js
vendored
142
dist/recline.js
vendored
@ -66,15 +66,25 @@ this.recline.Backend.Ckan = this.recline.Backend.Ckan || {};
|
||||
var actualQuery = {
|
||||
resource_id: dataset.id,
|
||||
q: queryObj.q,
|
||||
filters: {},
|
||||
limit: queryObj.size || 10,
|
||||
offset: queryObj.from || 0
|
||||
};
|
||||
|
||||
if (queryObj.sort && queryObj.sort.length > 0) {
|
||||
var _tmp = _.map(queryObj.sort, function(sortObj) {
|
||||
return sortObj.field + ' ' + (sortObj.order || '');
|
||||
});
|
||||
actualQuery.sort = _tmp.join(',');
|
||||
}
|
||||
|
||||
if (queryObj.filters && queryObj.filters.length > 0) {
|
||||
_.each(queryObj.filters, function(filter) {
|
||||
if (filter.type === "term") {
|
||||
actualQuery.filters[filter.field] = filter.term;
|
||||
}
|
||||
});
|
||||
}
|
||||
return actualQuery;
|
||||
};
|
||||
|
||||
@ -105,15 +115,14 @@ this.recline.Backend.Ckan = this.recline.Backend.Ckan || {};
|
||||
//
|
||||
// @param endpoint: CKAN api endpoint (e.g. http://datahub.io/api)
|
||||
my.DataStore = function(endpoint) {
|
||||
var that = {
|
||||
endpoint: endpoint || my.API_ENDPOINT
|
||||
};
|
||||
var that = {endpoint: endpoint || my.API_ENDPOINT};
|
||||
|
||||
that.search = function(data) {
|
||||
var searchUrl = that.endpoint + '/3/action/datastore_search';
|
||||
var jqxhr = jQuery.ajax({
|
||||
url: searchUrl,
|
||||
data: data,
|
||||
dataType: 'json'
|
||||
type: 'POST',
|
||||
data: JSON.stringify(data)
|
||||
});
|
||||
return jqxhr;
|
||||
};
|
||||
@ -2131,7 +2140,7 @@ my.Flot = Backbone.View.extend({
|
||||
// convert x to a string and make sure that it is not too long or the
|
||||
// tick labels will overlap
|
||||
// TODO: find a more accurate way of calculating the size of tick labels
|
||||
var label = self._xaxisLabel(x);
|
||||
var label = self._xaxisLabel(x) || "";
|
||||
|
||||
if (typeof label !== 'string') {
|
||||
label = label.toString();
|
||||
@ -4803,7 +4812,8 @@ my.Timeline = Backbone.View.extend({
|
||||
});
|
||||
var stateData = _.extend({
|
||||
startField: null,
|
||||
endField: null
|
||||
endField: null,
|
||||
timelineJSOptions: {}
|
||||
},
|
||||
options.state
|
||||
);
|
||||
@ -4836,9 +4846,8 @@ my.Timeline = Backbone.View.extend({
|
||||
if (width) {
|
||||
$timeline.width(width);
|
||||
}
|
||||
var config = {};
|
||||
var data = this._timelineJSON();
|
||||
this.timeline.init(data, this.elementId, config);
|
||||
this.timeline.init(data, this.elementId, this.state.get("timelineJSOptions"));
|
||||
this._timelineIsInitialized = true
|
||||
},
|
||||
|
||||
@ -5523,3 +5532,118 @@ my.QueryEditor = Backbone.View.extend({
|
||||
|
||||
})(jQuery, recline.View);
|
||||
|
||||
/*jshint multistr:true */
|
||||
|
||||
this.recline = this.recline || {};
|
||||
this.recline.View = this.recline.View || {};
|
||||
|
||||
(function($, my) {
|
||||
|
||||
my.ValueFilter = Backbone.View.extend({
|
||||
className: 'recline-filter-editor well',
|
||||
template: ' \
|
||||
<div class="filters"> \
|
||||
<h3>Filters</h3> \
|
||||
<button class="btn js-add-filter add-filter">Add filter</button> \
|
||||
<form class="form-stacked js-add" style="display: none;"> \
|
||||
<fieldset> \
|
||||
<label>Field</label> \
|
||||
<select class="fields"> \
|
||||
{{#fields}} \
|
||||
<option value="{{id}}">{{label}}</option> \
|
||||
{{/fields}} \
|
||||
</select> \
|
||||
<button type="submit" class="btn">Add</button> \
|
||||
</fieldset> \
|
||||
</form> \
|
||||
<form class="form-stacked js-edit"> \
|
||||
{{#filters}} \
|
||||
{{{filterRender}}} \
|
||||
{{/filters}} \
|
||||
{{#filters.length}} \
|
||||
<button type="submit" class="btn update-filter">Update</button> \
|
||||
{{/filters.length}} \
|
||||
</form> \
|
||||
</div> \
|
||||
',
|
||||
filterTemplates: {
|
||||
term: ' \
|
||||
<div class="filter-{{type}} filter"> \
|
||||
<fieldset> \
|
||||
{{field}} \
|
||||
<a class="js-remove-filter" href="#" title="Remove this filter" data-filter-id="{{id}}">×</a> \
|
||||
<input type="text" value="{{term}}" name="term" data-filter-field="{{field}}" data-filter-id="{{id}}" data-filter-type="{{type}}" /> \
|
||||
</fieldset> \
|
||||
</div> \
|
||||
'
|
||||
},
|
||||
events: {
|
||||
'click .js-remove-filter': 'onRemoveFilter',
|
||||
'click .js-add-filter': 'onAddFilterShow',
|
||||
'submit form.js-edit': 'onTermFiltersUpdate',
|
||||
'submit form.js-add': 'onAddFilter'
|
||||
},
|
||||
initialize: function() {
|
||||
this.el = $(this.el);
|
||||
_.bindAll(this, 'render');
|
||||
this.model.fields.bind('all', this.render);
|
||||
this.model.queryState.bind('change', this.render);
|
||||
this.model.queryState.bind('change:filters:new-blank', this.render);
|
||||
this.render();
|
||||
},
|
||||
render: function() {
|
||||
var self = this;
|
||||
var tmplData = $.extend(true, {}, this.model.queryState.toJSON());
|
||||
// we will use idx in list as the id ...
|
||||
tmplData.filters = _.map(tmplData.filters, function(filter, idx) {
|
||||
filter.id = idx;
|
||||
return filter;
|
||||
});
|
||||
tmplData.fields = this.model.fields.toJSON();
|
||||
tmplData.filterRender = function() {
|
||||
return Mustache.render(self.filterTemplates.term, this);
|
||||
};
|
||||
var out = Mustache.render(this.template, tmplData);
|
||||
this.el.html(out);
|
||||
},
|
||||
updateFilter: function(input) {
|
||||
var self = this;
|
||||
var filters = self.model.queryState.get('filters');
|
||||
var $input = $(input);
|
||||
var filterIndex = parseInt($input.attr('data-filter-id'), 10);
|
||||
var value = $input.val();
|
||||
filters[filterIndex].term = value;
|
||||
},
|
||||
onAddFilterShow: function(e) {
|
||||
e.preventDefault();
|
||||
var $target = $(e.target);
|
||||
$target.hide();
|
||||
this.el.find('form.js-add').show();
|
||||
},
|
||||
onAddFilter: function(e) {
|
||||
e.preventDefault();
|
||||
var $target = $(e.target);
|
||||
$target.hide();
|
||||
var field = $target.find('select.fields').val();
|
||||
this.model.queryState.addFilter({type: 'term', field: field});
|
||||
},
|
||||
onRemoveFilter: function(e) {
|
||||
e.preventDefault();
|
||||
var $target = $(e.target);
|
||||
var filterId = $target.attr('data-filter-id');
|
||||
this.model.queryState.removeFilter(filterId);
|
||||
},
|
||||
onTermFiltersUpdate: function(e) {
|
||||
var self = this;
|
||||
e.preventDefault();
|
||||
var filters = self.model.queryState.get('filters');
|
||||
var $form = $(e.target);
|
||||
_.each($form.find('input'), function(input) {
|
||||
self.updateFilter(input);
|
||||
});
|
||||
self.model.queryState.set({filters: filters, from: 0});
|
||||
self.model.queryState.trigger('change');
|
||||
}
|
||||
});
|
||||
|
||||
})(jQuery, recline.View);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user