From 144772c080305f18879ba883d7a45117efd3ad0f Mon Sep 17 00:00:00 2001 From: Will Ezell Date: Thu, 21 Sep 2023 17:05:18 -0400 Subject: [PATCH] feat(ui) show full screen when it is the only thing on the tab ref: #26222 --- core-web/libs/dotcms-scss/jsp/css/dotcms.css | 5 - .../webapp/html/css/dijit-dotcms/dotcms.css | 13 +- .../ext/contentlet/edit_contentlet.jsp | 138 +++++++++++++++++- .../ext/contentlet/field/edit_field.jsp | 18 ++- 4 files changed, 154 insertions(+), 20 deletions(-) diff --git a/core-web/libs/dotcms-scss/jsp/css/dotcms.css b/core-web/libs/dotcms-scss/jsp/css/dotcms.css index d3a09213037f..1f8620e23380 100644 --- a/core-web/libs/dotcms-scss/jsp/css/dotcms.css +++ b/core-web/libs/dotcms-scss/jsp/css/dotcms.css @@ -6397,7 +6397,6 @@ hr { .dijitTextBox, .dijitSelect { width: 100%; - max-width: 1100px; } .dijitComboBox { @@ -9272,7 +9271,6 @@ Styles for commons fields along the backend } .editor-toolbar { - max-width: 1100px; width: 100%; } @@ -9287,7 +9285,6 @@ Styles for commons fields along the backend .wysiwyg-wrapper { width: 100%; - max-width: 1100px; } .key-value-form { @@ -10184,7 +10181,6 @@ a.tag_higlighted { .aceText { border: 1px solid #afb3c0; - max-width: 1100px; width: 100%; height: 100%; min-height: 200px; @@ -10203,7 +10199,6 @@ a.tag_higlighted { border: 1px solid #afb3c0; max-height: 600px; min-height: 300px; - max-width: 900px; width: 100%; text-overflow: clip; white-space: nowrap; diff --git a/dotCMS/src/main/webapp/html/css/dijit-dotcms/dotcms.css b/dotCMS/src/main/webapp/html/css/dijit-dotcms/dotcms.css index 5db2f16f393e..72614593f810 100644 --- a/dotCMS/src/main/webapp/html/css/dijit-dotcms/dotcms.css +++ b/dotCMS/src/main/webapp/html/css/dijit-dotcms/dotcms.css @@ -5942,7 +5942,6 @@ hr { .dijitTextBox, .dijitSelect { width: 100%; - max-width: 1100px; } .dijitComboBox { @@ -8795,7 +8794,6 @@ Styles for commons fields along the backend } .editor-toolbar { - max-width: 1100px; width: 100%; } @@ -8810,7 +8808,6 @@ Styles for commons fields along the backend .wysiwyg-wrapper { width: 100%; - max-width: 1100px; } .key-value-form { @@ -9655,7 +9652,6 @@ a.category_higlighted, a.tag_higlighted { .aceText { border: 1px solid #afb3c0; - max-width: 1100px; width: 100%; height: 100%; min-height: 200px; @@ -11183,3 +11179,12 @@ body { text-rendering: optimizeLegibility; -moz-osx-font-smoothing: grayscale; } + +.edit-content-full-screen{ + + width:100% !important; + max-width:100% !important; + margin:0px; + border:1px solid red; + min-height: fit-content; +} diff --git a/dotCMS/src/main/webapp/html/portlet/ext/contentlet/edit_contentlet.jsp b/dotCMS/src/main/webapp/html/portlet/ext/contentlet/edit_contentlet.jsp index 9d7f5c918323..4f494c0f209e 100644 --- a/dotCMS/src/main/webapp/html/portlet/ext/contentlet/edit_contentlet.jsp +++ b/dotCMS/src/main/webapp/html/portlet/ext/contentlet/edit_contentlet.jsp @@ -1,7 +1,103 @@ +<%! + + public boolean isFullScreenField(ContentType type, com.dotcms.contenttype.model.field.Field fieldIn) { + try { + + + com.dotcms.contenttype.model.field.Field field = fieldIn; + + if (!(field instanceof WysiwygField || + field instanceof StoryBlockField || + field instanceof TextAreaField || + field instanceof CustomField || + field instanceof JSONField + )) { + return false; + } + + + boolean showFullScreen = Try.of(() -> Boolean.parseBoolean(field.fieldVariablesMap().get("showFullScreen").value())).getOrElse(true); + if (!showFullScreen) { + return false; + } + + + List fieldsWithColumns = type.fields().stream().filter(f -> { + return !(f instanceof RowField || f instanceof LineDividerField); + }).collect(Collectors.toList()); + + + com.dotcms.contenttype.model.field.Field previousField = Try.of(() -> fieldsWithColumns.get(fieldsWithColumns.indexOf(field) - 1)).getOrNull(); + com.dotcms.contenttype.model.field.Field nextField = Try.of(() -> fieldsWithColumns.get(fieldsWithColumns.indexOf(field) + 1)).getOrNull(); + + // we are in a multi column field + if (previousField instanceof ColumnField && nextField instanceof ColumnField) { + return false; + } + + List fields = fieldsWithColumns.stream().filter(f -> { + return !(f instanceof ColumnField); + }).collect(Collectors.toList()); + + + + + int fieldOrder = fields.indexOf(field); + previousField = Try.of(() -> fields.get(fieldOrder - 1)).getOrNull(); + nextField = Try.of(() -> fields.get(fieldOrder + 1)).getOrNull(); + + // is first field and then nextField is TabDividerField or no other field + if (fieldOrder == 0 + && (nextField instanceof TabDividerField || nextField == null)) { + return true; + } + + // Previous field a TabDividerField and nextField a TabDividerField or no other field + if (fieldOrder > 0 && previousField instanceof TabDividerField + && (nextField instanceof TabDividerField || nextField == null)) { + return true; + } + + + } catch (Exception e) { + return false; + } + + + return false; + + } + + public boolean isFullScreenField(Structure structure, Field oldField) { + + try{ + + return isFullScreenField(new StructureTransformer(structure).from(),LegacyFieldTransformer.from(oldField)); + } + catch(Exception e){ + return false; + } + + + } + public boolean isNextFieldFullScreen(Structure structure, Field oldField) { + + try{ + ContentType type = new StructureTransformer(structure).from(); + com.dotcms.contenttype.model.field.Field fieldIn = LegacyFieldTransformer.from(oldField); + com.dotcms.contenttype.model.field.Field field = type.fields().subList(type.fields().indexOf(fieldIn), type.fields().size()).stream().filter(f->!(f instanceof RowField || f instanceof ColumnField || f instanceof TabDividerField)).findFirst().get(); + return isFullScreenField(type,field); + } + catch(Exception e){ + return false; + } + + + } + +%> <%@page import="com.dotmarketing.portlets.structure.model.Field"%> -<%@page import="com.dotcms.contenttype.model.field.ColumnField"%> -<%@page import="com.dotcms.contenttype.model.field.RowField"%> <%@page import="com.dotcms.contenttype.transform.field.LegacyFieldTransformer"%> <%@page import="com.dotmarketing.business.LayoutAPI"%> <%@page import="com.dotmarketing.beans.Host"%> @@ -12,7 +108,7 @@ <%@page import="com.dotmarketing.portlets.categories.business.CategoryAPI"%> <%@page import="com.dotmarketing.business.APILocator"%> <%@page import="com.dotmarketing.portlets.containers.model.Container"%> -<%@page import="com.dotmarketing.portlets.contentlet.struts.ContentletForm"%> +<%@page import="com.dotmarketing.portlets.contentlet.struts.ContentletForm"%> <%@page import="com.dotmarketing.portlets.structure.model.ContentletRelationships"%> <%@page import="com.dotmarketing.portlets.structure.model.ContentletRelationships.ContentletRelationshipRecords"%> <%@page import="com.dotmarketing.portlets.categories.model.Category"%> @@ -31,6 +127,14 @@ <%@page import="com.dotmarketing.portlets.contentlet.business.ContentletAPI"%> <%@ page import="com.dotmarketing.portlets.htmlpageasset.model.IHTMLPage"%> <%@ page import="com.dotmarketing.db.DbConnectionFactory" %> +<%@ page import="com.dotcms.contenttype.model.type.ContentType" %> +<%@ page import="java.util.List" %> +<%@ page import="java.util.stream.Collectors" %> +<%@ page import="com.dotcms.contenttype.model.field.*" %> +<%@ page import="io.vavr.control.Try" %> +<%@ page import="com.dotcms.contenttype.transform.contenttype.StructureTransformer" %> +<%@ page import="org.apache.poi.ss.usermodel.Row" %> +<%@ page import="com.dotcms.contenttype.transform.field.FieldTransformer" %> @@ -46,7 +150,7 @@ - @@ -182,7 +286,10 @@ request.setAttribute(com.dotmarketing.util.WebKeys.PERMISSIONABLE_EDIT, contentlet); request.setAttribute(com.dotmarketing.util.WebKeys.PERMISSIONABLE_EDIT_BASE, structure); - + boolean fullScreenField = isNextFieldFullScreen(structure, fields.get(0)); + String fullScreenClass= fullScreenField ? "edit-content-full-screen": ""; + boolean fullScreenNextField = isNextFieldFullScreen(structure, fields.get(0)); + String fullScreenNextClass= fullScreenNextField ? "edit-content-full-screen": ""; List structures = StructureFactory.getStructuresByUser(user, "", "name", 100, 0,"asc"); /*### DRAW THE DYNAMIC FIELDS ###*/ @@ -278,7 +385,7 @@ <%}%> -
+
<% if(widgetUsageField != null && UtilMethods.isSet(widgetUsageField.getValues())){ %>
@@ -295,7 +402,7 @@
<% } %> -
+
<%-- Begin Looping over fields --%> @@ -307,9 +414,24 @@ boolean rowOpen = true; boolean columnOpen = true; + for (; i < fields.size(); i++) { + Field f = fields.get(i); com.dotcms.contenttype.model.field.Field newField = new LegacyFieldTransformer(f).from(); + fullScreenField = isFullScreenField(structure,f); + fullScreenNextField = isNextFieldFullScreen(structure, f); + + fullScreenClass=fullScreenField ? "edit-content-full-screen": ""; + fullScreenNextClass=fullScreenNextField ? "edit-content-full-screen": ""; + request.setAttribute("DOT_FULL_SCREEN_FIELD",fullScreenField ); + request.setAttribute("DOT_FULL_SCREEN_NEXT_FIELD",fullScreenNextField ); + + + + + + if (fieldSetOpen && (f.getFieldType().equals(Field.FieldType.LINE_DIVIDER.toString()) || @@ -349,7 +471,7 @@
-
+
<%}else if(f.getFieldType().equals(Field.FieldType.CATEGORIES_TAB.toString()) && !categoriesTabFieldExists) { categoriesTabFieldExists = true;%> diff --git a/dotCMS/src/main/webapp/html/portlet/ext/contentlet/field/edit_field.jsp b/dotCMS/src/main/webapp/html/portlet/ext/contentlet/field/edit_field.jsp index 7d7fd6553976..93278b824fd8 100644 --- a/dotCMS/src/main/webapp/html/portlet/ext/contentlet/field/edit_field.jsp +++ b/dotCMS/src/main/webapp/html/portlet/ext/contentlet/field/edit_field.jsp @@ -59,8 +59,18 @@ String counter = (String) request.getAttribute("counter"); + boolean fullScreenField = Try.of(()->(boolean)request.getAttribute("DOT_FULL_SCREEN_FIELD")).getOrElse(false); + String fullScreenClass=fullScreenField ? "edit-content-full-screen": ""; + + %> -
+ +
+ + + fullscreen: <%=fullScreenField%> + +
<% if (hint != null) {%> @@ -329,8 +339,8 @@ <%} %> }); -
- <% @@ -409,6 +419,8 @@ } } %> + +