-
Notifications
You must be signed in to change notification settings - Fork 147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Publish subscribe ajax #183
Publish subscribe ajax #183
Conversation
…sh/subscribe pattern for AJAX updates
This reverts commit 53f24cd.
Hi, sorry for taking so long to review. I think it's a good step towards clearer separation - only those Nice idea to use javascript triggers. |
Ah, that's clearer, thanks! I'm doubting which would be better: duplicating the comments in the source vs. a separate document (in doc/ ?) explaining the whole process, referenced from the source with a pointer to where in the process it is, and mentioning exceptions. p.s. nice book! |
Nice idea. I just considered explaining the stuff once in the source code and then referencing. But my idea I rejected due to bad maintainability (if the single view with the comment was modified/renamed/..., all references to that place might have needed an update) |
Something similar would be useful for balancing too. Using it in the beginnings of a new receive screen (and I'd like to be able to create a new order article on the spot - very much like deliveries). |
My aim for next week is to implement all suggestions so far here. Sorry I had a busy time and could not follow all discussions in other issues etc. If you think there is anything more urgent, please let me know. |
Closed in favor of #219. |
StockArticle#show
viewThe problem: wrong controller
StockArticle
manipulation inDelivery
formThe changes in #141 made it easier to create a delivery because the user can create and update
StockArticles
in the delivery form. However, a probably bad practice was used: All theStockArticle
manipulation was done in theDeliveries
controller. Here I would like to suggest a new pattern in order toStockArticle
manipulation to the correct controllerDeliveries
,StockArticles
, ...).More use cases
I am planning to provide similar features for
StockArticles
in theStockTaking
form, so there is the need of at least one more application of this pattern in the future.How it could work (my suggestion)
Let us assume the current view is
views/deliveries/new.html.haml
and we would like to create a newStockArticle
.StockArticle#new
views/stockit/new.js.erb
StockArticle#create
views/stockit/create.js.erb
and do$('body').trigger('StockArticle#create', ...)
passing the newStockArticle
's id.trigger(...)
causes another AJAX request (GET) toDelivery#on_stock_article_create
views/deliveries/on_stock_article_create.js.erb
Disadvantages of this approach
..._on_stock_article_create
,..._on_stock_article_update
etc.)Question to you
Would you be fine if I followed this approach to the end? Do you have some experience in that and/or a better idea?