diff --git a/backend/internal/data/repo/repo_locations.go b/backend/internal/data/repo/repo_locations.go index 32ecdb2..da4894f 100644 --- a/backend/internal/data/repo/repo_locations.go +++ b/backend/internal/data/repo/repo_locations.go @@ -19,8 +19,9 @@ type LocationRepository struct { type ( LocationCreate struct { - Name string `json:"name"` - Description string `json:"description"` + Name string `json:"name"` + ParentID uuid.UUID `json:"parentId" extensions:"x-nullable"` + Description string `json:"description"` } LocationUpdate struct { @@ -170,11 +171,18 @@ func (r *LocationRepository) GetOneByGroup(ctx context.Context, GID, ID uuid.UUI } func (r *LocationRepository) Create(ctx context.Context, GID uuid.UUID, data LocationCreate) (LocationOut, error) { - location, err := r.db.Location.Create(). + q := r.db.Location.Create(). SetName(data.Name). SetDescription(data.Description). - SetGroupID(GID). - Save(ctx) + SetGroupID(GID) + + println(data.ParentID.String()) + if data.ParentID != uuid.Nil { + println("SET PARENT") + q.SetParentID(data.ParentID) + } + + location, err := q.Save(ctx) if err != nil { return LocationOut{}, err diff --git a/frontend/components/Location/CreateModal.vue b/frontend/components/Location/CreateModal.vue index 3503a0d..91778d3 100644 --- a/frontend/components/Location/CreateModal.vue +++ b/frontend/components/Location/CreateModal.vue @@ -10,6 +10,13 @@ label="Location Name" /> + @@ -18,6 +25,8 @@