mirror of
https://github.com/opensupports/opensupports.git
synced 2025-07-31 01:35:15 +02:00
Fix #460 issue: Unable to edit email templates with two text fields
This commit is contained in:
parent
eed0fdce03
commit
4b80a9b397
@ -185,21 +185,24 @@ class AdminPanelEmailSettings extends React.Component {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<FormField label={i18n('TEXT') + '1'} name="text1" validation="TEXT_AREA" required
|
||||
<FormField key="text1" label={i18n('TEXT') + '1'} name="text1" validation="TEXT_AREA" required
|
||||
decorator={'textarea'}
|
||||
fieldProps={{className: 'admin-panel-email-settings__text-area'}}/>
|
||||
{(this.state.form.text2) ?
|
||||
<FormField label={i18n('TEXT') + '2'} name="text2" validation="TEXT_AREA" required
|
||||
<FormField key="text2" label={i18n('TEXT') + '2'} name="text2" validation="TEXT_AREA" required
|
||||
decorator={'textarea'}
|
||||
fieldProps={{className: 'admin-panel-email-settings__text-area'}}/> : null}
|
||||
{(this.state.form.text3) ?
|
||||
<FormField label={i18n('TEXT') + '3'} name="text3" validation="TEXT_AREA" required
|
||||
<FormField key="text3" label={i18n('TEXT') + '3'} name="text3" validation="TEXT_AREA" required
|
||||
decorator={'textarea'}
|
||||
fieldProps={{className: 'admin-panel-email-settings__text-area'}}/> : null}
|
||||
|
||||
<div className="admin-panel-email-settings__actions">
|
||||
<div className="admin-panel-email-settings__save-button">
|
||||
<SubmitButton type="secondary" size="small">{i18n('SAVE')}</SubmitButton>
|
||||
<SubmitButton key="submit-email-template" type="secondary" size="small" onClick={e => {
|
||||
e.preventDefault();
|
||||
this.onFormSubmit(this.state.form);
|
||||
}}>{i18n('SAVE')}</SubmitButton>
|
||||
</div>
|
||||
<div className="admin-panel-email-settings__optional-buttons">
|
||||
{(this.state.edited) ? this.renderDiscardButton() : null}
|
||||
@ -245,7 +248,6 @@ class AdminPanelEmailSettings extends React.Component {
|
||||
onValidateErrors: (errors) => {
|
||||
this.setState({errors})
|
||||
},
|
||||
onSubmit: this.onFormSubmit.bind(this)
|
||||
}
|
||||
}
|
||||
|
||||
@ -281,6 +283,7 @@ class AdminPanelEmailSettings extends React.Component {
|
||||
}
|
||||
|
||||
onFormSubmit(form) {
|
||||
console.log('form submmited');
|
||||
const {selectedIndex, language, templates} = this.state;
|
||||
|
||||
this.setState({loadingForm: true});
|
||||
|
@ -62,7 +62,7 @@ class EditMailTemplateController extends Controller {
|
||||
}
|
||||
|
||||
public function handler() {
|
||||
$this->language = Controller::request('language');
|
||||
$this->langauge = Controller::request('language');
|
||||
$this->templateType = Controller::request('template');
|
||||
$this->subject = Controller::request('subject', true);
|
||||
$this->texts = [
|
||||
@ -71,7 +71,7 @@ class EditMailTemplateController extends Controller {
|
||||
Controller::request('text3'),
|
||||
];
|
||||
|
||||
$mailTemplate = MailTemplate::findOne(' language = ? AND template = ?', [$this->language, $this->templateType]);
|
||||
$mailTemplate = MailTemplate::findOne(' language = ? AND template = ?', [$this->langauge, $this->templateType]);
|
||||
|
||||
if($mailTemplate->isNull()) {
|
||||
throw new RequestException(ERRORS::INVALID_TEMPLATE);
|
||||
@ -90,23 +90,23 @@ class EditMailTemplateController extends Controller {
|
||||
}
|
||||
|
||||
public function validateReplacements() {
|
||||
$originalText = MailTexts::getTexts()[$this->language][$this->templateType];
|
||||
$originalText = MailTexts::getTexts()[$this->langauge][$this->templateType];
|
||||
|
||||
if(!$this->includes(
|
||||
if(array_key_exists(1, $originalText) && !$this->includes(
|
||||
$this->getReplacementStrings($originalText[1]),
|
||||
$this->getReplacementStrings($this->texts[0])
|
||||
)) {
|
||||
throw new RequestException(ERRORS::INVALID_TEXT_1);
|
||||
}
|
||||
|
||||
if(!$this->includes(
|
||||
if(array_key_exists(2, $originalText) && !$this->includes(
|
||||
$this->getReplacementStrings($originalText[2]),
|
||||
$this->getReplacementStrings($this->texts[1])
|
||||
)) {
|
||||
throw new RequestException(ERRORS::INVALID_TEXT_2);
|
||||
}
|
||||
|
||||
if(!$this->includes(
|
||||
if(array_key_exists(3, $originalText) && !$this->includes(
|
||||
$this->getReplacementStrings($originalText[3]),
|
||||
$this->getReplacementStrings($this->texts[2])
|
||||
)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user