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

Added simple view for single fields #26

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Neos package for adding repeatables fields to neos-ui react
```bash
composer require mireo91/repeatablefields
```

## Configuration

Create property with type `reapeatable`.
Expand Down
67 changes: 46 additions & 21 deletions Resources/Private/Backend/RepeatableField/src/View/Repeatable.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,34 +292,59 @@ export default class Repeatable extends PureComponent {
createElement = (idx) => {
const { options } = this.props;
const { allowRemove, currentValue } = this.state;
const isPredefined = options.predefinedProperties && options.predefinedProperties[idx]?true:false;
const isPredefined = options.predefinedProperties && options.predefinedProperties[idx] ? true : false;
const DragHandle = SortableHandle(() => (
<span type="button" className={style.move}>
<Icon icon="sort" />
</span>
));

const propertiesCount = Object.keys(options.properties).length;
if (propertiesCount === 1) {
return (
<div className={style.simpleWrapper}>
{this.getProperties(idx)}
<div class={style.simpleButtons}>
{!isPredefined && options.controls.remove && allowRemove ? (
<IconButton
onClick={() => this.handleRemove(idx)}
className={style.delete}
icon="trash"
/>
) : (
""
)}
{!isPredefined && options.controls.move && currentValue.length > 1 ? (
<DragHandle />
) : (
""
)}
</div>
</div>
);
}

return (
<div className={style.wrapper}>
<div class={style.buttons}>
{!isPredefined && options.controls.move && currentValue.length > 1 ? (
<DragHandle />
) : (
""
)}
{!isPredefined && options.controls.remove && allowRemove ? (
<IconButton
onClick={() => this.handleRemove(idx)}
className={style.delete}
icon="trash"
/>
) : (
""
)}
<div className={style.wrapper}>
<div class={style.buttons}>
{!isPredefined && options.controls.move && currentValue.length > 1 ? (
<DragHandle />
) : (
""
)}
{!isPredefined && options.controls.remove && allowRemove ? (
<IconButton
onClick={() => this.handleRemove(idx)}
className={style.delete}
icon="trash"
/>
) : (
""
)}
</div>
{this.getProperties(idx)}
</div>
{this.getProperties(idx)}
</div>
);
);
};

getProperties = (idx) => {
Expand Down Expand Up @@ -374,7 +399,7 @@ export default class Repeatable extends PureComponent {
editorOptions.dataSourceAdditionalData["repeatableValue"] = this.getValue();
}
return (
<div className={style.property} hidden={propertyDefinition.hidden}>
<div className={Object.keys(this.props.options.properties).length > 1 ? style.property : ""} hidden={propertyDefinition.hidden}>
<Envelope
identifier={`repeatable-${idx}-${property}`}
// label={propertyDefinition.label?propertyDefinition.label:''}
Expand Down
38 changes: 38 additions & 0 deletions Resources/Private/Backend/RepeatableField/src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,41 @@
background-color: #3f3f3f;
}
}

.simpleWrapper {
display: flex;
position: relative;
}

.simpleWrapper span label span {
display: none;
}

.group {
flex: 1;
margin-bottom: 10px;
}

.simpleButtons {
margin-top: 6px;
margin-left: 2px;
display: flex;
justify-content: flex-end;
margin-bottom: 10px;
color: #fff;
font-size: 14px;
gap: 2px;

& > * {
display: flex;
align-items: center;
justify-content: center;
height: 40px;
min-width: 40px;
background-color: #323232;
}

&:empty {
display: none
}
}
37 changes: 37 additions & 0 deletions Resources/Public/Inspector/RepeatableFieldEditor/Plugin.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Resources/Public/Inspector/RepeatableFieldEditor/Plugin.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.