Skip to content

Instantly share code, notes, and snippets.

@sammso
Last active June 21, 2016 07:47
Show Gist options
  • Save sammso/96380153f10df86caf155baa762b2aa5 to your computer and use it in GitHub Desktop.
Save sammso/96380153f10df86caf155baa762b2aa5 to your computer and use it in GitHub Desktop.
<%--
/**
* Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
--%>

<%@page import="com.liferay.portal.kernel.portlet.LiferayWindowState"%>
<%@include file="/html/init.jsp" %>

<%
	boolean hasAddPermission = InventoryPermission.contains(
			permissionChecker, scopeGroupId, "ADD_MANUFACTURER");
	boolean hasConfigurePermission = InventoryPermission.contains(
			permissionChecker, scopeGroupId, ActionKeys.PERMISSIONS);
%>

<liferay-ui:success key="manufacturer-added" message="manufacturer-added-successfully" />
<liferay-ui:success key="manufacturer-updated" message="manufacturer-updated-successfully" />
<liferay-ui:success key="manufacturer-deleted" message="manufacturer-deleted-successfully" />

<%
	String redirect = PortalUtil.getCurrentURL(renderRequest);	
	String windowStateString = renderRequest.getWindowState().toString();
%>
		<portlet:renderURL var="addManufacturerURL">
			<portlet:param name="mvcPath" value="/html/manufacturer/edit_manufacturer.jsp" />
			<portlet:param name="redirect" value="<%= redirect %>" />
		</portlet:renderURL>

		<portlet:renderURL var="addManufacturerURL2" windowState="<%=com.liferay.portal.kernel.portlet.LiferayWindowState.EXCLUSIVE.toString() %>">
			<portlet:param name="mvcPath" value="/html/manufacturer/edit_manufacturer.jsp" />
			<portlet:param name="redirect" value="<%= redirect %>" />
			<portlet:param name="windowstate" value="<%=windowStateString %>" />
		</portlet:renderURL>
		
		<h1><%=addManufacturerURL%></h1>
		<h1><%=addManufacturerURL2 %></h1>
<aui:button-row cssClass="manufacturer-buttons">
	<c:if test='<%= hasAddPermission %>'>


		<aui:script use="aui-button,node-load,aui-parse-content">
			var buttonRow = A.one("#p_p_id<portlet:namespace/> .manufacturer-buttons");
			
			var buttonLabel = "<liferay-ui:message key="add-manufacturer" />";

			//var contentPane = A.one("#<portlet:namespace/>manufacturer-dynamic-content");
			var contentPane = A.one("#p_p_id<portlet:namespace /> .portlet-body");
			
			contentPane.plug(A.Plugin.ParseContent);

			var button = new A.Button({
				icon: 'icon-plus',
				label: buttonLabel,
				
				on: { click: function(event) {
					//contentPane.load('<%=addManufacturerURL.toString()%>', '#p_p_id<portlet:namespace /> .portlet-body');}
					contentPane.load('<%=addManufacturerURL2.toString()%>', '');}
				}
			}).render(buttonRow);
				
			A.getDoc().on('key', function() {
				button.fire('click');					
			},'down:77+alt+shift');
		</aui:script>
	</c:if>

	<c:if test='<%= hasConfigurePermission %>'>
		<liferay-security:permissionsURL
			modelResource="com.liferay.training.parts.model"
			modelResourceDescription="Parts Inventory Top Level Actions"
			resourcePrimKey="<%= String.valueOf(scopeGroupId) %>"
			var="permissionsURL" />

		<aui:script use="aui-button">
			var buttonRow = A.one("#p_p_id<portlet:namespace/> .manufacturer-buttons");
			
			var buttonLabel = "<liferay-ui:message key="Permissions" />";
			
			new A.Button({
				icon: 'icon-gear',
				label: buttonLabel,
				on: { click: function(event) {
					location.href = "<%=permissionsURL %>";} 
					}
			})
				.render(buttonRow);
		</aui:script>
	</c:if>

</aui:button-row>
<aui:layout>
	<aui:column id="manufacturer-dynamic-content">
<liferay-ui:search-container emptyResultsMessage="manufacturer-empty-results-message">
	<liferay-ui:search-container-results
		results="<%=ManufacturerLocalServiceUtil
						.getManufacturersByGroupId(scopeGroupId,
								searchContainer.getStart(), searchContainer.getEnd())%>"
		total="<%=ManufacturerLocalServiceUtil
						.getManufacturersCountByGroupId(scopeGroupId)%>" />

	<liferay-ui:search-container-row
		className="com.liferay.training.parts.model.Manufacturer"
		keyProperty="manufacturerId"
		modelVar="manufacturer" escapedModel="<%= true %>"
	>
		<liferay-ui:search-container-column-text
			name="name"
			value="<%= manufacturer.getName() %>"
		/>

		<liferay-ui:search-container-column-text
			name="email-address"
			property="emailAddress"
		/>

		<liferay-ui:search-container-column-text
			name="phone-number"
			property="phoneNumber"
		/>

		<liferay-ui:search-container-column-text
			name="website"
			property="website"
		/>

		<liferay-ui:search-container-column-jsp
			align="right"
			path="/html/manufacturer/manufacturer_actions.jsp"
		/>
	</liferay-ui:search-container-row>

	<liferay-ui:search-iterator />
</liferay-ui:search-container> 
	</aui:column>
</aui:layout>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment