diff --git a/CHANGELOG.md b/CHANGELOG.md index e285107..f420e18 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Stanford Migrate + +8.x-1.18 +-------------------------------------------------------------------------------- +_Release Date: 2021-10-20_ + +- Removed unwanted status message +- D8CORE-4886 improvements to the CSV form (#39) +- Merge branch 'master' into 8.x-1.x + 8.x-1.17 -------------------------------------------------------------------------------- _Release Date: 2021-10-11_ diff --git a/src/Form/StanfordMigrateCsvImportForm.php b/src/Form/StanfordMigrateCsvImportForm.php index 65cb944..8b76493 100644 --- a/src/Form/StanfordMigrateCsvImportForm.php +++ b/src/Form/StanfordMigrateCsvImportForm.php @@ -119,9 +119,9 @@ public function buildForm(array $form, FormStateInterface $form_state) { '@link' => $template_link, '%title' => $this->entity->label(), ]), + '#required' => TRUE, '#upload_location' => 'public://csv/', '#upload_validators' => ['file_validate_extensions' => ['csv']], - '#default_value' => array_slice($previously_uploaded_files, -1), ]; if (!empty($this->entity->get('source')['csv_help'])) { $help = $this->entity->get('source')['csv_help']; @@ -129,6 +129,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#markup' => is_array($help) ? implode('
', $help) : $help, ]; } + unset($form['actions']['submit']); $form['actions']['import'] = [ '#type' => 'submit', '#value' => $this->t('Save and Import'), @@ -142,6 +143,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { $form['forget'] = [ '#type' => 'details', '#title' => $this->t('Previously Uploaded Files'), + '#open' => TRUE, ]; // Create render arrays of links to the files. @@ -157,11 +159,13 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#list_type' => 'ul', '#items' => $previously_uploaded_files, ]; + $form['forget']['previous_files_help']['#markup'] = $this->t('

DANGER: To avoid overwriting any of the previously imported content; check the unique ID column(s) (%ids) on the previously uploaded CSV file. Each imported item (Row) should have the unique values in the columns(s).

', ['%ids' => implode(', ', $this->migrationPlugin->getSourceConfiguration()['ids'])]); $form['forget']['forget_previous'] = [ '#type' => 'checkbox', '#title' => $this->t('Forget previously imported content.'), '#description' => $this->t('DANGER: Leave this box unchecked to update existing content based on the unique identifier column(s): %ids.', ['%ids' => implode(', ', $this->migrationPlugin->getSourceConfiguration()['ids'])]), + '#access' => $this->currentUser()->id() == 1, ]; return $form; } @@ -262,12 +266,10 @@ public function save(array $form, FormStateInterface $form_state) { // Store the file id into state for use in the config overrider. $state = $this->state->get("stanford_migrate.csv.$migration_id", []); $state[] = $file_id; - $this->state->set("stanford_migrate.csv.$migration_id", array_unique($state)); + $this->state->set("stanford_migrate.csv.$migration_id", $state); $link = Link::createFromRoute($this->t('import page'), 'stanford_migrate.list') ->toString(); - $this->messenger() - ->addStatus($this->t('File saved. Import the contents on the @link.', ['@link' => $link])); // Track the file usage on the migration. $this->fileUsage->add($file, 'stanford_migrate', 'migration', $migration_id); diff --git a/stanford_migrate.info.yml b/stanford_migrate.info.yml index aee6049..a59855e 100755 --- a/stanford_migrate.info.yml +++ b/stanford_migrate.info.yml @@ -3,7 +3,7 @@ description: 'Adds more functionality to migrate and migrate plus modules' type: module core_version_requirement: ^8.8 || ^9 package: 'Stanford' -version: 8.x-1.17 +version: 8.x-1.18 dependencies: - drupal:migrate - migrate_plus:migrate_plus