# You must use a tab-size of 4 spaces to edit this file.
---
zenario_user__change_password:
    priv: _PRIV_VIEW_USER
    key:
        id: ""
    identifier:
        css_class: user
        label: User ID
    tabs:
        details:
            label: Details
            edit_mode:
                priv: _PRIV_EDIT_USER
                enabled: Yes
            fields:
                desc:
                    snippet:
                        html: |
                            <div class="zenario_fbInfo">
                                <p>Passwords are 1-way encrypted. They can be changed but not read from the database.</p>

                                <p>If a user cannot log in, they should use a page containing a password-reset plugin to request a new password via email. Alternatively, you may set a new password for them.</p>
                            </div>
                status:
                    type: hidden
                    hidden: true
                #The 3 columns below are required for the ze\userAdm::save() function.
                first_name:
                    type: hidden
                    hidden: true
                last_name:
                    type: hidden
                    hidden: true
                screen_name:
                    type: hidden
                    hidden: true
                change_password:
                    dataset_label: '[Change password toggle]'
                    priv: _PRIV_EDIT_USER
                    type: toggle
                    redraw_onchange: true
                    post_field_label: Set a new password
                    visible_if: |
                        zenarioAB.tuix.key.id
                        && zenarioAB.value('status', 'details')
                        && zenarioAB.value('status', 'details') != 'contact'
                password:
                    label: "Password:"
                    type: password
                    visible_if: |
                        (zenarioAB.value('change_password', 'details') == 1)
                        && zenarioAB.value('status', 'details')
                        && zenarioAB.value('status', 'details') != 'contact'
                    
                    # This is a little hack to try and stop Google Chrome auto-filling a username and password in here
                    # http://stackoverflow.com/questions/15738259/disabling-chrome-autofill
                    autocomplete: "off_yes_really_i_want_this_off"
                    oninput: |
                        var adminFacing = true;
                        zenarioP.updatePasswordNotifier(
                            '#password',
                            {
                                min_extranet_user_password_length: lib.tuix.key.min_extranet_user_password_length,
                                min_extranet_user_password_score: lib.tuix.key.min_extranet_user_password_score
                            },
                            '#snippet_password_message',
                            adminFacing
                        );
                        
                    pre_field_html: |
                        <input type="text" name="dummy_username" autocomplete="off_yes_really_i_want_this_off" tabindex="-1" style="
                            position: fixed;
                            top: -1000px;
                            width: 1px;
                            height: 1px;
                        "/>
                        <input type="password" name="dummy_password" autocomplete="off_yes_really_i_want_this_off" tabindex="-1" style="
                            position: fixed;
                            top: -1000px;
                            width: 1px;
                            height: 1px;
                        "/>
                reveal_password:
                    same_row: true
                    visible_if: |
                        (zenarioAB.value('change_password', 'details') == 1)
                        && zenarioAB.value('status', 'details')
                        && zenarioAB.value('status', 'details') != 'contact'
                    value: Reveal
                    dataset_label: '[Reveal password button]'
                    type: toggle
                    onclick: |
                        var fields = zenarioAB.tuix.tabs.details.fields,
                            passwordEl = zenario.get('password'),
                            passwordField = fields.password,
                            revealEl = zenario.get('reveal_password'),
                            revealField = fields.reveal_password,
                            previouslyPressed = zenarioAB.value('reveal_password', 'details');
                    
                        if (passwordEl && revealEl) {
                            passwordEl.type = 
                            passwordField.type =
                                previouslyPressed? 'password' : 'text';
                            
                            revealEl.value =
                            revealField.current_value =
                                previouslyPressed? 'Reveal' : 'Hide';
                        }
                suggest_password:
                    same_row: true
                    visible_if: |
                        (zenarioAB.value('change_password', 'details') == 1)
                        && zenarioAB.value('status', 'details')
                        && zenarioAB.value('status', 'details') != 'contact'
                    dataset_label: '[Suggest password button]'
                    snippet:
                        html: |
                            <input type="button" value="Suggest" onclick="
                                zenario.ajax('zenario/admin/quick_ajax.php', {password_suggestion: 1}, false, false).after(function(password) {
                                    var passwordEl;
                                    if (passwordEl = zenario.get('password')) {
                                        passwordEl.value = password;
                                    }
                                
                                    $('#password').trigger('oninput');
                                });
                            "/>
                password_message:
                    indent: 1
                    visible_if: |
                        (zenarioAB.value('change_password', 'details') == 1)
                        && zenarioAB.value('status', 'details')
                        && zenarioAB.value('status', 'details') != 'contact'
                    post_field_html: |
                        <div>
                            <span id="snippet_password_message" class="title_red">Password does not match the requirements</span>
                        </div>
                password_needs_changing:
                    priv: _PRIV_EDIT_USER
                    visible_if: |
                        zenarioAB.value('status', 'details')
                        && zenarioAB.value('status', 'details') != 'contact'
                    label: "User must change password on next login"
                    type: checkbox
                    side_note: "When the extranet user next logs in to the site, they will be asked to change their password before they can access the extranet area."
                send_password_reset_email_upon_save:
                    post_field_label: 'Send password reset email upon save'
                    dataset_label: '[Send password reset email toggle]'
                    type: toggle
                    visible_if: |
                        zenarioAB.value('status', 'details')
                        && zenarioAB.value('status', 'details') != 'contact'
                    format_onchange: true
                password_reset_email:
                    indent: 1
                    label: 'Email template:'
                    pick_items:
                        path: zenario__email_template_manager/panels/email_templates
                        min_path: zenario__email_template_manager/panels/email_templates
                        max_path: zenario__email_template_manager/panels/email_templates
                        target_path: zenario__email_template_manager/panels/email_templates
                        select_phrase: Select email template...
                        hide_remove_button: Yes
                    validation:
                        required_if_not_hidden: Please select an email template
                    visible_if: lib.value('send_password_reset_email_upon_save')