<vn-watcher
    vn-id="watcher"
    url="Zones"
    data="$ctrl.zone"
    insert-mode="true"
    form="form">
</vn-watcher>
<vn-crud-model
    auto-load="true"
    url="Warehouses"
    data="warehouses"
    order="name">
</vn-crud-model>
<vn-crud-model
    auto-load="true"
    url="AgencyModes/isActive"
    data="activeAgencyModes"
    order="name">
</vn-crud-model>
<form
    name="form"
    vn-http-submit="$ctrl.onSubmit()"
    class="vn-w-md">
    <vn-card class="vn-pa-lg">
        <vn-horizontal>
            <vn-textfield
                label="Name" 
                ng-model="$ctrl.zone.name"
                rule
                vn-focus>
            </vn-textfield>
        </vn-horizontal>
        <vn-horizontal>
            <vn-autocomplete
                label="Warehouse"
                ng-model="$ctrl.zone.warehouseFk"
                data="warehouses"
                show-field="name"
                value-field="id"
                label="Warehouse"
                rule>
            </vn-autocomplete>
            <vn-autocomplete
                label="Agency"
                ng-model="$ctrl.zone.agencyModeFk"
                data="activeAgencyModes"
                show-field="name"
                value-field="id"
                label="Agency"
                rule>
            </vn-autocomplete>
        </vn-horizontal>
        <vn-horizontal>
            <vn-input-number
                label="Traveling days"
                ng-model="$ctrl.zone.travelingDays"
                min="0"
                step="1"
                rule>
            </vn-input-number>
            <vn-input-time
                label="Closing hour"
                ng-model="$ctrl.zone.hour"
                rule>
            </vn-input-time>
        </vn-horizontal>
        <vn-horizontal>
            <vn-input-number
                label="Price"
                ng-model="$ctrl.zone.price"
                min="0"
                step="0.01"
                rule>
            </vn-input-number>
            <vn-input-number
                label="Bonus"
                ng-model="$ctrl.zone.bonus"
                min="0"
                step="0.01"
                rule>
            </vn-input-number> 
        </vn-horizontal>
        <vn-horizontal>
            <vn-check ng-model="$ctrl.zone.isVolumetric" label="Volumetric"></vn-check>
        </vn-horizontal>
    </vn-card>
    <vn-button-bar>
        <vn-submit
            disabled="!watcher.dataChanged()"
            label="Create">
        </vn-submit>
        <vn-button
            class="cancel"
            label="Cancel"
            ui-sref="zone.index">
        </vn-button>
    </vn-button-bar>
</form>