<vn-watcher
    vn-id="watcher"
    url="Accounts"
    id-field="id"
    data="$ctrl.account"
    form="form">
</vn-watcher>
<form name="form" ng-submit="watcher.submit()" class="vn-w-md">
    <vn-card class="vn-pa-lg">
        <vn-horizontal>
            <vn-check
                vn-one
                label="Enable web access"
                ng-model="$ctrl.account.active"
                vn-acl="employee">
            </vn-check>
        </vn-horizontal>
        <vn-horizontal>
            <vn-textfield
                vn-focus
                vn-one
                label="User"
                ng-model="$ctrl.account.name"
                rule>
            </vn-textfield>
        </vn-horizontal>
    </vn-card>
    <vn-button-bar>
        <vn-submit
            disabled="!watcher.dataChanged()"
            label="Save">
        </vn-submit>
        <vn-button
        ng-if="$ctrl.canChangePassword"
        label="Change password"
        vn-dialog="change-pass">
        </vn-button>
        <vn-button
            class="cancel"
            label="Undo changes"
            disabled="!watcher.dataChanged()"
            ng-click="watcher.loadOriginalData()">
        </vn-button>
    </vn-button-bar>
</form>
<vn-dialog
    vn-id="change-pass"
    on-open="$ctrl.onPassOpen()"
    on-accept="$ctrl.onPassChange()">
    <tpl-body>
        <vn-textfield
            type="password"
            label="New password"
            ng-model="$ctrl.newPassword">
        </vn-textfield>
        <vn-textfield
            type="password"
            label="Repeat password"
            ng-model="$ctrl.repeatPassword">
        </vn-textfield>
    </tpl-body>
    <tpl-buttons>
        <input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/>
        <button response="accept" translate>Change password</button>
    </tpl-buttons>
</vn-dialog>