Misc. UI improvements for truck dump receiving on desktop
links back and forth between parent/child rows, a little help text etc.
This commit is contained in:
parent
255485296c
commit
4a610ba2e6
|
@ -731,12 +731,26 @@ class Form(object):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def render_field_readonly(self, field_name, **kwargs):
|
def render_field_readonly(self, field_name, **kwargs):
|
||||||
|
"""
|
||||||
|
Render the given field completely, but in read-only fashion.
|
||||||
|
|
||||||
|
Note that this method will generate the wrapper div and label, as well
|
||||||
|
as the field value.
|
||||||
|
"""
|
||||||
if field_name not in self.fields:
|
if field_name not in self.fields:
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
# TODO: fair bit of duplication here, should merge with deform.mako
|
||||||
label = HTML.tag('label', self.get_label(field_name), for_=field_name)
|
label = HTML.tag('label', self.get_label(field_name), for_=field_name)
|
||||||
field = self.render_field_value(field_name) or ''
|
field = self.render_field_value(field_name) or ''
|
||||||
field_div = HTML.tag('div', class_='field', c=[field])
|
field_div = HTML.tag('div', class_='field', c=[field])
|
||||||
return HTML.tag('div', class_='field-wrapper {}'.format(field_name), c=[label, field_div])
|
contents = [label, field_div]
|
||||||
|
|
||||||
|
if self.has_helptext(field_name):
|
||||||
|
contents.append(HTML.tag('span', class_='instructions',
|
||||||
|
c=[self.render_helptext(field_name)]))
|
||||||
|
|
||||||
|
return HTML.tag('div', class_='field-wrapper {}'.format(field_name), c=contents)
|
||||||
|
|
||||||
def render_field_value(self, field_name):
|
def render_field_value(self, field_name):
|
||||||
record = self.model_instance
|
record = self.model_instance
|
||||||
|
|
|
@ -628,7 +628,8 @@ class PurchasingBatchView(BatchMasterView):
|
||||||
if row.status_code in (row.STATUS_INCOMPLETE,
|
if row.status_code in (row.STATUS_INCOMPLETE,
|
||||||
row.STATUS_CASE_QUANTITY_DIFFERS,
|
row.STATUS_CASE_QUANTITY_DIFFERS,
|
||||||
row.STATUS_ORDERED_RECEIVED_DIFFER,
|
row.STATUS_ORDERED_RECEIVED_DIFFER,
|
||||||
row.STATUS_TRUCKDUMP_UNCLAIMED):
|
row.STATUS_TRUCKDUMP_UNCLAIMED,
|
||||||
|
row.STATUS_TRUCKDUMP_PARTCLAIMED):
|
||||||
return 'notice'
|
return 'notice'
|
||||||
|
|
||||||
def configure_row_form(self, f):
|
def configure_row_form(self, f):
|
||||||
|
|
|
@ -140,6 +140,7 @@ class ReceivingBatchView(PurchasingBatchView):
|
||||||
'id',
|
'id',
|
||||||
'vendor',
|
'vendor',
|
||||||
'truck_dump',
|
'truck_dump',
|
||||||
|
'description',
|
||||||
'department',
|
'department',
|
||||||
'buyer',
|
'buyer',
|
||||||
'date_ordered',
|
'date_ordered',
|
||||||
|
@ -428,7 +429,7 @@ class ReceivingBatchView(PurchasingBatchView):
|
||||||
truck_dump = batch.truck_dump_batch
|
truck_dump = batch.truck_dump_batch
|
||||||
if not truck_dump:
|
if not truck_dump:
|
||||||
return ""
|
return ""
|
||||||
text = six.text_type(truck_dump)
|
text = "({}) {}".format(truck_dump.id_str, truck_dump.description or '')
|
||||||
url = self.request.route_url('receiving.view', uuid=truck_dump.uuid)
|
url = self.request.route_url('receiving.view', uuid=truck_dump.uuid)
|
||||||
return tags.link_to(text, url)
|
return tags.link_to(text, url)
|
||||||
|
|
||||||
|
@ -445,7 +446,7 @@ class ReceivingBatchView(PurchasingBatchView):
|
||||||
if children:
|
if children:
|
||||||
items = []
|
items = []
|
||||||
for child in children:
|
for child in children:
|
||||||
text = six.text_type(child)
|
text = "({}) {}".format(child.id_str, child.description or '')
|
||||||
url = self.request.route_url('receiving.view', uuid=child.uuid)
|
url = self.request.route_url('receiving.view', uuid=child.uuid)
|
||||||
items.append(HTML.tag('li', c=[tags.link_to(text, url)]))
|
items.append(HTML.tag('li', c=[tags.link_to(text, url)]))
|
||||||
contents.append(HTML.tag('ul', c=items))
|
contents.append(HTML.tag('ul', c=items))
|
||||||
|
@ -704,20 +705,40 @@ class ReceivingBatchView(PurchasingBatchView):
|
||||||
|
|
||||||
# claims
|
# claims
|
||||||
if batch.is_truck_dump_parent():
|
if batch.is_truck_dump_parent():
|
||||||
f.set_renderer('claims', self.render_row_claims)
|
f.set_renderer('claims', self.render_parent_row_claims)
|
||||||
|
f.set_helptext('claims', "Parent row is claimed by these child rows.")
|
||||||
|
elif batch.is_truck_dump_child():
|
||||||
|
f.set_renderer('claims', self.render_child_row_claims)
|
||||||
|
f.set_helptext('claims', "Child row makes claims against these parent rows.")
|
||||||
else:
|
else:
|
||||||
f.remove_field('claims')
|
f.remove_field('claims')
|
||||||
|
|
||||||
def render_row_claims(self, row, field):
|
def render_parent_row_claims(self, row, field):
|
||||||
items = []
|
items = []
|
||||||
for claim in row.claims:
|
for claim in row.claims:
|
||||||
child_row = claim.claiming_row
|
child_row = claim.claiming_row
|
||||||
child_batch = child_row.batch
|
child_batch = child_row.batch
|
||||||
text = child_batch.id_str
|
text = child_batch.id_str
|
||||||
|
if child_batch.description:
|
||||||
|
text = "{} ({})".format(text, child_batch.description)
|
||||||
|
text = "{}, row {}".format(text, child_row.sequence)
|
||||||
url = self.get_row_action_url('view', child_row)
|
url = self.get_row_action_url('view', child_row)
|
||||||
items.append(HTML.tag('li', c=[tags.link_to(text, url)]))
|
items.append(HTML.tag('li', c=[tags.link_to(text, url)]))
|
||||||
return HTML.tag('ul', c=items)
|
return HTML.tag('ul', c=items)
|
||||||
|
|
||||||
|
def render_child_row_claims(self, row, field):
|
||||||
|
items = []
|
||||||
|
for claim in row.truck_dump_claims:
|
||||||
|
parent_row = claim.claimed_row
|
||||||
|
parent_batch = parent_row.batch
|
||||||
|
text = parent_batch.id_str
|
||||||
|
if parent_batch.description:
|
||||||
|
text = "{} ({})".format(text, parent_batch.description)
|
||||||
|
text = "{}, row {}".format(text, parent_row.sequence)
|
||||||
|
url = self.get_row_action_url('view', parent_row)
|
||||||
|
items.append(HTML.tag('li', c=[tags.link_to(text, url)]))
|
||||||
|
return HTML.tag('ul', c=items)
|
||||||
|
|
||||||
def validate_row_form(self, form):
|
def validate_row_form(self, form):
|
||||||
|
|
||||||
# if normal validation fails, stop there
|
# if normal validation fails, stop there
|
||||||
|
|
Loading…
Reference in a new issue