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 clear button email #285

Merged
merged 3 commits into from
Jul 2, 2024
Merged
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
4 changes: 2 additions & 2 deletions frontend/src/components/controls/email/EmailForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import './EmailForm.scss';
type EmailFormProps = BaseInputProps<EmailModel> & {
/** Attachments that are available for emailing */
attachmentsAvailable: string[],
textEditorReplacements?: ITextEditorCustomReplacement[];
textEditorReplacements?: ITextEditorCustomReplacement[]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

};

export const EmailForm = ({value, onChange, attachmentsAvailable, textEditorReplacements}: EmailFormProps) => {
Expand All @@ -29,7 +29,7 @@ export const EmailForm = ({value, onChange, attachmentsAvailable, textEditorRepl
let getToolbarCustomButtons: (editorState: EditorState) => JSX.Element[] = () => [];
if (textEditorReplacements && textEditorReplacements.length) {
getToolbarCustomButtons = (editorState: EditorState) => (
[<TextEditorReplacements editorState={editorState} replacements={textEditorReplacements} />]
[<TextEditorReplacements editorState={editorState} replacements={textEditorReplacements}/>]
);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/* eslint-disable jsx-a11y/click-events-have-key-events */
/* eslint-disable jsx-a11y/no-noninteractive-element-interactions */
import React, {useState} from 'react';
import {Modifier, EditorState} from 'draft-js';
import {Modifier, EditorState, ContentState} from 'draft-js';
import {t} from '../../../utils';
import {ITextEditorCustomReplacement} from '../../../invoice/invoice-replacements';


type TextEditorReplacementsProps = {
onChange?: (editorState: EditorState) => void,
editorState: EditorState,
replacements: ITextEditorCustomReplacement[],
replacements: ITextEditorCustomReplacement[]
}


Expand All @@ -30,25 +30,43 @@ export const TextEditorReplacements = ({onChange, editorState, replacements}: Te
}
};

const clearText = (): void => {
const contentState = ContentState.createFromText('');
const result = EditorState.push(editorState, contentState, 'remove-range');
if (onChange) {
onChange(result);
}
}

return (
<div onClick={() => setOpen(!open)} className="rdw-block-wrapper" aria-label="rdw-block-control" role="button" tabIndex={0}>
<div className="rdw-dropdown-wrapper rdw-block-dropdown" aria-label="rdw-dropdown" style={{width: 180}}>
<div className="rdw-dropdown-selectedtext">
<span>{t('config.invoiceReplacements.title')}</span>
<div className={`rdw-dropdown-caretto${open ? 'close' : 'open'}`} />
<>
<div onClick={() => setOpen(!open)} className="rdw-block-wrapper" aria-label="rdw-block-control" role="button" tabIndex={0}>
<div className="rdw-dropdown-wrapper rdw-block-dropdown" aria-label="rdw-dropdown" style={{width: 180}}>
<div className="rdw-dropdown-selectedtext">
<span>{t('config.invoiceReplacements.title')}</span>
<div className={`rdw-dropdown-caretto${open ? 'close' : 'open'}`} />
</div>
<ul className={`rdw-dropdown-optionwrapper ${open ? '' : 'placeholder-ul'}`}>
{replacements.map(item => (
<li
onClick={() => addPlaceholder(item.defaultValue || item.code)}
key={item.code}
className="rdw-dropdownoption-default placeholder-li"
>
{item.code.replace(/\{|\}/g, '')}
</li>
))}
</ul>
</div>
<ul className={`rdw-dropdown-optionwrapper ${open ? '' : 'placeholder-ul'}`}>
{replacements.map(item => (
<li
onClick={() => addPlaceholder(item.defaultValue || item.code)}
key={item.code}
className="rdw-dropdownoption-default placeholder-li"
>
{item.code.replace(/\{|\}/g, '')}
</li>
))}
</ul>
</div>
</div>
<div className="rdw-inline-wrapper" aria-label="rdw-inline-control">
<div
className="rdw-option-wrapper"
aria-selected={false}
title={t("config.invoiceReplacements.clearButton")}
onClick={() => clearText()} > {t("config.invoiceReplacements.clearButton")}</div>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probeer dezelfde styling aan te houden van de rest van het project:

 <div 
          className="rdw-option-wrapper" 
          aria-selected={false}
          title={t("config.invoiceReplacements.clearButton")}
          onClick={() => clearText()}
>
     {t("config.invoiceReplacements.clearButton")}
</div>

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je zou dit kunnen doen met: onClick={clearText}

</div>
</>

);
};
1 change: 1 addition & 0 deletions frontend/src/trans.en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ export const trans = {
consultantName: 'Naam consultant',
projectMonth: 'Project maand (MomentJS)',
projectMonthShort: 'Project maand',
clearButton: 'Clear'
},
company: {
title: 'Your company',
Expand Down
1 change: 1 addition & 0 deletions frontend/src/trans.nl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ export const trans = {
consultantName: 'Naam consultant',
projectMonth: 'Project maand (MomentJS)',
projectMonthShort: 'Project maand',
clearButton: 'Clear'
},
company: {
title: 'Jouw bedrijfsgegevens',
Expand Down
6 changes: 6 additions & 0 deletions package-lock.json

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

Loading