[yast-devel] Re: [yast-commit] <web-client> master : first version with writing: 0.0.2
Jiri Suchomel napsal(a):
ref: refs/heads/master commit 6bb7f85ae3d25e33e674ab8a64d5bcd8035ba576 Author: Jiri Suchomel <jsuchome@suse.cz> Date: Fri Oct 9 16:12:51 2009 +0200
first version with writing: 0.0.2 --- .../app/controllers/mail_settings_controller.rb | 28 +++++++++++++++++++- .../app/views/mail_settings/index.html.erb | 17 +++++++++++- .../package/yast2-webclient-mailsettings.changes | 6 ++++ .../package/yast2-webclient-mailsettings.spec | 2 +- 4 files changed, 50 insertions(+), 3 deletions(-)
diff --git a/plugins/mail_settings/app/controllers/mail_settings_controller.rb b/plugins/mail_settings/app/controllers/mail_settings_controller.rb index 53d00e4..d434864 100644 --- a/plugins/mail_settings/app/controllers/mail_settings_controller.rb +++ b/plugins/mail_settings/app/controllers/mail_settings_controller.rb @@ -21,7 +21,33 @@ class MailSettingsController < ApplicationController def update @mail_settings = load_proxy 'org.opensuse.yast.modules.yapi.mailsettings' return unless @mail_settings - redirect_to :action => "index" + + mail = params["mail_settings"] + @mail_settings.smtp_server = mail["smtp_server"] + @mail_settings.password = mail["password"] + @mail_settings.user = mail["user"] + @mail_settings.transport_layer_security = mail["transport_layer_security"]
I think it is not neccesary code. Look at this method, it should automatic loads hash to ActiveResource - http://api.rubyonrails.org/classes/ActiveResource/Base.html#M000918 so you could use @mail_settings.load params["mail_settings"] And if we in future improve our code to use common ActiveResource model, then just 'Model.create params' creates new instance, fill it and then store, but it is more complicated to do it with current code
+ + begin + response = @mail_settings.save + rescue ActiveResource::ClientError => e + flash[:error] = YaST::ServiceResource.error(e) + logger.warn e.inspect + rescue ActiveResource::ServerError => e + error = Hash.from_xml e.response.body + logger.warn error.inspect + if error["error"] && error["error"]["type"] == "MAIL_SETTINGS_ERROR" + flash[:error] = _("Error while saving mail settings: #{error["error"]["output"]}") + else + raise e + end + end + + if params.has_key? "commit" + redirect_success # redirect to next step + else + redirect_to :action => "index" + end end
end diff --git a/plugins/mail_settings/app/views/mail_settings/index.html.erb b/plugins/mail_settings/app/views/mail_settings/index.html.erb index 304b655..a38fec0 100644 --- a/plugins/mail_settings/app/views/mail_settings/index.html.erb +++ b/plugins/mail_settings/app/views/mail_settings/index.html.erb @@ -1,5 +1,20 @@ <div class='plugin-icon'><img src='/icons/yast-mail-server.png'/></div>
+<% content_for :head do %> + <%= javascript_include_tag :defaults %> ^^^^ you don't need this. this add support for AJAX, which you don't use.
+ + <style type="text/css"> + label.error { float: none; color: red; padding-left: .5em; vertical-align: top; } + </style> + + <script type="text/javascript"> + $(document).ready(function(){ ^^^ Are you sure that it work? (I am not on work station). I think that it after load of page call validate on mailForm. Do you try change mail to invalid and it work? (if it doesn't work, look at time module, where I also validate time and date) + $("#mailForm").validate() + ); + </script> +<% end %> + + <h2><%=_("Mail Settings")%></h2>
<% disabled = ! @permissions[:write] %> @@ -26,7 +41,7 @@ </tr> <tr class="bg"> <td class="first"><strong><%=_("Confirm Password")%></strong></td> - <td class="last"><%= f.password_field :confirm_password, :disabled => disabled, :equalTo => "#administrator_password" %></td> + <td class="last"><%= f.password_field :confirm_password, :disabled => disabled, :equalTo => "#password" %></td> </tr> <tr> <td><%= form_send_buttons :onclick=>"Element.show('progress')" %></td> diff --git a/plugins/mail_settings/package/yast2-webclient-mailsettings.changes b/plugins/mail_settings/package/yast2-webclient-mailsettings.changes index ffe663e..87eb10c 100644 --- a/plugins/mail_settings/package/yast2-webclient-mailsettings.changes +++ b/plugins/mail_settings/package/yast2-webclient-mailsettings.changes @@ -1,4 +1,10 @@ ------------------------------------------------------------------- +Fri Oct 9 16:11:05 CEST 2009 - jsuchome@suse.cz + +- first version of writing +- 0.0.2 + +------------------------------------------------------------------- Fri Oct 9 13:44:11 CEST 2009 - jsuchome@suse.cz
- initial version diff --git a/plugins/mail_settings/package/yast2-webclient-mailsettings.spec b/plugins/mail_settings/package/yast2-webclient-mailsettings.spec index 30dde35..a688c69 100644 --- a/plugins/mail_settings/package/yast2-webclient-mailsettings.spec +++ b/plugins/mail_settings/package/yast2-webclient-mailsettings.spec @@ -14,7 +14,7 @@ PreReq: yast2-webclient >= 0.0.2 License: GPL Group: Productivity/Networking/Web/Utilities Autoreqprov: on -Version: 0.0.1 +Version: 0.0.2 Release: 0 Summary: YaST2 - Webclient - Mail Settings Source: www.tar.bz2
-- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
On 9.10.2009 23:11, josef reidinger wrote:
Jiri Suchomel napsal(a):
+ <script type="text/javascript"> + $(document).ready(function(){ ^^^ Are you sure that it work? (I am not on work station). I think that it after load of page call validate on mailForm. Do you try change mail to invalid and it work? (if it doesn't work, look at time module, where I also validate time and date)
No, it validates the form after pressing the submit button. -- 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
participants (2)
-
josef reidinger
-
Ladislav Slezak