We should display status messages whenever the user is waiting...
UI - design
Add yellow box with the message into black toolbar at the top or bit bigger message to center of the screen...
These are just ideas feel free to listen to your head / heart...
Messages
LOADING, when:
page navigation
loading tickets
loading projects
loading ticket revisions
waiting for authentication
SAVING, when:
creating ticket
creating project
creating ticket revision
DELETING, when:
deleting ticket
deleting project
Implementation
Note these ideas are just suggestions, feel free to do it your way ! You might come up with better idea then me...
All this logic should be in one place. I would create service $status or something like that. This service has one property message and couple of methods loading, deleting, saving or just generic set...
The main controller publishes this service into the scope, so that we can display the message in the UI - template. This message should be visible only when non-empty. Use ng:show to do so...
The service should use $browser.notifyWhenNoOutstandingRequests to be notified when no outstanding request and clear the message. Note this event the registered callback is always called just once, so you have to register at all over again. You will probably need $defer service as well, as this needs to be aynchronous, otherwise the callback will be called even before actual request...
So when anyone sets the message, the service should handle everything - change the message property, register callback to clear the message when all requests are finished. (should register always just one callback...)
Write unit test for this service first !
When this service is ready - use it in the controller. E.g. when creating ticket createTicket method is called, so inside this method, call $status.saving()...
Again unit test that - try to cover all cases...
The $status methods could take optional argument to display more verbosing messages like "saving ticket", "deleting project", ...
We should display status messages whenever the user is waiting...
UI - design
Add yellow box with the message into black toolbar at the top or bit bigger message to center of the screen... These are just ideas feel free to listen to your head / heart...
Messages
LOADING, when:
SAVING, when:
DELETING, when:
Implementation
Note these ideas are just suggestions, feel free to do it your way ! You might come up with better idea then me...
All this logic should be in one place. I would create service $status or something like that. This service has one property
message
and couple of methodsloading
,deleting
,saving
or just genericset
...The main controller publishes this service into the scope, so that we can display the message in the UI - template. This message should be visible only when non-empty. Use
ng:show
to do so...The service should use
$browser.notifyWhenNoOutstandingRequests
to be notified when no outstanding request and clear the message. Note this event the registered callback is always called just once, so you have to register at all over again. You will probably need$defer
service as well, as this needs to be aynchronous, otherwise the callback will be called even before actual request...So when anyone sets the message, the service should handle everything - change the message property, register callback to clear the message when all requests are finished. (should register always just one callback...)
Write unit test for this service first !
When this service is ready - use it in the controller. E.g. when creating ticket
createTicket
method is called, so inside this method, call$status.saving()
...Again unit test that - try to cover all cases...
The
$status
methods could take optional argument to display more verbosing messages like "saving ticket", "deleting project", ...