掲示板

Override OOTB Upload.js in Liferay 7

thumbnail
7年前 に Sandip Patel によって更新されました。

Override OOTB Upload.js in Liferay 7

Regular Member 投稿: 205 参加年月日: 11/01/05 最新の投稿
Hi All,
I am using Liferay 7 CE ge3 . I want to override Liferay uploader javascript file upload.js.
I have take reference from this forum : https://web.liferay.com/community/forums/-/message_boards/message/77090513
I have followed below steps but not able to success.

Step1: Create new mvc module name as "file-upload-js-override-web".
Step2 : Update module bnd.bnd file as below

Bundle-SymbolicName: file.upload.js.override.web
                Liferay-JS-Config:/META-INF/resources/js/config.js
             Bundle-Version: 1.0.0

Step 3: create config.js at mentioned location as below.
;(function() {
	AUI().applyConfig(
		{
			groups: {
				uploaddocext: {
					base: MODULE_PATH + '/js/',
					combine: Liferay.AUI.getCombine(),
					filter: Liferay.AUI.getFilterConfig(),
					modules: {
						'liferay-upload-override': {
							path: 'upload.js',
							condition: {
								name: 'liferay-upload-override',
								trigger: 'liferay-upload',
								when: 'instead'
							}
						}
					},
					root: MODULE_PATH + '/js/'
				}
			}
		}
	);
})();


Step4 : Copy uplaod.js file from Liferay soruce code.
Step5 : deploy custom module with blade deploy command
Step 6 : Use Liferay Uploader with below code.

var caseDocumentUploader = new Liferay.Upload(
							{
								boundingBox: '#<portlet:namespace />caseDocumentUpload',
								deleteFile: deleteCaseDocumentURL,
								decimalSeparator: '&lt;%= decimalFormatSymbols.getDecimalSeparator() %&gt;',
								fileDescription: '&lt;%= StringUtil.merge(PrefsPropsUtil.getStringArray(PropsKeys.DL_FILE_EXTENSIONS, StringPool.COMMA)) %&gt;',
								maxFileSize: '&lt;%= PrefsPropsUtil.getLong(PropsKeys.DL_FILE_MAX_SIZE) %&gt; B',
								metadataContainer: '#<portlet:namespace />commonFileMetadataContainer',
								metadataExplanationContainer: '#<portlet:namespace />metadataExplanationContainer',
								namespace: '<portlet:namespace />',
								uploadFile: caseFileUplaodURL
							}
						);

The document upload is working fine but not come with template changes I made in var TPL_FILE_LIST.
In short the above steps are not overriding upload.js.
Plese let me know if I miss any steps.

Regards,
Sandip Patel
thumbnail
6年前 に Chema Balsas によって更新されました。

RE: Override OOTB Upload.js in Liferay 7

Regular Member 投稿: 127 参加年月日: 13/02/25 最新の投稿
Hey Sandip,

I'm assuming you have something like this in your overriden upload.js file

 AUI.add(
	'liferay-upload',
	[...]


Instead, it should be:

 AUI.add(
	'liferay-upload-override',
	[...]


Could you give that a try?

We're working on a tutorial to make these steps more understandable soon.

Hope that helps!
thumbnail
6年前 に Sandip Patel によって更新されました。

RE: Override OOTB Upload.js in Liferay 7

Regular Member 投稿: 205 参加年月日: 11/01/05 最新の投稿
Hi,
I have also tried with "liferay-upload-override" but no success.
I just want to confirm the approach to override is correct or not ?