<template>
  <byjove-model-index model-name="PurchaseBatch"
                      model-index-title="Ordering"
                      model-title="Ordering Batch"
                      model-title-plural="Ordering Batches"
                      model-path-prefix="/ordering"
                      model-permission-prefix="ordering"
                      api-index-url="/api/ordering-batches"
                      :api-index-sort="{field: 'id', dir: 'desc'}"
                      :api-index-filters="filters"
                      :label-renderer="renderLabel">
  </byjove-model-index>
</template>

<script>
import {ByjoveModelIndex} from 'byjove'

export default {
    name: 'OrderingBatches',
    components: {
        ByjoveModelIndex,
    },
    data() {
        return {
            filters: [
                {field: 'executed', op: 'is_null'},
                {or: [
                    {field: 'complete', op: 'is_null'},
                    {field: 'complete', op: 'eq', value: false},
                ]},
            ],
        }
    },
    methods: {
        renderLabel(batch) {
            return `(${batch.id_str}) ${batch.vendor_display}`
        },
    },
}
</script>
