<vn-crud-model
    vn-id="model"
    url="ItemBarcodes"
    fields="['id', 'itemFk', 'code']"
    link="{itemFk: $ctrl.$params.id}"
    data="barcodes"
    auto-load="true">
</vn-crud-model>
<vn-watcher
    vn-id="watcher"
    data="barcodes"
    form="form">
</vn-watcher>
<form name="form" ng-submit="$ctrl.onSubmit()" class="vn-w-md">
    <vn-card class="vn-pa-lg">
        <vn-horizontal ng-repeat="barcode in barcodes track by $index">
            <vn-textfield
                vn-three
                label="Code"
                ng-model="barcode.code"
                vn-acl="buyer, replenisher"
                vn-focus>
            </vn-textfield>
            <vn-none>
                <vn-icon-button
                    vn-acl="buyer,replenisher"
                    pointer
                    vn-tooltip="Remove barcode"
                    icon="delete"
                    ng-click="model.remove($index)">
                </vn-icon-button>
            </vn-none>
        </vn-horizontal>
        <vn-one>
            <vn-icon-button
                vn-acl="buyer, replenisher"
                vn-tooltip="Add barcode"
                vn-bind="+"
                icon="add_circle"
                ng-click="model.insert()">
            </vn-icon-button>
        </vn-one>
    </vn-card>
    <vn-button-bar>
        <vn-submit
            disabled="!watcher.dataChanged()"
            label="Save">
        </vn-submit>
        <!-- # #2680 Undo changes button bugs -->
        <!-- <vn-button
            class="cancel"
            label="Undo changes"
            disabled="!watcher.dataChanged()"
            ng-click="watcher.loadOriginalData()">
        </vn-button> -->
    </vn-button-bar>
</form>