diff --git a/dt-core/utilities/dt-components.php b/dt-core/utilities/dt-components.php
index 307dc692f..bb77fe4f2 100644
--- a/dt-core/utilities/dt-components.php
+++ b/dt-core/utilities/dt-components.php
@@ -67,6 +67,7 @@ public static function shared_attributes( $field_key, $fields, $post, $params =
$shared_attributes = '
id="' . esc_attr( $display_field_id ) . '"
name="' . esc_attr( $field_key ) . '"
+ placeholder="' . esc_attr( $params['placeholder'] ?? '' ) . '"
' . $class . '
' . $label_attr . '
' . esc_html( $post_type ?? '' ) . '
diff --git a/dt-users/template-new-user.php b/dt-users/template-new-user.php
index 55b673d06..9c6a41043 100644
--- a/dt-users/template-new-user.php
+++ b/dt-users/template-new-user.php
@@ -90,36 +90,55 @@
-
-
- -
-
-
-
+
+ [
+ 'name' => __( 'Contact to make a user (optional)', 'disciple_tools' ),
+ 'default' => '',
+ 'type' => 'connection',
+ 'post_type' => 'contacts',
+ ]
+ ], [], [ 'placeholder' => __( 'Search multipliers and contacts', 'disciple_tools' ) ] ) ?>
+
-
-
- -
-
- -
+
+ [
+ 'name' => __( 'Display Name', 'disciple_tools' ),
+ 'type' => 'text',
+ 'default' => '',
+ ]
+ ], [], [ 'placeholder' => __( 'Nickname (Display Name)', 'disciple_tools' ) ] ) ?>
+
+
+ [
+ 'name' => __( 'Email', 'disciple_tools' ),
+ 'type' => 'text',
+ 'default' => '',
+ 'required' => true,
+ ]
+ ], [], [ 'placeholder' => __( 'Email', 'disciple_tools' ) ] ) ?>
+
-
-
-
-
-
-
+
+ [
+ 'name' => __( 'Username', 'disciple_tools' ),
+ 'type' => 'text',
+ 'default' => '',
+ ]
+ ], [], [ 'placeholder' => __( 'Username', 'disciple_tools' ) ] ) ?>
+
+
+ [
+ 'name' => __( 'Password', 'disciple_tools' ),
+ 'type' => 'text',
+ 'default' => '',
+ ]
+ ], [], [ 'placeholder' => __( 'Password', 'disciple_tools' ) ] ) ?>
+
@@ -131,11 +150,10 @@
-
-
+
+
-
- -
+
-
-
+
+ [
+ 'name' => __( 'Last Name (optional)', 'disciple_tools' ),
+ 'type' => 'text',
+ 'default' => '',
+ ]
+ ], [], [ 'placeholder' => __( 'Last Name', 'disciple_tools' ) ] ) ?>
+
+
+ [
+ 'name' => __( 'Gender (optional)', 'disciple_tools' ),
+ 'type' => 'key_select',
+ 'default' => $gender_fields['default'],
+ ]
+ ], [], [] ) ?>
+
+
+
-
-
-
-
-
+
+ [
+ 'name' => $dt_field['label'],
+ 'type' => 'text',
+ 'default' => '',
+ ]
+ ], [], [ 'placeholder' => $dt_field['label'], 'data-optional' => true ] ) ?>
+
+
+
+
@@ -300,4 +320,10 @@ class="input"
+
+
diff --git a/dt-users/template-user-management.php b/dt-users/template-user-management.php
index bd81da38d..bc895894a 100644
--- a/dt-users/template-user-management.php
+++ b/dt-users/template-user-management.php
@@ -9,6 +9,7 @@
$dt_url_path = dt_get_url_path();
$dt_user_fields = Disciple_Tools_Users::get_users_fields();
$default_user_roles = Disciple_Tools_Roles::get_dt_roles_and_permissions();
+$gender_fields = DT_Posts::get_post_settings( 'contacts' )['fields']['gender'];
?>
@@ -101,40 +102,47 @@
-
-
+
+ [
+ 'name' => __( 'User Status', 'disciple_tools' ),
+ 'type' => 'key_select',
+ 'default' => $dt_user_fields['user_status']['options'],
+ 'select_cannot_be_empty' => true,
+ ]
+ ], [ 'key_select' => [ 'key' => 'active' ] ], [] ) ?>
+
-
-
+
+ [
+ 'name' => __( 'Workload Status', 'disciple_tools' ),
+ 'type' => 'key_select',
+ 'default' => $dt_user_fields['workload_status']['options'],
+ 'select_cannot_be_empty' => true,
+ ]
+ ], [ 'key_select' => [ 'key' => 'active' ] ], [ 'key_select' => [ 'disable_color' => true ] ] ) ?>
+
-
- [
- 'name' => __( 'Location Responsibility', 'disciple_tools' ),
- 'type' => 'location_meta',
- ]
- ], null ) ?>
-
- [
- 'name' => __( 'Location Responsibility', 'disciple_tools' ),
- 'type' => 'location',
- ]
- ], null ) ?>
-
+
+
+ [
+ 'name' => __( 'Location Responsibility', 'disciple_tools' ),
+ 'type' => 'location_meta',
+ ]
+ ], null ) ?>
+
+ [
+ 'name' => __( 'Location Responsibility', 'disciple_tools' ),
+ 'type' => 'location',
+ ]
+ ], null ) ?>
+
+
@@ -222,19 +230,24 @@ class="dt_multi_select empty-select-button select-button button ">
:
-
-
-
-
-
-
-
-
-
+
+ [
+ 'name' => __( 'Display Name', 'disciple_tools' ),
+ 'type' => 'text',
+ 'default' => '',
+ ]
+ ], [], [ 'placeholder' => __( 'Display Name', 'disciple_tools' ) ] ) ?>
+
+
+ [
+ 'name' => __( 'Gender', 'disciple_tools' ),
+ 'type' => 'key_select',
+ 'default' => $gender_fields['default'],
+ ]
+ ], [], [] ) ?>
+
continue;
}
?>
-
-
-
-
-
+
+ [
+ 'name' => $dt_field['label'],
+ 'type' => 'text',
+ 'default' => '',
+ 'data-optional' => true,
+ ]
+ ], [], [ 'placeholder' => $dt_field['label'] ] ) ?>
+
-
-
-
-
-
-
-
+
+ [
+ 'name' => __( 'Biography', 'disciple_tools' ),
+ 'type' => 'textarea',
+ 'default' => '',
+ 'data-optional' => true,
+ ]
+ ], [], [ 'placeholder' => __( 'Biography', 'disciple_tools' ), 'rows' => 5 ] ) ?>
+
@@ -482,4 +487,10 @@ class="input text-input"
+
+
diff --git a/dt-users/user-management.js b/dt-users/user-management.js
index e58c14595..4f5f0cb51 100644
--- a/dt-users/user-management.js
+++ b/dt-users/user-management.js
@@ -97,6 +97,13 @@ jQuery(document).ready(function ($) {
$('#status-select').val('');
$('#workload-select').val('');
+ // Reset form components
+ document.getElementById('update_display_name').reset();
+ document.getElementById('gender').reset();
+ document.getElementById('description').reset();
+ document.getElementById('user_status').reset();
+ document.getElementById('workload_status').reset();
+
// Determine if provision for magic link apps should be made.
const user_apps = get_magic_link_apps();
if (user_apps) {
@@ -539,8 +546,8 @@ jQuery(document).ready(function ($) {
${window.SHAREDFUNCTIONS.escapeHTML(magic_link['label'])}
-
@@ -567,7 +574,7 @@ jQuery(document).ready(function ($) {
$('#magic_link_apps_spinner').hide();
}
- $(document).on('click', '.app-state-switches', function (e) {
+ $(document).on('change', '.app-state-switches', function (e) {
const app_state = $(e.target);
switch_magic_link_app_state(
$(app_state).data('user_id'),
@@ -765,27 +772,35 @@ jQuery(document).ready(function ($) {
);
};
- $('textarea.text-input, input.text-input').change(function () {
- const id = $(this).attr('id');
- const val = $(this).val();
- $(`#${id}-spinner`).addClass('active');
- update_user(window.current_user_lookup, id, val).then(() => {
- $(`#${id}-spinner`).removeClass('active');
- });
- });
- $('select.select-field').change((e) => {
- const id = $(e.currentTarget).attr('id');
- const val = $(e.currentTarget).val();
- $(`#${id}-spinner`).addClass('active');
+ $('dt-textarea, dt-text').change(function () {
+ if (window.current_user_lookup) {
+ const id = $(this).attr('id');
+ const val = $(this).val();
- update_user(window.current_user_lookup, id, val).then(() => {
- $(`#${id}-spinner`).removeClass('active');
- });
+ document.getElementById(id)?.setAttribute('loading', true);
+
+ update_user(window.current_user_lookup, id, val).then(() => {
+ document.getElementById(id)?.removeAttribute('loading');
+ document.getElementById(id)?.setAttribute('saved', true);
+ });
+ }
+ });
+ $('select.select-field, dt-single-select').change((e) => {
+ if (window.current_user_lookup) {
+ const id = $(e.currentTarget).attr('id');
+ const val = $(e.currentTarget).val();
+ document.getElementById(id)?.setAttribute('loading', true);
+
+ update_user(window.current_user_lookup, id, val).then(() => {
+ document.getElementById(id)?.removeAttribute('loading');
+ document.getElementById(id)?.setAttribute('saved', true);
+ });
+ }
});
$('button.dt_multi_select').on('click', function () {
let fieldKey = $(this).data('field-key');
let optionKey = $(this).attr('id');
- $(`#${fieldKey}-spinner`).addClass('active');
+ document.getElementById(fieldKey)?.setAttribute('loading', true);
let field = $(`[data-field-key="${fieldKey}"]#${optionKey}`);
field.addClass('submitting-select-button');
let action = 'add';
@@ -815,7 +830,7 @@ jQuery(document).ready(function ($) {
? 'empty-select-button'
: 'selected-select-button',
);
- $(`#${fieldKey}-spinner`).removeClass('active');
+ document.getElementById(fieldKey)?.removeAttribute('loading');
})
.catch((err) => {
field.removeClass('submitting-select-button selected-select-button');
@@ -1015,6 +1030,13 @@ jQuery(document).ready(function ($) {
}
function write_add_user() {
+ const componentService = new window.DtWebComponents.ComponentService(
+ 'users',
+ window.current_user_lookup,
+ window.wpApiShare.nonce,
+ );
+ componentService.attachLoadEvents();
+
const showOptionsButton = $('#show-hidden-fields');
const hideOptionsButton = $('#hide-hidden-fields');
const hiddenFields = $('.hidden-fields');
@@ -1083,12 +1105,12 @@ jQuery(document).ready(function ($) {
});
let create_user = (corresponds_to_contact, archive_comments = false) => {
- let name = $('#eman').val();
+ let name = $('#emankcin').val();
let email = $('#liame').val();
let locale = $('#locale').val();
const username = $('#emanresu').val();
- const password = $('#drowssap').val();
+ const password = $('#ddrowssap').val();
const optionalFields = document.querySelectorAll('[data-optional=""]');
const optionalValues = {};
@@ -1200,6 +1222,7 @@ jQuery(document).ready(function ($) {
});
}
+ // subassigned check here
['subassigned'].forEach((field_id) => {
$.typeahead({
input: `.js-typeahead-${field_id}`,
@@ -1249,12 +1272,16 @@ jQuery(document).ready(function ($) {
}
function write_language_dropdown(translations, default_language) {
- let select = '';
- return select;
+
+ return ``;
}
});
|