Class EditableModule
java.lang.Object
io.mindspice.simplypages.core.HtmlTag
io.mindspice.simplypages.components.Div
io.mindspice.simplypages.modules.EditableModule
- All Implemented Interfaces:
Component
Decorator that wraps a module/component with edit/delete controls.
Lifecycle: wrapper markup is built lazily once on first render via buildWrapper().
Configure all options before first render.
Security boundary: this class emits client-side controls and HTMX attributes only. Endpoint authorization, CSRF handling, and edit policy enforcement remain application responsibilities.
Mutability and thread-safety: mutable and not thread-safe. Use request-scoped wrappers and avoid concurrent mutation/reuse after render.
-
Field Summary
Fields inherited from class HtmlTag
attributes, children, id, innerText, innerTextSlot, selfClosing, tagName, trustedHtml -
Method Summary
Modifier and TypeMethodDescriptionReturns the module ID used for targeting.render(RenderContext context) Renders this EditableModule and its wrapped module with context.withCanDelete(boolean canDelete) Sets whether this module can be deleted.withCanEdit(boolean canEdit) Sets whether this module can be edited.withDeleteButton(String label) Sets custom label for the delete button (default: "🗑").withDeleteConfirm(String message) Sets a confirmation message for delete operations.withDeleteSwap(String swap) Sets the HTMX swap strategy for delete operations (default: "outerHTML").withDeleteTarget(String target) Sets the HTMX target for delete operations.withDeleteTitle(String title) Sets the title attribute for the delete button (default: "Delete").withDeleteUrl(String deleteUrl) Sets the complete caller URL for deleting this module (HTMX hx-delete).withEditButton(String label) Sets custom label for the edit button (default: "✏").withEditMode(EditMode editMode) Sets the edit mode for this module.withEditSwap(String swap) Sets the HTMX swap strategy for edit operations (default: "innerHTML").withEditTarget(String target) Sets the HTMX target for edit operations (default: "#edit-modal-container").withEditTitle(String title) Sets the title attribute for the edit button (default: "Edit").withEditUrl(String editUrl) Sets the complete caller URL for editing this module (HTMX hx-get).withModuleId(String id) Sets a custom module ID for this wrapper.static EditableModuleWraps a module with edit/delete functionality.Methods inherited from class Div
withAttribute, withChild, withClass, withIdMethods inherited from class HtmlTag
addClass, addStyle, addTrustedStyle, getChildrenStream, getId, hxDelete, hxGet, hxInclude, hxPatch, hxPost, hxPushUrl, hxPut, hxScrollTargetTop, hxSwap, hxTarget, hxTrigger, withInnerText, withInnerText, withMaxWidth, withMinWidth, withUnsafeHtml, withWidth
-
Method Details
-
wrap
Wraps a module with edit/delete functionality.- Parameters:
module- the module to wrap- Returns:
- new EditableModule instance
-
withModuleId
Sets a custom module ID for this wrapper. This ID is used for HTMX targeting and as the DOM id attribute.- Parameters:
id- the module ID- Returns:
- this EditableModule for method chaining
-
getModuleId
-
withCanEdit
Sets whether this module can be edited. If false, the edit button will not be displayed even if editUrl is set.- Parameters:
canEdit- true to allow editing, false to lock editing- Returns:
- this EditableModule for method chaining
-
withCanDelete
Sets whether this module can be deleted. If false, the delete button will not be displayed even if deleteUrl is set.- Parameters:
canDelete- true to allow deletion, false to lock deletion- Returns:
- this EditableModule for method chaining
-
withEditMode
Sets the edit mode for this module.The edit mode is appended as a query parameter before any fragment in edit/delete URLs so the server can apply appropriate approval workflows. Existing parameters (including editMode) and fragment text are retained; null mode leaves the complete URL unchanged.
- Parameters:
editMode- the edit mode (USER_EDIT requires approval, OWNER_EDIT is immediate)- Returns:
- this EditableModule for method chaining
-
withEditUrl
Sets the complete caller URL for editing this module (HTMX hx-get). No template substitution or identifier encoding is applied; a configured edit mode is appended to its pre-fragment query.- Parameters:
editUrl- the endpoint to fetch edit modal from- Returns:
- this EditableModule for method chaining
-
withEditButton
Sets custom label for the edit button (default: "✏").- Parameters:
label- the button label (emoji or text)- Returns:
- this EditableModule for method chaining
-
withEditTarget
Sets the HTMX target for edit operations (default: "#edit-modal-container").- Parameters:
target- the CSS selector for the target element- Returns:
- this EditableModule for method chaining
-
withEditSwap
Sets the HTMX swap strategy for edit operations (default: "innerHTML").- Parameters:
swap- the swap strategy- Returns:
- this EditableModule for method chaining
-
withEditTitle
Sets the title attribute for the edit button (default: "Edit").- Parameters:
title- the tooltip text- Returns:
- this EditableModule for method chaining
-
withDeleteUrl
Sets the complete caller URL for deleting this module (HTMX hx-delete). No template substitution or identifier encoding is applied; a configured edit mode is appended to its pre-fragment query.- Parameters:
deleteUrl- the endpoint to delete the module- Returns:
- this EditableModule for method chaining
-
withDeleteButton
Sets custom label for the delete button (default: "🗑").- Parameters:
label- the button label (emoji or text)- Returns:
- this EditableModule for method chaining
-
withDeleteTarget
Sets the HTMX target for delete operations. If not set, the module itself will be swapped out.- Parameters:
target- the CSS selector for the target element- Returns:
- this EditableModule for method chaining
-
withDeleteSwap
Sets the HTMX swap strategy for delete operations (default: "outerHTML").- Parameters:
swap- the swap strategy- Returns:
- this EditableModule for method chaining
-
withDeleteConfirm
Sets a confirmation message for delete operations.- Parameters:
message- the confirmation prompt text- Returns:
- this EditableModule for method chaining
-
withDeleteTitle
Sets the title attribute for the delete button (default: "Delete").- Parameters:
title- the tooltip text- Returns:
- this EditableModule for method chaining
-
render
-