uadmin icon indicating copy to clipboard operation
uadmin copied to clipboard

question about relations and admin GUI

Open blinkinglight opened this issue 9 months ago • 0 comments

hey, i am trying to make simple "issue tracker" user has many projects issue belongs to project

problem is that in issue, Project "has many" shows all projects and i cant find where i can filter choises out. this only works in Projects to filter out but not for Project selection in issue.

projects.ListModifier = func(s *uadmin.ModelSchema, u *uadmin.User) (string, []interface{}) {

		var userProject []models.UserProject

		uadmin.Filter(&userProject, "user_id = ?", u.ID)
		var ids []uint
		for _, v := range userProject {
			ids = append(ids, v.ProjectID)
		}

		if !u.Admin {
			return "id in (?)", []interface{}{ids}
		}
		return "", []interface{}{}
	}
	```

blinkinglight avatar Nov 05 '23 07:11 blinkinglight