Skip to content

Commit

Permalink
EZP-27871: Implemented ContentService#removeTranslation (#86)
Browse files Browse the repository at this point in the history
* EZP-27871: Implemented ContentService#removeTranslation

* Rebuild CAPI
  • Loading branch information
dpobel authored and andrerom committed Feb 9, 2018
1 parent fbbb34d commit ca18a99
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dist/CAPI-min.js

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions dist/CAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -3876,6 +3876,25 @@ define('services/ContentService',["structures/ContentCreateStruct", "structures/
);
};

/**
* Removes the translation in `languageCode` from the given Content item.
*
* @method removeTranslation
* @param contentId {String} REST content id
* @param languageCode {String}
* @param callback {Function} callback executed after performing the request (see
* {{#crossLink "ContentService"}}Note on the callbacks usage{{/crossLink}} for more info)
*/
ContentService.prototype.removeTranslation = function (contentId, languageCode, callback) {
this._connectionManager.request(
'DELETE',
contentId + '/translations/' + languageCode,
'',
{},
callback
);
};

// ******************************
// Versions management
// ******************************
Expand Down
19 changes: 19 additions & 0 deletions src/services/ContentService.js
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,25 @@ define(["structures/ContentCreateStruct", "structures/ContentUpdateStruct", "str
);
};

/**
* Removes the translation in `languageCode` from the given Content item.
*
* @method removeTranslation
* @param contentId {String} REST content id
* @param languageCode {String}
* @param callback {Function} callback executed after performing the request (see
* {{#crossLink "ContentService"}}Note on the callbacks usage{{/crossLink}} for more info)
*/
ContentService.prototype.removeTranslation = function (contentId, languageCode, callback) {
this._connectionManager.request(
'DELETE',
contentId + '/translations/' + languageCode,
'',
{},
callback
);
};

// ******************************
// Versions management
// ******************************
Expand Down
18 changes: 18 additions & 0 deletions test/ContentService.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,24 @@ define(function (require) {
);
});

it('removeTranslation', function () {
var lang = 'whatever';

contentService.removeTranslation(
testContentId,
lang,
mockCallback
);

expect(mockConnectionManager.request).toHaveBeenCalledWith(
'DELETE',
testContentId + '/translations/' + lang,
"",
{},
mockCallback
);
});

it("loadContentByRemoteId", function () {
contentService.loadContentByRemoteId(
testRemoteId,
Expand Down

0 comments on commit ca18a99

Please sign in to comment.