Skip to content

Commit

Permalink
Merge pull request #349 from City-of-Helsinki/develop
Browse files Browse the repository at this point in the history
Release 7.11.
  • Loading branch information
tvalimaa authored Nov 7, 2022
2 parents 52f9af4 + 435beda commit d18ed23
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public function getFormId() {
*/
public function buildForm(array $form, FormStateInterface $form_state, string $user_id = NULL, string $project_id = NULL) {
$project_id = \Drupal::request()->get('project') ?? NULL;
$apartment_id = \Drupal::request()->get('apartment') ?? NULL;
$project = NULL;
$contact_person_value = NULL;

Expand All @@ -37,6 +38,22 @@ public function buildForm(array $form, FormStateInterface $form_state, string $u
$form['#contact_form_title'] = t('Apply for an apartment');
$form['#contact_form_text'] = t('Leave your contact information and we will personally contact you regarding this apartment.');

$form['field_project'] = [
'#type' => 'textfield',
'#title' => t('Project'),
'#value' => $project->getTitle(),
'#required' => TRUE,
'#disabled' => TRUE,
];

$form['field_apartment_id'] = [
'#type' => 'textfield',
'#title' => t('Apartment'),
'#required' => TRUE,
'#value' => $apartment_id,
'#disabled' => TRUE,
];

$form['field_name'] = [
'#type' => 'textfield',
'#title' => t('Name'),
Expand Down Expand Up @@ -121,6 +138,8 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
*/
private function convertMessage(array $values): string {
$message_values = [
'Project' => $values['field_project'],
'Apartment' => $values['field_apartment_id'],
'Name' => $values['field_name'],
'Apartment information' => $values['field_apartment_information'],
'Phone' => $values['field_phone'],
Expand Down
4 changes: 3 additions & 1 deletion public/modules/custom/asu_content/src/Entity/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,14 @@ public function getOwnershipType(): string {
*/
public function getApplicationUrl($apartmentId = NULL): string {
$baseurl = \Drupal::request()->getSchemeAndHttpHost();
$langcode = \Drupal::languageManager()->getCurrentLanguage()->getId();
$baseurl = $baseurl . '/' . $langcode;
if ($this->isApplicationPeriod() || $this->isApplicationPeriod('before')) {
$apartmentType = strtolower($this->field_ownership_type->referencedEntities()[0]->getName());
return sprintf('%s/application/add/%s/%s', $baseurl, $apartmentType, $this->id());
}
if ($this->isApplicationPeriod('after')) {
$queryParameter = $apartmentId ? "?apartment=$apartmentId" : '?project=' . $this->id();
$queryParameter = $apartmentId ? "?apartment=$apartmentId" . '&project=' . $this->id() : '?project=' . $this->id();
return sprintf('%s/contact/apply_for_free_apartment%s', $baseurl, $queryParameter);
}
return '';
Expand Down
2 changes: 1 addition & 1 deletion public/themes/custom/asuntotuotanto/asuntotuotanto.theme
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ function asuntotuotanto_preprocess_views_view_table(&$variables) {
$variables['rows'][$key]['application_url'] = $application_url;
$variables['rows'][$key]['apartment_number'] = $apartment->field_apartment_number->value;
$variables['rows'][$key]['reserved_or_sold'] = $reserved_or_sold;
$variables['rows'][$key]['application_url'] = $project->getApplicationUrl();
$variables['rows'][$key]['application_url'] = $project->getApplicationUrl($apartment->field_apartment_number->value);
$variables['rows'][$key]['application_url_title'] = $apartment->getApplicationUrlTitle();
$variables['rows'][$key]['is_free'] = $apartment->isFree();
}
Expand Down

0 comments on commit d18ed23

Please sign in to comment.