Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@spficklin
Copy link
Member

@spficklin spficklin commented Jun 10, 2024

Tripal 4 Core Dev Task

Issue #1350

Tripal Version: 4.x

Description

In order to implement the ChadoStorage::deleteValues() function we need to differentiate between an "unpublish" and "delete". This PR simply adds that functionality to the UI. It doesn't' fully implement a delete. or the deleteValues() function. I separted this as a separte PR to simplify the number of files that have to be checked in a full PR for this issue.

Testing?

  1. Go to a Tripal entity page. You'll see both an "Unpublish" and "Delete" tab at the to of the page. Click and test each one. For the delete you should see a message that the delete is currently not fully implemented and it works like an "unpublish".
  2. Edit any Tripal entity page. You'll see a new "Unpublish" button (it's red on the default theme) at the bottom of the page. The delete button is the default button in Drupal. They should also both work. They use the same underlying functions, but use a "pop-up" to confirm unpublish/delete (default Drupal behavior).
  3. Go the the Tripal content page listing. In the action bar on the right you'll now see an unpublish option. It uses the same pop-up as the entity edit page.

@spficklin spficklin changed the title Tv4g1 issue1350 chadostorage deletevalues Unpublish UI Jun 10, 2024
@spficklin spficklin added Tripal 4 Group 1 - Tripal Content Types | Terms | Fields Any issue relating to Tripal Content including types, terms, and fields. labels Jun 10, 2024
@dsenalik
Copy link
Contributor

I built a docker on this branch, and if I log in and then try to add any content type I get:

The website encountered an unexpected error. Try again later.

Drupal\Core\Entity\EntityMalformedException: The "tripal_entity" entity cannot have a URI as it does not have an ID in Drupal\Core\Entity\EntityBase->toUrl() (line 161 of core/lib/Drupal/Core/Entity/EntityBase.php).

*/
protected function actions(array $form, FormStateInterface $form_state) {
$actions = parent::actions($form, $form_state);
$route_info = $this->entity->toUrl('unpublish-form');
Copy link
Contributor

@dsenalik dsenalik Jun 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line (68) is what is generating the error - apparently at this point $this->entity->id() is NULL.

So if I wrap the remainder of this function in

if ($this->entity->id()) {
  $route_info = ...
...
}

then I can add content. But I don't understand enough to know if this is something that would be correct to add

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @dsenalik for hitting on this problem! When I overwrote the actions() function I failed to include a check if the entity was new (similar to the parent function that adds the "edit" and "delete" actions). I've updated the code and tested a brand new installation and it's working now. Please feel free to try again.

@laceysanderson laceysanderson self-requested a review June 13, 2024 23:32
Copy link
Contributor

@dsenalik dsenalik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing with the latest changes works as expected.
I have a request, though. Save is right next to unpublish and delete.
2024-06-14_deletebutton
In Tripal 3 we had the "dangerous" buttons on the far right side.
2024-06-14_tripal3delete

I request similar placement. And do we want similarly "Update" and "Cancel" when editing?

Tripal 3 button placement was discussed in PR #1061

@spficklin
Copy link
Member Author

spficklin commented Jun 15, 2024

Thanks @dsenalik for the review. Regarding the button floating on the right like it did in Tripal 3. Something like this is required in the form element:

  '#attributes' => ['style' => 'float: right'],

I specifially decided not to do that because it requires a hard coding of a style that floats the button on the right. In Tripal 3 we did some forcing of style which didn't always play nice with different themes. It should be easy enough to do, I was trying to avoid forcing any style.

@dsenalik
Copy link
Contributor

dsenalik commented Jun 16, 2024

As an idea, what if we just add a "Cancel" button, and have it between the "Save" and "Unpublish" buttons, It can act as a less-harmful buffer, and then you don't have to mess with placement and messing with themes. But just an idea.
* But would that show up in the dropdown menu too? That would be confusing...

@spficklin
Copy link
Member Author

spficklin commented Jun 17, 2024

@dsenalik I think a Cancel button is reasonable. I added one.

image

The 'Cancel' won't show up in the dropdown actions, it's only on the form.

Copy link
Contributor

@dsenalik dsenalik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!
Verified that the cancel button works as expected.

@laceysanderson
Copy link
Member

It agree that it would be best floated to the right but also that there is definitely a balance with the overriding theme 🙈

With both in mind, I like this solution (the cancel button to provide some buffer) :-)

@spficklin spficklin merged commit 75ab06d into 4.x Jun 17, 2024
@spficklin spficklin deleted the tv4g1-issue1350-chadostorage-deletevalues branch June 17, 2024 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Group 1 - Tripal Content Types | Terms | Fields Any issue relating to Tripal Content including types, terms, and fields.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants