Changeset 8ea379b in tailbone


Ignore:
Timestamp:
07/30/2020 04:38:03 PM (3 years ago)
Author:
Lance Edgar <lance@…>
Branches:
master
Children:
6bd049e
Parents:
dfeb14e
Message:

Add more customization hooks for making grid actions in master view

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tailbone/views/master.py

    rdfeb14e r8ea379b  
    11401140                self.get_model_title(), self.get_instance_title(instance)))
    11411141            self.request.session.flash("(NOTE, you are now viewing the clone!)")
    1142             return self.redirect(self.get_action_url('view', cloned))
     1142            return self.redirect_after_clone(cloned)
    11431143        return self.render_to_response('clone', {
    11441144            'instance': instance,
     
    11671167        self.Session.flush()
    11681168        return cloned
     1169
     1170    def redirect_after_clone(self, instance, mobile=False):
     1171        return self.redirect(self.get_action_url('view', instance, mobile=mobile))
    11691172
    11701173    def touch(self):
     
    25232526        """
    25242527        actions = []
     2528        if self.viewable and self.has_perm('view'):
     2529            actions.append(self.make_grid_action_view())
     2530        return actions
     2531
     2532    def make_grid_action_view(self):
    25252533        use_buefy = self.get_use_buefy()
    2526         if self.viewable and self.has_perm('view'):
    2527             url = self.get_view_index_url if self.use_index_links else None
    2528             icon = 'eye' if use_buefy else 'zoomin'
    2529             actions.append(self.make_action('view', icon=icon, url=url))
    2530         return actions
     2534        url = self.get_view_index_url if self.use_index_links else None
     2535        icon = 'eye' if use_buefy else 'zoomin'
     2536        return self.make_action('view', icon=icon, url=url)
    25312537
    25322538    def get_view_index_url(self, row, i):
     
    25392545        """
    25402546        actions = []
    2541         use_buefy = self.get_use_buefy()
    25422547
    25432548        # Edit
    25442549        if self.editable and self.has_perm('edit'):
    2545             icon = 'edit' if use_buefy else 'pencil'
    2546             actions.append(self.make_action('edit', icon=icon, url=self.default_edit_url))
     2550            actions.append(self.make_grid_action_edit())
    25472551
    25482552        # Delete
    25492553        if self.deletable and self.has_perm('delete'):
    2550             kwargs = {}
    2551             if use_buefy and self.delete_confirm == 'simple':
    2552                 kwargs['click_handler'] = 'deleteObject'
    2553             actions.append(self.make_action('delete', icon='trash', url=self.default_delete_url, **kwargs))
     2554            actions.append(self.make_grid_action_delete())
    25542555
    25552556        return actions
     2557
     2558    def make_grid_action_edit(self):
     2559        use_buefy = self.get_use_buefy()
     2560        icon = 'edit' if use_buefy else 'pencil'
     2561        return self.make_action('edit', icon=icon, url=self.default_edit_url)
     2562
     2563    def make_grid_action_clone(self):
     2564        return self.make_action('clone', icon='object-ungroup',
     2565                                url=self.default_clone_url)
     2566
     2567    def make_grid_action_delete(self):
     2568        use_buefy = self.get_use_buefy()
     2569        kwargs = {}
     2570        if use_buefy and self.delete_confirm == 'simple':
     2571            kwargs['click_handler'] = 'deleteObject'
     2572        return self.make_action('delete', icon='trash', url=self.default_delete_url, **kwargs)
    25562573
    25572574    def default_edit_url(self, row, i=None):
     
    25592576            return self.request.route_url('{}.edit'.format(self.get_route_prefix()),
    25602577                                          **self.get_action_route_kwargs(row))
     2578
     2579    def default_clone_url(self, row, i=None):
     2580        return self.request.route_url('{}.clone'.format(self.get_route_prefix()),
     2581                                      **self.get_action_route_kwargs(row))
    25612582
    25622583    def default_delete_url(self, row, i=None):
Note: See TracChangeset for help on using the changeset viewer.