-
Notifications
You must be signed in to change notification settings - Fork 91
#1390 Add related content information to the delete asset warning #1401
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
84eae32
Add related content information to the delete asset warning
ProkopovVitaliy e7889e5
corrected message text
ProkopovVitaliy f17ecca
Merge branch '2.0.0-stabilization' into #1390
ProkopovVitaliy 3b0cd3c
changed message for delete confirmation
ProkopovVitaliy eedc6ab
Merge branch '#1390' of github.com:ProkopovVitaliy/adobe-stock-integr…
ProkopovVitaliy ee31084
Merge branch '2.0.0-stabilization' into #1390
ProkopovVitaliy 3a1c9d1
Update Provider.php
ProkopovVitaliy 41a0c4a
corrected static test
ProkopovVitaliy ff3dd10
Merge branch '#1390' of github.com:ProkopovVitaliy/adobe-stock-integr…
ProkopovVitaliy 18fecea
processing of additional information for the removal process has been…
ProkopovVitaliy 2d7b00f
Merge branch '2.0-develop' into #1390
ProkopovVitaliy 1ac1e12
Update MediaGalleryUi/Ui/Component/Listing/Provider.php
ProkopovVitaliy 7243241
apply code review recommendations
ProkopovVitaliy b94408d
Merge branch '2.0-develop' into #1390
ProkopovVitaliy fa88116
fixed failed static test
ProkopovVitaliy 167d92e
Merge branch '#1390' of github.com:ProkopovVitaliy/adobe-stock-integr…
ProkopovVitaliy 05443d7
fixed confirmation message for deleting ffrom detail window
ProkopovVitaliy 48d3a3e
fixed code style
ProkopovVitaliy c7e80a4
Merge branch '2.0-develop' into #1390
ProkopovVitaliy 728ccbb
fixed eslint errors
ProkopovVitaliy 5b1feeb
removed extra char
ProkopovVitaliy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
77 changes: 77 additions & 0 deletions
77
MediaGalleryUi/view/adminhtml/web/js/action/deleteImageWithDetailConfirmation.js
This file contains hidden or 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,77 @@ | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
define([ | ||
'jquery', | ||
'underscore', | ||
'Magento_MediaGalleryUi/js/action/getDetails', | ||
'Magento_MediaGalleryUi/js/action/deleteImage' | ||
], function ($, _, getDetails, deleteImage) { | ||
'use strict'; | ||
|
||
return { | ||
|
||
/** | ||
* Get information about image use | ||
* | ||
* @param {Object} record | ||
* @param {String} imageDetailsUrl | ||
* @param {String} deleteImageUrl | ||
*/ | ||
deleteImageAction: function (record, imageDetailsUrl, deleteImageUrl) { | ||
var confirmationContent = $.mage.__('%1 Are you sure you want to delete "%2" image?') | ||
.replace('%2', record.path); | ||
|
||
getDetails(imageDetailsUrl, record.id) | ||
.then(function (imageDetails) { | ||
confirmationContent = confirmationContent.replace( | ||
'%1', | ||
this.getConfirmationContentByImageDetails(imageDetails) | ||
); | ||
}.bind(this)).fail(function () { | ||
confirmationContent = confirmationContent.replace('%1', ''); | ||
}).always(function () { | ||
deleteImage.deleteImageAction(record, deleteImageUrl, confirmationContent); | ||
}); | ||
}, | ||
|
||
/** | ||
* Returns confirmation content with information about related content | ||
* | ||
* @param {Object} imageDetails | ||
* @return String | ||
*/ | ||
getConfirmationContentByImageDetails: function (imageDetails) { | ||
var details = imageDetails.details; | ||
|
||
if (_.isObject(details) && !_.isUndefined(details['6'])) { | ||
return this.getRecordRelatedContentMessage(details['6'].value); | ||
} | ||
|
||
return ''; | ||
}, | ||
|
||
/** | ||
* Get information about image use | ||
* | ||
* @param {Object|String} value | ||
* @return {String} | ||
*/ | ||
getRecordRelatedContentMessage: function (value) { | ||
var usedInMessage = $.mage.__('This image is used in %s.'), | ||
usedIn = ''; | ||
|
||
if (_.isObject(value) && !_.isEmpty(value)) { | ||
_.each(value, function (numberOfTimeUsed, moduleName) { | ||
usedIn += numberOfTimeUsed + ' ' + moduleName + ', '; | ||
}); | ||
usedIn = usedIn.replace(/,\s*$/, ''); | ||
|
||
return usedInMessage.replace('%s', usedIn); | ||
} | ||
|
||
return ''; | ||
} | ||
}; | ||
}); |
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.