<vn-watcher
    vn-id="watcher"
    url="Routes"
    data="$ctrl.route"
    insert-mode="true"
    form="form">
</vn-watcher>
<form name="form" ng-submit="$ctrl.onSubmit()" class="vn-w-md">
    <vn-card class="vn-pa-lg">
        <vn-horizontal>
            <vn-autocomplete
                label="Worker"
                ng-model="$ctrl.route.workerFk"
                url="Workers/activeWithInheritedRole"
                show-field="nickname"
                search-function="{firstName: $search}"
                where="{role: 'employee'}">
            </vn-autocomplete>
            <vn-date-picker
                label="Created" 
                ng-model="$ctrl.route.created">
            </vn-date-picker>
        </vn-horizontal>
        <vn-horizontal>
            <vn-autocomplete
                label="Vehicle"
                ng-model="$ctrl.route.vehicleFk"
                url="Vehicles"
                where="{warehouseFk: $ctrl.vnConfig.warehouseFk}"
                show-field="numberPlate">
            </vn-autocomplete>
            <vn-autocomplete
                label="Agency"
                ng-model="$ctrl.route.agencyModeFk"
                url="AgencyModes">
            </vn-autocomplete>
        </vn-horizontal>
        <vn-horizontal>
            <vn-textfield
                label="Description"
                ng-model="$ctrl.route.description"
                rule>
            </vn-textfield>
        </vn-horizontal>
    </vn-card>
    <vn-button-bar>
        <vn-submit
            disabled="!watcher.dataChanged()"
            label="Create">
        </vn-submit>
        <vn-button
            class="cancel"
            label="Cancel"
            ui-sref="route.index">
        </vn-button>
    </vn-button-bar>
</form>