<vn-watcher
    vn-id="watcher"
    data="$ctrl.claim"
    form="form"
    url="Claims/{{$ctrl.$params.id}}/updateClaim"
    save="post">
</vn-watcher>
<form name="form" ng-submit="$ctrl.onSubmit()" class="vn-w-md">
    <vn-card class="vn-pa-lg">
        <vn-horizontal>
            <vn-textfield
                vn-one
                label="Client"
                ng-model="$ctrl.claim.client.name"
                readonly="true">
            </vn-textfield>
            <vn-textfield
                vn-one
                label="Created" 
                field="::$ctrl.claim.created | date:'yyyy-MM-dd HH:mm'"
                readonly="true">
            </vn-textfield>
        </vn-horizontal>
        <vn-horizontal>
            <vn-autocomplete 
                vn-one
                disabled="false"
                ng-model="$ctrl.claim.workerFk"
                url="Clients/activeWorkersWithRole"
                show-field="nickname"
                search-function="{firstName: $search}"
                value-field="id"
                where="{role: 'employee'}"
                label="Attended by">
            </vn-autocomplete>
            <vn-autocomplete
                vn-one
                ng-model="$ctrl.claim.claimStateFk"
                url="ClaimStates"
                show-field="description"
                value-field="id"
                label="Claim state"
                order="priority ASC"
                vn-focus>
            </vn-autocomplete>
            </vn-horizontal>
        </vn-horizontal>
        <vn-horizontal>
            <vn-textarea
                vn-one
                label="Observation" 
                ng-model="$ctrl.claim.observation"
                rule>
            </vn-textarea>
        </vn-horizontal>
        <vn-horizontal>
            <vn-check vn-one class="vn-mr-md"
                label="Pick up"
                ng-model="$ctrl.claim.hasToPickUp"
                vn-acl="salesAssistant">
            </vn-check>
        </vn-horizontal>
    </vn-card>
    <vn-button-bar>
        <vn-submit label="Save"></vn-submit>
        <vn-button label="Undo changes" 
            ng-if="$ctrl.$.form.$dirty" 
            ng-click="watcher.loadOriginalData()">
        </vn-button>
    </vn-button-bar>
</form>