From a472f078e236dfcf7dafcb9c1e4488f0baffc02e Mon Sep 17 00:00:00 2001 From: Alfredo Sumaran Date: Wed, 24 May 2017 21:04:31 -0500 Subject: [PATCH] Remove parent group prefix from current orphan group [ci skip] --- .../groups/components/group_folder.vue | 6 +++- .../groups/components/group_item.vue | 33 +++++++++++++++++-- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/groups/components/group_folder.vue b/app/assets/javascripts/groups/components/group_folder.vue index b393a922ad7..b99186a005e 100644 --- a/app/assets/javascripts/groups/components/group_folder.vue +++ b/app/assets/javascripts/groups/components/group_folder.vue @@ -5,6 +5,10 @@ export default { type: Object, required: true, }, + baseGroup: { + type: Object, + required: false, + }, }, computed: { hasGroups() { @@ -16,6 +20,6 @@ export default { diff --git a/app/assets/javascripts/groups/components/group_item.vue b/app/assets/javascripts/groups/components/group_item.vue index 6d50f44f7dd..0c54c8d82ce 100644 --- a/app/assets/javascripts/groups/components/group_item.vue +++ b/app/assets/javascripts/groups/components/group_item.vue @@ -7,6 +7,10 @@ export default { type: Object, required: true, }, + baseGroup: { + type: Object, + required: false, + }, }, methods: { toggleSubGroups(e) { @@ -31,6 +35,31 @@ export default { isExpandable() { return Object.keys(this.group.subGroups).length > 0; }, + fullPath() { + let fullPath = ''; + + if (this.group.isOrphan) { + // check if current group is baseGroup + if (this.baseGroup) { + // Remove baseGroup prefix from our current group.fullName. e.g: + // baseGroup.fullName: `level1` + // group.fullName: `level1 / level2 / level3` + // Result: `level2 / level3` + const gfn = this.group.fullName; + const bfn = this.baseGroup.fullName; + const length = bfn.length; + const start = gfn.indexOf(bfn); + + fullPath = gfn.substr(start + length + 2); + } else { + fullPath = this.group.fullName; + } + } else { + fullPath = this.group.name; + } + + return fullPath; + }, }, }; @@ -92,13 +121,13 @@ export default {
- {{group.isOrphan ? group.fullName : group.name}} + {{fullPath}}
{{group.description}}
- +