Fix custom cell click handlers in main buefy grid tables

just used for editing catalog/invoice cost in receiving thus far..
This commit is contained in:
Lance Edgar 2023-08-08 18:06:22 -05:00
parent f2915afda4
commit 845b5cda1a
3 changed files with 22 additions and 10 deletions

View file

@ -180,18 +180,21 @@
% endif % endif
:checkable="checkable" :checkable="checkable"
% if grid.checkboxes: % if grid.checkboxes:
:checked-rows.sync="checkedRows" :checked-rows.sync="checkedRows"
% if grid.clicking_row_checks_box: % if grid.clicking_row_checks_box:
@click="rowClick" @click="rowClick"
% endif % endif
% endif % endif
% if grid.check_handler: % if grid.check_handler:
@check="${grid.check_handler}" @check="${grid.check_handler}"
% endif % endif
% if grid.check_all_handler: % if grid.check_all_handler:
@check-all="${grid.check_all_handler}" @check-all="${grid.check_all_handler}"
% endif % endif
% if isinstance(grid.checkable, str): % if isinstance(grid.checkable, str):
:is-row-checkable="${grid.row_checkable}" :is-row-checkable="${grid.row_checkable}"
% elif grid.checkable: % elif grid.checkable:
@ -204,6 +207,10 @@
@sort="onSort" @sort="onSort"
% endif % endif
% if grid.click_handlers:
@cellclick="cellClick"
% endif
:paginated="paginated" :paginated="paginated"
:per-page="perPage" :per-page="perPage"
:current-page="currentPage" :current-page="currentPage"
@ -227,9 +234,6 @@
searchable searchable
% endif % endif
cell-class="c_${column['field']}" 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'])}"> :visible="${json.dumps(column['visible'])}">
% if column['field'] in grid.raw_renderers: % if column['field'] in grid.raw_renderers:
${grid.raw_renderers[column['field']]()} ${grid.raw_renderers[column['field']]()}
@ -392,6 +396,16 @@
methods: { 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() { copyDirectLink() {
if (navigator.clipboard) { if (navigator.clipboard) {

View file

@ -103,7 +103,8 @@
ref="input" ref="input"
v-show="editing" v-show="editing"
@keydown.native="inputKeyDown" @keydown.native="inputKeyDown"
@blur="inputBlur"> @blur="inputBlur"
style="width: 6rem;">
</b-input> </b-input>
</div> </div>
</script> </script>

View file

@ -968,19 +968,16 @@ class ReceivingBatchView(PurchasingBatchView):
g.filters['vendor_code'].default_verb = 'contains' g.filters['vendor_code'].default_verb = 'contains'
# catalog_unit_cost # catalog_unit_cost
if (self.handler.has_purchase_order(batch) if self.allow_edit_catalog_unit_cost(batch):
or self.handler.has_invoice_file(batch)):
g.remove('catalog_unit_cost')
elif self.allow_edit_catalog_unit_cost(batch):
g.set_raw_renderer('catalog_unit_cost', self.render_catalog_unit_cost) g.set_raw_renderer('catalog_unit_cost', self.render_catalog_unit_cost)
g.set_click_handler('catalog_unit_cost', g.set_click_handler('catalog_unit_cost',
'catalogUnitCostClicked(props.row)') 'this.catalogUnitCostClicked')
# invoice_unit_cost # invoice_unit_cost
if self.allow_edit_invoice_unit_cost(batch): if self.allow_edit_invoice_unit_cost(batch):
g.set_raw_renderer('invoice_unit_cost', self.render_invoice_unit_cost) g.set_raw_renderer('invoice_unit_cost', self.render_invoice_unit_cost)
g.set_click_handler('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 # nb. only show PO *or* invoice cost; prefer the latter unless
# we have a PO and no invoice # we have a PO and no invoice