web/formwidgets.py
branchstable
changeset 5383 fbe7416104c6
parent 5377 84d14ddfae13
child 5384 b619531ddbd2
equal deleted inserted replaced
5377:84d14ddfae13 5383:fbe7416104c6
   520         daynames = [_(dname) for dname in cls.daynames]
   520         daynames = [_(dname) for dname in cls.daynames]
   521         req.html_headers.define_var('MONTHNAMES', monthnames)
   521         req.html_headers.define_var('MONTHNAMES', monthnames)
   522         req.html_headers.define_var('DAYNAMES', daynames)
   522         req.html_headers.define_var('DAYNAMES', daynames)
   523 
   523 
   524     def _render(self, form, field, renderer):
   524     def _render(self, form, field, renderer):
   525         txtwidget = super(DateTimePicker, self).render(form, field, renderer)
   525         txtwidget = super(DateTimePicker, self)._render(form, field, renderer)
   526         self.add_localized_infos(form._cw)
   526         self.add_localized_infos(form._cw)
   527         cal_button = self._render_calendar_popup(form, field)
   527         cal_button = self._render_calendar_popup(form, field)
   528         return txtwidget + cal_button
   528         return txtwidget + cal_button
   529 
   529 
   530     def _render_calendar_popup(self, form, field):
   530     def _render_calendar_popup(self, form, field):
   630                 timestr = req.format_time(self.initialtime)
   630                 timestr = req.format_time(self.initialtime)
   631         datepicker = JQueryDatePicker(datestr=datestr, suffix='date')
   631         datepicker = JQueryDatePicker(datestr=datestr, suffix='date')
   632         timepicker = JQueryTimePicker(timestr=timestr, timesteps=self.timesteps,
   632         timepicker = JQueryTimePicker(timestr=timestr, timesteps=self.timesteps,
   633                                       suffix='time')
   633                                       suffix='time')
   634         return u'<div id="%s">%s%s</div>' % (field.dom_id(form),
   634         return u'<div id="%s">%s%s</div>' % (field.dom_id(form),
   635                                             datepicker.render(form, field),
   635                                             datepicker.render(form, field, renderer),
   636                                             timepicker.render(form, field))
   636                                             timepicker.render(form, field, renderer))
   637 
   637 
   638     def process_field_data(self, form, field):
   638     def process_field_data(self, form, field):
   639         req = form._cw
   639         req = form._cw
   640         datestr = req.form.get(field.input_name(form, 'date')).strip() or None
   640         datestr = req.form.get(field.input_name(form, 'date')).strip() or None
   641         timestr = req.form.get(field.input_name(form, 'time')).strip() or None
   641         timestr = req.form.get(field.input_name(form, 'time')).strip() or None
   773         etype_from = entity.e_schema.subjrels[field.name].objects(entity.e_schema)[0]
   773         etype_from = entity.e_schema.subjrels[field.name].objects(entity.e_schema)[0]
   774         attrs['cubicweb:etype_from'] = etype_from
   774         attrs['cubicweb:etype_from'] = etype_from
   775         return attrs
   775         return attrs
   776 
   776 
   777     def _render(self, form, field, renderer):
   777     def _render(self, form, field, renderer):
   778         return super(AddComboBoxWidget, self).render(form, field, renderer) + u'''
   778         return super(AddComboBoxWidget, self)._render(form, field, renderer) + u'''
   779 <div id="newvalue">
   779 <div id="newvalue">
   780   <input type="text" id="newopt" />
   780   <input type="text" id="newopt" />
   781   <a href="javascript:noop()" id="add_newopt">&#160;</a></div>
   781   <a href="javascript:noop()" id="add_newopt">&#160;</a></div>
   782 '''
   782 '''
   783 
   783