Skip to content

Commit

Permalink
fix(API): Fix various premature string conversions
Browse files Browse the repository at this point in the history
API data objects were being prematurely converted to a string and were
bypassing the casing renamer http transformer.

Fixes #280

Original bug introduced in
cd00962
  • Loading branch information
atruskie committed Feb 10, 2017
1 parent 29267b1 commit 7a678bf
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/app/listen/listen.js
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ angular
function success(value, headers) {

// possible race condition: may no longer may be selected after async
$scope.model.selectedAudioEvent.taggings[index] = new baw.Tagging(value);
$scope.model.selectedAudioEvent.taggings[index] = new baw.Tagging(value.data);
$scope.model.selectedAudioEvent.tags[index] = addedTag.tag;

console.assert(
Expand Down
6 changes: 3 additions & 3 deletions src/components/services/audioEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ angular
return q;
});

return $http.post(url, qb.toJSONString());
return $http.post(url, qb.toJSON());
};

const filterUrl = paths.api.routes.audioEvent.filterAbsolute;
Expand All @@ -87,7 +87,7 @@ angular
});

return $http
.post(filterUrl, query.toJSONString())
.post(filterUrl, query.toJSON())
.then(x => AudioEventModel.makeFromApi(x));
};

Expand All @@ -100,7 +100,7 @@ angular
);
});

return $http.post(filterUrl, query.toJSONString())
return $http.post(filterUrl, query.toJSON())
.then(resultPager.loadAll)
.then(x => AudioEventModel.makeFromApi(x));
};
Expand Down
12 changes: 6 additions & 6 deletions src/components/services/queryBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ angular

function filterToQueryString(filterObject) {
var results = [];
for(let [key, value] of Object.entries(filterObject)) {
for (let [key, value] of Object.entries(filterObject)) {
if (!validCombinators.hasOwnProperty(key)) {
if (value.hasOwnProperty("eq")) {
results.push(["filter_" + key, value.eq]);
Expand Down Expand Up @@ -417,7 +417,7 @@ angular
return this.end.call(query);
};

this.toJSON = function() {
this.toJSON = function () {
var compiledQuery = {},
that = this;

Expand All @@ -427,11 +427,11 @@ angular
}
});

return compiledQuery;
};
return compiledQuery;
};

this.toJSONString = function toJSON(spaces) {
return JSON.stringify(this.toJSON(), null, spaces);
this.toJSONString = function toJSON(spaces) {
return JSON.stringify(this.toJSON(), null, spaces);
};

this.toQueryString = function toQueryString() {
Expand Down
2 changes: 1 addition & 1 deletion src/components/services/tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ angular
return q.in("audioEvents.id", audioEventIds);
});

return $http.post(url, query.toJSONString()).then(x => TagModel.makeFromApi(x));
return $http.post(url, query.toJSON()).then(x => TagModel.makeFromApi(x));
};

return resource;
Expand Down

0 comments on commit 7a678bf

Please sign in to comment.