This is an automated email from the ASF dual-hosted git repository. machristie pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/airavata-django-portal.git
commit aeac6687686391869ba36298d784d5a9d96b5e39 Author: Marcus Christie <[email protected]> AuthorDate: Wed Jul 10 12:38:39 2019 -0400 AIRAVATA-3100 Sorting new members first, highlighted --- django_airavata/apps/groups/package.json | 2 +- .../js/group_components/GroupMembersEditor.vue | 70 +++++++++++++++------- 2 files changed, 51 insertions(+), 21 deletions(-) diff --git a/django_airavata/apps/groups/package.json b/django_airavata/apps/groups/package.json index 7a87e5a..68958d2 100755 --- a/django_airavata/apps/groups/package.json +++ b/django_airavata/apps/groups/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "bootstrap": "^4.0.0-beta.2", - "bootstrap-vue": "^2.0.0-rc.11", + "bootstrap-vue": "^2.0.0-rc.26", "django-airavata-api": "file:../api", "django-airavata-common-ui": "file:../../static/common", "moment": "^2.18.1", diff --git a/django_airavata/apps/groups/static/django_airavata_groups/js/group_components/GroupMembersEditor.vue b/django_airavata/apps/groups/static/django_airavata_groups/js/group_components/GroupMembersEditor.vue index 092a6a1..dccd28c 100644 --- a/django_airavata/apps/groups/static/django_airavata_groups/js/group_components/GroupMembersEditor.vue +++ b/django_airavata/apps/groups/static/django_airavata_groups/js/group_components/GroupMembersEditor.vue @@ -14,6 +14,7 @@ :items="currentMembers" :fields="fields" sort-by="name" + :sort-compare="sortCompare" > <template slot="HEAD_role"> <div class="d-flex"> @@ -73,7 +74,8 @@ export default { }, data() { return { - userProfiles: null + userProfiles: null, + newMembers: [] }; }, computed: { @@ -87,24 +89,26 @@ export default { if (!this.userProfiles) { return []; } - return this.userProfiles - // Filter out current members - .filter( - userProfile => - this.group.members.indexOf(userProfile.airavataInternalUserId) < 0 - ) - .map(userProfile => { - return { - id: userProfile.airavataInternalUserId, - name: - userProfile.firstName + - " " + - userProfile.lastName + - " (" + - userProfile.userId + - ")" - }; - }); + return ( + this.userProfiles + // Filter out current members + .filter( + userProfile => + this.group.members.indexOf(userProfile.airavataInternalUserId) < 0 + ) + .map(userProfile => { + return { + id: userProfile.airavataInternalUserId, + name: + userProfile.firstName + + " " + + userProfile.lastName + + " (" + + userProfile.userId + + ")" + }; + }) + ); }, fields() { return [ @@ -148,7 +152,8 @@ export default { username: userProfile.userId, email: userProfile.email, role: isOwner ? "OWNER" : isAdmin ? "ADMIN" : "MEMBER", - editable: editable + editable: editable, + _rowVariant: this.newMembers.indexOf(m) >= 0 ? "success" : null }; }) ); @@ -176,6 +181,7 @@ export default { }, methods: { suggestionSelected(suggestion) { + this.newMembers.push(suggestion.id); this.$emit("add-member", suggestion.id); }, removeMember(item) { @@ -187,6 +193,30 @@ export default { } else { this.$emit("change-role-to-member", item.id); } + }, + sortCompare(aRow, bRow, key) { + // Sort new members before all others + const aNewIndex = this.newMembers.indexOf(aRow.id); + const bNewIndex = this.newMembers.indexOf(bRow.id); + if (aNewIndex >= 0 && bNewIndex >= 0) { + return aNewIndex - bNewIndex; + } else if (aNewIndex >= 0) { + return -1; + } else if (bNewIndex >= 0) { + return 1; + } + const a = aRow[key]; + const b = bRow[key]; + if ( + (typeof a === "number" && typeof b === "number") || + (a instanceof Date && b instanceof Date) + ) { + // If both compared fields are native numbers or both are dates + return a < b ? -1 : a > b ? 1 : 0; + } else { + // Otherwise stringify the field data and use String.prototype.localeCompare + return new String(a).localeCompare(new String(b)); + } } } };
