def update_tab_actions(self, actions): # XXX: This method is used from tabbed.py, which does not call this # view. This means, that the class variable extjs_enable is still False # although extjs is enabled. config_view = self.context.restrictedTraverse('@@tabbedview_config') extjs_enabled = config_view.extjs_enabled(self) if extjs_enabled: actions.append({ 'label': _(u'Reset table configuration'), 'href': 'javascript:reset_grid_state()', 'description': _(u'Resets the table configuration for this tab.') }) return actions
def get_tab_menu_actions(self, view): """Returns a list of actions for the tab ``view``. """ actions = [ {'label': _(u'Set tab as default'), 'href': 'javascript:tabbedview.set_tab_as_default()', 'description': _( u'Make the current tab the default tab when opening this ' u'view. This is a personal setting and does not impact ' u'other users.') }] if getattr(view, 'update_tab_actions', None) is not None: actions = view.update_tab_actions(actions) return actions
def set_default_tab(self, tab=None, view=None): """Sets the default tab. The id of the tab is passed as argument or in the request payload as ``tab``. """ user = AccessControl.getSecurityManager().getUser() if user == AccessControl.SpecialUsers.nobody: tab = None else: tab = tab or self.request.get('tab') if not tab: return json.dumps([ 'error', translate('Error', 'plone', context=self.request), translate(_(u'error_set_default_tab', u'Could not set default tab.'), context=self.request) ]) tab_title = translate(tab, 'ftw.tabbedview', context=self.request) success = [ 'info', translate('Information', 'plone', context=self.request), translate(_(u'info_set_default_tab', u'The tab ${title} is now your default tab. ' + u'This is a personal setting.', mapping={'title': tab_title}), context=self.request) ] if not view and self.request.get('viewname', False): view = self.context.restrictedTraverse( self.request.get('viewname')) else: view = self key_generator = getMultiAdapter((self.context, view, self.request), IDefaultTabStorageKeyGenerator) key = key_generator.get_key() storage = IDictStorage(self) storage.set(key, tab.lower()) return json.dumps(success)
def set_default_tab(self, tab=None, view=None): """Sets the default tab. The id of the tab is passed as argument or in the request payload as ``tab``. """ user = AccessControl.getSecurityManager().getUser() if user == AccessControl.SpecialUsers.nobody: tab = None else: tab = tab or self.request.get('tab') if not tab: return json.dumps([ 'error', translate('Error', 'plone', context=self.request), translate(_(u'error_set_default_tab', u'Could not set default tab.'), context=self.request)]) tab_title = translate(tab, 'ftw.tabbedview', context=self.request) success = [ 'info', translate('Information', 'plone', context=self.request), translate(_(u'info_set_default_tab', u'The tab ${title} is now your default tab. ' + u'This is a personal setting.', mapping={'title': tab_title}), context=self.request)] if not view and self.request.get('viewname', False): view = self.context.restrictedTraverse( self.request.get('viewname')) else: view = self key_generator = getMultiAdapter((self.context, view, self.request), IDefaultTabStorageKeyGenerator) key = key_generator.get_key() storage = IDictStorage(self) storage.set(key, tab.lower()) return json.dumps(success)
def get_tab_menu_actions(self, view): """Returns a list of actions for the tab ``view``. """ actions = [{ 'label': _(u'Set tab as default'), 'href': 'javascript:tabbedview.set_tab_as_default()', 'description': _(u'Make the current tab the default tab when opening this ' u'view. This is a personal setting and does not impact ' u'other users.') }] if getattr(view, 'update_tab_actions', None) is not None: actions = view.update_tab_actions(actions) return actions
def msg_unknownresponse(self): """Return the message that is rendered when a javascript request gets a response from a different source than a tabbed view. This happens when a redirect occurs, for example a redirect to a login form due to a session timeout. """ return _('There was an error loading the tab. Try ' '${anchor_open}reloading${anchor_close} the page.', mapping={'anchor_open': '<a href="#" onclick="window.location.reload();">', 'anchor_close': '</a>'})
def msg_unknownresponse(self): """Return the message that is rendered when a javascript request gets a response from a different source than a tabbed view. This happens when a redirect occurs, for example a redirect to a login form due to a session timeout. """ return _( 'There was an error loading the tab. Try ' '${anchor_open}reloading${anchor_close} the page.', mapping={ 'anchor_open': '<a href="#" onclick="window.location.reload();">', 'anchor_close': '</a>' })