Hello community,

here is the log from the commit of package yast2 for openSUSE:Factory checked 
in at 2017-06-20 09:32:33
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/yast2 (Old)
 and      /work/SRC/openSUSE:Factory/.yast2.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "yast2"

Tue Jun 20 09:32:33 2017 rev:403 rq:504224 version:3.2.38

Changes:
--------
--- /work/SRC/openSUSE:Factory/yast2/yast2.changes      2017-06-07 
13:08:54.911376395 +0200
+++ /work/SRC/openSUSE:Factory/.yast2.new/yast2.changes 2017-06-20 
09:32:37.381824443 +0200
@@ -1,0 +2,9 @@
+Tue Jun  6 10:33:22 UTC 2017 - [email protected]
+
+- Fix showing help text when CWM::ReplacePoint contains another
+  CWM::ReplacePoint. Fix including new
+  CWM::AbstractWidget#refresh_help functionality for widgets where
+  help text can change during its lifetime. (boo#1039901)
+- 3.2.38
+
+-------------------------------------------------------------------

Old:
----
  yast2-3.2.37.tar.bz2

New:
----
  yast2-3.2.38.tar.bz2

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ yast2.spec ++++++
--- /var/tmp/diff_new_pack.4xtsEa/_old  2017-06-20 09:32:38.013735295 +0200
+++ /var/tmp/diff_new_pack.4xtsEa/_new  2017-06-20 09:32:38.017734731 +0200
@@ -17,7 +17,7 @@
 
 
 Name:           yast2
-Version:        3.2.37
+Version:        3.2.38
 Release:        0
 Summary:        YaST2 - Main Package
 License:        GPL-2.0

++++++ yast2-3.2.37.tar.bz2 -> yast2-3.2.38.tar.bz2 ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-3.2.37/library/cwm/examples/replace_point_with_nested_replace_point.rb
 
new/yast2-3.2.38/library/cwm/examples/replace_point_with_nested_replace_point.rb
--- 
old/yast2-3.2.37/library/cwm/examples/replace_point_with_nested_replace_point.rb
    1970-01-01 01:00:00.000000000 +0100
+++ 
new/yast2-3.2.38/library/cwm/examples/replace_point_with_nested_replace_point.rb
    2017-06-16 15:53:41.894328511 +0200
@@ -0,0 +1,164 @@
+# Simple example to demonstrate object oriented replace_point widget
+
+require_relative "example_helper"
+
+require "yast"
+
+require "cwm"
+
+Yast.import "UI"
+Yast.import "CWM"
+Yast.import "Wizard"
+Yast.import "Popup"
+
+class SwitchWidget < CWM::PushButton
+  def initialize(replace_point, widgets)
+    @replace_point = replace_point
+    @widgets = widgets
+  end
+
+  def label
+    "Switch"
+  end
+
+  def handle
+    @widgets.rotate!
+    @replace_point.replace(@widgets.first)
+  end
+end
+
+class PopupButtonWidget < CWM::PushButton
+  def label
+    "Popup"
+  end
+
+  def handle
+    Yast::Popup.Message("Click!")
+  end
+
+  def help
+    "shows nice click popup"
+  end
+end
+
+class WrappedPopup < CWM::CustomWidget
+  def contents
+    VBox(
+      PopupButtonWidget.new
+    )
+  end
+end
+
+class StoreWidget < CWM::InputField
+  def label
+    "write here"
+  end
+
+  def validate
+    return true unless value.empty?
+
+    Yast::Popup.Error("Empty value!")
+    false
+  end
+
+  def store
+    Yast::Popup.Message(value)
+  end
+end
+
+class LuckyNumberWidget < CWM::IntField
+  attr_reader :result, :minimum, :maximum
+
+  def initialize
+    @minimum = 0
+    @maximum = 1000
+  end
+
+  def label
+    _("Lucky number")
+  end
+
+  def store
+    @result = value
+  end
+end
+
+class GenerateButton < CWM::PushButton
+  def initialize(lucky_number_widget)
+    @lucky_number_widget = lucky_number_widget
+  end
+
+  def label
+    _("Generate Lucky Number")
+  end
+
+  def handle
+    Yast::Builtins.y2milestone("handle called")
+    @lucky_number_widget.value = rand(1000)
+
+    nil
+  end
+end
+
+class LuckyNumberGenerator < CWM::CustomWidget
+  def contents
+    HBox(
+      button_widget,
+      lucky_number_widget
+    )
+  end
+
+  def result
+    lucky_number_widget.result
+  end
+
+private
+
+  def button_widget
+    @button_widget ||= GenerateButton.new(lucky_number_widget)
+  end
+
+  def lucky_number_widget
+    @lucky_number_widget ||= LuckyNumberWidget.new
+  end
+end
+
+class Page < CWM::CustomWidget
+  def contents
+    VBox(
+      PushButton(Id(:innew_switch), "Inner Switch"),
+      replace_point
+    )
+  end
+
+  def handle
+    widgets.rotate!
+    replace_point.replace(widgets.first)
+  end
+
+  def lucky_number_generator
+    @lng = LuckyNumberGenerator.new
+  end
+
+  def widgets
+    @widgets ||= [
+      CWM::Empty.new("test_empty"),
+      PopupButtonWidget.new
+    ]
+  end
+
+  def replace_point
+    @replace_point ||= CWM::ReplacePoint.new(id: "inner_replace", widget: 
widgets.first)
+  end
+end
+
+widgets = [WrappedPopup.new, StoreWidget.new, Page.new]
+replace_point = CWM::ReplacePoint.new(widget: widgets.first)
+
+content = Yast::Term.new(:VBox,
+  SwitchWidget.new(replace_point, widgets),
+  replace_point)
+
+Yast::Wizard.CreateDialog
+Yast::CWM.show(content)
+Yast::Wizard.CloseDialog
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-3.2.37/library/cwm/src/Makefile.am 
new/yast2-3.2.38/library/cwm/src/Makefile.am
--- old/yast2-3.2.37/library/cwm/src/Makefile.am        2017-06-05 
14:44:42.349952870 +0200
+++ new/yast2-3.2.38/library/cwm/src/Makefile.am        2017-06-16 
15:53:41.898328511 +0200
@@ -18,6 +18,7 @@
   lib/cwm/page.rb \
   lib/cwm/pager.rb \
   lib/cwm/replace_point.rb \
+  lib/cwm/rspec.rb \
   lib/cwm/table.rb \
   lib/cwm/tabs.rb \
   lib/cwm/tree.rb \
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-3.2.37/library/cwm/src/lib/cwm/abstract_widget.rb 
new/yast2-3.2.38/library/cwm/src/lib/cwm/abstract_widget.rb
--- old/yast2-3.2.37/library/cwm/src/lib/cwm/abstract_widget.rb 2017-06-05 
14:44:42.349952870 +0200
+++ new/yast2-3.2.38/library/cwm/src/lib/cwm/abstract_widget.rb 2017-06-16 
15:53:41.898328511 +0200
@@ -1,4 +1,5 @@
 require "abstract_method"
+require "yast"
 
 module CWM
   # A Yast::Term that can be passed as is to Yast::UI methods
@@ -81,6 +82,7 @@
     # used by Yast::CWMClass.
 
     # @!method help
+    #   Called only once by default. Also triggered by {#refresh_help}.
     #   @return [String] translated help text for the widget
 
     # @!method label
@@ -144,7 +146,7 @@
 
       res["_cwm_key"] = widget_id
       if respond_to?(:help)
-        res["help"] = help
+        res["help"] = help_method
       else
         res["no_help"] = ""
       end
@@ -189,6 +191,13 @@
       widget_id == event["ID"]
     end
 
+    # A widget will need to call this if its {#help} text has changed,to make 
the change effective.
+    def refresh_help
+      Yast.import "CWM"
+
+      Yast::CWM.ReplaceWidgetHelp
+    end
+
     # shortcut from Yast namespace to avoid including whole namespace
     # @todo kill converts in CWM module, to avoid this workaround for funrefs
     # @return [Yast::FunRef]
@@ -212,6 +221,10 @@
       fun_ref(method(:handle_wrapper), "symbol (string, map)")
     end
 
+    def help_method
+      fun_ref(method(:help), "string ()")
+    end
+
     # allows both variant of handle. with event map and without.
     # with map it make sense when handle_all_events is true or in custom 
widgets
     # with multiple elements, that generate events, otherwise map is not needed
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-3.2.37/library/cwm/src/lib/cwm/replace_point.rb 
new/yast2-3.2.38/library/cwm/src/lib/cwm/replace_point.rb
--- old/yast2-3.2.37/library/cwm/src/lib/cwm/replace_point.rb   2017-06-05 
14:44:42.353952870 +0200
+++ new/yast2-3.2.38/library/cwm/src/lib/cwm/replace_point.rb   2017-06-16 
15:53:41.898328511 +0200
@@ -44,7 +44,7 @@
       Yast::UI.ReplaceWidget(Id(widget_id), term)
       Yast::CWM.initWidgets(@widgets_hash)
       @widget = widget
-      Yast::CWM.ReplaceWidgetHelp(widget_id, 
Yast::CWM.MergeHelps(@widgets_hash))
+      refresh_help
     end
 
     # Passes to replace point content
@@ -52,6 +52,11 @@
       Yast::CWM.handleWidgets(@widgets_hash, event)
     end
 
+    # Dynamic help, that compute help of current displayed widgets
+    def help
+      Yast::CWM.MergeHelps(@widgets_hash)
+    end
+
     # Passes to replace point content
     def validate
       Yast::CWM.validateWidgets(@widgets_hash, "ID" => widget_id)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-3.2.37/library/cwm/src/lib/cwm/rspec.rb 
new/yast2-3.2.38/library/cwm/src/lib/cwm/rspec.rb
--- old/yast2-3.2.37/library/cwm/src/lib/cwm/rspec.rb   2017-06-05 
14:44:42.353952870 +0200
+++ new/yast2-3.2.38/library/cwm/src/lib/cwm/rspec.rb   2017-06-16 
15:53:41.898328511 +0200
@@ -78,3 +78,25 @@
   include_examples "CWM::AbstractWidget"
   include_examples "CWM::ItemsSelection"
 end
+
+RSpec.shared_examples "CWM::Table" do
+  include_examples "CWM::AbstractWidget"
+
+  describe "#header" do
+    it "produces an array of strings" do
+      expect(subject.header).to be_an Enumerable
+      subject.header.each do |header|
+        expect(header).to be_a String
+      end
+    end
+  end
+
+  describe "#items" do
+    it "produces an array of arrays" do
+      expect(subject.items).to be_an Enumerable
+      subject.items.each do |item|
+        expect(item).to be_a Array
+      end
+    end
+  end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-3.2.37/library/cwm/src/modules/CWM.rb 
new/yast2-3.2.38/library/cwm/src/modules/CWM.rb
--- old/yast2-3.2.37/library/cwm/src/modules/CWM.rb     2017-06-05 
14:44:42.353952870 +0200
+++ new/yast2-3.2.38/library/cwm/src/modules/CWM.rb     2017-06-16 
15:53:41.898328511 +0200
@@ -216,7 +216,6 @@
         "widget"        => "symbol",
         "custom_widget" => "term",
         "handle_events" => "list",
-        "help"          => "string",
         "label"         => "string",
         "opt"           => "list",
         "ui_timeout"    => "integer",
@@ -230,22 +229,22 @@
       type = Ops.get(types, key)
       success = true
       if type.nil?
-        if key == "widget_func"
-          success = Ops.is(value, "term ()")
-        elsif key == "init"
-          success = Ops.is(value, "void (string)")
-        elsif key == "handle"
-          success = Ops.is(value, "symbol (string, map)")
-        elsif key == "store"
-          success = Ops.is(value, "void (string, map)")
-        elsif key == "cleanup"
-          success = Ops.is(value, "void (string)")
-        elsif key == "validate_function"
-          success = Ops.is(value, "boolean (string, map)")
-        elsif key == "items"
-          success = Ops.is(value, "list <list <string>>")
-        elsif key == "_cwm_do_validate"
-          success = Ops.is(value, "boolean (string, map <string, any>)")
+        success = case key
+        when "widget_func" then Ops.is(value, "term ()")
+        when "init" then Ops.is(value, "void (string)")
+        when "handle" then Ops.is(value, "symbol (string, map)")
+        when "store" then Ops.is(value, "void (string, map)")
+        when "cleanup" then Ops.is(value, "void (string)")
+        when "validate_function" then Ops.is(value, "boolean (string, map)")
+        when "items" then Ops.is(value, "list <list <string>>")
+        when "_cwm_do_validate" then Ops.is(value, "boolean (string, map 
<string, any>)")
+        when "help"
+          # help can be static string or dynamic callback, that allows to 
recompute help for
+          # widgets with dynamic contents like replace_point
+          Ops.is(value, "string") || Ops.is(value, "string ()")
+        else
+          # unknown key, always valid
+          true
         end
       else
         success = ValidateBasicType(value, type)
@@ -278,9 +277,6 @@
         elsif Builtins.size(Builtins.filterchars(s, "&")) != 1
           error = "Label has no shortcut or more than 1 shortcuts"
         end
-      elsif key == "help"
-        s = Convert.to_string(value)
-        error = "Empty help" if s.nil?
       elsif key == "widget"
         s = Convert.to_symbol(value)
         error = "No widget specified" if s.nil?
@@ -469,13 +465,6 @@
         else
           ["label", "widget"]
         end
-        if !Builtins.haskey(v, "no_help")
-          to_check = Convert.convert(
-            Builtins.merge(to_check, ["help"]),
-            from: "list",
-            to:   "list <string>"
-          )
-        end
         Builtins.foreach(to_check) do |key|
           if key != "label" ||
               Ops.get(v, "widget") != :radio_buttons &&
@@ -744,10 +733,14 @@
     # @param [Array<::CWM::WidgetHash>] widgets a list of widget description 
maps
     # @return [String] merged helps of the widgets
     def MergeHelps(widgets)
-      widgets = deep_copy(widgets)
-      helps = Builtins.maplist(widgets) { |w| Ops.get_string(w, "help") }
-      helps = Builtins.filter(helps) { |h| !h.nil? }
-      Builtins.mergestring(helps, "\n")
+      return "" unless widgets
+
+      helps = widgets.map do |widget|
+        help = widget["help"]
+        help.respond_to?(:call) ? help.call : help
+      end
+      helps.compact!
+      helps.join("\n")
     end
 
     # Prepare the dialog, replace strings in the term with appropriate
@@ -768,12 +761,20 @@
     end
 
     # Replace help for a particular widget
-    # @param [String] widget string widget ID of widget to replace help
-    # @param [String] help string new help to the widget
-    def ReplaceWidgetHelp(widget, help)
-      @current_dialog_widgets = Builtins.maplist(@current_dialog_widgets) do 
|w|
-        Ops.set(w, "help", help) if Ops.get_string(w, "_cwm_key", "") == widget
-        deep_copy(w)
+    # @param [String] widget string widget ID of widget to replace help,
+    # if nil is passed, then just regenerate help. Useful for refresh dynamic 
help content.
+    # @param [String] help string new help to the widget. If widget is nil, 
then this argument is ignored
+    #
+    # @example change help content for widget w which had static help
+    #   Yast::CWM.ReplaceWidgetHelp("my_widget", "my new free-cool-in help")
+    # @example refresh help for widget with dynamic content
+    #   Yast::CWM.ReplaceWidgetHelp
+    def ReplaceWidgetHelp(widget = nil, help = "")
+      if widget
+        @current_dialog_widgets = Builtins.maplist(@current_dialog_widgets) do 
|w|
+          Ops.set(w, "help", help) if Ops.get_string(w, "_cwm_key", "") == 
widget
+          deep_copy(w)
+        end
       end
       help = MergeHelps(@current_dialog_widgets)
       Wizard.RestoreHelp(help)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-3.2.37/library/cwm/test/abstract_widget_test.rb 
new/yast2-3.2.38/library/cwm/test/abstract_widget_test.rb
--- old/yast2-3.2.37/library/cwm/test/abstract_widget_test.rb   2017-06-05 
14:44:42.357952870 +0200
+++ new/yast2-3.2.38/library/cwm/test/abstract_widget_test.rb   2017-06-16 
15:53:41.902328511 +0200
@@ -69,8 +69,8 @@
       end
     end
 
-    it "returns hash with \"help\" key and #help result as value" do
-      expect(THelp.new.cwm_definition["help"]).to eq "helpful string"
+    it "returns hash with \"help\" key and reference to #help as result" do
+      expect(THelp.new.cwm_definition["help"].call).to eq "helpful string"
     end
 
     class TNoHelp < CWM::AbstractWidget
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-3.2.37/library/cwm/test/table_test.rb 
new/yast2-3.2.38/library/cwm/test/table_test.rb
--- old/yast2-3.2.37/library/cwm/test/table_test.rb     2017-06-05 
14:44:42.357952870 +0200
+++ new/yast2-3.2.38/library/cwm/test/table_test.rb     2017-06-16 
15:53:41.902328511 +0200
@@ -20,5 +20,6 @@
   end
   subject { MyTable.new }
 
+  include_examples "CWM::Table"
   include_examples "CWM::CustomWidget"
 end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-3.2.37/library/cwm/testsuite/tests/t1.out 
new/yast2-3.2.38/library/cwm/testsuite/tests/t1.out
--- old/yast2-3.2.37/library/cwm/testsuite/tests/t1.out 2017-06-05 
14:44:42.357952870 +0200
+++ new/yast2-3.2.38/library/cwm/testsuite/tests/t1.out 2017-06-16 
15:53:41.902328511 +0200
@@ -1,8 +1,6 @@
 Dump   ========================================
 Dump   ==========   Common stuff   ============
 Dump   ========================================
-Log    Error on key help of widget w1: Empty help
-Log    Error on key help of widget w2: Empty help
 Dump   W1: $["_cwm_key":"w1", "custom_widget":nil, "handle":<YCPRef:symbol 
w1_handle (string, map<any,any>)>, "init":<YCPRef:void w1_init (string)>, 
"label":"Check&Box", "opt":[`notify, `immediate], 
"validate_function":<YCPRef:boolean w1_validate (string, map<any,any>)>, 
"validate_type":`function, "widget":`CheckBox (`id ("w1"), `opt (`notify, 
`immediate), "Check&Box")]
 Dump   W2: $["_cwm_key":"w2", "custom_widget":nil, "handle":<YCPRef:symbol 
w2_handle (string, map<any,any>)>, "label":"Text&Entry", "store":<YCPRef:void 
w2_store (string, map<any,any>)>, "validate_function":<YCPRef:boolean 
w2_validate (string, map<any,any>)>, "validate_type":`function, 
"widget":`InputField (`id ("w2"), `opt (`hstretch), "Text&Entry")]
 Dump   ========================================
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-3.2.37/package/yast2.changes 
new/yast2-3.2.38/package/yast2.changes
--- old/yast2-3.2.37/package/yast2.changes      2017-06-05 14:44:42.441952870 
+0200
+++ new/yast2-3.2.38/package/yast2.changes      2017-06-16 15:53:41.986328511 
+0200
@@ -1,4 +1,13 @@
 -------------------------------------------------------------------
+Tue Jun  6 10:33:22 UTC 2017 - [email protected]
+
+- Fix showing help text when CWM::ReplacePoint contains another
+  CWM::ReplacePoint. Fix including new
+  CWM::AbstractWidget#refresh_help functionality for widgets where
+  help text can change during its lifetime. (boo#1039901)
+- 3.2.38
+
+-------------------------------------------------------------------
 Fri Jun  2 15:54:34 UTC 2017 - [email protected]
 
 - Add EventDispatcher#event_handler to allow custom events
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-3.2.37/package/yast2.spec 
new/yast2-3.2.38/package/yast2.spec
--- old/yast2-3.2.37/package/yast2.spec 2017-06-05 14:44:42.441952870 +0200
+++ new/yast2-3.2.38/package/yast2.spec 2017-06-16 15:53:41.986328511 +0200
@@ -17,7 +17,7 @@
 
 
 Name:           yast2
-Version:        3.2.37
+Version:        3.2.38
 Release:        0
 Summary:        YaST2 - Main Package
 License:        GPL-2.0


Reply via email to