Welcome Guest, Not a member yet? Register   Sign In
article deleted > back to admin home > I want to display a box saying "you just deleted $article - UNDO ?"
#1

[eluser]Dagobert Renouf[/eluser]
what's the best way to do this ?
#2

[eluser]Sarfaraz Momin[/eluser]
Well I did something similar in one of my apps. The way I followed was pretty simple and straightforward.
I set a session variable for delete action along with some info which I want to display. Like the type of content deleted and also what is deleted so I can allow the user to know what he had done.
Now of the deletion I had an extra field in the db table named marked which is boolean and marked 'Y' when the specific content is deleted. Now in case the user clicks undo the ajax gets the content undeleted which is that it just changes the value of the field marked to 'N' so you undelete the content. I also had an option there which said confirm delete which cannot be undo. So if the user confirms deletion the content is deleted. If he changes the page a popup prompts to say he would not be able to undo his previous actions anymore if he changes the page without any action.

I think this makes sense.

Lemme know if you need my help !!!

Good Day !!!
#3

[eluser]Crimp[/eluser]
Why not add a standard confirm before deletion instead of offering an undo after deletion? If it's not implemented in a longer history, the difference is arguably subtle.
#4

[eluser]Bramme[/eluser]
Flashdata with the message and the previous article, making it possible to put it back in the database... That's my first thought.

But I'm with Crimp... A "Are you sure you want to delete this, there's no way of getting it back if you delete it" javascript confirm seems so much easier..

I like Sarfaraz Momin's solution better than mine though. Probably loads faster, and safer!
#5

[eluser]Dagobert Renouf[/eluser]
thank you guys for your thoughts.

Of course a box is so much simpler, but i would advice you to read this to get the real problem. Never use a warning when you mean undo.

As I put ergonomics in the center of all my projects, I couldn't just "prompt a box".

Sarfaraz : your solution is clearly the best, and I thank you for your help. My system is now fairly similar with yours here's how it works if it helps some :

1- when data is processed, a flashdata session [see there ] is created and store the action and article's id. I then redirect to the admin home.
2- the admin home check if flashdata session is there, and print out the action that has just be done.

__________________


Now for the delete action I handle it that way :

there's a status column in my articles table: 0 means unactive and 1 means active.
when I delete, I just change the status from 1 to 0.
So when the delete action is done => the flashdata is send to the admin home with the articles id and action. Then I know what articles I just deactivated and I can just add an undo action that would change their status.

Now for the REAL DELETE action, I manage a recylce bin, that just stores all the articles with status = 0. Then when you delete the one in the trash they are DELETED for real.

I haven't done that already, but I'm thinking about creating a trash table that would store the date it was added to the trash, and like after XX days it would permanently delete the article.




Theme © iAndrew 2016 - Forum software by © MyBB