Skip to content

Commit

Permalink
FEATURE: Refactor edit template to AFX
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebobo committed Jul 5, 2024
1 parent 3646341 commit da2a0bc
Show file tree
Hide file tree
Showing 7 changed files with 166 additions and 74 deletions.
4 changes: 2 additions & 2 deletions Neos.Workspace.Ui/Classes/Controller/WorkspaceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,14 +288,14 @@ public function editAction(WorkspaceName $workspaceName): void
* @param WorkspaceName $workspaceName
* @param WorkspaceTitle $title Human friendly title of the workspace, for example "Christmas Campaign"
* @param WorkspaceDescription $description A description explaining the purpose of the new workspace
* @param string $workspaceOwner Id of the owner of the workspace
* @param string|null $workspaceOwner Id of the owner of the workspace
* @return void
*/
public function updateAction(
WorkspaceName $workspaceName,
WorkspaceTitle $title,
WorkspaceDescription $description,
?string $workspaceOwner
?string $workspaceOwner = null
): void {
$contentRepositoryId = SiteDetectionResult::fromRequest($this->request->getHttpRequest())
->contentRepositoryId;
Expand Down
2 changes: 1 addition & 1 deletion Neos.Workspace.Ui/Configuration/Views.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- 'resource://Neos.Workspace.Ui/Private/Partials'
- 'resource://Neos.Neos/Private/Partials'

- requestFilter: 'isPackage("Neos.Workspace.Ui") && isController("Workspace") && isFormat("html") && (isAction("index") || isAction("new"))'
- requestFilter: 'isPackage("Neos.Workspace.Ui") && isController("Workspace") && isFormat("html") && (isAction("index") || isAction("new") || isAction("edit"))'
viewObjectName: 'Neos\Fusion\View\FusionView'
options:
fusionPathPatterns:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ prototype(Neos.Workspace.Ui:Component.WorkspaceTableRow) < prototype(Neos.Fusion
workspace = ${props.workspaceName}
}
}
editWorkspaceUri = Neos.Fusion:UriBuilder {
action = 'edit'
arguments {
workspaceName = ${props.workspaceName}
}
}
}

renderer = afx`
Expand Down Expand Up @@ -81,15 +87,14 @@ prototype(Neos.Workspace.Ui:Component.WorkspaceTableRow) < prototype(Neos.Fusion
<i
class="fas fa-review"></i> {I18n.translate('table.column.action.show', 'Show', [], 'Main', 'Neos.Workspace.Ui')}
</a>
<button
<a
class="neos-button"
type="button"
title={I18n.translate('table.column.action.edit', 'Edit workspace ' + workspace.title, {workspace: workspace.title}, 'Main', 'Neos.Workspace.Ui')}
onClick=""
disabled={!props.canManage || props.workspaceData.changesCounts == null}
href={private.editWorkspaceUri}
@if={!props.canManage || props.workspaceData.changesCounts == null}
>
<i class="fas fa-pencil-alt"></i>
</button>
</a>
<button
class="neos-button neos-button-danger"
title={I18n.translate('workspaces.deleteWorkspace', 'Delete workspace', [], 'Main', 'Neos.Workspace.Ui')}
Expand Down
147 changes: 147 additions & 0 deletions Neos.Workspace.Ui/Resources/Private/Fusion/Views/Edit.fusion
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
Neos.Workspace.Ui.WorkspaceController.edit = Neos.Fusion:Component {
flashMessages = ${flashMessages}
baseWorkspaceOptions = ${baseWorkspaceOptions}
showOwnerSelector = ${showOwnerSelector}
ownerOptions = ${ownerOptions}
workspace = ${workspace}
i18n = ${I18n.id('').source('Main').package('Neos.Workspace.Ui')}

prototype(Neos.Fusion.Form:LabelRenderer) {
translationPackage = 'Neos.Workspace.Ui'
translationSource = 'Main'
}

prototype(Neos.Fusion.Form:Neos.BackendModule.FieldContainer) {
translation.label {
package = 'Neos.Workspace.Ui'
source = 'Main'
}
}

renderer = afx`
<Neos.Workspace.Ui:Component.FlashMessages flashMessages={props.flashMessages}/>
<main>
<h2>{props.i18n.id('workspaces.editWorkspace').arguments([props.workspace.workspaceTitle.value])}</h2>
<Neos.Fusion.Form:Form form.target.action="update">
<Neos.Fusion.Form:Hidden
field.name="workspaceName"
field.value={props.workspace.workspaceName.value}
/>
<fieldset>
<Neos.Fusion.Form:Neos.BackendModule.FieldContainer
field.name="title"
field.value={props.workspace.workspaceTitle.value}
label="workspaces.workspace.title"
class="neos-control-group"
>
<Neos.Fusion.Form:Textfield
attributes.required
attributes.pattern="/^[\p{L}\p{P}\d \.]{1,200}$/u"
attributes.autofocus
/>
</Neos.Fusion.Form:Neos.BackendModule.FieldContainer>

<Neos.Fusion.Form:Neos.BackendModule.FieldContainer
field.name="description"
field.value={props.workspace.workspaceDescription.value}
label="workspaces.workspace.description"
class="neos-control-group"
>
<Neos.Fusion.Form:Textfield
attributes.pattern="/^[\p{L}\p{P}\d \.]{0,500}$/u"
/>
</Neos.Fusion.Form:Neos.BackendModule.FieldContainer>

<Neos.Fusion.Form:Neos.BackendModule.FieldContainer
field.name="baseWorkspace"
field.value={props.workspace.baseWorkspaceName.value}
label="workspaces.workspace.baseWorkspace"
class="neos-control-group"
>
<Neos.Fusion.Form:Select
attributes.disabled
>
<Neos.Fusion:Loop items={props.baseWorkspaceOptions} itemName="workspaceTitle" itemKey="workspaceName">
<Neos.Fusion.Form:Select.Option
option.value={workspaceName}
attributes.selected={workspaceName == props.workspace.baseWorkspaceName.value}
>
{workspaceTitle}
</Neos.Fusion.Form:Select.Option>
</Neos.Fusion:Loop>
</Neos.Fusion.Form:Select>
</Neos.Fusion.Form:Neos.BackendModule.FieldContainer>

<Neos.Fusion.Form:Neos.BackendModule.FieldContainer
field.name="workspaceOwner"
field.value={props.workspace.baseWorkspaceName.value}
label="workspaces.workspace.owner"
class="neos-control-group"
@if={props.showOwnerSelector}
>
<Neos.Fusion.Form:Select
field.value={props.workspace.baseWorkspaceName.value}
>
<Neos.Fusion:Loop items={props.ownerOptions} itemName="ownerTitle" itemKey="ownerName">
<Neos.Fusion.Form:Select.Option option.value={ownerName}>
{ownerTitle}
</Neos.Fusion.Form:Select.Option>
</Neos.Fusion:Loop>
</Neos.Fusion.Form:Select>
</Neos.Fusion.Form:Neos.BackendModule.FieldContainer>
</fieldset>
<fieldset>
<Neos.Fusion:Fragment
@if={Security.hasAccess('Neos.Workspace.Ui:Backend.Module.Management.Workspace.ManageInternalWorkspaces')}>
<h3 class="neos-control-label">
{props.i18n.id('workspaces.workspace.visibility')}
</h3>
<Neos.Fusion.Form:Neos.BackendModule.FieldContainer
class="neos-control-group"
>
<Neos.Fusion.Form:Radio
id="visibility.private"
field.value="private"
attributes.disabled
attributes.checked={props.workspace.privateWorkspace}
>
<span></span>
<span>
{props.i18n.id('workspaces.workspace.visibility.private')}
<span class="neos-help-inline">
{props.i18n.id('workspaces.workspace.visibility.private.help')}
</span>
</span>
</Neos.Fusion.Form:Radio>
<br/>
<Neos.Fusion.Form:Radio
id="visibility.internal"
field.value="internal"
attributes.disabled
attributes.checked={props.workspace.internalWorkspace}
>
<span></span>
<span>
{props.i18n.id('workspaces.workspace.visibility.internal')}
<span class="neos-help-inline">
{props.i18n.id('workspaces.workspace.visibility.internal.help')}
</span>
</span>
</Neos.Fusion.Form:Radio>
</Neos.Fusion.Form:Neos.BackendModule.FieldContainer>
</Neos.Fusion:Fragment>

<Neos.Fusion.Form:Button attributes.class="neos-button neos-button-primary">
{props.i18n.id('applyChanges')}
</Neos.Fusion.Form:Button>
</fieldset>
</Neos.Fusion.Form:Form>

<Neos.Workspace.Ui:Component.Footer>
<Neos.Fusion:Link.Action href.action="index" class="neos-button">
{props.i18n.id('cancel')}
</Neos.Fusion:Link.Action>
</Neos.Workspace.Ui:Component.Footer>
</main>
`
}
4 changes: 3 additions & 1 deletion Neos.Workspace.Ui/Resources/Private/Fusion/Views/New.fusion
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ Neos.Workspace.Ui.WorkspaceController.new = Neos.Fusion:Component {
label="workspaces.workspace.description"
class="neos-control-group"
>
<Neos.Fusion.Form:Textarea attributes.rows={3} />
<Neos.Fusion.Form:Textfield
attributes.pattern="/^[\p{L}\p{P}\d \.]{0,500}$/u"
/>
</Neos.Fusion.Form:Neos.BackendModule.FieldContainer>

<Neos.Fusion.Form:Neos.BackendModule.FieldContainer
Expand Down
65 changes: 0 additions & 65 deletions Neos.Workspace.Ui/Resources/Private/Templates/Workspace/Edit.html

This file was deleted.

3 changes: 3 additions & 0 deletions Neos.Workspace.Ui/Resources/Private/Translations/en/Main.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
<trans-unit id="cancel" xml:space="preserve">
<source>Cancel</source>
</trans-unit>
<trans-unit id="applyChanges" xml:space="preserve">
<source>Apply changes</source>
</trans-unit>
<trans-unit id="pathCaption" xml:space="preserve">
<source>Path</source>
</trans-unit>
Expand Down

0 comments on commit da2a0bc

Please sign in to comment.