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 issue #2817: Field about for profiles #2914

Merged
merged 4 commits into from Oct 3, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/Backend/Modules/Profiles/Actions/Add.php
Expand Up @@ -91,6 +91,7 @@ private function loadForm(): void
$this->form->addDropdown('month', $months);
$this->form->addDropdown('year', array_combine($years, $years));
$this->form->addDropdown('country', Intl::getRegionBundle()->getCountryNames(BL::getInterfaceLanguage()));
$this->form->addTextarea('about');

// set default elements dropdowns
$this->form->getField('gender')->setDefaultElement('');
Expand Down Expand Up @@ -119,6 +120,7 @@ private function validateForm(): void
$ddmMonth = $this->form->getField('month');
$ddmYear = $this->form->getField('year');
$ddmCountry = $this->form->getField('country');
$txtAbout = $this->form->getField('about');

// email filled in?
if ($txtEmail->isFilled(BL::getError('EmailIsRequired'))) {
Expand Down Expand Up @@ -191,6 +193,7 @@ private function validateForm(): void
BackendProfilesModel::setSetting($this->id, 'birth_date', $birthDate);
BackendProfilesModel::setSetting($this->id, 'city', $txtCity->getValue());
BackendProfilesModel::setSetting($this->id, 'country', $ddmCountry->getValue());
BackendProfilesModel::setSetting($this->id, 'about', $txtAbout->getValue());

// notify values
$notifyValues = array_merge(
Expand Down
3 changes: 3 additions & 0 deletions src/Backend/Modules/Profiles/Actions/Edit.php
Expand Up @@ -116,6 +116,7 @@ private function loadForm(): void
Intl::getRegionBundle()->getCountryNames(BL::getInterfaceLanguage()),
BackendProfilesModel::getSetting($this->id, 'country')
);
$this->form->addTextarea('about', BackendProfilesModel::getSetting($this->id, 'about'));

// set default elements dropdowns
$this->form->getField('gender')->setDefaultElement('');
Expand Down Expand Up @@ -213,6 +214,7 @@ private function validateForm(): void
$ddmMonth = $this->form->getField('month');
$ddmYear = $this->form->getField('year');
$ddmCountry = $this->form->getField('country');
$txtAbout = $this->form->getField('about');

// email filled in?
if ($chkNewEmail->isChecked() && $txtEmail->isFilled(BL::getError('EmailIsRequired'))) {
Expand Down Expand Up @@ -306,6 +308,7 @@ private function validateForm(): void
BackendProfilesModel::setSetting($this->id, 'birth_date', $birthDate);
BackendProfilesModel::setSetting($this->id, 'city', $txtCity->getValue());
BackendProfilesModel::setSetting($this->id, 'country', $ddmCountry->getValue());
BackendProfilesModel::setSetting($this->id, 'about', $txtAbout->getValue());

$displayName = (isset($values['display_name'])) ?
$values['display_name'] : $this->profile['display_name'];
Expand Down
356 changes: 214 additions & 142 deletions src/Backend/Modules/Profiles/Installer/Data/locale.xml

Large diffs are not rendered by default.

171 changes: 96 additions & 75 deletions src/Backend/Modules/Profiles/Layout/Templates/Add.html.twig
Expand Up @@ -7,97 +7,118 @@

{% block content %}
{% form add %}
{% if notifyProfile %}
<p class="text-warning">{{ macro.icon('warning') }} {{ 'lbl.NewProfileWillBeNotified'|trans|ucfirst }}
</p>
{% endif %}
<div class="row fork-module-content">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading">
<h2 class="panel-title">{{ 'lbl.Profile'|trans|ucfirst }}</h2>
</div>
<div class="panel-body">
<div class="form-group">
<label for="email" class="control-label">
{{ 'lbl.Email'|trans|ucfirst }}
{{ macro.required }}
</label>
{% form_field email %} {% form_field_error email %}
</div>
<div class="form-group">
<label for="displayName" class="control-label">
{{ 'lbl.DisplayName'|trans|ucfirst }}
{{ macro.required }}
</label>
{% form_field display_name %} {% form_field_error display_name %}
{% if notifyProfile %}
<p class="text-warning">{{ macro.icon('warning') }} {{ 'lbl.NewProfileWillBeNotified'|trans|ucfirst }}
</p>
{% endif %}
<div class="row fork-module-content">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading">
<h2 class="panel-title">{{ 'lbl.Profile'|trans|ucfirst }}</h2>
</div>
<div class="form-group">
<label for="password" class="control-label">
{{ 'lbl.Password'|trans|ucfirst }}
{% if not notifyProfile %}
{{ macro.required }}{% endif %}
</label>
{% form_field password %} {% form_field_error password %}
{% if notifyProfile %}<span class="helpTxt">{{ 'msg.AutoGeneratedPasswordIfEmpty'|trans }}</span>{% endif %}
<div class="panel-body">
<div class="form-group">
<label for="email" class="control-label">
{{ 'lbl.Email'|trans|ucfirst }}
{{ macro.required }}
</label>
{% form_field email %} {% form_field_error email %}
</div>
<div class="form-group">
<label for="displayName" class="control-label">
{{ 'lbl.DisplayName'|trans|ucfirst }}
{{ macro.required }}
</label>
{% form_field display_name %} {% form_field_error display_name %}
</div>
<div class="form-group">
<label for="password" class="control-label">
{{ 'lbl.Password'|trans|ucfirst }}
{% if not notifyProfile %}
{{ macro.required }}{% endif %}
</label>
{% form_field password %} {% form_field_error password %}
{% if notifyProfile %}<span class="helpTxt">{{ 'msg.AutoGeneratedPasswordIfEmpty'|trans }}</span>{% endif %}
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row fork-module-content">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading">
<h2 class="panel-title">{{ 'lbl.Settings'|trans|ucfirst }}</h2>
</div>
<div class="panel-body">
<div class="form-group">
<label for="firstName" class="control-label">{{ 'lbl.FirstName'|trans|ucfirst }}</label>
{% form_field first_name %} {% form_field_error first_name %}
</div>
<div class="form-group">
<label for="lastName" class="control-label">{{ 'lbl.LastName'|trans|ucfirst }}</label>
{% form_field last_name %} {% form_field_error last_name %}
</div>
<div class="form-group">
<label for="gender" class="control-label">{{ 'lbl.Gender'|trans|ucfirst }}</label>
{% form_field gender %} {% form_field_error gender %}
<div class="row fork-module-content">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading">
<h2 class="panel-title">{{ 'lbl.Settings'|trans|ucfirst }}</h2>
</div>
<div class="form-group">
<label for="day" class="control-label">{{ 'lbl.BirthDate'|trans|ucfirst }}</label>
<div class="form-inline">
<div class="form-group">
{% form_field day %}
{% form_field month %}
{% form_field year %}
<div class="panel-body">
<div class="form-group">
<label for="firstName" class="control-label">{{ 'lbl.FirstName'|trans|ucfirst }}</label>
{% form_field first_name %} {% form_field_error first_name %}
</div>
<div class="form-group">
<label for="lastName" class="control-label">{{ 'lbl.LastName'|trans|ucfirst }}</label>
{% form_field last_name %} {% form_field_error last_name %}
</div>
<div class="form-group">
<label for="gender" class="control-label">{{ 'lbl.Gender'|trans|ucfirst }}</label>
{% form_field gender %} {% form_field_error gender %}
</div>
<div class="form-group">
<label for="day" class="control-label">{{ 'lbl.BirthDate'|trans|ucfirst }}</label>
<div class="form-inline">
<div class="form-group">
{% form_field day %}
{% form_field month %}
{% form_field year %}
</div>
{% form_field_error year %}
</div>
{% form_field_error year %}
</div>
<div class="form-group">
<label for="city" class="control-label">{{ 'lbl.City'|trans|ucfirst }}</label>
{% form_field city %} {% form_field_error city %}
</div>
<div class="form-group">
<label for="country" class="control-label">{{ 'lbl.Country'|trans|ucfirst }}</label>
{% form_field country %} {% form_field_error country %}
</div>
</div>
<div class="form-group">
<label for="city" class="control-label">{{ 'lbl.City'|trans|ucfirst }}</label>
{% form_field city %} {% form_field_error city %}
</div>
</div>
</div>
<div class="row fork-module-content">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading">
<h2>
<label for="about">
{{ 'lbl.About'|trans|ucfirst }}
</label>
</h2>
</div>
<div class="form-group">
<label for="country" class="control-label">{{ 'lbl.Country'|trans|ucfirst }}</label>
{% form_field country %} {% form_field_error country %}
<div class="panel-body">
{% form_field about %}
</div>
{% if txtAboutError %}
<div class="panel-footer">
{% form_field_error about %}
</div>
{% endif %}
</div>
</div>
</div>
</div>
<div class="row fork-module-actions">
<div class="col-md-12">
<div class="btn-toolbar">
<div class="btn-group" role="group">
{{ macro.buttonIcon(geturl('Index'), 'times', 'lbl.Cancel'|trans|ucfirst) }}
</div>
<div class="btn-group pull-right" role="group">
{{ macro.buttonIcon('', 'plus-square', 'lbl.Add'|trans|ucfirst, 'btn-primary', { "type":"submit", "id":"addButton", "name":"add" }) }}
<div class="row fork-module-actions">
<div class="col-md-12">
<div class="btn-toolbar">
<div class="btn-group" role="group">
{{ macro.buttonIcon(geturl('Index'), 'times', 'lbl.Cancel'|trans|ucfirst) }}
</div>
<div class="btn-group pull-right" role="group">
{{ macro.buttonIcon('', 'plus-square', 'lbl.Add'|trans|ucfirst, 'btn-primary', { "type":"submit", "id":"addButton", "name":"add" }) }}
</div>
</div>
</div>
</div>
</div>
{% endform %}
{% endblock %}
21 changes: 21 additions & 0 deletions src/Backend/Modules/Profiles/Layout/Templates/Edit.html.twig
Expand Up @@ -107,6 +107,27 @@
</div>
</div>
</div>
<div class="row fork-module-content">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading">
<h2>
<label for="about">
{{ 'lbl.About'|trans|ucfirst }}
</label>
</h2>
</div>
<div class="panel-body">
{% form_field about %}
</div>
{% if txtAboutError %}
<div class="panel-footer">
{% form_field_error about %}
</div>
{% endif %}
</div>
</div>
</div>
</div>
<div role="tabpanel" class="tab-pane" id="tabGroups">
<div class="row">
Expand Down
2 changes: 2 additions & 0 deletions src/Frontend/Modules/Profiles/Actions/Settings.php
Expand Up @@ -96,6 +96,7 @@ private function buildForm(): void
$this->form->addDropdown('month', $months, $birthMonth)->setDefaultElement('');
$this->form->addDropdown('year', array_combine($years, $years), (int) $birthYear)->setDefaultElement('');
$this->form->addImage('avatar');
$this->form->addTextarea('about', $this->profile->getSetting('about'));
}

private function parse(): void
Expand Down Expand Up @@ -206,6 +207,7 @@ private function handleForm(): void
'gender' => $this->form->getField('gender')->getValue(),
'birth_date' => $this->getSubmittedBirthDate(),
'avatar' => $this->getAvatar(),
'about' => $this->form->getField('about')->getValue(),
]
);

Expand Down
Expand Up @@ -103,6 +103,12 @@
</div>
</fieldset>

<fieldset>
<legend>{{ 'lbl.About'|trans|ucfirst }}</legend>
<div class="form-group{% if txtAboutError %} has-error{% endif %}">
{% form_field_error about %} {% form_field about %}
</div>
</fieldset>
<fieldset class="form-horizontal">
<legend>{{ 'lbl.YourAvatar'|trans|ucfirst }}</legend>
<div class="form-group{% if fileAvatarError %} has-error{% endif %}">
Expand Down