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

Fix name size from edit preset (in backend and frontend). #848

Open
wants to merge 4 commits into
base: develop
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
1 change: 1 addition & 0 deletions bbbeasy-backend/app/src/Actions/Presets/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public function rename($f3, $params): void
$dataChecker = new DataChecker();

$dataChecker->verify($form['name'], Validator::notEmpty()->setName('name'));
$dataChecker->verify($form['name'], Validator::length(1, 64)->setName('name'));
$dataChecker->verify($id, Validator::notEmpty()->setName('id'));

$errorMessage = 'Preset could not be updated';
Expand Down
5 changes: 5 additions & 0 deletions bbbeasy-frontend/src/App-webapp.css
Original file line number Diff line number Diff line change
Expand Up @@ -1565,3 +1565,8 @@ fieldset {
.edit-room-form {
display: block !important;
}
div.edit-preset-name{
margin-top: 10px;
width: 250px;
white-space: pre-line;
}
95 changes: 52 additions & 43 deletions bbbeasy-frontend/src/components/Presets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -282,53 +282,62 @@ const PresetsCol: React.FC<PresetColProps> = ({
)}
</>
) : (
<Form form={editForm}>
<Form.Item
name="name"
className="input-editable"
{...('name' in errorsEdit && {
help: (
<Trans
i18nKey={Object.keys(EN_US).filter(
(elem) => EN_US[elem] == errorsEdit['name']
)}
/>
),
validateStatus: 'error',
})}
rules={[
{
required: true,
message: <Trans i18nKey="name.required" />,
},
]}
<div className="edit-preset-name">
<Form
form={editForm}
validateTrigger="onSubmit"
>
<Input
onPressEnter={handleSaveEdit}
suffix={
<>
<Popconfirm
title={t('cancel_edit')}
placement="leftTop"
onConfirm={() => cancelEdit()}
>
<Form.Item
name="name"
className="input-editable"
{...('name' in errorsEdit && {
help: (
<Trans
i18nKey={Object.keys(EN_US).filter(
(elem) => EN_US[elem] == errorsEdit['name']
)}
/>
),
validateStatus: 'error',
})}
rules={[
{
required: true,
message: <Trans i18nKey="name.required" />,
},
{
max: 64,
message: <Trans i18nKey="preset_name.maxSize" />,
},
]}
>
<Input
onPressEnter={handleSaveEdit}
suffix={
<>
<Popconfirm
title={t('cancel_edit')}
placement="leftTop"
onConfirm={() => cancelEdit()}
>
<Button
icon={<CloseOutlined />}
size="small"
className="cell-input-cancel"
/>
</Popconfirm>
<Button
icon={<CloseOutlined />}
icon={<CheckOutlined />}
size="small"
className="cell-input-cancel"
onClick={handleSaveEdit}
type="primary"
/>
</Popconfirm>
<Button
icon={<CheckOutlined />}
size="small"
onClick={handleSaveEdit}
type="primary"
/>
</>
}
/>
</Form.Item>
</Form>
</>
}
/>
</Form.Item>
</Form>
</div>
)}
</Space>
</div>
Expand Down