[yast-devel] Webyast - How to show details in flash object
Hi, we sometime need to show details in flash message. Especially in error. Definition of details is that it should be something which can be hide/show. Question is how to do it. I see two ways: 1) special mark which separate message from details. This mark is then replaced by code we want. example: flash[:error] = "You don't have enough permissions to run this module. Contact administrator if you need it. ===DETAILS=== User #{user} doesn't have permission #{permission}." advantage: - easy to use - you can easy switch way how details is generated - unified way of details disadvantage: - not common in rails world and don't know where to document it 2) allow html elements in flash message. And details write to flash message (maybe some helper for it is possible) example: flash[:error] = "You don't have enough permissions to run this module. Contact administrator if you need it. " + details("User #{user} doesn't have permission #{permission}.") advantage: - easy to use (again :) - you can easy switch way how details is generated disadvantage: - allows all elements in flash message - allows different personal "improvements" which could lead to inconsistent flash messages Any other ideas how to solve it? Which solution do you prefer? I personally prefer solution 2) which is cleaner for me. So if there is no complains or better ideas I use it. Josef -- Josef Reidinger YaST team maintainer of perl-Bootloader, YaST2-Repair, parts of webyast -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
On Monday 22 February 2010 11:30:58 Josef Reidinger wrote:
Hi, we sometime need to show details in flash message. Especially in error. Definition of details is that it should be something which can be hide/show. Question is how to do it.
There is already a helper in html_helpers which can be used to show an Exception object, it automatically puts the backtrace in a details link which opens a popup with copy paste. That helper uses flash[], and I guess it can be used with normal messages, or we can refactor it in two functions, one taking a normal message and details and a second which takes an exception, calling the former. The helpers automatically setup unique DOM ids for exceptions, or use a random one if none was provided. -- Duncan Mac-Vicar P. - Novell® Making IT Work As One™ SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nuernberg) -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
On 22.2.2010 11:30, Josef Reidinger wrote:
Hi, we sometime need to show details in flash message. Especially in error. Definition of details is that it should be something which can be hide/show. Question is how to do it. I see two ways: 1) special mark which separate message from details. This mark is then replaced by code we want. example: flash[:error] = "You don't have enough permissions to run this module. Contact administrator if you need it. ===DETAILS=== User #{user} doesn't have permission #{permission}."
IIRC flash doesn't limit the type of the messages, we could use e.g. flash[:error_details] for details. The main page (actually the main layout) would then handle flash *_details values in a different way. -- Best Regards Ladislav Slezák Yast Developer ------------------------------------------------------------------------ SUSE LINUX, s.r.o. e-mail: lslezak@suse.cz Lihovarská 1060/12 tel: +420 284 028 960 190 00 Prague 9 fax: +420 284 028 951 Czech Republic http://www.suse.cz/ -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
Ladislav Slezak write:
On 22.2.2010 11:30, Josef Reidinger wrote:
Hi, we sometime need to show details in flash message. Especially in error. Definition of details is that it should be something which can be hide/show. Question is how to do it. I see two ways: 1) special mark which separate message from details. This mark is then replaced by code we want. example: flash[:error] = "You don't have enough permissions to run this module. Contact administrator if you need it. ===DETAILS=== User #{user} doesn't have permission #{permission}."
IIRC flash doesn't limit the type of the messages, we could use e.g. flash[:error_details] for details.
The main page (actually the main layout) would then handle flash *_details values in a different way.
Yes, but there is problem that we must somehow associate flash message with its details and if you store 2 errors in flash and only 1 details it is hard to say which one has these details.
--
Best Regards
Ladislav Slezák Yast Developer ------------------------------------------------------------------------ SUSE LINUX, s.r.o. e-mail: lslezak@suse.cz Lihovarská 1060/12 tel: +420 284 028 960 190 00 Prague 9 fax: +420 284 028 951 Czech Republic http://www.suse.cz/
-- Josef Reidinger YaST team maintainer of perl-Bootloader, YaST2-Repair, parts of webyast -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
On Monday 22 February 2010 15:15:45 Ladislav Slezak wrote:
On 22.2.2010 11:30, Josef Reidinger wrote:
Hi, we sometime need to show details in flash message. Especially in error. Definition of details is that it should be something which can be hide/show. Question is how to do it. I see two ways: 1) special mark which separate message from details. This mark is then replaced by code we want. example: flash[:error] = "You don't have enough permissions to run this module. Contact administrator if you need it. ===DETAILS=== User #{user} doesn't have permission #{permission}."
IIRC flash doesn't limit the type of the messages, we could use e.g. flash[:error_details] for details.
What if you have multiple errors to report? :-) The helper used for exceptions handles that case -- Duncan Mac-Vicar P. - Novell® Making IT Work As One™ SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nuernberg) -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
participants (3)
-
Duncan Mac-Vicar Prett
-
Josef Reidinger
-
Ladislav Slezak