29 'category': dict(type='String', default='moreactions', |
29 'category': dict(type='String', default='moreactions', |
30 vocabulary=('mainactions', 'moreactions', 'addrelated', |
30 vocabulary=('mainactions', 'moreactions', 'addrelated', |
31 'useractions', 'siteactions', 'hidden'), |
31 'useractions', 'siteactions', 'hidden'), |
32 help=_('context where this component should be displayed')), |
32 help=_('context where this component should be displayed')), |
33 } |
33 } |
34 site_wide = True # don't want user to configuration actions eproperties |
34 site_wide = True # don't want user to configurate actions |
35 category = 'moreactions' |
35 category = 'moreactions' |
|
36 # actions in category 'moreactions' can specify a sub-menu in which they should be filed |
|
37 submenu = None |
|
38 |
|
39 def actual_actions(self): |
|
40 yield self |
|
41 |
|
42 def fill_menu(self, box, menu): |
|
43 """add action(s) to the given submenu of the given box""" |
|
44 for action in self.actual_actions(): |
|
45 menu.append(box.box_action(action)) |
36 |
46 |
37 def url(self): |
47 def url(self): |
38 """return the url associated with this action""" |
48 """return the url associated with this action""" |
39 raise NotImplementedError |
49 raise NotImplementedError |
40 |
50 |
41 def html_class(self): |
51 def html_class(self): |
42 if self.req.selected(self.url()): |
52 if self.req.selected(self.url()): |
43 return 'selected' |
53 return 'selected' |
44 if self.category: |
54 if self.category: |
45 return 'box' + self.category.capitalize() |
55 return 'box' + self.category.capitalize() |
|
56 |
|
57 def build_action(self, title, path, **kwargs): |
|
58 return UnregisteredAction(self.req, self.rset, title, path, **kwargs) |
46 |
59 |
47 |
60 |
48 class UnregisteredAction(Action): |
61 class UnregisteredAction(Action): |
49 """non registered action used to build boxes. Unless you set them |
62 """non registered action used to build boxes. Unless you set them |
50 explicitly, .vreg and .schema attributes at least are None. |
63 explicitly, .vreg and .schema attributes at least are None. |
70 action apply and if the logged user has access to it |
83 action apply and if the logged user has access to it |
71 """ |
84 """ |
72 __select__ = (match_search_state('normal') & one_line_rset() |
85 __select__ = (match_search_state('normal') & one_line_rset() |
73 & partial_relation_possible(action='add') |
86 & partial_relation_possible(action='add') |
74 & partial_may_add_relation()) |
87 & partial_may_add_relation()) |
75 category = 'addrelated' |
88 |
|
89 submenu = 'addrelated' |
76 |
90 |
77 def url(self): |
91 def url(self): |
78 current_entity = self.rset.get_entity(self.row or 0, self.col or 0) |
92 current_entity = self.rset.get_entity(self.row or 0, self.col or 0) |
79 linkto = '%s:%s:%s' % (self.rtype, current_entity.eid, target(self)) |
93 linkto = '%s:%s:%s' % (self.rtype, current_entity.eid, target(self)) |
80 return self.build_url(vid='creation', etype=self.etype, |
94 return self.build_url(vid='creation', etype=self.etype, |