This commit is contained in:
2026-09-15 10:35:56 +08:00
commit 782f8ea7aa
4086 changed files with 631288 additions and 0 deletions
@@ -0,0 +1,58 @@
define([
'jquery',
'Magento_Ui/js/grid/columns/actions',
'mage/translate',
'mage/backend/notification'
], function ($, Actions) {
'use strict';
function notify(message, isError) {
$('body').notification('clear').notification('add', {
error: isError,
message: message,
insertMethod: function (renderedMessage) {
$('.page-main-actions').after(renderedMessage);
}
});
}
function fallbackCopy(value) {
var input = $('<textarea>')
.css({position: 'fixed', opacity: 0})
.val(value)
.appendTo('body');
input[0].select();
document.execCommand('copy');
input.remove();
}
return Actions.extend({
defaultCallback: function (actionIndex, recordId, action) {
var promise;
if (actionIndex !== 'copy') {
return this._super(actionIndex, recordId, action);
}
try {
if (navigator.clipboard && window.isSecureContext) {
promise = navigator.clipboard.writeText(action.url);
promise.then(function () {
notify($.mage.__('URL copied successfully.'), false);
}).catch(function () {
fallbackCopy(action.url);
notify($.mage.__('URL copied successfully.'), false);
});
} else {
fallbackCopy(action.url);
notify($.mage.__('URL copied successfully.'), false);
}
} catch (error) {
notify($.mage.__('The URL could not be copied.'), true);
}
return this;
}
});
});
@@ -0,0 +1,97 @@
define([
'jquery',
'uiRegistry',
'mage/translate',
'mage/backend/notification'
], function ($, registry) {
'use strict';
function notify(message, isError) {
$('body').notification('add', {
error: isError,
message: message,
insertMethod: function (renderedMessage) {
$('.page-main-actions').after(renderedMessage);
}
});
}
return function (config, element) {
var $container = $(element),
$form = $container.find('[data-role=upload-form]'),
$button = $form.find('button[type=submit]'),
$progress = $form.find('[data-role=upload-progress]'),
$progressBar = $form.find('[data-role=upload-progress-bar]'),
$progressLabel = $form.find('[data-role=upload-progress-label]');
function setProgress(percent) {
$progressBar.val(percent);
$progressLabel.text(percent + '%');
}
$form.on('submit', function (event) {
var data;
event.preventDefault();
if (!$form.find('input[type=file]')[0].files.length) {
notify($.mage.__('Please select at least one file.'), true);
return;
}
data = new FormData($form[0]);
$button.prop('disabled', true);
setProgress(0);
$progress.prop('hidden', false);
$.ajax({
url: $form.attr('action'),
method: 'POST',
data: data,
processData: false,
contentType: false,
dataType: 'json',
xhr: function () {
var xhr = $.ajaxSettings.xhr();
if (xhr.upload) {
xhr.upload.addEventListener('progress', function (progressEvent) {
if (progressEvent.lengthComputable) {
setProgress(Math.round(
progressEvent.loaded / progressEvent.total * 100
));
}
});
}
return xhr;
}
}).done(function (response) {
setProgress(100);
if (response.ajaxExpired && response.ajaxRedirect) {
window.location.href = response.ajaxRedirect;
return;
}
$('body').notification('clear');
if (response.message) {
notify(response.message, response.error);
}
$.each(response.errors || [], function (index, message) {
notify(message, true);
});
if ((response.files || []).length) {
$form[0].reset();
registry.async(
'esun_filemanager_file_listing.esun_filemanager_file_listing_data_source'
)(function (provider) {
provider.reload({refresh: true});
});
}
}).fail(function () {
notify($.mage.__('The upload request failed.'), true);
}).always(function () {
$button.prop('disabled', false);
$progress.prop('hidden', true);
setProgress(0);
});
});
};
});