Skip to content
This repository has been archived by the owner on May 3, 2022. It is now read-only.

Commit

Permalink
fixup! EZP-27914: As an Editor I want to remove permanently a languag…
Browse files Browse the repository at this point in the history
…e from a content item
  • Loading branch information
adamwojs committed Feb 9, 2018
1 parent 9a372c6 commit 784b406
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 31 deletions.
8 changes: 6 additions & 2 deletions Resources/public/css/views/actions/translate.css
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,12 @@
top: 0.9em;
}

.ez-view-translateactionview .ez-contenttranslation-edit-link,
.ez-view-translateactionview .ez-contenttranslation-delete-link {
.ez-view-translateactionview .ez-contenttranslation:hover .ez-contenttranslation-actions {
display: block;
}

.ez-view-translateactionview .ez-contenttranslation-actions .ez-contenttranslation-edit-link,
.ez-view-translateactionview .ez-contenttranslation-actions .ez-contenttranslation-delete-link {
display: inline-block;
padding: 0.1em 0.5em;
}
Expand Down
24 changes: 4 additions & 20 deletions Resources/public/js/alloyeditor/buttons/linkedit.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,23 +312,15 @@ YUI.add('ez-alloyeditor-button-linkedit', function (Y) {
var editor = this.props.editor.get('nativeEditor'),
linkUtils = new CKEDITOR.Link(editor),
selection = editor.getSelection(),
bookmarks = selection.createBookmarks(),
scrollY;
bookmarks = selection.createBookmarks();

linkUtils.remove(this.state.element, {advance: true});

selection.selectBookmarks(bookmarks);

this.props.cancelExclusive();

if (navigator.userAgent.indexOf('Chrome') > -1) {
// Workaround for https://jira.ez.no/browse/EZP-28565
scrollY = window.pageYOffset;
editor.fire('actionPerformed', this);
window.scroll(window.pageXOffset, scrollY);
} else {
editor.fire('actionPerformed', this);
}
editor.fire('actionPerformed', this);
},

/**
Expand Down Expand Up @@ -361,21 +353,13 @@ YUI.add('ez-alloyeditor-button-linkedit', function (Y) {
title: this.state.linkTitle,
"data-ez-temporary-link": this.state.isTemporary ? true : null,
},
modifySelection = {advance: true},
scrollY;
modifySelection = {advance: true};

if (this.state.linkHref) {
linkAttrs.href = this.state.linkHref;
linkUtils.update(linkAttrs, this.state.element, modifySelection);

if (navigator.userAgent.indexOf('Chrome') > -1) {
// Workaround for https://jira.ez.no/browse/EZP-28565
scrollY = window.pageYOffset;
editor.fire('actionPerformed', this);
window.scroll(window.pageXOffset, scrollY);
} else {
editor.fire('actionPerformed', this);
}
editor.fire('actionPerformed', this);
}

// We need to cancelExclusive with the bound parameters in case the
Expand Down
1 change: 1 addition & 0 deletions Resources/public/js/models/ez-contentmodel.js
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ YUI.add('ez-contentmodel', function (Y) {
if ( !this.get('id') ) {
return callback(false);
}

contentService.removeTranslation(this.get('id'), languageCode, callback);
},
}, {
Expand Down
9 changes: 8 additions & 1 deletion Resources/public/js/views/actions/ez-translateactionview.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ YUI.add('ez-translateactionview', function (Y) {
'.ez-newtranslation-button': {
'tap': '_newTranslationLanguageSelectionBox',
},

'.ez-contenttranslation-delete-link': {
'tap': '_deleteTranslation',
},
Expand Down Expand Up @@ -166,6 +165,14 @@ YUI.add('ez-translateactionview', function (Y) {
};

e.preventDefault();

/**
* Fired when the translation is deleted
*
* @event deleteTranslation
* @param {e.translation} Language code of translation
* @param {e.contentId} The content Id
*/
this.fire('deleteTranslation', data);
},

Expand Down
22 changes: 18 additions & 4 deletions Resources/public/js/views/services/ez-locationviewviewservice.js
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ YUI.add('ez-locationviewviewservice', function (Y) {
},

/**
* Removes translation form content.
* Removes translation from content.
*
* @method _deleteTranslation
* @protected
Expand All @@ -581,9 +581,17 @@ YUI.add('ez-locationviewviewservice', function (Y) {
api: this.get('capi')
};

content.removeTranslation(options, languageCode, Y.bind(function() {
content.removeTranslation(options, languageCode, Y.bind(function(error) {
if (error) {
this._notify(
Y.eZ.trans('failed.delete.content.translation', { language: languageCode }, 'bar'),
'content-delete-translation-' + content.get('id'), 'error', 0
);
return ;
}

this._notify(
Y.eZ.trans('success.delete.content.translation', {}, 'bar'),
Y.eZ.trans('success.delete.content.translation', { language: languageCode }, 'bar'),
'content-delete-translation-' + content.get('id'), 'done', 5
);

Expand All @@ -595,7 +603,7 @@ YUI.add('ez-locationviewviewservice', function (Y) {
},

/**
* `deleteTranslationAction` event handler,
* `deleteTranslation` event handler,
* it asks confirmation to the user before delete the translation item.
*
* @method _confirmDeleteTranslation
Expand All @@ -613,6 +621,12 @@ YUI.add('ez-locationviewviewservice', function (Y) {
'content-delete-translation-' + content.get('id'), 'error', 0
);
} else {
/**
* Opens confirmation modal of deleting translation
*
* @event deleteTranslation
* @param {e.config} Modal configuration
*/
this.fire('confirmBoxOpen', {
config: {
title: Y.eZ.trans('confirm.delete.translation', { language: languageCode }, 'bar'),
Expand Down
14 changes: 10 additions & 4 deletions Resources/translations/bar.en.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -228,17 +228,23 @@
<jms:reference-file>Resources/public/templates/translateaction.hbt</jms:reference-file>
</trans-unit>
<trans-unit id="f066151955a2dd9163a84081f8f2ef175966bbd4" resname="confirm.delete.translation">
<source>Are you sure you want to delete %language% translation ?</source>
<target>Are you sure you want to delete %language% translation ?</target>
<source>Are you sure you want to delete "%language%" translation?</source>
<target>Are you sure you want to delete "%language%" translation?</target>
<note>key: confirm.delete.translation</note>
<jms:reference-file>Resources/public/js/views/services/ez-locationviewviewservice.js</jms:reference-file>
</trans-unit>
<trans-unit id="e5e147f6fd07facc4a3318e223553c790faa0641" resname="success.delete.content.translation">
<source>Translation %language% has been deleted.</source>
<target>Translation %language% has been deleted.</target>
<source>Translation "%language%" has been deleted.</source>
<target>Translation "%language%" has been deleted.</target>
<note>key: success.delete.content.translation</note>
<jms:reference-file>Resources/public/js/views/services/ez-locationviewviewservice.js</jms:reference-file>
</trans-unit>
<trans-unit id="011d57b24d3097d18e29e303e9b6c0c54ba82a8c" resname="failed.delete.content.translation">
<source>Cannot delete translation "%language%" from content.</source>
<target>Cannot delete translation "%language%" from content.</target>
<note>key: failed.delete.content.translation</note>
<jms:reference-file>Resources/public/js/views/services/ez-locationviewviewservice.js</jms:reference-file>
</trans-unit>
<trans-unit id="011d57b24d3097d18e29e303e9b6c0c54ba82a8c" resname="failed.delete.content.main.translation">
<source>Cannot delete main translation from content.</source>
<target>Cannot delete main translation from content.</target>
Expand Down

0 comments on commit 784b406

Please sign in to comment.