Skip to content

Persist tab state without adding to browser history - #582

Merged
openshift-bot merged 1 commit into
openshift:masterfrom
jwforres:persist_page_state
Sep 23, 2016
Merged

openshift-bot merged 1 commit into
openshift:masterfrom
jwforres:persist_page_state

Conversation

@jwforres

Copy link
Copy Markdown
Member

No description provided.

@jwforres

Copy link
Copy Markdown
Member Author

@spadgett WDYT of this change? I can't think of a reason that reloadOnSearch matters on the pages where we have tabs or filters.

@spadgett

Copy link
Copy Markdown
Member

+1 reloadOnSearch: false seems like exactly what we want

@jwforres jwforres changed the title [WIP] Persist tab state without adding to browser history Persist tab state without adding to browser history Sep 23, 2016
@jwforres

Copy link
Copy Markdown
Member Author

@spadgett ok i think I got all the pages that have tabs today

@benjaminapetersen

benjaminapetersen commented Sep 23, 2016 •

Copy link
Copy Markdown
Contributor

@jwforres, i think uib-tab supports select= as a callback, so something like:

select="selectTab('environment')"

and the JS could just be:

$scope.selectTab = function(what) {
      $location.replace().search('tab', what);
};

might be nice, less code, no additional $watch?

Tempted to even put that little fn in our navigate service, and

$scope.selectTab = navigate.selectTab

and get it down to a controller one-liner.

@jwforres

Copy link
Copy Markdown
Member Author

@benjaminapetersen in the version we have its on each tab, it adds it to every tab in the view

@jwforres

Copy link
Copy Markdown
Member Author

I agree its less code for the controller, but it doesn't feel right to me to make each tab in the view responsible for making sure the callback gets fired. In my ideal world the uib-tabset element should have had a callback option for when any of its tabs are selected

@benjaminapetersen

Copy link
Copy Markdown
Contributor

@jwforres, yup, each would get <uib-tab select="onSelect('tab-name')"

@benjaminapetersen

Copy link
Copy Markdown
Contributor

Hmm. I think if our views are declarative & we get all the work into a service its a win, but I'm good if you prefer the current approach!

@jwforres

Copy link
Copy Markdown
Member Author

@spadgett can be the deciding vote

@benjaminapetersen

Copy link
Copy Markdown
Contributor

Cool cool! I'll readily admit I'm an awful controller troll/nag 😄

@jwforres

Copy link
Copy Markdown
Member Author

@benjaminapetersen how do you feel about the latest version

});
};
})
.directive('persistTabState', function($routeParams, $location) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably worth a comment saying reloadOnSearch should be false for the route to use this directive.

@benjaminapetersen

Copy link
Copy Markdown
Contributor

Oooo nice, even less in the controllers! +1
Only thought, perhaps put it on the tabset itself for context:

<uib-tabset class="mar-top-none" persist-tab-state>

Either way though, def looks good to me.

@jwforres

Copy link
Copy Markdown
Member Author

[merge]

@openshift-bot

Copy link
Copy Markdown

Evaluated for origin web console merge up to a7809a4

@openshift-bot

openshift-bot commented Sep 23, 2016 •

Copy link
Copy Markdown

@openshift-bot
openshift-bot merged commit 1e5ca1a into openshift:master Sep 23, 2016
@spadgett spadgett mentioned this pull request Oct 20, 2016
13 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants