Skip to content

Commit

Permalink
Show assigned to display names in filters.
Browse files Browse the repository at this point in the history
  • Loading branch information
corsac committed Apr 14, 2018
1 parent f67e13b commit 7165e65
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions dt-assets/js/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,12 +300,17 @@
}



let users = {}
function countFilteredItems() {
const counts = {};
let currentView = $(".js-list-view:checked").val()
if (wpApiSettings.current_post_type === "contacts") {
const contacts = items.filter(viewFilterFunctions[currentView])
contacts.forEach(c=>{
if (!users[_.get(c, "assigned_to.user_login")]){
users[_.get(c, "assigned_to.user_login")] = _.get(c, "assigned_to.name")
}
})
_.assign(counts, {
assigned_login: _.countBy(_(contacts).map('assigned_to.user_login').filter().value()),
overall_status: _.countBy(_.map(contacts, 'overall_status')),
Expand Down Expand Up @@ -379,14 +384,16 @@
humanText = ccfs[filterType].default[key];
} else if (wpApiSettings.current_post_type === 'contacts' && filterType === 'requires_update') {
humanText = key === "true" ? wpApiSettings.txt_yes : wpApiSettings.txt_no;
} else if (wpApiSettings.current_post_type === 'contacts' && filterType === 'assigned_login') {
humanText = users[key]
} else if (wpApiSettings.current_post_type === 'groups' && (filterType === 'group_status' || filterType === 'group_type')) {
humanText = gcfs[filterType].default[key];
} else {
humanText = key;
}
const checkbox = $("<input>")
.attr("type", "checkbox")
.val(humanText)
.val(key)
.on("change", function() {
updateFilterFunctions();
dataTable.draw();
Expand Down
2 changes: 1 addition & 1 deletion dt-assets/parts/contact-details.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function dt_contact_details_edit( $id, $field_type, $remove = false ) {
</section>
<?php } ?>

<?php if ( isset( $contact['is_a_user']['key'] ) && $contact['is_a_user']['key'] === 'yes' ) { ?>
<?php if ( isset( $contact['type']['key'] ) && $contact['type']['key'] === 'user' ) { ?>
<section class="cell accept-contact" id="contact-is-user">
<div class="bordered-box">
<h4><?php esc_html_e( 'This contact represents a user.', 'disciple_tools' )?></h4>
Expand Down

0 comments on commit 7165e65

Please sign in to comment.