From 3151085f26ad7abe06c261299cc34ad7074657b3 Mon Sep 17 00:00:00 2001 From: matteo Date: Thu, 8 Jun 2023 17:03:42 +0200 Subject: [PATCH 1/4] add articles attribute to group model --- app/models/group.js | 1 + app/templates/groups/show.hbs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/group.js b/app/models/group.js index 112352a8d..826928802 100644 --- a/app/models/group.js +++ b/app/models/group.js @@ -17,6 +17,7 @@ export default class Group extends Model { // Relations @hasMany memberships; @hasMany permissions; + @hasMany articles; @hasMany({ inverse: 'group' }) mailAliases; @hasMany('mail-alias', { inverse: 'moderatorGroup' }) moderatorForMailAliases; diff --git a/app/templates/groups/show.hbs b/app/templates/groups/show.hbs index 7f4ed485f..09cd1664b 100644 --- a/app/templates/groups/show.hbs +++ b/app/templates/groups/show.hbs @@ -77,7 +77,7 @@ - +
From 2dccf1a2cb8bd7d56e3ebec240cbd5d30189bb29 Mon Sep 17 00:00:00 2001 From: DrumsnChocolate Date: Tue, 14 Nov 2023 12:35:34 +0100 Subject: [PATCH 2/4] rework tab visibility logic a bit to allow for more readability and extensibility --- .../application/group-memberships.js | 51 ++++++++++++------- app/templates/groups/group/index.hbs | 12 ++--- app/templates/users/user/groups.hbs | 12 ++--- 3 files changed, 44 insertions(+), 31 deletions(-) diff --git a/app/controllers/application/group-memberships.js b/app/controllers/application/group-memberships.js index 473d8832c..89bb5c2ac 100644 --- a/app/controllers/application/group-memberships.js +++ b/app/controllers/application/group-memberships.js @@ -5,21 +5,30 @@ import moment from 'moment'; import { tracked } from '@glimmer/tracking'; export default class GroupMembershipsController extends Controller { + currentMembershipsTab = 'currentMemberships'; + oldMembershipsTab = 'oldMemberships'; @tracked sortedAttribute = null; @tracked sortedAscending = true; @tracked filter = ''; - @tracked oldMembershipsAreVisible = false; + @tracked selectedTab = this.currentMembershipsTab; get models() { return this.model.memberships; } + get selectedModels() { + if (this.currentMembershipsSelected) { + return this.currentMemberships; + } + if (this.oldMembershipsSelected) { + return this.oldMemberships; + } + return []; + } + get filteredModels() { - const records = this.oldMembershipsAreVisible - ? this.oldMemberships - : this.currentMemberships; - return this.sortModels(this.filterModels(records)); + return this.sortModels(this.filterModels(this.selectedModels)); } get oldMemberships() { @@ -34,26 +43,30 @@ export default class GroupMembershipsController extends Controller { ); } - get oldMembershipsTabActive() { - return this.oldMembershipsAreVisible - ? !( - this.oldMemberships.length === 0 && this.currentMemberships.length > 0 - ) - : this.currentMemberships.length === 0 && this.oldMemberships.length > 0; + get currentMembershipsExist() { + return this.currentMemberships.length > 0; + } + + get oldMembershipsExist() { + return this.oldMemberships.length > 0; + } + + get currentMembershipsSelected() { + return this.selectedTab === this.currentMembershipsTab; + } + + get oldMembershipsSelected() { + return this.selectedTab === this.oldMembershipsTab; } @action - showOldMemberships() { - if (this.oldMemberships.length > 0) { - this.oldMembershipsAreVisible = true; - } + selectOldMemberships() { + this.selectedTab = this.oldMembershipsTab; } @action - hideOldMemberships() { - if (this.currentMemberships.length > 0) { - this.oldMembershipsAreVisible = false; - } + selectCurrentMemberships() { + this.selectedTab = this.currentMembershipsTab; } @action diff --git a/app/templates/groups/group/index.hbs b/app/templates/groups/group/index.hbs index 582d92b9a..5b8c6af61 100644 --- a/app/templates/groups/group/index.hbs +++ b/app/templates/groups/group/index.hbs @@ -46,9 +46,9 @@