<mg-ajax path="Roadmaps/{{patch.params.id}}" options="vnPatch"></mg-ajax>
<vn-watcher
    vn-id="watcher"
    data="$ctrl.roadmap"
    form="form"
    save="patch">
</vn-watcher>
<form name="form" ng-submit="$ctrl.onSubmit()" class="vn-w-md">
    <vn-card class="vn-pa-lg">
        <vn-horizontal>
            <vn-textfield vn-focus
                vn-one
                label="Roadmap"
                ng-model="$ctrl.roadmap.name"
                rule>
            </vn-textfield>
            <vn-date-picker
                vn-one
                label="ETD date"
                ng-model="$ctrl.roadmap.etd">
            </vn-date-picker>
            <vn-input-time
                vn-one
                label="ETD hour"
                ng-model="$ctrl.roadmap.etd">
            </vn-input-time>
        </vn-horizontal>
        <vn-horizontal>
            <vn-textfield
                vn-one
                label="Tractor plate"
                ng-model="$ctrl.roadmap.tractorPlate"
                rule>
            </vn-textfield>
            <vn-textfield
                vn-one
                label="Trailer plate"
                ng-model="$ctrl.roadmap.trailerPlate"
                rule>
            </vn-textfield>
        </vn-horizontal>
        <vn-horizontal>
            <vn-autocomplete
                vn-one
                ng-model="$ctrl.roadmap.supplierFk"
                url="Suppliers"
                show-field="nickname"
                search-function="{or: [{id: $search}, {nickname: {like: '%'+ $search +'%'}}]}"
                value-field="id"
                order="nickname"
                label="Carrier">
                <tpl-item>
                    {{::id}} - {{::nickname}}
                </tpl-item>
            </vn-autocomplete>
            <vn-input-number
                vn-one
                label="Price"
                ng-model="$ctrl.roadmap.price"
                rule>
            </vn-input-number>
        </vn-horizontal>
        <vn-horizontal>
            <vn-textfield
                vn-one
                label="Driver name"
                ng-model="$ctrl.roadmap.driverName"
                rule>
            </vn-textfield>
            <vn-textfield
                vn-one
                label="Phone"
                ng-model="$ctrl.roadmap.phone"
                rule>
            </vn-textfield>
        </vn-horizontal>
        <vn-horizontal>
            <vn-textArea
                vn-one
                label="Observations"
                ng-model="$ctrl.roadmap.observations"
                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>