META-INF.resources.import_portlet_validation.jsp Maven / Gradle / Ivy
<%--
/**
* SPDX-FileCopyrightText: (c) 2000 Liferay, Inc. https://liferay.com
* SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
*/
--%>
<%@ include file="/init.jsp" %>
<%
String redirect = ParamUtil.getString(request, "redirect");
%>
<%
FileEntry fileEntry = ExportImportHelperUtil.getTempFileEntry(scopeGroupId, themeDisplay.getUserId(), ExportImportHelper.TEMP_FOLDER_NAME + selPortlet.getPortletId());
%>
">
<%
Date expirationDate = new Date(System.currentTimeMillis() + (PropsValues.SESSION_TIMEOUT * Time.MINUTE));
Ticket ticket = TicketLocalServiceUtil.addTicket(user.getCompanyId(), User.class.getName(), user.getUserId(), TicketConstants.TYPE_IMPERSONATE, null, expirationDate, new ServiceContext());
%>
var liferayUpload = new Liferay.Upload({
'boundingBox': '# fileUpload',
<%
DecimalFormatSymbols decimalFormatSymbols = DecimalFormatSymbols.getInstance(locale);
%>
'decimalSeparator': '<%= decimalFormatSymbols.getDecimalSeparator() %>',
'deleteFile':
' &ticketKey=<%= ticket.getKey() %> ',
<%
DLConfiguration dlConfiguration = ConfigurationProviderUtil.getSystemConfiguration(DLConfiguration.class);
%>
'fileDescription':
'<%= StringUtil.merge(dlConfiguration.fileExtensions()) %>',
'maxFileSize':
'<%= UploadServletRequestConfigurationProviderUtil.getMaxSize() %> B',
'metadataContainer': '# commonFileMetadataContainer',
'metadataExplanationContainer':
'# metadataExplanationContainer',
'multipleFiles': false,
'namespace': ' ',
'strings.dropFileText':
' ',
'strings.fileCannotBeSavedText':
' ',
'strings.pendingFileText':
' ',
'strings.uploadsCompleteText':
' ',
'tempFileURL': {
method: Liferay.Service.bind('/layout/get-temp-file-names'),
params: {
folderName:
'<%= HtmlUtil.escapeJS(ExportImportHelper.TEMP_FOLDER_NAME + selPortlet.getPortletId()) %>',
groupId: <%= scopeGroupId %>,
},
},
'uploadFile':
' &ticketKey=<%= ticket.getKey() %> ',
});
liferayUpload._uploader.on('alluploadscomplete', (event) => {
toggleContinueButton();
});
Liferay.on('tempFileRemoved', (event) => {
toggleContinueButton();
});
function toggleContinueButton() {
var lfrDynamicUploader = liferayUpload
.get('boundingBox')
.ancestor('.lfr-dynamic-uploader');
var uploadedFiles = liferayUpload._fileListContent.all(
'.upload-file.upload-complete'
);
if (uploadedFiles.size() == 1) {
lfrDynamicUploader.removeClass('hide-dialog-footer');
}
else {
lfrDynamicUploader.addClass('hide-dialog-footer');
}
}
var continueButton = document.getElementById(
' continueButton'
);
var exportImportOptions = document.getElementById(
' exportImportOptions'
);
if (continueButton && exportImportOptions) {
var form = document. fm1;
continueButton.addEventListener('click', (event) => {
event.preventDefault();
Liferay.Util.fetch(form.action)
.then((response) => {
return response.text();
})
.then((response) => {
exportImportOptions.innerHTML = response;
Liferay.Util.runScriptsInElement(exportImportOptions);
});
});
}