<mg-ajax path="Suppliers/{{patch.params.id}}" options="vnPatch"></mg-ajax>
<vn-watcher
    vn-id="watcher"
    data="$ctrl.supplier"
    form="form"
    save="patch">
</vn-watcher>
<form name="form" ng-submit="watcher.submit()" class="vn-w-md">
    <vn-card class="vn-pa-lg">
        <vn-horizontal>
            <vn-textfield
                vn-one
                label="Alias"
                ng-model="$ctrl.supplier.nickname"
                rule
                vn-focus>
            </vn-textfield>
            <vn-autocomplete
                vn-one
                ng-model="$ctrl.supplier.workerFk"
                url="Workers/activeWithInheritedRole"
                search-function="{firstName: $search}"
                show-field="nickname"
                value-field="id"
                where="{role: 'employee'}"
                label="Responsible"
                info="Responsible for approving invoices">
            </vn-autocomplete>
        </vn-horizontal>
        <vn-horizontal>
            <vn-check
                label="Verified" 
                ng-model="$ctrl.supplier.isSerious">
            </vn-check>
            <vn-check
                label="Active" 
                ng-model="$ctrl.supplier.isActive">
            </vn-check>
            <vn-check
                label="PayMethodChecked" 
                ng-model="$ctrl.supplier.isPayMethodChecked"
                vn-acl="financial">
            </vn-check>
        </vn-horizontal>
        <vn-horizontal>
            <vn-textarea
                vn-one
                label="Notes" 
                ng-model="$ctrl.supplier.note"
                rule>
            </vn-textarea>
        </vn-horizontal>
    </vn-card>
    <vn-button-bar>
        <vn-submit
            disabled="!watcher.dataChanged()"
            label="Save">
        </vn-submit>
        <vn-button
            class="cancel"
            label="Undo changes"
            disabled="!watcher.dataChanged()"
            ng-click="watcher.loadOriginalData()">
        </vn-button>
    </vn-button-bar>
</form>