# You must use a tab-size of 4 spaces to edit this file.
---
zenario_user__convert_to_user:
    priv: _PRIV_EDIT_USER
    key:
        id: ""
    tabs:
        details:
            label: Details for user account
            edit_mode:
                enabled: Yes
            fields:
                activate_user_info:
                    ord: 1
                    full_width: 1
                    snippet:
                        html: "You are about to convert this contact into an active user, so they will be able to log into this site's password-protected area."
                email: 
                    label: "Email:"
                    type: text
                    readonly: true
                    format_onchange: Yes
                salutation: 
                    label: "Salutation:"
                    type: text
                    readonly: true
                first_name: 
                    label: "First name:"
                    type: text
                    readonly: true
                last_name: 
                    label: "Last name:"
                    type: text
                    readonly: true
                screen_name: 
                    label: "Screen name:"
                    type: text
                    maxlength: 50
                suggest_screen_name:
                    same_row: true
                    dataset_label: '[Suggest screen name button]'
                    snippet:
                        html: |
                            <input type="button" value="Suggest" onclick="
                                    screen_name_field = zenarioAB.get('screen_name');
                                    if (screen_name_field) {
                                        screen_name_field.value = zenario.nonAsyncAJAX('zenario/admin/quick_ajax.php', {screen_name_suggestion: 1, first_name: zenarioAB.get('first_name').value, last_name: zenarioAB.get('last_name').value, email: zenarioAB.get('email').value}, false, false);
                                    }
                            "/>
                password:
                    label: "Password:"
                    type: password
                    validation:
                        required: "Please enter a password, or click Suggest to have one auto-generated."
                reveal_password:
                    same_row: true
                    value: Reveal
                    dataset_label: '[Reveal password button]'
                    type: toggle
                    onclick: |
                        var fields = zenarioAB.tuix.tabs.details.fields,
                            passwordEl = zenarioAB.get('password'),
                            passwordField = fields.password,
                            revealEl = zenarioAB.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
                    dataset_label: '[Suggest password button]'
                    snippet:
                        html: |
                            <input type="button" value="Suggest" onclick="
                                var password = zenario.nonAsyncAJAX('zenario/admin/quick_ajax.php', {password_suggestion: 1}, false, false),
                                    passwordEl;
                            
                                if (passwordEl = zenarioAB.get('password')) {
                                    passwordEl.value = password;
                                }
                            "/>
                password_needs_changing:
                    priv: _PRIV_EDIT_USER
                    label: "Ask user to change their password on next login"
                    type: checkbox
                terms_and_conditions_accepted:
                    label: "Has accepted terms and conditions"
                    note_below: "This indicates if the user or contact has accepted the site's terms and conditions (recorded in the consent log when a user/contact signs up themself). If using Newsletters in Zenario, they will only be sent to recipients where this is checked."

                    type: checkbox
                send_activation_email_to_user:
                    label: 'Send email to user with login details'
                    type: checkbox
                    format_onchange: Yes
                    hidden: false
                email_to_send:
                    label: 'Email template:'
                    indent: 1
                    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: |
                        zenarioAB.value('send_activation_email_to_user', 'details')
                    side_note: >
                        An email based on the selected Email Template will be sent
                        to the User.
