gooddata
Advanced tools
Comparing version
@@ -650,2 +650,3 @@ 'use strict'; | ||
* - restrictiveDefinition {String} | ||
* - afm {Object} | ||
* @return {Object} ValidElements response with: | ||
@@ -661,9 +662,29 @@ * - items {Array} elements | ||
var queryParams = (0, _util.queryString)(query); | ||
var pickedOptions = (0, _lodash.pick)(options, ['uris', 'complement', 'includeTotalCountWithoutFilters', 'restrictiveDefinition']); | ||
var afm = options.afm; | ||
var requestBody = (0, _lodash.pick)(options, ['uris', 'complement', 'includeTotalCountWithoutFilters', 'restrictiveDefinition']); | ||
return xhr.post(('/gdc/md/' + projectId + '/obj/' + id + '/validElements' + queryParams).replace(/\?$/, ''), { | ||
data: JSON.stringify({ | ||
validElementsRequest: requestBody | ||
}) | ||
}).then(xhr.parseJSON); | ||
var getRequestBodyWithReportDefinition = function getRequestBodyWithReportDefinition() { | ||
return xhr.post('/gdc/app/projects/' + projectId + '/executeAfm/debug', { | ||
body: { | ||
execution: { | ||
afm: afm | ||
} | ||
} | ||
}).then(xhr.parseJSON).then(function (reportDefinitionResult) { | ||
return _extends({}, pickedOptions, { | ||
restrictiveDefinitionContent: reportDefinitionResult.reportDefinition.content | ||
}); | ||
}); | ||
}; | ||
var getOptions = afm ? getRequestBodyWithReportDefinition : function () { | ||
return Promise.resolve(pickedOptions); | ||
}; | ||
return getOptions().then(function (requestBody) { | ||
return xhr.post(('/gdc/md/' + projectId + '/obj/' + id + '/validElements' + queryParams).replace(/\?$/, ''), { | ||
data: JSON.stringify({ validElementsRequest: requestBody }) | ||
}).then(xhr.parseJSON); | ||
}); | ||
} | ||
@@ -670,0 +691,0 @@ |
{ | ||
"name": "gooddata", | ||
"version": "6.0.0-alpha3", | ||
"version": "6.0.0-alpha4", | ||
"author": "GoodData", | ||
@@ -5,0 +5,0 @@ "description": "GoodData JavaScript SDK", |
@@ -543,2 +543,3 @@ // Copyright (C) 2007-2014, GoodData(R) Corporation. All rights reserved. | ||
/** | ||
@@ -583,2 +584,3 @@ * Get attribute elements with their labels and uris. | ||
* - restrictiveDefinition {String} | ||
* - afm {Object} | ||
* @return {Object} ValidElements response with: | ||
@@ -592,9 +594,31 @@ * - items {Array} elements | ||
const queryParams = queryString(query); | ||
const pickedOptions = pick(options, [ | ||
'uris', 'complement', 'includeTotalCountWithoutFilters', 'restrictiveDefinition' | ||
]); | ||
const { afm } = options; | ||
const requestBody = pick(options, ['uris', 'complement', 'includeTotalCountWithoutFilters', 'restrictiveDefinition']); | ||
return xhr.post(`/gdc/md/${projectId}/obj/${id}/validElements${queryParams}`.replace(/\?$/, ''), { | ||
data: JSON.stringify({ | ||
validElementsRequest: requestBody | ||
}) | ||
}).then(xhr.parseJSON); | ||
const getRequestBodyWithReportDefinition = | ||
() => xhr | ||
.post(`/gdc/app/projects/${projectId}/executeAfm/debug`, { | ||
body: { | ||
execution: { | ||
afm | ||
} | ||
} | ||
}) | ||
.then(xhr.parseJSON) | ||
.then(reportDefinitionResult => ({ | ||
...pickedOptions, | ||
restrictiveDefinitionContent: reportDefinitionResult.reportDefinition.content | ||
})); | ||
const getOptions = afm ? getRequestBodyWithReportDefinition : () => Promise.resolve(pickedOptions); | ||
return getOptions() | ||
.then(requestBody => xhr | ||
.post(`/gdc/md/${projectId}/obj/${id}/validElements${queryParams}`.replace(/\?$/, ''), { | ||
data: JSON.stringify({ validElementsRequest: requestBody }) | ||
}) | ||
.then(xhr.parseJSON) | ||
); | ||
} | ||
@@ -601,0 +625,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
1188528
0.24%27716
0.21%