bleehu / CXDocs

Compound X rules displayed as web pages. Written in Python, served with Flask and bootstraped with bootswatch.
1 stars 1 forks source link

The Asynch delete character button should remove character card from the DOM. #203

Open bleehu opened 5 years ago

bleehu commented 5 years ago

While the delete character button works fine, it appears not to, since I never went back and actually had the asynchronous call to delete character actually remove the display of the character card.

New code should go here https://github.com/bleehu/CXDocs/blob/master/server/static/character_select.js#L24

bleehu commented 5 years ago

@RyuGuardian, this is kind of a UI/UX thing. Are you going to write over all of this anyway?

RyuGuardian commented 5 years ago

@bleehu Huh, I never saw your comment before. Updating the UI for an AJAX request is, in my opinion, a UI/UX thing, but it should be a simple bit to accomplish here (especially if you're just looking to refresh the page, which is what it looks like the code is trying to do). I think it'd only get written over if we change the architecture.

bleehu commented 5 years ago

The idea wasn't to refresh the page, but to remove the DOM element which is the card that displayed the name and data for the character. That card also contains the delete button.

RyuGuardian commented 5 years ago

@bleehu I was just saying that it seems like the line you refer to is supposed to reload the page, but I'm not sure (mostly because it doesn't seem to be working). Reloading the page is the easiest quick-fix to remove a DOM element of deleted data, so that's what I thought you were trying to do. Updating the DOM after an AJAX call requires front-end code, though, so I would consider that UI/UX and it would only be overwritten if we switch to a different architecture, like React or Vue.

RyuGuardian commented 5 years ago

I got curious about this, so I pursued it. Turns out the AJAX was getting an error because the back-end was sending a response with the current page's url (redirecting) instead of a simple success response. I updated the jQuery to remove the DOM object that contains the character card. I noticed the flask.flash function doesn't show its message unless the page refreshes, so I'm going to add an issue for that.

bleehu commented 5 years ago

The flash method is part of flask's framework, not one that we wrote ourselves. Not sure how to get around that. Some research may be in order.

bleehu commented 5 years ago

It looks like the answer is that when we move away from using Jinja and flash to do synchronous and bootstrapped View/Control, I should have changed the feedback away from flashing as well. I changed the control without changing the view. So I should have removed the python flash() call, and created a replacement jquery function that was called on successful return of the AJAX delete call. Mixing the synch/asynch architectures is very messy.