-
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.
Browse files
Browse the repository at this point in the history
* Improved handling Language Limitation * Disabled HTTP cache for ContentController::checkEditPermissionAction * Enabled right sidebar edit button for translated Content Editing should be possible if Content is already translated. * Added permission check for edit button in Sub-items Co-authored-by: Jakub <[email protected]>
- Loading branch information
Showing
25 changed files
with
478 additions
and
106 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
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
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
42 changes: 33 additions & 9 deletions
42
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,46 @@ | ||
(function (global, doc, $) { | ||
(function (global, doc, $, eZ, Translator) { | ||
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 don't have permission to edit the content")*/ 'content.edit.permission.error', | ||
{}, | ||
'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(); | ||
|
||
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(link => link.addEventListener('click', editVersion, false)); | ||
})(window, document, window.jQuery); | ||
doc.querySelectorAll('.ez-btn--content-draft-edit').forEach((button) => button.addEventListener('click', editVersion, false)); | ||
})(window, document, window.jQuery, window.eZ, window.Translator); |
Oops, something went wrong.