<vn-descriptor-content
    module="account"
    description="$ctrl.user.nickname"
    summary="$ctrl.$.summary">
    <slot-before>
        <vn-user-photo user-id="{{$ctrl.id}}"/>
    </slot-before>
    <slot-menu>
        <vn-item
            ng-click="deleteUser.show()"
            name="deleteUser"
            vn-acl="itManagement"
            vn-acl-action="remove"
            translate>
            Delete
        </vn-item>
        <vn-item
            ng-if="::$root.user.id == $ctrl.id"
            ng-click="$ctrl.onChangePassClick(true)"
            name="changePassword"
            vn-acl="sysadmin"
            vn-acl-action="remove"
            translate>
            Change password
        </vn-item>
        <vn-item
            ng-click="$ctrl.onChangePassClick(false)"
            name="setPassword"
            vn-acl="sysadmin"
            vn-acl-action="remove"
            translate>
            Set password
        </vn-item>
        <vn-item
            ng-if="!$ctrl.hasAccount"
            ng-click="enableAccount.show()"
            name="enableAccount"
            vn-acl="sysadmin"
            vn-acl-action="remove"
            translate>
            Enable account
        </vn-item>
        <vn-item
            ng-if="$ctrl.hasAccount"
            ng-click="disableAccount.show()"
            name="disableAccount"
            vn-acl="sysadmin"
            vn-acl-action="remove"
            translate>
            Disable account
        </vn-item>
        <vn-item
            ng-if="!$ctrl.user.active"
            ng-click="activateUser.show()"
            name="activateUser"
            vn-acl="itManagement"
            vn-acl-action="remove"
            translate>
            Activate user
        </vn-item>
        <vn-item
            ng-if="$ctrl.user.active"
            ng-click="deactivateUser.show()"
            name="deactivateUser"
            vn-acl="itManagement"
            vn-acl-action="remove"
            translate>
            Deactivate user
        </vn-item>
        <vn-item
            ng-click="syncUser.show()"
            name="synchronizeUser"
            vn-acl="it"
            vn-acl-action="remove"
            translate>
            Synchronize
        </vn-item>
    </slot-menu>
    <slot-body>
        <div class="attributes">
            <vn-label-value
                label="User"
                value="{{$ctrl.user.name}}">
            </vn-label-value>
            <vn-label-value
                label="Role"
                value="{{$ctrl.user.role.name}}">
            </vn-label-value>
        </div>
        <div class="icons">
            <vn-icon
                vn-tooltip="User deactivated"
                icon="icon-disabled"
                ng-if="!$ctrl.user.active">
            </vn-icon>
            <vn-icon
                vn-tooltip="Account enabled"
                icon="contact_mail"
                ng-if="$ctrl.hasAccount">
            </vn-icon>
        </div>
    </slot-body>
</vn-descriptor-content>
<vn-confirm
    vn-id="deleteUser"
    on-accept="$ctrl.onDelete()"
    question="Are you sure you want to continue?"
    message="User will be removed">
</vn-confirm>
<vn-confirm
    vn-id="enableAccount"
    on-accept="$ctrl.onEnableAccount()"
    question="Are you sure you want to continue?"
    message="Account will be enabled">
</vn-confirm>
<vn-confirm
    vn-id="disableAccount"
    on-accept="$ctrl.onDisableAccount()"
    question="Are you sure you want to continue?"
    message="Account will be disabled">
</vn-confirm>
<vn-confirm
    vn-id="activateUser"
    on-accept="$ctrl.onSetActive(true)"
    question="Are you sure you want to continue?"
    message="User will activated">
</vn-confirm>
<vn-confirm
    vn-id="deactivateUser"
    on-accept="$ctrl.onSetActive(false)"
    question="Are you sure you want to continue?"
    message="User will be deactivated">
</vn-confirm>
<vn-dialog
    vn-id="changePass"
    on-accept="$ctrl.onPassChange()"
    on-close="$ctrl.onPassClose()">
    <tpl-body>
        <vn-textfield
            ng-if="$ctrl.askOldPass"
            label="Old password"
            ng-model="$ctrl.oldPassword"
            type="password"
            vn-focus>
        </vn-textfield>
        <vn-textfield
            label="New password"
            ng-model="$ctrl.newPassword"
            type="password"
            info="{{'Password requirements' | translate:$ctrl.passRequirements}}"
            vn-focus>
        </vn-textfield>
        <vn-textfield
            label="Repeat password"
            ng-model="$ctrl.repeatPassword"
            type="password">
        </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>
<vn-dialog
    vn-id="syncUser"
    on-accept="$ctrl.onSync()"
    on-close="$ctrl.onSyncClose()">
    <tpl-title translate>
        Do you want to synchronize user?
    </tpl-title>
    <tpl-body>
        <vn-check
            label="Synchronize password"
            ng-model="$ctrl.shouldSyncPassword"
            info="If password is not specified, just user attributes are synchronized"
            vn-focus>
        </vn-check>
        <vn-textfield
            label="Password"
            ng-model="$ctrl.syncPassword"
            type="password"
            ng-if="$ctrl.shouldSyncPassword">
        </vn-textfield>
    </tpl-body>
    <tpl-buttons>
        <input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/>
        <button response="accept" translate>Synchronize</button>
    </tpl-buttons>
</vn-dialog>
<vn-popup vn-id="summary">
    <vn-user-summary user="$ctrl.user"></vn-user-summary>
</vn-popup>