Announcement

Collapse
No announcement yet.

Multiple settings tabs always return to first tab after save

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Multiple settings tabs always return to first tab after save

    With multiple settings pages (tabs) the page always returns to the first tab after a save.
    To me it looks much cleaner if you stay on the tab you just saved.

    Setting SelectedPageIndex doesn't seem to do much, but maybe i am missing something.

    Any hints?

    #2
    If you look in HomeSeer's html folder, you can see how their setup.html page works. They appear to use a requested_tab and set the property to 'active' if the tab.id==requested_tab.

    In your plugin, you would need to do something similar. Just use a global variable for the last tab that was displayed and set the property accordingly.
    HS4Pro Running on a Raspberry Pi4
    67 Z-Wave Nodes, 111 Events, 422 Devices
    Z-Wave, UPB, WiFi
    Plugins: EasyTrigger, weatherXML, OMNI, Z-Wave, Tuya, Device History
    HSTouch Clients: 3 Android, 1 Joggler

    Comment


      #3
      When I add a page to settings - I specify the display order, then when returning list of pages in OnSettingsLoad() I sort pages by order.

      This way I can control the display order and keep on the current page by setting the order to minimum.

      But I guess it's difficult to know "the tab you just saved", because from the callback point of view all tabs are just a set of views.

      I work out the current tab by the view which was modified.

      Click image for larger version

Name:	2022-04-05 (4).png
Views:	108
Size:	39.7 KB
ID:	1535304

      Click image for larger version

Name:	2022-04-05 (3).png
Views:	121
Size:	64.7 KB
ID:	1535303

      Comment


        #4
        Originally posted by alexbk66 View Post
        But I guess it's difficult to know "the tab you just saved", because from the callback point of view all tabs are just a set of views.
        I work out the current tab by the view which was modified.
        Using
        Code:
        Settings.IndexOf(pageId)
        in OnSettingChange to find "the tab you just saved" seems to work fine.

        Comment


          #5
          Originally posted by Blob View Post

          Using
          Code:
          Settings.IndexOf(pageId)
          in OnSettingChange to find "the tab you just saved" seems to work fine.
          But you need to pass pageId? What's that?

          Comment


            #6
            Originally posted by alexbk66 View Post

            But you need to pass pageId? What's that?
            Try this:
            Code:
             protected override bool OnSettingChange(string pageId, AbstractView currentView, AbstractView changedView) {
                Console.WriteLine($"Page:{pageId} (PageIndex:{Settings.IndexOf(pageId)}) has changed value of id:{changedView.Id} to {changedView.GetStringValue()}");
             }

            Comment


              #7
              Originally posted by rmasonjr View Post
              If you look in HomeSeer's html folder, you can see how their setup.html page works. They appear to use a requested_tab and set the property to 'active' if the tab.id==requested_tab.

              In your plugin, you would need to do something similar. Just use a global variable for the last tab that was displayed and set the property accordingly.
              Fairly easy on a feature page, but what would be the best way to get extra tags on a settings page?

              Comment


                #8
                I gave up on settings pages long ago...
                HS4Pro Running on a Raspberry Pi4
                67 Z-Wave Nodes, 111 Events, 422 Devices
                Z-Wave, UPB, WiFi
                Plugins: EasyTrigger, weatherXML, OMNI, Z-Wave, Tuya, Device History
                HSTouch Clients: 3 Android, 1 Joggler

                Comment


                  #9
                  Originally posted by rmasonjr View Post
                  I gave up on settings pages long ago...
                  It's not too bad

                  Click image for larger version

Name:	2022-04-06 (1).png
Views:	127
Size:	128.4 KB
ID:	1535338

                  Comment


                    #10
                    That looks great, Alex!

                    I just didnt like that I couldnt make changes to the layout, such as adding columns, or display repeating data. I also couldnt figure out how to load the settings for editing so I gave up and just used Feature Pages which give me much more control over the layout and behavior.

                    Click image for larger version

Name:	screenshot1.png
Views:	103
Size:	182.9 KB
ID:	1535351

                    Ignore the yellow heading - it reminds me I am on my development instance instead of production
                    HS4Pro Running on a Raspberry Pi4
                    67 Z-Wave Nodes, 111 Events, 422 Devices
                    Z-Wave, UPB, WiFi
                    Plugins: EasyTrigger, weatherXML, OMNI, Z-Wave, Tuya, Device History
                    HSTouch Clients: 3 Android, 1 Joggler

                    Comment


                      #11
                      Originally posted by rmasonjr View Post
                      I just didnt like that I couldnt make changes to the layout, such as adding columns, or display repeating data
                      HST added Grid view later, but I can't be bothered now. The only downside of Settings pages - you can't get immediate callback from, say, checkboxes - so you can't dynamically change the UI, you need to click Save first...

                      Comment


                        #12
                        Originally posted by alexbk66 View Post
                        When I add a page to settings - I specify the display order, then when returning list of pages in OnSettingsLoad() I sort pages by order.

                        This way I can control the display order and keep on the current page by setting the order to minimum.

                        But I guess it's difficult to know "the tab you just saved", because from the callback point of view all tabs are just a set of views.

                        I work out the current tab by the view which was modified.
                        Swapping the modified tab to index 0 does work and seems like a viable workaround for now.
                        Still it would be far nicer to be able to select the active tab like (I guess) the SelectedPageIndex property is supposed to do.

                        Comment

                        Working...
                        X