15 from logilab.common.decorators import cached |
15 from logilab.common.decorators import cached |
16 |
16 |
17 from cubicweb.interfaces import IWorkflowable |
17 from cubicweb.interfaces import IWorkflowable |
18 from cubicweb.common.utils import make_uid |
18 from cubicweb.common.utils import make_uid |
19 from cubicweb.common.uilib import cut |
19 from cubicweb.common.uilib import cut |
20 from cubicweb.common.selectors import (etype_form_selector, kwargs_selector, |
20 from cubicweb.common.selectors import (accept_etype, match_kwargs, |
21 one_line_rset, interface_selector, |
21 one_line_rset, implement_interface, |
22 req_form_params_selector, accept_selector) |
22 match_form_params, accept) |
23 from cubicweb.common.view import EntityView |
23 from cubicweb.common.view import EntityView |
24 from cubicweb.web import INTERNAL_FIELD_VALUE, stdmsgs, eid_param |
24 from cubicweb.web import INTERNAL_FIELD_VALUE, stdmsgs, eid_param |
25 from cubicweb.web.controller import NAV_FORM_PARAMETERS |
25 from cubicweb.web.controller import NAV_FORM_PARAMETERS |
26 from cubicweb.web.widgets import checkbox, InputWidget, ComboBoxWidget |
26 from cubicweb.web.widgets import checkbox, InputWidget, ComboBoxWidget |
27 from cubicweb.web.form import EntityForm, relation_id |
27 from cubicweb.web.form import EntityForm, relation_id |
85 |
85 |
86 class ChangeStateForm(EntityForm): |
86 class ChangeStateForm(EntityForm): |
87 id = 'statuschange' |
87 id = 'statuschange' |
88 title = _('status change') |
88 title = _('status change') |
89 |
89 |
90 __selectors__ = (interface_selector, req_form_params_selector) |
90 __selectors__ = (implement_interface, match_form_params) |
91 accepts_interfaces = (IWorkflowable,) |
91 accepts_interfaces = (IWorkflowable,) |
92 form_params = ('treid',) |
92 form_params = ('treid',) |
93 |
93 |
94 def cell_call(self, row, col, vid='secondary'): |
94 def cell_call(self, row, col, vid='secondary'): |
95 entity = self.entity(row, col) |
95 entity = self.entity(row, col) |
148 return entity.rest_path() |
148 return entity.rest_path() |
149 |
149 |
150 |
150 |
151 class ClickAndEditForm(EntityForm): |
151 class ClickAndEditForm(EntityForm): |
152 id = 'reledit' |
152 id = 'reledit' |
153 __selectors__ = (kwargs_selector, ) |
153 __selectors__ = (match_kwargs, ) |
154 expected_kwargs = ('rtype',) |
154 expected_kwargs = ('rtype',) |
155 |
155 |
156 #FIXME editableField class could be toggleable from userprefs |
156 #FIXME editableField class could be toggleable from userprefs |
157 |
157 |
158 EDITION_BODY = ''' |
158 EDITION_BODY = ''' |
214 named 'default_ATTRNAME' on the entity instance, where ATTRNAME is the |
214 named 'default_ATTRNAME' on the entity instance, where ATTRNAME is the |
215 name of the attribute being edited. You may use this feature to compute |
215 name of the attribute being edited. You may use this feature to compute |
216 dynamic default values such as the 'tomorrow' date or the user's login |
216 dynamic default values such as the 'tomorrow' date or the user's login |
217 being connected |
217 being connected |
218 """ |
218 """ |
219 __selectors__ = (one_line_rset, accept_selector) |
219 __selectors__ = (one_line_rset, accept) |
220 |
220 |
221 id = 'edition' |
221 id = 'edition' |
222 title = _('edition') |
222 title = _('edition') |
223 controller = 'edit' |
223 controller = 'edit' |
224 skip_relations = EntityForm.skip_relations.copy() |
224 skip_relations = EntityForm.skip_relations.copy() |
515 return self.req._('element edited') |
515 return self.req._('element edited') |
516 |
516 |
517 |
517 |
518 |
518 |
519 class CreationForm(EditionForm): |
519 class CreationForm(EditionForm): |
520 __selectors__ = (etype_form_selector, ) |
520 __selectors__ = (accept_etype, ) |
521 id = 'creation' |
521 id = 'creation' |
522 title = _('creation') |
522 title = _('creation') |
523 |
523 |
524 def call(self, **kwargs): |
524 def call(self, **kwargs): |
525 """creation view for an entity""" |
525 """creation view for an entity""" |
628 return ctx |
628 return ctx |
629 |
629 |
630 |
630 |
631 class InlineEntityCreationForm(InlineFormMixIn, CreationForm): |
631 class InlineEntityCreationForm(InlineFormMixIn, CreationForm): |
632 id = 'inline-creation' |
632 id = 'inline-creation' |
633 __selectors__ = (kwargs_selector, etype_form_selector) |
633 __selectors__ = (match_kwargs, accept_etype) |
634 expected_kwargs = ('ptype', 'peid', 'rtype') |
634 expected_kwargs = ('ptype', 'peid', 'rtype') |
635 |
635 |
636 EDITION_BODY = u'''\ |
636 EDITION_BODY = u'''\ |
637 <div id="div-%(parenteid)s-%(rtype)s-%(eid)s" class="inlinedform"> |
637 <div id="div-%(parenteid)s-%(rtype)s-%(eid)s" class="inlinedform"> |
638 <div class="iformBody"> |
638 <div class="iformBody"> |
667 |
667 |
668 |
668 |
669 |
669 |
670 class InlineEntityEditionForm(InlineFormMixIn, EditionForm): |
670 class InlineEntityEditionForm(InlineFormMixIn, EditionForm): |
671 id = 'inline-edition' |
671 id = 'inline-edition' |
672 __selectors__ = (accept_selector, kwargs_selector) |
672 __selectors__ = (accept, match_kwargs) |
673 expected_kwargs = ('ptype', 'peid', 'rtype') |
673 expected_kwargs = ('ptype', 'peid', 'rtype') |
674 |
674 |
675 EDITION_BODY = u'''\ |
675 EDITION_BODY = u'''\ |
676 <div onclick="restoreInlinedEntity('%(parenteid)s', '%(rtype)s', '%(eid)s')" id="div-%(parenteid)s-%(rtype)s-%(eid)s" class="inlinedform"> |
676 <div onclick="restoreInlinedEntity('%(parenteid)s', '%(rtype)s', '%(eid)s')" id="div-%(parenteid)s-%(rtype)s-%(eid)s" class="inlinedform"> |
677 <div id="notice-%(parenteid)s-%(rtype)s-%(eid)s" class="notice">%(notice)s</div> |
677 <div id="notice-%(parenteid)s-%(rtype)s-%(eid)s" class="notice">%(notice)s</div> |
870 return '\n'.join(html) |
870 return '\n'.join(html) |
871 |
871 |
872 |
872 |
873 class UnrelatedDivs(EntityView): |
873 class UnrelatedDivs(EntityView): |
874 id = 'unrelateddivs' |
874 id = 'unrelateddivs' |
875 __selectors__ = (req_form_params_selector,) |
875 __selectors__ = (match_form_params,) |
876 form_params = ('relation',) |
876 form_params = ('relation',) |
877 |
877 |
878 @property |
878 @property |
879 def limit(self): |
879 def limit(self): |
880 if self.req.form.get('__force_display'): |
880 if self.req.form.get('__force_display'): |