forked from liferay/liferay-portal
/
asset_entries.jsp
84 lines (62 loc) · 2.75 KB
/
asset_entries.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
<%--
/**
* 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" %>
<%
AssetEntriesSearchFacet assetEntriesSearchFacet = (AssetEntriesSearchFacet)request.getAttribute("facet_configuration.jsp-searchFacet");
JSONObject dataJSONObject = assetEntriesSearchFacet.getData();
int frequencyThreshold = dataJSONObject.getInt("frequencyThreshold");
String[] assetTypes = new String[0];
List<KeyValuePair> currentAssetTypes = new ArrayList<KeyValuePair>();
if (dataJSONObject.has("values")) {
JSONArray valuesJSONArray = dataJSONObject.getJSONArray("values");
assetTypes = new String[valuesJSONArray.length()];
for (int i = 0; i < valuesJSONArray.length(); i++) {
assetTypes[i] = valuesJSONArray.getString(i);
currentAssetTypes.add(new KeyValuePair(assetTypes[i], ResourceActionsUtil.getModelResource(locale, assetTypes[i])));
}
}
List<KeyValuePair> availableAssetTypes = new ArrayList<KeyValuePair>();
for (AssetRendererFactory<?> assetRendererFactory : assetEntriesSearchFacet.getAssetRendererFactories(company.getCompanyId())) {
String className = assetRendererFactory.getClassName();
if (assetRendererFactory.isSearchable() && !ArrayUtil.contains(assetTypes, className)) {
availableAssetTypes.add(new KeyValuePair(className, ResourceActionsUtil.getModelResource(locale, className)));
}
}
%>
<aui:input label="frequency-threshold" name='<%= assetEntriesSearchFacet.getClassName() + "frequencyThreshold" %>' value="<%= frequencyThreshold %>" />
<aui:input name='<%= assetEntriesSearchFacet.getClassName() + "assetTypes" %>' type="hidden" />
<liferay-ui:input-move-boxes
leftBoxName="currentAssetTypes"
leftList="<%= currentAssetTypes %>"
leftTitle="current"
rightBoxName="availableAssetTypes"
rightList="<%= availableAssetTypes %>"
rightTitle="available"
/>
<script>
var form = document.<portlet:namespace />fm;
var currentAssetTypes = Liferay.Util.getFormElement(form, 'currentAssetTypes');
if (currentAssetTypes) {
form.addEventListener('submit', (event) => {
event.preventDefault();
var data = {};
data[
'<%= assetEntriesSearchFacet.getClassName() + "assetTypes" %>'
] = Liferay.Util.getSelectedOptionValues(currentAssetTypes);
Liferay.Util.postForm(form, {data: data});
});
}
</script>