diff --git a/Resources/public/js/models/ez-contentmodel.js b/Resources/public/js/models/ez-contentmodel.js index 8a907af17..42a282208 100644 --- a/Resources/public/js/models/ez-contentmodel.js +++ b/Resources/public/js/models/ez-contentmodel.js @@ -464,6 +464,25 @@ YUI.add('ez-contentmodel', function (Y) { } contentService.deleteContent(this.get('id'), callback); }, + + /** + * Removes translation + * + * @method removeTranslation + * @param {Object} options + * @param {Object} options.api (required) the JS REST client instance + * @param {String} languageCode + * @param {Function} callback + */ + removeTranslation: function (options, languageCode, callback) { + var capi = options.api, + contentService = capi.getContentService(); + + if ( !this.get('id') ) { + return callback(false); + } + contentService.removeTranslation(this.get('contentId'), languageCode, callback); + }, }, { REST_STRUCT_ROOT: "Content", ATTRS_REST_MAP: [ diff --git a/Resources/public/js/views/actions/ez-translateactionview.js b/Resources/public/js/views/actions/ez-translateactionview.js index e5a066717..ed2cac137 100644 --- a/Resources/public/js/views/actions/ez-translateactionview.js +++ b/Resources/public/js/views/actions/ez-translateactionview.js @@ -14,7 +14,11 @@ YUI.add('ez-translateactionview', function (Y) { var events = { '.ez-newtranslation-button': { 'tap': '_newTranslationLanguageSelectionBox', - } + }, + + '.ez-contenttranslation-delete-link': { + 'tap': '_deleteTranslation', + }, }; /** @@ -147,6 +151,22 @@ YUI.add('ez-translateactionview', function (Y) { this._hideView(); }, + /** + * Tap event handler on + * + * @method + * @private + * @param {EventFacade} e + */ + _deleteTranslation: function (e) { + var data = { + translation: e.target.getAttribute('data-translation'), + contentId: this.get('content').get('contentId'), + } + e.preventDefault(); + this.fire('deleteTranslation', data); + }, + /** * Fires `translate` event after making a selection on LanguageSelectionBox * diff --git a/Resources/public/js/views/services/ez-locationviewviewservice.js b/Resources/public/js/views/services/ez-locationviewviewservice.js index 5495b1c97..95c4a7ef3 100644 --- a/Resources/public/js/views/services/ez-locationviewviewservice.js +++ b/Resources/public/js/views/services/ez-locationviewviewservice.js @@ -30,6 +30,7 @@ YUI.add('ez-locationviewviewservice', function (Y) { this.on('*:translateContent', this._translateContent); this.on('*:sortUpdate', this._updateSorting); this.on('*:updatePriority', this._updatePriority); + this.on('*:deleteTranslation', this._deleteTranslation); this.after('*:requestChange', this._setLanguageCode); this._setLanguageCode(); @@ -505,6 +506,21 @@ YUI.add('ez-locationviewviewservice', function (Y) { this.set('languageCode', this.get('request').params.languageCode); }, + /** + * + * + * @method _deleteTranslation + * @protected + */ + _deleteTranslation: function (e) { + var loadOptions = { + api: this.get('capi') + }; + + + + }, + _getViewParameters: function () { return { content: this.get('content'), diff --git a/Resources/public/templates/translateaction.hbt b/Resources/public/templates/translateaction.hbt index 306d75015..b178200ef 100644 --- a/Resources/public/templates/translateaction.hbt +++ b/Resources/public/templates/translateaction.hbt @@ -24,6 +24,9 @@ {{translate 'translateaction.edit' 'bar'}} + + {{translate 'translateaction.delete' 'bar'}} + {{/each}}