class CustomFieldAdminDetail(ffw.StateField): template = 'jinja:forgetracker:templates/tracker_widgets/custom_field_admin_detail.html' defaults = dict( ffw.StateField.defaults, selector=ffw.AdminField(field=ew.SingleSelectField( name='type', options=[ ew.Option(py_value='string', label='Text'), ew.Option(py_value='number', label='Number'), ew.Option(py_value='boolean', label='Boolean'), ew.Option(py_value='select', label='Select'), ew.Option(py_value='milestone', label='Milestone'), ew.Option(py_value='user', label='User'), ], )), states=dict( select=ffw.FieldCluster(fields=[ ffw.AdminField(field=ew.TextField( name='options', label= 'Options (separate with spaces; quote if containing spaces; prefix with * to set a default)', )) ], show_labels=False), milestone=ffw.FieldCluster( # name='milestones', fields=[MilestonesAdmin(name='milestones')])))
class MilestonesAdmin(ffw.SortableTable): defaults = dict( ffw.SortableTable.defaults, button=ffw.AdminField(field=ew.InputField( css_class='add', field_type='button', value='New Milestone')), empty_msg='No milestones have been created.', nonempty_msg='Drag and drop the milestones to reorder.', repetitions=0) fields = [ ew.HiddenField(name='old_name'), ffw.Radio(name='default', label='Default', css_class='default-milestone'), ew.Checkbox(name='complete', show_label=True, suppress_label=True), ew.TextField(name='name', attrs={'style': 'width: 80px'}), ffw.DateField(name='due_date', attrs={'style': 'width: 80px'}), ffw.AutoResizeTextarea(name='description', attrs={'style': 'height:1em; width: 150px'}), ew.InputField(label='Delete', field_type='button', attrs={ 'class': 'delete', 'value': 'Delete' }), ] button = ew.InputField(css_class='add', field_type='button', value='New Milestone') def prepare_context(self, context): response = super(MilestonesAdmin, self).prepare_context(context) if 'value' in response: for milestone_data in response['value']: if 'name' in milestone_data: milestone_data['old_name'] = milestone_data['name'] return response def resources(self): for r in super(MilestonesAdmin, self).resources(): yield r yield ew.CSSScript('''div.state-field table{ width: 700px; }''')