diff --git a/mobile/src/router/index.js b/mobile/src/router/index.js index afb1c4f..cd9f35b 100644 --- a/mobile/src/router/index.js +++ b/mobile/src/router/index.js @@ -52,6 +52,12 @@ const routes = [ // component: OrderingBatch, // props: {mode: 'editing'}, // }, + { + path: '/ordering/:uuid/execute', + name: 'ordering.execute', + component: OrderingBatch, + props: {mode: 'executing'}, + }, { path: '/ordering/rows/:uuid', name: 'ordering.rows.view', diff --git a/mobile/src/views/ordering/OrderingBatch.vue b/mobile/src/views/ordering/OrderingBatch.vue index 2da6301..cbc5236 100644 --- a/mobile/src/views/ordering/OrderingBatch.vue +++ b/mobile/src/views/ordering/OrderingBatch.vue @@ -1,120 +1,144 @@ diff --git a/mobile/src/views/ordering/OrderingBatchRow.vue b/mobile/src/views/ordering/OrderingBatchRow.vue index ca5f511..ea2fa08 100644 --- a/mobile/src/views/ordering/OrderingBatchRow.vue +++ b/mobile/src/views/ordering/OrderingBatchRow.vue @@ -7,9 +7,13 @@ api-object-url="/api/ordering-batch-row/" model-path-prefix="/ordering" row-path-prefix="/ordering/rows" - @refresh="record => { row = record }" + @refresh="refresh" is-row - @save="save"> + @save="save" + :allow-edit="!row.batch_executed && !row.batch_complete" + :allow-delete="!row.batch_executed && !row.batch_complete" + quick-delete + @delete="deleteRow"> @@ -42,7 +46,7 @@ ref="unitsOrdered" @keypress.native="handleEnter"> - + {{ row.units_ordered_display }} @@ -89,11 +93,23 @@ export default { if (this.mode == 'editing') { this.$nextTick(function() { this.$refs.casesOrdered.focus() + // this.$refs.unitsOrdered.focus() }) } }, methods: { + refresh(record) { + this.row = record + if (this.mode == 'editing' && !this.row.batch_mutable) { + this.$buefy.toast.open({ + message: "Batch is not mutable.", + type: 'is-danger', + }) + this.$router.push(`/ordering/rows/${this.row.uuid}`) + } + }, + renderParentHeaderLabel(row) { return row.batch_id_str }, @@ -118,8 +134,28 @@ export default { url = `/api/ordering-batch-row/${this.row.uuid}` } this.$http.post(url, params).then(response => { + if (response.data.error) { + this.$buefy.toast.open({ + message: response.data.error || "Save failed: " + response.data.error, + type: 'is-danger', + }) + } else { + // go back to the purchase order + this.$router.push('/ordering/' + response.data.data.batch_uuid) + } + }, response => { + this.$buefy.toast.open({ + message: "Save failed: (unknown error)", + type: 'is-danger', + }) + }) + }, + + deleteRow() { + let url = `/api/ordering-batch-row/${this.row.uuid}` + this.$http.delete(url).then(response => { // go back to the purchase order - this.$router.push('/ordering/' + response.data.data.batch_uuid) + this.$router.push(`/ordering/${this.row.batch_uuid}`) }) }, }, diff --git a/mobile/src/views/ordering/OrderingBatches.vue b/mobile/src/views/ordering/OrderingBatches.vue index cdc0ec4..79eac75 100644 --- a/mobile/src/views/ordering/OrderingBatches.vue +++ b/mobile/src/views/ordering/OrderingBatches.vue @@ -9,6 +9,26 @@ :api-index-sort="{field: 'id', dir: 'desc'}" :api-index-filters="filters" :label-renderer="renderLabel"> + + + + pending + + + complete + + + executed + + + all + + + @@ -22,15 +42,31 @@ export default { }, data() { return { - filters: [ - {field: 'executed', op: 'is_null'}, - {or: [ - {field: 'complete', op: 'is_null'}, - {field: 'complete', op: 'eq', value: false}, - ]}, - ], + possibleFilters: { + 'pending': [ + {field: 'executed', op: 'is_null'}, + {or: [ + {field: 'complete', op: 'is_null'}, + {field: 'complete', op: 'eq', value: false}, + ]}, + ], + 'complete': [ + {field: 'executed', op: 'is_null'}, + {field: 'complete', op: 'eq', value: true}, + ], + 'executed': [ + {field: 'executed', op: 'is_not_null'}, + ], + 'all': [], + }, + selectedFilter: 'pending', } }, + computed: { + filters: function() { + return this.possibleFilters[this.selectedFilter] + }, + }, methods: { renderLabel(batch) { return `(${batch.id_str}) ${batch.vendor_display}`