Skip to content

Commit

Permalink
TASK: Extract htmxconfig into component
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebobo committed Jul 18, 2024
1 parent e42f94b commit 3a3ea13
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
prototype(Neos.Workspace.Ui:Component.HTMXConfig) < prototype(Neos.Fusion:Component) {
htmxConfig = Neos.Fusion:DataStructure {
// 204 - No Content by default does nothing, but is not an error
noContent {
code = 204
swap = false
}
// 200 & 300 responses are non-errors and are swapped
nonErrors {
code = '[23]..'
swap = true
}
// 422 responses are swapped
invalidRequest {
code = 422
swap = true
}
// 400 & 500 responses are not swapped and are errors
errors {
code = '[45]..'
swap = false
error = true
}
}

renderer = afx`
<meta name="htmx-config" content={Json.stringify(Array.values(props.htmxConfig))}/>
`
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,8 @@ Neos.Workspace.Ui.WorkspaceController.index = Neos.Fusion:Component {
action = 'new'
}

htmxConfig = '[
{"code": "204", "swap": false},
{"code": "[23]..", "swap": true},
{"code": "422", "swap": true},
{"code": "[45]..", "swap": false, "error":true}
]'

renderer = afx`
<meta name="htmx-config" content={props.htmxConfig}/>
<Neos.Workspace.Ui:Component.HTMXConfig/>
<Neos.Workspace.Ui:Component.FlashMessages flashMessages={props.flashMessages}/>
<main class="neos-content neos-container-fluid">
<div class="neos-row-fluid">
Expand Down

0 comments on commit 3a3ea13

Please sign in to comment.