Hello community,

here is the log from the commit of package libyui-rest-api for openSUSE:Factory 
checked in at 2020-11-23 15:35:54
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/libyui-rest-api (Old)
 and      /work/SRC/openSUSE:Factory/.libyui-rest-api.new.5913 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "libyui-rest-api"

Mon Nov 23 15:35:54 2020 rev:11 rq:849267 version:0.5.9

Changes:
--------
--- /work/SRC/openSUSE:Factory/libyui-rest-api/libyui-rest-api.changes  
2020-10-26 16:10:51.374635775 +0100
+++ 
/work/SRC/openSUSE:Factory/.libyui-rest-api.new.5913/libyui-rest-api.changes    
    2020-11-23 18:50:25.553364058 +0100
@@ -1,0 +2,6 @@
+Tue Nov 17 09:08:14 UTC 2020 - Rodion Iafarov <riafa...@suse.com>
+
+- Add support for the child items in the table (bsc#1139747)
+- 0.5.9
+
+-------------------------------------------------------------------

Old:
----
  libyui-rest-api-0.5.8.tar.bz2

New:
----
  libyui-rest-api-0.5.9.tar.bz2

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

Other differences:
------------------
++++++ libyui-rest-api.spec ++++++
--- /var/tmp/diff_new_pack.Qt1VHp/_old  2020-11-23 18:50:26.281364795 +0100
+++ /var/tmp/diff_new_pack.Qt1VHp/_new  2020-11-23 18:50:26.285364799 +0100
@@ -21,7 +21,7 @@
 %define libyui_devel_version libyui-devel >= 3.10.1
 
 Name:           libyui-rest-api
-Version:        0.5.8
+Version:        0.5.9
 Release:        0
 Summary:        Libyui - REST API plugin, the shared part
 License:        LGPL-2.1-only OR LGPL-3.0-only

++++++ libyui-rest-api-0.5.8.tar.bz2 -> libyui-rest-api-0.5.9.tar.bz2 ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libyui-rest-api-0.5.8/API_v1.md 
new/libyui-rest-api-0.5.9/API_v1.md
--- old/libyui-rest-api-0.5.8/API_v1.md 2020-10-22 08:09:02.000000000 +0200
+++ new/libyui-rest-api-0.5.9/API_v1.md 2020-11-18 11:47:43.000000000 +0100
@@ -173,7 +173,9 @@
 - **select** - select value in the combobox, row in the table or node in the
   tree, item in button menu requires *value* parameter
   - In case of table: select row in the table with given value. If
-        *column* parameter is not provided, the first column will be used.  
+        *column* parameter is not provided, the first column will be used.
+        If table contains sub-items, child nodes can be selected by sending
+        path, similarly to the Tree widgets: `root_row|sub_item_row`.
   - In case of tree: select node in the tree. Use `|` as a delimiter for
         the child nodes. For example: `root|subnode|subsubnode`.
   - In case of button menu: to select item, use `|` as a delimiter for the
@@ -195,6 +197,8 @@
 curl -X POST 'http://localhost:9999/v1/widgets?id=names&action=select&row=1'
 # select row with "test" cell value in the 2-nd column (counting from zero) in 
table with id "names"
 curl -X POST 
'http://localhost:9999/v1/widgets?id=names&action=select&value=test&column=2'
+# select row with "sub_item_row" cell value, which is child row of "root_row" 
cell value in table with id "names"
+curl -X POST 
'http://localhost:9999/v1/widgets?id=names&action=select&value=root_row|sub_item_row'
 # select tree item with in tree with id "files" and path 'root|subnode|subnode
 curl -X POST 
'http://localhost:9999/v1/widgets?id=files&action=select&value=root%7Csubnode%7Csubnode'
 # press url (<a href=\"firewall\">(enable)</a>) in richtext
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libyui-rest-api-0.5.8/SOURCECONF.cmake 
new/libyui-rest-api-0.5.9/SOURCECONF.cmake
--- old/libyui-rest-api-0.5.8/SOURCECONF.cmake  2020-10-22 08:09:02.000000000 
+0200
+++ new/libyui-rest-api-0.5.9/SOURCECONF.cmake  2020-11-18 11:47:43.000000000 
+0100
@@ -5,6 +5,7 @@
  YHttpRootHandler.cc
  YHttpVersionHandler.cc
  YHttpAppHandler.cc
+ YTableActionHandler.cc
  YHttpWidgetsHandler.cc
  YHttpWidgetsActionHandler.cc
  YHttpMount.cc
@@ -20,6 +21,7 @@
  YHttpRootHandler.h
  YHttpVersionHandler.h
  YHttpAppHandler.h
+ YTableActionHandler.h
  YHttpWidgetsHandler.h
  YHttpWidgetsActionHandler.h
  YHttpMount.h
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libyui-rest-api-0.5.8/VERSION.cmake 
new/libyui-rest-api-0.5.9/VERSION.cmake
--- old/libyui-rest-api-0.5.8/VERSION.cmake     2020-10-22 08:09:02.000000000 
+0200
+++ new/libyui-rest-api-0.5.9/VERSION.cmake     2020-11-18 11:47:43.000000000 
+0100
@@ -1,6 +1,6 @@
 SET( VERSION_MAJOR "0")
 SET( VERSION_MINOR "5" )
-SET( VERSION_PATCH "8" )
+SET( VERSION_PATCH "9" )
 SET( VERSION 
"${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}${GIT_SHA1_VERSION}" )
 
 ##### This is need for the libyui core, ONLY.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/libyui-rest-api-0.5.8/package/libyui-rest-api.changes 
new/libyui-rest-api-0.5.9/package/libyui-rest-api.changes
--- old/libyui-rest-api-0.5.8/package/libyui-rest-api.changes   2020-10-22 
08:09:02.000000000 +0200
+++ new/libyui-rest-api-0.5.9/package/libyui-rest-api.changes   2020-11-18 
11:47:43.000000000 +0100
@@ -1,4 +1,10 @@
 -------------------------------------------------------------------
+Tue Nov 17 09:08:14 UTC 2020 - Rodion Iafarov <riafa...@suse.com>
+
+- Add support for the child items in the table (bsc#1139747)
+- 0.5.9
+
+-------------------------------------------------------------------
 Wed Oct 21 14:50:03 UTC 2020 - Rodion Iafarov <riafa...@suse.com>
 
 - Do not set json value to nullptr when YCheckBoxState is
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libyui-rest-api-0.5.8/package/libyui-rest-api.spec 
new/libyui-rest-api-0.5.9/package/libyui-rest-api.spec
--- old/libyui-rest-api-0.5.8/package/libyui-rest-api.spec      2020-10-22 
08:09:02.000000000 +0200
+++ new/libyui-rest-api-0.5.9/package/libyui-rest-api.spec      2020-11-18 
11:47:43.000000000 +0100
@@ -21,7 +21,7 @@
 %define libyui_devel_version libyui-devel >= 3.10.1
 
 Name:           libyui-rest-api
-Version:        0.5.8
+Version:        0.5.9
 Release:        0
 Summary:        Libyui - REST API plugin, the shared part
 License:        LGPL-2.1-only OR LGPL-3.0-only
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/libyui-rest-api-0.5.8/src/YHttpWidgetsActionHandler.cc 
new/libyui-rest-api-0.5.9/src/YHttpWidgetsActionHandler.cc
--- old/libyui-rest-api-0.5.8/src/YHttpWidgetsActionHandler.cc  2020-10-22 
08:09:02.000000000 +0200
+++ new/libyui-rest-api-0.5.9/src/YHttpWidgetsActionHandler.cc  2020-11-18 
11:47:43.000000000 +0100
@@ -26,8 +26,7 @@
 #include "YPushButton.h"
 #include "YRadioButton.h"
 #include "YRichText.h"
-#include "YTable.h"
-#include "YTableItem.h"
+#include "YTableActionHandler.h"
 #include "YTree.h"
 #include "YTreeItem.h"
 #include "YWidgetID.h"
@@ -349,49 +348,17 @@
                 }
             } );
         }
-        else if( dynamic_cast<YTable*>(widget) )
+        else if( auto tbl = dynamic_cast<YTable*>(widget) )
         {
-            int row_id = 0;
+            int row_id = -1;
             if ( const char* val = MHD_lookup_connection_value(connection, 
MHD_GET_ARGUMENT_KIND, "row") )
-            {
                 row_id = atoi(val);
-                // Handle case when want select row by row number
-                return action_handler<YTable>( widget, body, [&] (YTable *tb) {
 
-                    if( row_id >= tb->itemsCount() || row_id < 0 ) {
-                        throw YUIException( "Table: '" + tb->label() + "' does 
NOT contain row #" + std::to_string( row_id ) );
-                    }
-
-                    if ( YItem * item = tb->itemAt(row_id) )
-                    {
-                            yuiMilestone() << "Activating Table \"" << 
tb->label() << '"' << std::endl;
-                            tb->setKeyboardFocus();
-                            tb->selectItem( item );
-                    }
-                    else
-                    {
-                        throw YUIException( "Row: '" + std::to_string( row_id 
) + "' cannot be found in the table" );
-                    }
-                } );
-            }
-            // Do the search of the value in the given column
             int column_id = 0;
             if ( const char* val = MHD_lookup_connection_value(connection, 
MHD_GET_ARGUMENT_KIND, "column") )
                 column_id = atoi(val);
 
-            return action_handler<YTable>( widget, body, [&] (YTable *tb) {
-                auto * item = dynamic_cast<YTableItem*>( tb->findItem( value, 
column_id ) );
-                if ( item )
-                {
-                        yuiMilestone() << "Activating Table \"" << tb->label() 
<< "\" Item: \"" << item->label( column_id ) << "\"" << std::endl;
-                        tb->setKeyboardFocus();
-                        tb->selectItem( item );
-                }
-                else
-                {
-                    throw YUIException( "Item: '" + value + "' cannot be found 
in the table" );
-                }
-            } );
+            return action_handler<YTable>( widget, body, 
YTableActionHandler::get_handler(tbl, value, column_id, row_id) );
         }
         else if( dynamic_cast<YTree*>(widget) )
         {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libyui-rest-api-0.5.8/src/YTableActionHandler.cc 
new/libyui-rest-api-0.5.9/src/YTableActionHandler.cc
--- old/libyui-rest-api-0.5.8/src/YTableActionHandler.cc        1970-01-01 
01:00:00.000000000 +0100
+++ new/libyui-rest-api-0.5.9/src/YTableActionHandler.cc        2020-11-18 
11:47:43.000000000 +0100
@@ -0,0 +1,108 @@
+/*
+  Copyright (C) 2020 SUSE LLC
+
+  This library is free software; you can redistribute it and/or modify
+  it under the terms of the GNU Lesser General Public License as
+  published by the Free Software Foundation; either version 2.1 of the
+  License, or (at your option) version 3.0 of the License. This library
+  is distributed in the hope that it will be useful, but WITHOUT ANY
+  WARRANTY; without even the implied warranty of MERCHANTABILITY or
+  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+  License for more details. You should have received a copy of the GNU
+  Lesser General Public License along with this library; if not, write
+  to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
+  Floor, Boston, MA 02110-1301 USA
+*/
+
+#include "YTable.h"
+#include "YTableItem.h"
+
+#include <boost/algorithm/string.hpp>
+#include <vector>
+
+#include "YTableActionHandler.h"
+
+#define YUILogComponent "rest-api"
+#include "YUILog.h"
+
+std::function<void (YTable*)> YTableActionHandler::get_handler( YTable * 
widget,
+                                                                const 
std::string &value,
+                                                                const int 
&column_id,
+                                                                const int 
&row_id )
+{
+    // Select a row in the table by the row number
+    if ( row_id != -1 )
+    {
+        return [&] (YTable *tb) {
+            if( row_id >= tb->itemsCount() || row_id < 0 )
+                throw YUIException( "Table: '" + tb->label() + "' does NOT 
contain row #" + std::to_string( row_id ) );
+
+            if ( YItem * item = tb->itemAt(row_id) )
+            {
+                    yuiMilestone() << "Activating Table \"" << tb->label() << 
'"' << std::endl;
+                    tb->setKeyboardFocus();
+                    tb->selectItem( item );
+            }
+            else
+            {
+                throw YUIException( "Row: '" + std::to_string( row_id ) + "' 
cannot be found in the table" );
+            }
+        };
+    }
+
+    // Do the search of the value in the given column
+    return [&] (YTable *tb) {
+        std::vector<std::string> path;
+        boost::split( path, value, boost::is_any_of( TablePathDelimiter ) );
+        auto * item = YTableActionHandler::table_findItem( path.begin(),
+                                                           path.end(),
+                                                           tb->itemsBegin(),
+                                                           tb->itemsEnd(),
+                                                           column_id );
+        if ( item )
+        {
+                yuiMilestone() << "Activating Table \"" << tb->label() << "\" 
Item: \"" << item->label( column_id ) << "\"" << std::endl;
+                tb->setKeyboardFocus();
+                tb->selectItem( item );
+        }
+        else
+        {
+            throw YUIException( "Item: '" + value + "' cannot be found in the 
table" );
+        }
+    };
+}
+
+
+YTableItem *
+YTableActionHandler::table_findItem( std::vector<std::string>::const_iterator 
path_begin,
+                                     std::vector<std::string>::const_iterator 
path_end,
+                                     YItemConstIterator                       
begin,
+                                     YItemConstIterator                       
end,
+                                     const int                               
&column_id )
+{
+    for ( YItemConstIterator it = begin; it != end; ++it )
+    {
+        YTableItem * item = dynamic_cast<YTableItem *>( *it );
+
+        if ( ! item )
+            return nullptr;
+
+        if ( item->label(column_id) == *path_begin )
+        {
+            if ( std::next( path_begin ) == path_end )
+                return item;
+
+            // Recursively search child items
+            YTableItem * result = YTableActionHandler::table_findItem( 
++path_begin,
+                                                                       
path_end,
+                                                                       
item->childrenBegin(),
+                                                                       
item->childrenEnd(),
+                                                                       
column_id );
+
+            if ( result )
+                return result;
+        }
+    }
+
+    return nullptr;
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libyui-rest-api-0.5.8/src/YTableActionHandler.h 
new/libyui-rest-api-0.5.9/src/YTableActionHandler.h
--- old/libyui-rest-api-0.5.8/src/YTableActionHandler.h 1970-01-01 
01:00:00.000000000 +0100
+++ new/libyui-rest-api-0.5.9/src/YTableActionHandler.h 2020-11-18 
11:47:43.000000000 +0100
@@ -0,0 +1,47 @@
+/*
+  Copyright (C) 2020 SUSE LLC
+
+  This library is free software; you can redistribute it and/or modify
+  it under the terms of the GNU Lesser General Public License as
+  published by the Free Software Foundation; either version 2.1 of the
+  License, or (at your option) version 3.0 of the License. This library
+  is distributed in the hope that it will be useful, but WITHOUT ANY
+  WARRANTY; without even the implied warranty of MERCHANTABILITY or
+  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+  License for more details. You should have received a copy of the GNU
+  Lesser General Public License along with this library; if not, write
+  to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
+  Floor, Boston, MA 02110-1301 USA
+*/
+
+#ifndef YTableActionHandler_h
+#define YTableActionHandler_h
+
+#include <functional>
+
+#include "YTable.h"
+#include "YTableItem.h"
+
+#define TablePathDelimiter "|"
+
+class YTableActionHandler
+{
+public:
+
+    YTableActionHandler() {}
+    virtual ~YTableActionHandler() {}
+
+    static std::function<void (YTable*)> get_handler( YTable * widget,
+                                                      const std::string &value,
+                                                      const int &column_id = 
0, //Use first column by default
+                                                      const int &row_id = -1 );
+
+protected:
+    static YTableItem * table_findItem( 
std::vector<std::string>::const_iterator path_begin,
+                                        
std::vector<std::string>::const_iterator path_end,
+                                        YItemConstIterator                     
  begin,
+                                        YItemConstIterator                     
  end,
+                                        const int                              
 &column_id );
+};
+
+#endif // YTableActionHandler_h
_______________________________________________
openSUSE Commits mailing list -- commit@lists.opensuse.org
To unsubscribe, email commit-le...@lists.opensuse.org
List Netiquette: https://en.opensuse.org/openSUSE:Mailing_list_netiquette
List Archives: 
https://lists.opensuse.org/archives/list/commit@lists.opensuse.org

Reply via email to