Commit 578bc40c authored by gbyte.co's avatar gbyte.co

Improve UX through dynamic buttons on settings page

parent 35aa3899
......@@ -72,6 +72,7 @@ class SimplesitemapSettingsForm extends SimplesitemapFormBase {
$form['simple_sitemap_settings']['#prefix'] = $this->getDonationText();
$form['simple_sitemap_settings']['#attached']['library'][] = 'simple_sitemap/sitemapSettings';
$queue_worker = $this->generator->getQueueWorker();
$form['simple_sitemap_settings']['status'] = [
'#type' => 'fieldset',
......@@ -85,24 +86,19 @@ class SimplesitemapSettingsForm extends SimplesitemapFormBase {
'#suffix' => '</div></div>',
];
$form['simple_sitemap_settings']['status']['actions']['regenerate_submit'] = [
$form['simple_sitemap_settings']['status']['actions']['rebuild_queue_submit'] = [
'#type' => 'submit',
'#value' => $this->t('Generate from queue'),
'#submit' => ['::generateSitemap'],
'#value' => $this->t('Rebuild queue'),
'#submit' => ['::rebuildQueue'],
'#validate' => [],
];
// $form['simple_sitemap_settings']['status']['actions']['regenerate_backend_submit'] = [
// '#type' => 'submit',
// '#value' => $this->t('Generate from queue (background)'),
// '#submit' => ['::generateSitemapBackend'],
// '#validate' => [],
// ];
$form['simple_sitemap_settings']['status']['actions']['rebuild_queue_submit'] = [
$form['simple_sitemap_settings']['status']['actions']['regenerate_submit'] = [
'#type' => 'submit',
'#value' => $this->t('Rebuild queue'),
'#submit' => ['::rebuildQueue'],
'#value' => $queue_worker->generationInProgress()
? $this->t('Resume generation')
: $this->t('Rebuild queue & generate'),
'#submit' => ['::generateSitemap'],
'#validate' => [],
];
......@@ -113,7 +109,6 @@ class SimplesitemapSettingsForm extends SimplesitemapFormBase {
$form['simple_sitemap_settings']['status']['progress']['title']['#markup'] = $this->t('Progress of sitemap regeneration');
$queue_worker = $this->generator->getQueueWorker();
$total_count = $queue_worker->getInitialElementCount();
if (!empty($total_count)) {
$indexed_count = $queue_worker->getProcessedElementCount();
......@@ -394,16 +389,6 @@ class SimplesitemapSettingsForm extends SimplesitemapFormBase {
$this->generator->generateSitemap();
}
/**
* @param array $form
* @param \Drupal\Core\Form\FormStateInterface $form_state
* @throws \Drupal\Component\Plugin\Exception\PluginException
*/
public function generateSitemapBackend (array &$form, FormStateInterface $form_state) {
$this->generator->generateSitemap('backend');
}
/**
* @param array $form
* @param \Drupal\Core\Form\FormStateInterface $form_state
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment