-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EZP-30344: Implemented Translation Limitation - language limitation
- Loading branch information
1 parent
9a56766
commit 79483d9
Showing
18 changed files
with
171 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ active_domains: | |
- 'fieldtypes_edit' | ||
- 'notifications' | ||
- 'search' | ||
- 'content' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 33 additions & 10 deletions
43
src/bundle/Resources/public/js/scripts/admin.version.edit.conflict.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,45 @@ | ||
(function (global, doc, $) { | ||
(function (global, doc, $, eZ) { | ||
const editVersion = (event) => { | ||
const showErrorNotification = eZ.helpers.notification.showErrorNotification; | ||
const contentDraftEditUrl = event.currentTarget.dataset.contentDraftEditUrl; | ||
const versionHasConflictUrl = event.currentTarget.dataset.versionHasConflictUrl; | ||
const contentId = event.currentTarget.dataset.contentId; | ||
const languageCode = event.currentTarget.dataset.languageCode; | ||
const checkEditPermissionLink = global.Routing.generate('ezplatform.content.check_edit_permission', { contentId, languageCode }); | ||
const errorMessage = Translator.trans( | ||
/*@Desc("You cannot edit Content with ID: %id%")*/ 'content.edit.permission.error', | ||
{ id: contentId }, | ||
'content' | ||
); | ||
const handleCanEditCheck = (response) => { | ||
if (response.canEdit) { | ||
return fetch(versionHasConflictUrl, { mode: 'same-origin', credentials: 'same-origin' }); | ||
} | ||
|
||
event.preventDefault(); | ||
|
||
fetch(versionHasConflictUrl, { | ||
credentials: 'same-origin' | ||
}).then(function (response) { | ||
throw new Error(errorMessage); | ||
}; | ||
const handleVersionDraftConflict = (response) => { | ||
// Status 409 means that a draft conflict has occurred and the modal must be displayed. | ||
// Otherwise we can go to Content Item edit page. | ||
if (response.status === 409) { | ||
doc.querySelector('#edit-conflicted-draft').href = contentDraftEditUrl; | ||
$('#version-conflict-modal').modal('show'); | ||
} | ||
if (response.status === 403) { | ||
response.text().then(showErrorNotification); | ||
} | ||
if (response.status === 200) { | ||
global.location.href = contentDraftEditUrl; | ||
} | ||
}) | ||
}; | ||
}; | ||
|
||
event.preventDefault(); | ||
|
||
[...doc.querySelectorAll('.ez-btn--content-draft-edit')].forEach(link => link.addEventListener('click', editVersion, false)); | ||
})(window, document, window.jQuery); | ||
fetch(checkEditPermissionLink, { mode: 'same-origin', credentials: 'same-origin' }) | ||
.then(eZ.helpers.request.getJsonFromResponse) | ||
.then(handleCanEditCheck) | ||
.then(handleVersionDraftConflict) | ||
.catch(showErrorNotification); | ||
}; | ||
doc.querySelectorAll('.ez-btn--content-draft-edit').forEach((button) => button.addEventListener('click', editVersion, false)); | ||
})(window, document, window.jQuery, window.eZ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{% macro edit_content_button(content, title) %} | ||
<button class="btn btn-icon mx-2 ez-btn--content-edit" | ||
title="{{ title }}" | ||
data-content-id="{{ content.contentId }}" | ||
data-version-no="{{ content.version }}" | ||
data-language-code="{{ content.language }}"> | ||
<svg class="ez-icon ez-icon-edit"> | ||
<use xlink:href="{{ asset('bundles/ezplatformadminui/img/ez-icons.svg') }}#edit"></use> | ||
</svg> | ||
</button> | ||
{% endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.