<mg-ajax path="Claims/updateClaim/{{patch.params.id}}" options="vnPatch"></mg-ajax>
<vn-watcher
    vn-id="watcher"
    data="$ctrl.claim"
    form="form"
    save="patch">
</vn-watcher>
<vn-crud-model
    auto-load="true"
    url="ClaimStates"
    data="claimStates">
</vn-crud-model>
<form name="form" ng-submit="$ctrl.onSubmit()" class="vn-w-md">
    <vn-card class="vn-pa-lg">
        <vn-horizontal>
            <vn-textfield
                label="Client"
                ng-model="$ctrl.claim.client.name"
                readonly="true">
            </vn-textfield>
            <vn-textfield
                label="Created"
                field="::$ctrl.claim.created | date:'yyyy-MM-dd HH:mm'"
                readonly="true">
            </vn-textfield>
        </vn-horizontal>
        <vn-horizontal>
            <vn-worker-autocomplete
                disabled="false"
                show-field="nickname"
                ng-model="$ctrl.claim.workerFk"
                departments="['VT']"
                label="Attended by">
            </vn-worker-autocomplete>
            <vn-autocomplete
                ng-model="$ctrl.claim.claimStateFk"
                data="claimStates"
                show-field="description"
                value-field="id"
                label="Claim state"
                order="priority ASC"
                vn-focus>
            </vn-autocomplete>
        </vn-horizontal>
        <vn-horizontal>
            <vn-input-number vn-one
                min="0"
                type="number"
                label="Packages received"
                ng-model="$ctrl.claim.packages">
            </vn-input-number>
            <vn-check
                class="vn-mr-md"
                label="Pick up"
                ng-model="$ctrl.claim.hasToPickUp"
                vn-acl="claimManager"
                title="{{'When checked will notify to the salesPerson' | translate}}">
            </vn-check>
        </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>