Commit 0e2936b1 authored by Jürgen Haas's avatar Jürgen Haas
Browse files

Issue #3306003 by jurgenhaas, rkoller: Unexpected error on model re import

parent c561319d
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -760,7 +760,7 @@ abstract class ModellerBpmnBase extends ModellerBase {
          case 'checkboxes':
          case 'radios':
          case 'select':
            $fields[] = $this->optionsField($key, $label, $weight, $description, $definition['#options'], (string) $value);
            $fields[] = $this->optionsField($key, $label, $weight, $description, $definition['#options'], (string) $value, $definition['#required'] ?? FALSE);
            continue 2;

        }
@@ -816,17 +816,22 @@ abstract class ModellerBpmnBase extends ModellerBase {
   *   Key/value list of available options.
   * @param string $value
   *   The default value for the field.
   * @param bool $required
   *   The setting, if this field is required to be filled by the user.
   *
   * @return array
   *   Prepared option field.
   */
  protected function optionsField(string $name, string $label, int $weight, ?string $description, array $options, string $value): array {
  protected function optionsField(string $name, string $label, int $weight, ?string $description, array $options, string $value, bool $required = FALSE): array {
    $choices = [];
    foreach ($options as $optionValue => $optionName) {
      $choices[] = [
        'name' => (string) $optionName,
        'value' => (string) $optionValue,
      ];
      if ($required && $value === '') {
        $value = (string) $optionValue;
      }
    }
    $field = [
      'name' => $name,
+9 −2
Original line number Diff line number Diff line
@@ -322,13 +322,20 @@ class Import extends FormBase {
      $replacement_storage = new StorageReplaceDataWrapper($active_storage);
      foreach ($source_storage->listAll() as $name) {
        $data = $source_storage->read($name);
        if (is_array($data)) {
          $replacement_storage->replaceData($name, $data);
        }
        else {
          $this->messenger()->addError($this->t('The contained config entity %name is invalid and got ignored.', [
            '%name' => $name,
          ]));
        }
      }
      $source_storage = $replacement_storage;

      $storage_comparer = new StorageComparer($source_storage, $active_storage);
      if (!$storage_comparer->createChangelist()->hasChanges()) {
        $this->messenger()->addStatus(('There are no changes to import.'));
        $this->messenger()->addStatus('There are no changes to import.');
      }
      else {
        $config_importer = new ConfigImporter(
+4 −1
Original line number Diff line number Diff line
@@ -93,8 +93,10 @@ class ViewsQuery extends ConfigurableActionBase {
    $form = parent::buildConfigurationForm($form, $form_state);
    $views = [];
    foreach (View::loadMultiple() as $view) {
      if ($view->status()) {
        $views[$view->id()] = $view->label();
      }
    }
    $form['token_name'] = [
      '#type' => 'textfield',
      '#title' => $this->t('Name of token'),
@@ -107,6 +109,7 @@ class ViewsQuery extends ConfigurableActionBase {
      '#default_value' => $this->configuration['view_id'],
      '#weight' => -50,
      '#options' => $views,
      '#required' => TRUE,
    ];
    $form['display_id'] = [
      '#type' => 'textfield',