Add support for editing catalog cost in receiving batch, per new theme

had to add several "under the hood" features to make this work, to
embed a Vue component within grid `<td>` cells, etc.
This commit is contained in:
Lance Edgar 2022-12-05 14:03:03 -06:00
parent ec71f532a1
commit 2e3823364c
7 changed files with 296 additions and 27 deletions

View file

@ -48,7 +48,7 @@ from pyramid_deform import SessionFileUploadTempStore
from pyramid.renderers import render
from webhelpers2.html import tags, HTML
from tailbone.util import raw_datetime
from tailbone.util import raw_datetime, get_form_data
from . import types
from .widgets import ReadonlyWidget, PlainDateWidget, JQueryDateWidget, JQueryTimeWidget
from tailbone.exceptions import TailboneJSONFieldError
@ -1071,17 +1071,15 @@ class Form(object):
if self.request.method != 'POST':
return False
# use POST or JSON body, whichever is present
# TODO: per docs, some JS libraries may not set this flag?
# https://docs.pylonsproject.org/projects/pyramid/en/latest/api/request.html#pyramid.request.Request.is_xhr
if self.request.is_xhr and not self.request.POST:
controls = self.request.json_body.items()
controls = get_form_data(self.request).items()
# unfortunately the normal form logic (i.e. peppercorn) is
# expecting all values to be strings, whereas the JSON body we
# just parsed, may have given us some Pythonic objects. so
# here we must convert them *back* to strings...
# TODO: this seems like a hack, i must be missing something
# unfortunately the normal form logic (i.e. peppercorn) is
# expecting all values to be strings, whereas if our data
# came from JSON body, may have given us some Pythonic
# objects. so here we must convert them *back* to strings
# TODO: this seems like a hack, i must be missing something
# TODO: also this uses same "JSON" check as get_form_data()
if self.request.is_xhr and not self.request.POST:
controls = [[key, val] for key, val in controls]
for i in range(len(controls)):
key, value = controls[i]
@ -1094,9 +1092,6 @@ class Form(object):
elif not isinstance(value, six.string_types):
controls[i][1] = six.text_type(value)
else:
controls = self.request.POST.items()
dform = self.make_deform_form()
try:
self.validated = dform.validate(controls)