ref: refs/heads/basesystem
commit 31e4a695279bb7e6a0adf9a6b28b48532b5ee896
Author: Josef Reidinger
Date: Thu Sep 3 08:54:54 2009 +0200
add working wizard next/back buttons
---
.../app/controllers/language_controller.rb | 2 +-
plugins/language/app/views/language/index.rhtml | 2 +-
.../app/controllers/systemtime_controller.rb | 36 +----
.../systemtime/app/views/systemtime/index.rhtml | 154 ++++++++------------
plugins/systemtime/lib/systemtime.rb | 7 -
.../app/controllers/application_controller.rb | 9 +
.../app/controllers/controlpanel_controller.rb | 7 +-
webclient/app/helpers/application_helper.rb | 11 ++
webclient/app/views/layouts/main.rhtml | 5 -
9 files changed, 99 insertions(+), 134 deletions(-)
diff --git a/plugins/language/app/controllers/language_controller.rb b/plugins/language/app/controllers/language_controller.rb
index c61812f..bf21001 100644
--- a/plugins/language/app/controllers/language_controller.rb
+++ b/plugins/language/app/controllers/language_controller.rb
@@ -58,7 +58,7 @@ class LanguageController < ApplicationController
flash[:error] = YaST::ServiceResource.error(e)
end
end
- redirect_to :action => :index
+ redirect_success
end
end
diff --git a/plugins/language/app/views/language/index.rhtml b/plugins/language/app/views/language/index.rhtml
index e4ec067..a2f52ea 100644
--- a/plugins/language/app/views/language/index.rhtml
+++ b/plugins/language/app/views/language/index.rhtml
@@ -29,7 +29,7 @@
</tr>
</table>
<div>
- <%= submit_tag _("Save"), :disabled=>!@permissions[:write] %>
+ <%= form_send_buttons :disabled => !@permissions[:write] %>
</div>
<% end -%>
</div>
diff --git a/plugins/systemtime/app/controllers/systemtime_controller.rb b/plugins/systemtime/app/controllers/systemtime_controller.rb
index a8f9747..470b4a7 100644
--- a/plugins/systemtime/app/controllers/systemtime_controller.rb
+++ b/plugins/systemtime/app/controllers/systemtime_controller.rb
@@ -75,18 +75,23 @@ class SystemtimeController < ApplicationController
end
end
- # Update time handler. Sets to backend new time. If time is set to future it
+ # Update time handler. Sets to backend new timezone and time.
+ # If time is set to future it
# still shows problems. Now it invalidate session for logged user.If
# everything goes fine it redirect to index
- def update_time
+ def update
t = load_proxy 'org.opensuse.yast.modules.yapi.time'
unless t
return false
end
+ fill_proxy_with_timezone t, params, t.timezones
+ #TODO for future change between init types
fill_proxy_with_time t,params
+ t.timezone = [] #save bandwitch
+
begin
t.save
flash[:notice] = _('Settings have been written.')
@@ -102,32 +107,7 @@ class SystemtimeController < ApplicationController
logger.warn e
end
- redirect_to :action => :index
- end
-
- # Update time handler. Sets to backend new timezone. If everything goes fine
- # it redirect to index
- def update_timezone
- t = load_proxy 'org.opensuse.yast.modules.yapi.time'
-
- unless t
- return false
- end
-
- fill_proxy_with_timezone t,params, t.timezones
-
- begin
- t.save
- flash[:notice] = _('Settings have been written.')
- rescue ActiveResource::ClientError => e
- flash[:error] = YaST::ServiceResource.error(e)
- logger.warn e
- rescue Exception => e
- flash[:error] = e.message
- logger.warn e
- end
-
- redirect_to :action => :index
+ redirect_success
end
diff --git a/plugins/systemtime/app/views/systemtime/index.rhtml b/plugins/systemtime/app/views/systemtime/index.rhtml
index 070b7f4..37e1483 100644
--- a/plugins/systemtime/app/views/systemtime/index.rhtml
+++ b/plugins/systemtime/app/views/systemtime/index.rhtml
@@ -12,16 +12,16 @@
<!-- FIXME move javascript function outside of index -->
<% javascript_tag do -%>
function submitTime() {
- if (!$("#date_date")[0].value.match( /^\d{2}\/\d{2}\/\d{4}$/)){
- alert ("<%= _("Invalid date format. Correct one is dd/mm/yyyy") %>");
- return false;
- }
- if (!$("#currenttime")[0].value.match( /^\d{2}:\d{2}:\d{2}$/)) {
- alert ("<%= _("Invalid time format. Correct one is hh:mm:ss") %>");
- return false;
- }
- Element.show('progress');
- return true;
+ if (!$("#date_date")[0].value.match( /^\d{2}\/\d{2}\/\d{4}$/)){
+ alert ("<%= _("Invalid date format. Correct one is dd/mm/yyyy") %>");
+ return false;
+ }
+ if (!$("#currenttime")[0].value.match( /^\d{2}:\d{2}:\d{2}$/)) {
+ alert ("<%= _("Invalid time format. Correct one is hh:mm:ss") %>");
+ return false;
+ }
+ Element.show('progress');
+ return true;
};
<% end -%>
@@ -30,93 +30,67 @@
<div class='plugin-icon'><img src='/icons/yast-ntp-client.png' alt="time module"/></div>
<div class='plugin-content'>
- <h2><%=_("Configure timezone")%></h2>
- <% form_tag '/systemtime/update_timezone', :class => 'container' do %>
- ">
- <tr>
-
- <td>
- <label for="region">
- <%=_("Region:")%>
- </label>
- </td>
- <% #region is always non-nil as it is prerequisites which throws exception
- %>
- <td>
- <%= select_tag "region", options_for_select(@valid, @region.name), :disabled => disabled,
- :class=>'aligned-inputs' %>
- </td>
-
- </tr>
- <tr>
-
-
- <td>
- <label for="timezone">
- <%=_("Timezone:")%>
- </label>
- </td>
-
- <td id="timezones">
+ <h2><%=_("Configure timezone")%></h2>
+ <% form_tag '/systemtime/update', :class => 'container' do %>
+ <% #TODO tooltip for form <div> _("Table for settings timezone for target machine.") </div>
+ %>
+ <div>
+ <label for="region">
+ <%=_("Region:")%>
+ </label>
+ <%= select_tag "region", options_for_select(@valid, @region.name), :disabled => disabled,
+ :class=>'aligned-inputs' %>
+ </div>
+ <div>
+ <label for="timezone">
+ <%=_("Timezone:")%>
+ </label>
+ <span id="timezones">
<%= render(:partial => 'timezones',
:locals => {:region => @region, :default => @timezone,
:disabled => disabled}) %>
- </td>
- </tr>
-
+ </span>
+ </div>
<% if @utcstatus != "UTConly" %>
- <tr>
- <td>
- <label for="utc">
- <%=_("Hardware clock is set to UTC")%>
- </label>
- </td>
- <td>
- <% #don't use check_box helper as it generate also hidden opposite value
- %>
-
- <%= "disabled=\"disabled\"" if disabled %> />
- </td>
- </tr>
-
- <% end %>
- </table>
- <p>
- <%= submit_tag _("Save timezone"), :onclick=>"Element.show('progress')", :disabled=> disabled, :class => 'button' -%>
- </p>
- <% end %>
- <h2><%=_("Manually configure time")%></h2>
- <% form_tag '/systemtime/update_time', :class => 'container' do %>
- ">
- <tr>
- <td>
- <label for="date_date">
- <%= _("Date:") %>
+ <div>
+ <label for="utc">
+ <%=_("Hardware clock is set to UTC")%>
</label>
- </td>
- <td>
- <%= text_field "date","date", :class => 'datepicker aligned-inputs',
- :disabled=> disabled, :value => @date
- %>
- </td>
- </tr>
+ <% #don't use check_box helper as it generate also hidden opposite value
+ %>
+
+ <%= "disabled=\"disabled\"" if disabled %> />
+ </div>
+ <% end %>
- <tr>
- <td>
- <label for="currenttime">
- <%= _("Time:") %>
- </label>
- </td>
- <td><%= text_field_tag "currenttime", @time, :disabled=> disabled, :class=>'aligned-inputs' %></td>
- </tr>
- </table>
- <p>
- <%= submit_tag _("Save time"), :onclick=>"return submitTime()",
- :disabled=> disabled, :class => 'button' -%>
- </p>
- <% end %>
+ <div>
+ <input type="radio" name="timeconfig" value="manual" />
+ <%=_("Manually configure time")%>
+ </div>
+ <% #TODO for tooltip _("Manual time configuration table, where user selects data and time for target machine")
+ %>
+ <div>
+ <label for="date_date">
+ <%= _("Date:") %>
+ </label>
+
+ <%= text_field "date","date", :class => 'datepicker aligned-inputs',
+ :disabled=> disabled, :value => @date
+ %>
+ </div>
+ <div>
+ <label for="currenttime">
+ <%= _("Time:") %>
+ </label>
+
+ <span><%= text_field_tag "currenttime", @time, :disabled=> disabled, :class=>'aligned-inputs' %></span>
+ </div>
+ <div>
+ <%= form_send_buttons ({:disabled => disabled, :onclick => "submitTime();"}) %>
+ </div>
+ <% end %>
</div>
<%= observe_field(:region,
diff --git a/plugins/systemtime/lib/systemtime.rb b/plugins/systemtime/lib/systemtime.rb
index 137a2d9..e8a6bf3 100644
--- a/plugins/systemtime/lib/systemtime.rb
+++ b/plugins/systemtime/lib/systemtime.rb
@@ -4,9 +4,6 @@
def fill_proxy_with_time(proxy,params)
proxy.date = params[:date][:date]
proxy.time = params[:currenttime]
- proxy.timezones = [] #not needed anymore
- proxy.utcstatus = ""
- proxy.timezone = ""
end
#fills proxy with timezone parameters and set rest parameters to empty value
@@ -21,8 +18,4 @@ def fill_proxy_with_timezone(proxy,params,timezones)
if (proxy.utcstatus != "UTConly")
proxy.utcstatus = params[:utc] == "true" ? "UTC" : "localtime"
end
-
- proxy.time = ""
- proxy.date = ""
- proxy.timezones = [] #not needed anymore
end
\ No newline at end of file
diff --git a/webclient/app/controllers/application_controller.rb b/webclient/app/controllers/application_controller.rb
index 3d208e1..902764c 100644
--- a/webclient/app/controllers/application_controller.rb
+++ b/webclient/app/controllers/application_controller.rb
@@ -4,6 +4,15 @@
class ApplicationController < ActionController::Base
layout 'main'
+ def redirect_success
+ if session[:wizard_current] and session[:wizard_current] != "FINISH"
+ logger.debug "wizard redirect DONE"
+ redirect_to :controller => "controlpanel", :action => "nextstep"
+ else
+ redirect_to :action => :index
+ end
+ end
+
rescue_from Exception, :with => :exception_trap
include AuthenticatedSystem
diff --git a/webclient/app/controllers/controlpanel_controller.rb b/webclient/app/controllers/controlpanel_controller.rb
index 09d7494..eb543ba 100644
--- a/webclient/app/controllers/controlpanel_controller.rb
+++ b/webclient/app/controllers/controlpanel_controller.rb
@@ -48,9 +48,12 @@ class ControlpanelController < ApplicationController
def nextstep
+ logger.debug "Wizard next step: current one: #{session[:wizard_current]} - steps #{session[:wizard_steps]}"
steps = session[:wizard_steps].split ","
if (steps.last != session[:wizard_current])
session[:wizard_current] = steps[steps.index(session[:wizard_current])+1]
+ logger.debug "Wizard next step: next one #{session[:wizard_current]}"
+ redirect_to get_redirect_hash(session[:wizard_current])
else
proxy = YaST::ServiceResource.proxy_for 'org.opensuse.yast.modules.basesystem'
basesystem = proxy.find
@@ -60,9 +63,9 @@ class ControlpanelController < ApplicationController
# basesystem.save will set always current to FINAL_STEP
basesystem.save
session[:wizard_current] = FINAL_STEP
+ logger.debug "Wizard next step: DONE"
redirect_to "/controlpanel"
- end
- redirect_to get_redirect_hash(session[:wizard_current])
+ end
end
def backstep
diff --git a/webclient/app/helpers/application_helper.rb b/webclient/app/helpers/application_helper.rb
index 3857eb1..161e433 100644
--- a/webclient/app/helpers/application_helper.rb
+++ b/webclient/app/helpers/application_helper.rb
@@ -1,4 +1,15 @@
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
+ def form_send_buttons (send_options={})
+ if session[:wizard_current].nil? or session[:wizard_current] == "FINISH"
+ submit = submit_tag _("Save"),send_options
+ back = link_to _("Cancel"), :back
+ return submit+back
+ else
+ back = link_to "Back", :controller => "controlpanel", :action => "backstep"
+ nextb = link_to submit_tag _("Next"),send_options
+ return back+nextb
+ end
+ end
end
diff --git a/webclient/app/views/layouts/main.rhtml b/webclient/app/views/layouts/main.rhtml
index 6f029b1..013fbd5 100644
--- a/webclient/app/views/layouts/main.rhtml
+++ b/webclient/app/views/layouts/main.rhtml
@@ -79,11 +79,6 @@
</div>
<div id="footer" class="">
- <%- if session[:wizard_current] and session[:wizard_current] != "FINISH" -%>
- <%= button_to "Back", :controller => "controlpanel", :action => "backstep" %>
- <span> Wizard mode </span>
- <%= button_to "Next", :controller => "controlpanel", :action => "nextstep" %>
- <% end -%>
<div class="copy">© 2009 Novell, Inc.</div>
</div>
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org