Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LPS-102552 Replaces ToggleDisableInputs component with simpler HTML+JS #79698

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -19,22 +19,7 @@
<aui:row>
<aui:col cssClass="lfr-border-width use-for-all-column" width="<%= 33 %>">
<aui:fieldset label="border-width">

<%
Map<String, Object> contextUseForAllWidth = new HashMap<>();

contextUseForAllWidth.put("checked", portletConfigurationCSSPortletDisplayContext.isBorderSameForAll("borderWidth"));
contextUseForAllWidth.put("inputSelector", ".same-border-width");
contextUseForAllWidth.put("label", LanguageUtil.get(request, "same-for-all"));
contextUseForAllWidth.put("name", renderResponse.getNamespace() + "useForAllWidth");
%>

<soy:component-renderer
context="<%= contextUseForAllWidth %>"
module="js/ToggleDisableInputs.es"
servletContext="<%= application %>"
templateNamespace="com.liferay.portlet.configuration.css.web.ToggleDisableInputs.render"
/>
<aui:input checked='<%= portletConfigurationCSSPortletDisplayContext.isBorderSameForAll("borderWidth") %>' data-inputselector=".same-border-width" label="same-for-all" name="useForAllWidth" type="toggle-switch" />

<span class="field-row">
<aui:input inlineField="<%= true %>" label="top" name="borderWidthTop" value='<%= portletConfigurationCSSPortletDisplayContext.getBorderWidthProperty("top", "value") %>' />
Expand Down Expand Up @@ -77,22 +62,7 @@

<aui:col cssClass="lfr-border-style" width="<%= 33 %>">
<aui:fieldset label="border-style">

<%
Map<String, Object> contextUseForAllStyle = new HashMap<>();

contextUseForAllStyle.put("checked", portletConfigurationCSSPortletDisplayContext.isBorderSameForAll("borderStyle"));
contextUseForAllStyle.put("inputSelector", ".same-border-style");
contextUseForAllStyle.put("label", LanguageUtil.get(request, "same-for-all"));
contextUseForAllStyle.put("name", renderResponse.getNamespace() + "useForAllStyle");
%>

<soy:component-renderer
context="<%= contextUseForAllStyle %>"
module="js/ToggleDisableInputs.es"
servletContext="<%= application %>"
templateNamespace="com.liferay.portlet.configuration.css.web.ToggleDisableInputs.render"
/>
<aui:input checked='<%= portletConfigurationCSSPortletDisplayContext.isBorderSameForAll("borderStyle") %>' data-inputselector=".same-border-style" label="same-for-all" name="useForAllStyle" type="toggle-switch" />

<aui:select label="top" name="borderStyleTop" showEmptyOption="<%= true %>" wrapperCssClass="field-row">
<aui:option label="dashed" selected='<%= Objects.equals(portletConfigurationCSSPortletDisplayContext.getBorderProperty("top", "borderStyle"), "dashed") %>' />
Expand Down Expand Up @@ -146,22 +116,7 @@

<aui:col cssClass="lfr-border-color" last="<%= true %>" width="<%= 33 %>">
<aui:fieldset label="border-color">

<%
Map<String, Object> contextUseForAllColor = new HashMap<>();

contextUseForAllColor.put("checked", portletConfigurationCSSPortletDisplayContext.isBorderSameForAll("borderColor"));
contextUseForAllColor.put("inputSelector", ".same-border-color");
contextUseForAllColor.put("label", LanguageUtil.get(request, "same-for-all"));
contextUseForAllColor.put("name", renderResponse.getNamespace() + "useForAllColor");
%>

<soy:component-renderer
context="<%= contextUseForAllColor %>"
module="js/ToggleDisableInputs.es"
servletContext="<%= application %>"
templateNamespace="com.liferay.portlet.configuration.css.web.ToggleDisableInputs.render"
/>
<aui:input checked='<%= portletConfigurationCSSPortletDisplayContext.isBorderSameForAll("borderColor") %>' data-inputselector=".same-border-color" label="same-for-all" name="useForAllColor" type="toggle-switch" />

<%
Map<String, Object> contextBorderTop = new HashMap<>();
Expand Down
Expand Up @@ -19,19 +19,11 @@
<%
Map<String, Object> contextUseForAllTitle = new HashMap<>();

contextUseForAllTitle.put("checked", portletConfigurationCSSPortletDisplayContext.isUseCustomTitle());
contextUseForAllTitle.put("disableOnChecked", false);
contextUseForAllTitle.put("label", LanguageUtil.get(request, "use-custom-title"));
contextUseForAllTitle.put("name", renderResponse.getNamespace() + "useCustomTitle");
contextUseForAllTitle.put("inputSelector", ".custom-title input");
%>

<soy:component-renderer
context="<%= contextUseForAllTitle %>"
module="js/ToggleDisableInputs.es"
servletContext="<%= application %>"
templateNamespace="com.liferay.portlet.configuration.css.web.ToggleDisableInputs.render"
/>
<aui:input checked="<%= portletConfigurationCSSPortletDisplayContext.isUseCustomTitle() %>" data="<%= contextUseForAllTitle %>" label="use-custom-title" name="useCustomTitle" type="toggle-switch" />

<aui:field-wrapper cssClass="custom-title lfr-input-text-container">
<liferay-ui:input-localized
Expand Down

This file was deleted.

This file was deleted.

Expand Up @@ -19,22 +19,7 @@
<aui:row>
<aui:col cssClass="lfr-padding use-for-all-column" width="<%= 50 %>">
<aui:fieldset label="padding">

<%
Map<String, Object> contextUseForAllPadding = new HashMap<>();

contextUseForAllPadding.put("checked", portletConfigurationCSSPortletDisplayContext.isSpacingSameForAll("padding"));
contextUseForAllPadding.put("inputSelector", ".same-padding");
contextUseForAllPadding.put("label", LanguageUtil.get(request, "same-for-all"));
contextUseForAllPadding.put("name", renderResponse.getNamespace() + "useForAllPadding");
%>

<soy:component-renderer
context="<%= contextUseForAllPadding %>"
module="js/ToggleDisableInputs.es"
servletContext="<%= application %>"
templateNamespace="com.liferay.portlet.configuration.css.web.ToggleDisableInputs.render"
/>
<aui:input checked='<%= portletConfigurationCSSPortletDisplayContext.isSpacingSameForAll("padding") %>' data-inputselector=".same-padding" label="same-for-all" name="useForAllPadding" type="toggle-switch" />

<span class="field-row">
<aui:input inlineField="<%= true %>" label="top" name="paddingTop" value='<%= portletConfigurationCSSPortletDisplayContext.getPaddingProperty("top", "value") %>' />
Expand Down Expand Up @@ -77,22 +62,7 @@

<aui:col cssClass="lfr-margin use-for-all-column" last="<%= true %>" width="<%= 50 %>">
<aui:fieldset label="margin">

<%
Map<String, Object> contextUseForAllMargin = new HashMap<>();

contextUseForAllMargin.put("checked", portletConfigurationCSSPortletDisplayContext.isSpacingSameForAll("margin"));
contextUseForAllMargin.put("inputSelector", ".same-margin");
contextUseForAllMargin.put("label", LanguageUtil.get(request, "same-for-all"));
contextUseForAllMargin.put("name", renderResponse.getNamespace() + "useForAllMargin");
%>

<soy:component-renderer
context="<%= contextUseForAllMargin %>"
module="js/ToggleDisableInputs.es"
servletContext="<%= application %>"
templateNamespace="com.liferay.portlet.configuration.css.web.ToggleDisableInputs.render"
/>
<aui:input checked='<%= portletConfigurationCSSPortletDisplayContext.isSpacingSameForAll("margin") %>' data-inputselector=".same-margin" label="same-for-all" name="useForAllMargin" type="toggle-switch" />

<span class="field-row">
<aui:input inlineField="<%= true %>" label="top" name="marginTop" value='<%= portletConfigurationCSSPortletDisplayContext.getMarginProperty("top", "value") %>' />
Expand Down
Expand Up @@ -43,6 +43,26 @@
<aui:button type="cancel" />
</liferay-frontend:edit-form-footer>
</liferay-frontend:edit-form>

<aui:script require="metal-dom/src/dom as dom">
dom.delegate(
document.getElementById('<portlet:namespace />fm'),
'change',
'input[type=checkbox]',
function(event) {
const toggle = event.delegateTarget;

const disableOnChecked = toggle.dataset.disableonchecked;
const inputs = document.querySelectorAll(toggle.dataset.inputselector);

for (let i = 0; i < inputs.length; i++) {
const input = inputs[i];

input.disabled = disableOnChecked ? !toggle.checked : toggle.checked;
}
}
);
</aui:script>
</c:when>
<c:otherwise>
<liferay-util:include page="/html/portal/portlet_access_denied.jsp" />
Expand Down