forked from liferay/liferay-portal
-
Notifications
You must be signed in to change notification settings - Fork 1
/
configuration.jsp
123 lines (105 loc) · 3.71 KB
/
configuration.jsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<%--
/**
* Copyright (c) 2000-present 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.
*/
--%>
<%@ include file="/init.jsp" %>
<%
String redirect = ParamUtil.getString(request, "redirect");
String portletResource = ParamUtil.getString(request, "portletResource");
List<AssetRendererFactory<?>> classTypesAssetRendererFactories = new ArrayList<>();
%>
<liferay-portlet:actionURL portletConfiguration="<%= true %>" var="configurationActionURL" />
<liferay-portlet:renderURL portletConfiguration="<%= true %>" varImpl="configurationRenderURL" />
<liferay-frontend:edit-form
action="<%= configurationActionURL %>"
method="post"
name="fm"
onSubmit="event.preventDefault();"
>
<aui:input name="<%= Constants.CMD %>" type="hidden" value="<%= Constants.UPDATE %>" />
<aui:input name="redirect" type="hidden" value="<%= configurationRenderURL.toString() %>" />
<aui:input name="groupId" type="hidden" />
<aui:input name="typeSelection" type="hidden" />
<aui:input name="assetEntryIds" type="hidden" />
<aui:input name="assetEntryOrder" type="hidden" value="-1" />
<aui:input name="assetEntryType" type="hidden" />
<%
request.setAttribute("configuration.jsp-classTypesAssetRendererFactories", classTypesAssetRendererFactories);
request.setAttribute("configuration.jsp-configurationRenderURL", configurationRenderURL);
request.setAttribute("configuration.jsp-redirect", redirect);
%>
<liferay-ui:success key='<%= portletResource + "requestProcessed" %>' message="the-collection-was-created-successfully" />
<liferay-frontend:edit-form-body>
<liferay-frontend:form-navigator
id="<%= AssetPublisherConstants.FORM_NAVIGATOR_ID_CONFIGURATION %>"
showButtons="<%= false %>"
/>
</liferay-frontend:edit-form-body>
<liferay-frontend:edit-form-footer>
<aui:button onClick='<%= liferayPortletResponse.getNamespace() + "saveSelectBoxes();" %>' type="submit" />
<aui:button type="cancel" />
</liferay-frontend:edit-form-footer>
</liferay-frontend:edit-form>
<script>
function <portlet:namespace />saveSelectBoxes() {
var form = document.<portlet:namespace />fm;
<%
for (AssetRendererFactory<?> curRendererFactory : classTypesAssetRendererFactories) {
String className = assetPublisherWebHelper.getClassName(curRendererFactory);
%>
Liferay.Util.setFormValues(form, {
classTypeIds<%= className %>: Liferay.Util.getSelectedOptionValues(
Liferay.Util.getFormElement(
form,
'<%= className %>currentClassTypeIds'
)
),
});
<%
}
%>
var currentClassNameIdsSelect = Liferay.Util.getFormElement(
form,
'currentClassNameIds'
);
var currentMetadataFieldsInput = Liferay.Util.getFormElement(
form,
'currentMetadataFields'
);
if (currentClassNameIdsSelect && currentMetadataFieldsInput) {
Liferay.Util.postForm(form, {
data: {
classNameIds: Liferay.Util.getSelectedOptionValues(
currentClassNameIdsSelect
),
metadataFields: Liferay.Util.getSelectedOptionValues(
currentMetadataFieldsInput
),
},
});
}
else if (currentMetadataFieldsInput) {
Liferay.Util.postForm(form, {
data: {
metadataFields: Liferay.Util.getSelectedOptionValues(
currentMetadataFieldsInput
),
},
});
}
else {
submitForm(form);
}
}
</script>