Commit dabe8799 authored by Jesse van de Water's avatar Jesse van de Water Committed by Fabian de Rijk
Browse files

#3272948: possible solution disappearing blocks

parent 52eda075
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
@@ -101,6 +101,26 @@ class CalendarBlock extends O365UncachedBlockBase implements ContainerFactoryPlu
      '#max' => 999,
    ];

    $form['show_calendar_block'] = [
      '#type' => 'checkbox',
      '#title' => $this->t('Show the calendar block when there is no data'),
    ];

    $form['calendar_block_text'] = [
      '#type' => 'textarea',
      '#title' => t('Mail block text'),
      '#description' => t('Enter the text you would like to show'),
      '#default_value' => t('Enter the text you would like to show'),
      '#states' => [
        'visible' => [
          'input[name="show_calendar_block"]' => [
            'checked' => TRUE,
          ],
        ],
      ],
    ];
    

    return $form;
  }

@@ -110,6 +130,8 @@ class CalendarBlock extends O365UncachedBlockBase implements ContainerFactoryPlu
  public function blockSubmit($form, FormStateInterface $form_state) {
    $values = $form_state->getValues();
    $this->configuration['amount'] = $values['amount'];
    $this->configuration['show_calendar_block'] = $values['show_calendar_block'];
    $this->configuration['calendar_block_text'] = $values['calendar_block_text'];
  }

  /**
@@ -172,6 +194,10 @@ class CalendarBlock extends O365UncachedBlockBase implements ContainerFactoryPlu
      }
    }

    if ($config['show_calendar_block']) {
      return $items == $config['calendar_block_text'];
    }

    if (!empty($items)) {
      $build['content'] = [
        '#theme' => 'o365_calendar_list',