<vn-watcher
    vn-id="watcher"
    url="LdapConfigs"
    data="$ctrl.config"
    id-value="1"
    form="form">
</vn-watcher>
<form
    name="form"
    ng-submit="watcher.submit()"
    class="vn-w-md">
    <vn-card class="vn-pa-lg" vn-focus>
        <vn-vertical>
            <vn-check
                label="Enable synchronization" 
                ng-model="watcher.hasData">
            </vn-check>
        </vn-vertical>
        <vn-vertical
            ng-if="watcher.hasData"
            class="vn-mt-md">
            <vn-textfield
                label="Server" 
                ng-model="$ctrl.config.server"
                rule="LdapConfig">
            </vn-textfield>
            <vn-textfield
                label="RDN" 
                ng-model="$ctrl.config.rdn"
                rule="LdapConfig">
            </vn-textfield>
            <vn-textfield
                label="Password" 
                ng-model="$ctrl.config.password"
                type="password"
                rule="LdapConfig">
            </vn-textfield>
            <vn-textfield
                label="User DN" 
                ng-model="$ctrl.config.userDn"
                rule="LdapConfig">
            </vn-textfield>
            <vn-textfield
                label="Group DN" 
                ng-model="$ctrl.config.groupDn"
                rule="LdapConfig">
            </vn-textfield>
        </vn-vertical>
    </vn-card>
    <vn-button-bar>
        <vn-submit
            disabled="!watcher.dataChanged()"
            label="Save">
        </vn-submit>
        <vn-button
            label="Test connection"
            ng-click="$ctrl.onTestConection()">
        </vn-button>
        <vn-button
            class="cancel"
            label="Undo changes"
            disabled="!watcher.dataChanged()"
            ng-click="watcher.loadOriginalData()">
        </vn-button>
    </vn-button-bar>
</form>