Parent: [67df1e] (diff)

Child: [c2dc10] (diff)

Download this file

admin_custom_fields.py    114 lines (100 with data), 4.3 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import ew as ew_core
import ew.jinja2_ew as ew
from allura.lib.widgets import form_fields as ffw
from allura.lib.widgets import forms as f
from pylons import c
from forgetracker import model
from formencode import validators as fev
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.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 resources(self):
for r in super(MilestonesAdmin, self).resources(): yield r
yield ew.CSSScript('''div.state-field table{ width: 700px; }''')
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'),
],
)),
states=dict(
select=ffw.FieldCluster(
fields=[
ffw.AdminField(field=ew.TextField(name='options')) ],
show_labels=False),
milestone=ffw.FieldCluster(
# name='milestones',
fields=[ MilestonesAdmin(name='milestones') ])
))
class CustomFieldAdmin(ew.CompoundField):
template='jinja:forgetracker:templates/tracker_widgets/custom_field_admin.html'
def resources(self):
for r in super(CustomFieldAdmin, self).resources():
yield r
yield ew.JSLink('tool/Tickets/js/custom-fields.js')
fields = [
ew.TextField(name='label'),
ew.Checkbox(
name='show_in_search',
label='Show in search',
show_label=True,
suppress_label=True),
CustomFieldAdminDetail() ]
class TrackerFieldAdmin(f.ForgeForm):
submit_text=None
class fields(ew_core.NameList):
open_status_names = ew.TextField(label='Open Statuses')
closed_status_names = ew.TextField(label='Closed Statuses')
custom_fields = ffw.SortableRepeatedField(field=CustomFieldAdmin())
class buttons(ew_core.NameList):
save = ew.SubmitButton(label='Save')
cancel = ew.SubmitButton(
label="Cancel",
css_class='cancel', attrs=dict(
onclick='window.location.reload(); return false;'))
def resources(self):
for rr in self.fields['custom_fields'].resources():
yield rr
class CustomFieldDisplay(ew.CompoundField):
template='jinja:forgetracker:templates/tracker_widgets/custom_field_display.html'
class CustomFieldsDisplay(ew.RepeatedField):
template='jinja:forgetracker:templates/tracker_widgets/custom_fields_display.html'
class TrackerFieldDisplay(f.ForgeForm):
class fields(ew_core.NameList):
milestone_names = ew.TextField()
open_status_names = ew.TextField(label='Open Statuses')
closed_status_names = ew.TextField(label='Open Statuses')
custom_fields = CustomFieldsDisplay()
def resources(self):
for rr in self.fields['custom_fields'].resources():
yield rr