From 8bf599530b2b8bcfc2db9e1cdbf465feb474eee7 Mon Sep 17 00:00:00 2001 From: David Canas Date: Thu, 4 Aug 2016 13:02:33 -0700 Subject: [PATCH] Added search funcitonality to roster --- .../management/assets/src/vue/user-roster.vue | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/kolibri/plugins/management/assets/src/vue/user-roster.vue b/kolibri/plugins/management/assets/src/vue/user-roster.vue index 93014928435..b8d26d82243 100644 --- a/kolibri/plugins/management/assets/src/vue/user-roster.vue +++ b/kolibri/plugins/management/assets/src/vue/user-roster.vue @@ -19,8 +19,8 @@ + -
@@ -74,7 +74,7 @@ - +
@@ -94,14 +94,17 @@ // Has to be a funcion due to vue's treatment of data data: () => ({ roleFilter: '', - search: '', + searchFilter: '', }), computed: { visibleUsers() { return this.users.filter((user) => { const roleFilter = this.roleFilter; + const searchFilter = new RegExp(this.searchFilter, 'i'); + const names = [user.first_name, user.last_name, user.username]; + let hasRole = true; - const hasName = true; + let hasName = true; // check for filters if (roleFilter !== 'all') { @@ -120,8 +123,19 @@ } } - // check for search phrase + // makes sure there's text in the search box + if (this.searchFilter) { + hasName = false; + // check for searchFilter phrase in user's names + for (const name of names) { + if (searchFilter.test(name)) { + hasName = true; + } + } + } + + // determines whether name should be on list return hasRole && hasName; }); }, @@ -168,7 +182,7 @@ border-radius: 10px padding: inherit border: 1px solid #686868 - + select[name='user-filter'] float: left @@ -211,7 +225,7 @@ padding-left: 1em padding-right: 1em border-radius: 40px - + .search-button width: 20px height: 20px