[explorev2] Bug fixes in Save Modal (#1707)

* Bug fixes in Save Modal
Issues solved:
 - Save button doesn't pass in gotodash
 - slice_name was passed in from store as original slice_name instead of
   new one in 'saveas' action
 - datasource_type wasn't passed in to defaultViz and defaultForm
   function

* Change css filename to exploreV2

* Moved out utils
This commit is contained in:
vera-liu
2016-11-29 15:03:15 -08:00
committed by GitHub
parent dc98c6739f
commit 03b21dcf0a
7 changed files with 53 additions and 49 deletions

View File

@@ -154,38 +154,6 @@ export function slugify(string) {
.replace(/-$/, ''); // remove last floating dash
}
function formatFilters(filters) {
// outputs an object of url params of filters
// prefix can be 'flt' or 'having'
const params = {};
for (let i = 0; i < filters.length; i++) {
const filter = filters[i];
params[`${filter.prefix}_col_${i + 1}`] = filter.col;
params[`${filter.prefix}_op_${i + 1}`] = filter.op;
params[`${filter.prefix}_eq_${i + 1}`] = filter.value;
}
return params;
}
export function getParamObject(form_data, datasource_type) {
const data = {
// V2 tag temporarily for updating url
// Todo: remove after launch
V2: true,
datasource_id: form_data.datasource,
datasource_type,
};
Object.keys(form_data).forEach((field) => {
// filter out null fields
if (form_data[field] !== null && field !== 'datasource') {
data[field] = form_data[field];
}
});
const filterParams = formatFilters(form_data.filters);
Object.assign(data, filterParams);
return data;
}
export function getAjaxErrorMsg(error) {
const respJSON = error.responseJSON;
return (respJSON && respJSON.message) ? respJSON.message :