
function addUserFeedbackEventListener(portletId, resourceCommandName, nameSpace){
	$('#portlet_' + portletId + ' .ccew-user-feedback-button').on('click', function(){
		saveUserFeedback(portletId, resourceCommandName, this.getAttribute('ccew-data-feedback'), nameSpace)
	});
}

function saveUserFeedback(portletId, resourceCommandName, feedbackValue, nameSpace){

		
	AUI().use('aui-io-request','liferay-portlet-url', function(A){
		let url = Liferay.PortletURL.createResourceURL();
		let currentURL = Liferay.currentURL;
		url.setParameter("feedbackValue", feedbackValue);
		url.setParameter("currentURL", currentURL);
	
		url.setPortletId(portletId);
		url.setResourceId(resourceCommandName);
	
		A.io.request(url.toString(), {
			method: 'post',
			on: {
					success: function() {
						showMessage();
				}
			}
		});
	});
}

function showMessage(){
	$('.ccew-user-feedback-icons-wrapper').hide();

	$('.ccew-user-feedback-article').removeClass('hide');
}
