From 845b5cda1a6730fe27028d180b246e2c221b3f40 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Tue, 8 Aug 2023 18:06:22 -0500 Subject: [PATCH] Fix custom cell click handlers in main buefy grid tables just used for editing catalog/invoice cost in receiving thus far.. --- tailbone/templates/grids/buefy.mako | 20 +++++++++++++++++--- tailbone/templates/receiving/view.mako | 3 ++- tailbone/views/purchasing/receiving.py | 9 +++------ 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/tailbone/templates/grids/buefy.mako b/tailbone/templates/grids/buefy.mako index d96358d5..42451597 100644 --- a/tailbone/templates/grids/buefy.mako +++ b/tailbone/templates/grids/buefy.mako @@ -180,18 +180,21 @@ % endif :checkable="checkable" + % if grid.checkboxes: :checked-rows.sync="checkedRows" % if grid.clicking_row_checks_box: @click="rowClick" % endif % endif + % if grid.check_handler: @check="${grid.check_handler}" % endif % if grid.check_all_handler: @check-all="${grid.check_all_handler}" % endif + % if isinstance(grid.checkable, str): :is-row-checkable="${grid.row_checkable}" % elif grid.checkable: @@ -204,6 +207,10 @@ @sort="onSort" % endif + % if grid.click_handlers: + @cellclick="cellClick" + % endif + :paginated="paginated" :per-page="perPage" :current-page="currentPage" @@ -227,9 +234,6 @@ searchable % endif cell-class="c_${column['field']}" - % if grid.has_click_handler(column['field']): - @click.native="${grid.click_handlers[column['field']]}" - % endif :visible="${json.dumps(column['visible'])}"> % if column['field'] in grid.raw_renderers: ${grid.raw_renderers[column['field']]()} @@ -392,6 +396,16 @@ methods: { + % if grid.click_handlers: + cellClick(row, column, rowIndex, columnIndex) { + % for key in grid.click_handlers: + if (column._props.field == '${key}') { + ${grid.click_handlers[key]}(row) + } + % endfor + }, + % endif + copyDirectLink() { if (navigator.clipboard) { diff --git a/tailbone/templates/receiving/view.mako b/tailbone/templates/receiving/view.mako index 463fdf6c..b4de37f1 100644 --- a/tailbone/templates/receiving/view.mako +++ b/tailbone/templates/receiving/view.mako @@ -103,7 +103,8 @@ ref="input" v-show="editing" @keydown.native="inputKeyDown" - @blur="inputBlur"> + @blur="inputBlur" + style="width: 6rem;"> diff --git a/tailbone/views/purchasing/receiving.py b/tailbone/views/purchasing/receiving.py index d4bed60a..35e1d6b4 100644 --- a/tailbone/views/purchasing/receiving.py +++ b/tailbone/views/purchasing/receiving.py @@ -968,19 +968,16 @@ class ReceivingBatchView(PurchasingBatchView): g.filters['vendor_code'].default_verb = 'contains' # catalog_unit_cost - if (self.handler.has_purchase_order(batch) - or self.handler.has_invoice_file(batch)): - g.remove('catalog_unit_cost') - elif self.allow_edit_catalog_unit_cost(batch): + if self.allow_edit_catalog_unit_cost(batch): g.set_raw_renderer('catalog_unit_cost', self.render_catalog_unit_cost) g.set_click_handler('catalog_unit_cost', - 'catalogUnitCostClicked(props.row)') + 'this.catalogUnitCostClicked') # invoice_unit_cost if self.allow_edit_invoice_unit_cost(batch): g.set_raw_renderer('invoice_unit_cost', self.render_invoice_unit_cost) g.set_click_handler('invoice_unit_cost', - 'invoiceUnitCostClicked(props.row)') + 'this.invoiceUnitCostClicked') # nb. only show PO *or* invoice cost; prefer the latter unless # we have a PO and no invoice