META-INF.resources.edit_template.jsp Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of com.liferay.dynamic.data.mapping.web
Show all versions of com.liferay.dynamic.data.mapping.web
Liferay Dynamic Data Mapping Web
<%--
/**
* SPDX-FileCopyrightText: (c) 2000 Liferay, Inc. https://liferay.com
* SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
*/
--%>
<%@ include file="/init.jsp" %>
<%
String closeRedirect = ParamUtil.getString(request, "closeRedirect");
String portletResource = ParamUtil.getString(request, "portletResource");
String portletResourceNamespace = ParamUtil.getString(request, "portletResourceNamespace");
DDMTemplate template = (DDMTemplate)request.getAttribute(DDMWebKeys.DYNAMIC_DATA_MAPPING_TEMPLATE);
long templateId = BeanParamUtil.getLong(template, request, "templateId");
long groupId = BeanParamUtil.getLong(template, request, "groupId", PortalUtil.getScopeGroupId(request, refererPortletName));
long classNameId = BeanParamUtil.getLong(template, request, "classNameId");
long classPK = BeanParamUtil.getLong(template, request, "classPK");
long resourceClassNameId = BeanParamUtil.getLong(template, request, "resourceClassNameId");
boolean cacheable = BeanParamUtil.getBoolean(template, request, "cacheable", true);
boolean smallImage = BeanParamUtil.getBoolean(template, request, "smallImage");
DDMStructure structure = (DDMStructure)request.getAttribute(DDMWebKeys.DYNAMIC_DATA_MAPPING_STRUCTURE);
if ((structure == null) && (template != null)) {
structure = ddmDisplayContext.fetchStructure(template);
}
String type = BeanParamUtil.getString(template, request, "type", DDMTemplateConstants.TEMPLATE_TYPE_FORM);
String mode = BeanParamUtil.getString(template, request, "mode", DDMTemplateConstants.TEMPLATE_MODE_CREATE);
String language = BeanParamUtil.getString(template, request, "language", ddmDisplay.getDefaultTemplateLanguage());
String script = BeanParamUtil.getString(template, request, "script");
if (Validator.isNull(script) && type.equals(DDMTemplateConstants.TEMPLATE_TYPE_DISPLAY)) {
TemplateHandler templateHandler = TemplateHandlerRegistryUtil.getTemplateHandler(classNameId);
if ((templateHandler == null) && (structure != null)) {
templateHandler = TemplateHandlerRegistryUtil.getTemplateHandler(structure.getClassNameId());
}
if (templateHandler != null) {
script = templateHandler.getTemplatesHelpContent(language);
}
else {
script = StringUtil.read(DDMWebConfigurationUtil.class.getClassLoader(), DDMWebConfigurationUtil.get(DDMWebConfigurationKeys.DYNAMIC_DATA_MAPPING_TEMPLATE_LANGUAGE_CONTENT, new Filter(language)));
}
}
DDMTemplateVersion templateVersion = null;
if (template != null) {
templateVersion = template.getLatestTemplateVersion();
}
String structureAvailableFields = ParamUtil.getString(request, "structureAvailableFields");
if (Validator.isNotNull(structureAvailableFields)) {
scopeAvailableFields = structureAvailableFields;
}
boolean showBackURL = ParamUtil.getBoolean(request, "showBackURL", true);
boolean showCacheableInput = ParamUtil.getBoolean(request, "showCacheableInput");
boolean showHeader = ParamUtil.getBoolean(request, "showHeader", true);
DDMNavigationHelper ddmNavigationHelper = ddmDisplay.getDDMNavigationHelper();
%>
<%
String[] imageExtensions = ddmDisplayContext.smallImageExtensions();
%>
<%= HtmlUtil.escape(StringUtil.merge(imageExtensions, StringPool.COMMA)) %>.
<%
long imageMaxSize = ddmDisplayContext.smallImageMaxSize();
%>
<%
String title = StringPool.BLANK;
if ((structure != null) || (template != null)) {
title = ddmDisplay.getEditTemplateTitle(structure, template, locale);
}
else {
title = ddmDisplay.getEditTemplateTitle(classNameId, locale);
}
%>
<%
portletDisplay.setShowBackIcon(true);
portletDisplay.setURLBack(PortalUtil.escapeRedirect(ddmDisplay.getEditTemplateBackURL(liferayPortletRequest, liferayPortletResponse, classNameId, classPK, resourceClassNameId, portletResource)));
renderResponse.setTitle(title);
%>
var toolbarChildren = [
{
label: '<%= UnicodeLanguageUtil.get(request, "view-history") %>',
on: {
click: function (event) {
event.domEvent.preventDefault();
window.location.href = '<%= viewHistoryURL %>';
},
},
},
];
new A.Toolbar({
boundingBox: '# templateHistoryToolbar',
children: toolbarChildren,
}).render();
<%
for (String curLangType : ddmDisplay.getTemplateLanguageTypes()) {
StringBundler sb = new StringBundler(6);
sb.append(LanguageUtil.get(request, curLangType + "[stands-for]"));
sb.append(StringPool.SPACE);
sb.append(StringPool.OPEN_PARENTHESIS);
sb.append(StringPool.PERIOD);
sb.append(curLangType);
sb.append(StringPool.CLOSE_PARENTHESIS);
%>
<%
}
%>
" key="preview" />" class="lfr-ddm-small-image-preview" src="<%= HtmlUtil.escapeAttribute(template.getTemplateImageURL(themeDisplay)) %>" />
<%@ include file="/edit_template_form.jspf" %>
<%@ include file="/edit_template_display.jspf" %>
var container = A.one('# smallImageContainer');
var types = container.all('.lfr-ddm-small-image-type');
var values = container.all('.lfr-ddm-small-image-value');
var selectSmallImageType = function (index) {
types.attr('checked', false);
types.item(index).attr('checked', true);
values.attr('disabled', true);
values.item(index).attr('disabled', false);
};
container.delegate(
'change',
function (event) {
var index = types.indexOf(event.currentTarget);
selectSmallImageType(index);
},
'.lfr-ddm-small-image-type'
);
new A.Toggler({
animated: true,
content:
'# smallImageContainer .lfr-ddm-small-image-content',
expanded: <%= smallImage %>,
header:
'# smallImageContainer .lfr-ddm-small-image-header',
on: {
animatingChange: function (event) {
var instance = this;
var expanded = !instance.get('expanded');
A.one('# smallImage').attr('checked', expanded);
if (expanded) {
types.each(function (item, index) {
if (item.get('checked')) {
values.item(index).attr('disabled', false);
}
});
}
else {
values.attr('disabled', true);
}
},
},
});
selectSmallImageType(
'<%= ((template != null) && Validator.isNotNull(template.getSmallImageURL())) ? 0 : 1 %>'
);
function openDDMStructureSelector() {
Liferay.Util.openDDMPortlet(
{
basePortletURL:
'<%= PortletURLFactoryUtil.create(request, DDMPortletKeys.DYNAMIC_DATA_MAPPING, PortletRequest.RENDER_PHASE) %>',
classNameId: '<%= PortalUtil.getClassNameId(DDMStructure.class) %>',
classPK: 0,
eventName: ' selectStructure',
groupId: <%= groupId %>,
mvcPath: '/select_structure.jsp',
navigationStartsOn: '<%= DDMNavigationHelper.SELECT_STRUCTURE %>',
showAncestorScopes: true,
title: '<%= UnicodeLanguageUtil.get(request, "structures") %>',
},
function (event) {
if (
document. fm. classPK
.value != event.ddmstructureid
) {
document. fm. classPK.value =
event.ddmstructureid;
Liferay.fire(' refreshEditor');
}
}
);
}
Liferay.after(' saveTemplate', function () {
submitForm(document. fm);
});
function saveDraftTemplate() {
var form = document. fm;
var statusInput = Liferay.Util.getFormElement(form, 'status');
if (statusInput) {
Liferay.Util.setFormValues(form, {
statusInput: <%= String.valueOf(WorkflowConstants.STATUS_DRAFT) %>,
});
}
Liferay.fire(
'<%= liferayPortletResponse.getNamespace() + "saveTemplate" %>'
);
}
function saveAndContinueTemplate() {
document. fm. saveAndContinue.value =
'1';
Liferay.fire(' saveTemplate');
}
var onDestroyPortlet = function (event) {
Liferay.detach('destroyPortlet', onDestroyPortlet);
Liferay.detach(' saveTemplate');
};
Liferay.on('destroyPortlet', onDestroyPortlet);
<%
String taglibOnClick = "Liferay.fire('" + liferayPortletResponse.getNamespace() + "saveTemplate');";
%>