File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -174,6 +174,35 @@ func (g *Group) ShortName(length int) string {
174174 return util .EllipsisDisplayString (g .Name , length )
175175}
176176
177+ // Depth retrieves the depth/nesting level of this group
178+ func (g * Group ) Depth (ctx context.Context ) (d int ) {
179+ err := g .LoadParentGroup (ctx )
180+ if err != nil {
181+ return 0
182+ }
183+ pg := g .ParentGroup
184+ for {
185+ if pg == nil {
186+ break
187+ }
188+ if pg .ParentGroup == nil {
189+ err = pg .LoadParentGroup (ctx )
190+ if err != nil {
191+ return 0
192+ }
193+ }
194+ d ++
195+ pg = pg .ParentGroup
196+ }
197+ return
198+ }
199+
200+ // DisplayLeftMargin generates a value for the left margin
201+ // displayed on the frontend beside this group
202+ func (g * Group ) DisplayLeftMargin (ctx context.Context ) string {
203+ return fmt .Sprintf ("%drem" , g .Depth (ctx )+ 1 )
204+ }
205+
177206func GetGroupByID (ctx context.Context , id int64 ) (* Group , error ) {
178207 group := new (Group )
179208
You can’t perform that action at this time.
0 commit comments