43 def fill_menu(self, box, menu): |
43 def fill_menu(self, box, menu): |
44 """add action(s) to the given submenu of the given box""" |
44 """add action(s) to the given submenu of the given box""" |
45 for action in self.actual_actions(): |
45 for action in self.actual_actions(): |
46 menu.append(box.box_action(action)) |
46 menu.append(box.box_action(action)) |
47 |
47 |
|
48 def html_class(self): |
|
49 if self._cw.selected(self.url()): |
|
50 return 'selected' |
|
51 |
|
52 def build_action(self, title, url, **kwargs): |
|
53 return UnregisteredAction(self._cw, title, url, **kwargs) |
|
54 |
48 def url(self): |
55 def url(self): |
49 """return the url associated with this action""" |
56 """return the url associated with this action""" |
50 raise NotImplementedError |
57 raise NotImplementedError |
51 |
58 |
52 def html_class(self): |
|
53 if self._cw.selected(self.url()): |
|
54 return 'selected' |
|
55 if self.category: |
|
56 return 'box' + self.category.capitalize() |
|
57 |
|
58 def build_action(self, title, path, **kwargs): |
|
59 return UnregisteredAction(self._cw, self.cw_rset, title, path, **kwargs) |
|
60 |
|
61 |
59 |
62 class UnregisteredAction(Action): |
60 class UnregisteredAction(Action): |
63 """non registered action used to build boxes. Unless you set them |
61 """non registered action, used to build boxes""" |
64 explicitly, .vreg and .schema attributes at least are None. |
|
65 """ |
|
66 category = None |
62 category = None |
67 id = None |
63 id = None |
68 |
64 |
69 def __init__(self, req, rset, title, path, **kwargs): |
65 def __init__(self, req, title, url, **kwargs): |
70 Action.__init__(self, req, rset=rset) |
66 Action.__init__(self, req) |
71 self.title = req._(title) |
67 self.title = req._(title) |
72 self._path = path |
68 self._url = url |
73 self.__dict__.update(kwargs) |
69 self.__dict__.update(kwargs) |
74 |
70 |
75 def url(self): |
71 def url(self): |
76 return self._path |
72 return self._url |
77 |
73 |
78 |
74 |
79 class LinkToEntityAction(Action): |
75 class LinkToEntityAction(Action): |
80 """base class for actions consisting to create a new object with an initial |
76 """base class for actions consisting to create a new object with an initial |
81 relation set to an entity. |
77 relation set to an entity. |