Skip to content

Commit

Permalink
Feat: Add label to input list (#215)
Browse files Browse the repository at this point in the history
  • Loading branch information
rboixaderg authored Feb 7, 2024
1 parent e502969 commit f6c17df
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 27 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
0.27.0
------
- Feat: Add label to input list

0.26.0
------
- Feat: Add possibility to translate the workflow texts
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.26.0",
"version": "0.27.0",
"repository": {
"type": "git",
"url": "[email protected]:guillotinaweb/guillotina_react.git"
Expand Down
21 changes: 13 additions & 8 deletions src/guillo-gmi/components/fields/editComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,19 @@ export const EditComponent = React.forwardRef(
}
}
return (
<InputList
value={val || []}
className={className}
onChange={(ev) => setValue(ev)}
ref={ref}
dataTest={dataTest}
{...rest}
/>
<React.Fragment>
{rest.placeholder && (
<label className="label">{rest.placeholder}</label>
)}
<InputList
value={val || []}
className={className}
onChange={(ev) => setValue(ev)}
ref={ref}
dataTest={dataTest}
{...rest}
/>
</React.Fragment>
)
} else if (schema?.widget === 'file') {
return (
Expand Down
38 changes: 20 additions & 18 deletions src/guillo-gmi/components/input/input_list.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,26 @@ export const InputList = React.forwardRef(

return (
<div className="control">
<div className="tags">
{value.map((tag, index) => (
<div
key={`input_list_${tag}_${index}`}
className="tag is-info is-medium"
>
{tag}
<button
className="delete is-small"
onClick={() =>
onChange([
...value.filter((tag) => value.indexOf(tag) !== index),
])
}
></button>
</div>
))}
</div>
{(value ?? []).length > 0 && (
<div className="tags">
{value.map((tag, index) => (
<div
key={`input_list_${tag}_${index}`}
className="tag is-info is-medium"
>
{tag}
<button
className="delete is-small"
onClick={() =>
onChange([
...value.filter((tag) => value.indexOf(tag) !== index),
])
}
></button>
</div>
))}
</div>
)}
<Input
type="text"
placeholder={intl.formatMessage({
Expand Down

0 comments on commit f6c17df

Please sign in to comment.