Commit 315bc18b authored by catch's avatar catch

Issue #2516930 by coleman.sean.c, alexpott, jhedstrom, mohit_aghera: Remove...

Issue #2516930 by coleman.sean.c, alexpott, jhedstrom, mohit_aghera: Remove from outline button goes to node/x/delete instead
parent 7e4b50e6
......@@ -11,6 +11,7 @@
use Drupal\Core\Entity\ContentEntityForm;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
......@@ -91,7 +92,8 @@ public function form(array $form, FormStateInterface $form_state) {
protected function actions(array $form, FormStateInterface $form_state) {
$actions = parent::actions($form, $form_state);
$actions['submit']['#value'] = $this->entity->book['original_bid'] ? $this->t('Update book outline') : $this->t('Add to book outline');
$actions['delete']['#value'] = $this->t('Remove from book outline');
$actions['delete']['#title'] = $this->t('Remove from book outline');
$actions['delete']['#url'] = new Url('entity.node.book_remove_form', ['node' => $this->entity->book['nid']]);
$actions['delete']['#access'] = $this->bookManager->checkNodeIsRemovable($this->entity);
return $actions;
}
......@@ -126,11 +128,4 @@ public function save(array $form, FormStateInterface $form_state) {
}
}
/**
* {@inheritdoc}
*/
public function delete(array $form, FormStateInterface $form_state) {
$form_state->setRedirectUrl($this->entity->urlInfo('book-remove-form'));
}
}
......@@ -618,6 +618,7 @@ public function testBookOutline() {
$this->drupalGet('node/' . $empty_book->id() . '/outline');
$this->assertRaw(t('Book outline'));
$this->assertOptionSelected('edit-book-bid', 0, 'Node does not belong to a book');
$this->assertNoLink(t('Remove from book outline'));
$edit = array();
$edit['book[bid]'] = '1';
......@@ -637,6 +638,8 @@ public function testBookOutline() {
$this->drupalLogin($this->adminUser);
$this->drupalGet('node/' . $book->id() . '/outline');
$this->assertRaw(t('Book outline'));
$this->clickLink(t('Remove from book outline'));
$this->assertRaw(t('Are you sure you want to remove %title from the book hierarchy?', array('%title' => $book->label())));
// Create a new node and set the book after the node was created.
$node = $this->drupalCreateNode(array('type' => 'book'));
......
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