mirror of
https://github.com/sysadminsmedia/homebox.git
synced 2025-12-30 09:45:11 +01:00
Compare commits
2 Commits
tonya/conv
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b02b39c1b3 | ||
|
|
b290175bb0 |
8
.github/scripts/upgrade-test/README.md
vendored
8
.github/scripts/upgrade-test/README.md
vendored
@@ -7,7 +7,7 @@ This document describes the automated upgrade testing workflow for HomeBox.
|
||||
The upgrade test workflow is designed to ensure data integrity and functionality when upgrading HomeBox from one version to another. It automatically:
|
||||
|
||||
1. Deploys a stable version of HomeBox
|
||||
2. Creates test data (users, items, locations, tags, notifiers, attachments)
|
||||
2. Creates test data (users, items, locations, labels, notifiers, attachments)
|
||||
3. Upgrades to the latest version from the main branch
|
||||
4. Verifies all data and functionality remain intact
|
||||
|
||||
@@ -42,7 +42,7 @@ The workflow creates comprehensive test data using the `create-test-data.sh` scr
|
||||
- **Group 1**: Living Room, Garage
|
||||
- **Group 2**: Home Office
|
||||
|
||||
#### Tags
|
||||
#### Labels
|
||||
- **Group 1**: Electronics, Important
|
||||
- **Group 2**: Work Equipment
|
||||
|
||||
@@ -68,7 +68,7 @@ The workflow creates comprehensive test data using the `create-test-data.sh` scr
|
||||
The Playwright test suite (`upgrade-verification.spec.ts`) verifies:
|
||||
|
||||
- ✅ **User Authentication**: All 7 users can log in with their credentials
|
||||
- ✅ **Data Persistence**: All items, locations, and tags are present
|
||||
- ✅ **Data Persistence**: All items, locations, and labels are present
|
||||
- ✅ **Attachments**: File attachments are correctly associated with items
|
||||
- ✅ **Notifiers**: The "TESTING" notifier is still configured
|
||||
- ✅ **UI Functionality**: Version display, theme switching work correctly
|
||||
@@ -93,7 +93,7 @@ The setup script generates a JSON file at `/tmp/test-users.json` containing:
|
||||
"group1": ["location-id-1", "location-id-2"],
|
||||
"group2": ["location-id-3"]
|
||||
},
|
||||
"tags": {...},
|
||||
"labels": {...},
|
||||
"items": {...},
|
||||
"notifiers": {...}
|
||||
}
|
||||
|
||||
46
.github/scripts/upgrade-test/create-test-data.sh
vendored
46
.github/scripts/upgrade-test/create-test-data.sh
vendored
@@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Script to create test data in HomeBox for upgrade testing
|
||||
# This script creates users, items, attachments, notifiers, locations, and tags
|
||||
# This script creates users, items, attachments, notifiers, locations, and labels
|
||||
|
||||
set -e
|
||||
|
||||
@@ -128,19 +128,19 @@ create_location() {
|
||||
echo "$response"
|
||||
}
|
||||
|
||||
# Function to create a tag
|
||||
create_tag() {
|
||||
# Function to create a label
|
||||
create_label() {
|
||||
local token=$1
|
||||
local name=$2
|
||||
local description=$3
|
||||
|
||||
echo "Creating tag: $name" >&2
|
||||
echo "Creating label: $name" >&2
|
||||
|
||||
local response=$(curl -s -X POST \
|
||||
-H "Authorization: Bearer $token" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"name\":\"$name\",\"description\":\"$description\"}" \
|
||||
"$API_URL/tags")
|
||||
"$API_URL/labels")
|
||||
|
||||
echo "$response"
|
||||
}
|
||||
@@ -297,27 +297,27 @@ jq --arg loc1 "$location1_id" \
|
||||
'.locations = {"group1":[$loc1,$loc2],"group2":[$loc3]}' \
|
||||
"$TEST_DATA_FILE" > "$TEST_DATA_FILE.tmp" && mv "$TEST_DATA_FILE.tmp" "$TEST_DATA_FILE"
|
||||
|
||||
echo "=== Step 4: Create tags for each group ==="
|
||||
echo "=== Step 4: Create labels for each group ==="
|
||||
|
||||
# Create tags for group 1
|
||||
tag1=$(create_tag "$user1_token" "Electronics" "Electronic devices")
|
||||
tag1_id=$(echo "$tag1" | jq -r '.id // empty')
|
||||
echo "Created tag: Electronics (ID: $tag1_id)"
|
||||
# Create labels for group 1
|
||||
label1=$(create_label "$user1_token" "Electronics" "Electronic devices")
|
||||
label1_id=$(echo "$label1" | jq -r '.id // empty')
|
||||
echo "Created label: Electronics (ID: $label1_id)"
|
||||
|
||||
tag2=$(create_tag "$user1_token" "Important" "High priority items")
|
||||
tag2_id=$(echo "$tag2" | jq -r '.id // empty')
|
||||
echo "Created tag: Important (ID: $tag2_id)"
|
||||
label2=$(create_label "$user1_token" "Important" "High priority items")
|
||||
label2_id=$(echo "$label2" | jq -r '.id // empty')
|
||||
echo "Created label: Important (ID: $label2_id)"
|
||||
|
||||
# Create tag for group 2
|
||||
tag3=$(create_tag "$user6_token" "Work Equipment" "Items for work")
|
||||
tag3_id=$(echo "$tag3" | jq -r '.id // empty')
|
||||
echo "Created tag: Work Equipment (ID: $tag3_id)"
|
||||
# Create label for group 2
|
||||
label3=$(create_label "$user6_token" "Work Equipment" "Items for work")
|
||||
label3_id=$(echo "$label3" | jq -r '.id // empty')
|
||||
echo "Created label: Work Equipment (ID: $label3_id)"
|
||||
|
||||
# Store tags
|
||||
jq --arg tag1 "$tag1_id" \
|
||||
--arg tag2 "$tag2_id" \
|
||||
--arg tag3 "$tag3_id" \
|
||||
'.tags = {"group1":[$tag1,$tag2],"group2":[$tag3]}' \
|
||||
# Store labels
|
||||
jq --arg lab1 "$label1_id" \
|
||||
--arg lab2 "$label2_id" \
|
||||
--arg lab3 "$label3_id" \
|
||||
'.labels = {"group1":[$lab1,$lab2],"group2":[$lab3]}' \
|
||||
"$TEST_DATA_FILE" > "$TEST_DATA_FILE.tmp" && mv "$TEST_DATA_FILE.tmp" "$TEST_DATA_FILE"
|
||||
|
||||
echo "=== Step 5: Create test notifier ==="
|
||||
@@ -400,7 +400,7 @@ echo "Test data file saved to: $TEST_DATA_FILE"
|
||||
echo "Summary:"
|
||||
echo " - Users created: 7 (5 in group 1, 2 in group 2)"
|
||||
echo " - Locations created: 3"
|
||||
echo " - Tags created: 3"
|
||||
echo " - Labels created: 3"
|
||||
echo " - Notifiers created: 1"
|
||||
echo " - Items created: 7"
|
||||
echo " - Attachments created: 7"
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
func (a *app) SetupDemo() error {
|
||||
csvText := `HB.import_ref,HB.location,HB.tags,HB.quantity,HB.name,HB.description,HB.insured,HB.serial_number,HB.model_number,HB.manufacturer,HB.notes,HB.purchase_from,HB.purchase_price,HB.purchase_time,HB.lifetime_warranty,HB.warranty_expires,HB.warranty_details,HB.sold_to,HB.sold_price,HB.sold_time,HB.sold_notes
|
||||
csvText := `HB.import_ref,HB.location,HB.labels,HB.quantity,HB.name,HB.description,HB.insured,HB.serial_number,HB.model_number,HB.manufacturer,HB.notes,HB.purchase_from,HB.purchase_price,HB.purchase_time,HB.lifetime_warranty,HB.warranty_expires,HB.warranty_details,HB.sold_to,HB.sold_price,HB.sold_time,HB.sold_notes
|
||||
,Garage,IOT;Home Assistant; Z-Wave,1,Zooz Universal Relay ZEN17,"Zooz 700 Series Z-Wave Universal Relay ZEN17 for Awnings, Garage Doors, Sprinklers, and More | 2 NO-C-NC Relays (20A, 10A) | Signal Repeater | Hub Required (Compatible with SmartThings and Hubitat)",,,ZEN17,Zooz,,Amazon,39.95,10/13/2021,,,,,,,
|
||||
,Living Room,IOT;Home Assistant; Z-Wave,1,Zooz Motion Sensor,"Zooz Z-Wave Plus S2 Motion Sensor ZSE18 with Magnetic Mount, Works with Vera and SmartThings",,,ZSE18,Zooz,,Amazon,29.95,10/15/2021,,,,,,,
|
||||
,Office,IOT;Home Assistant; Z-Wave,1,Zooz 110v Power Switch,"Zooz Z-Wave Plus Power Switch ZEN15 for 110V AC Units, Sump Pumps, Humidifiers, and More",,,ZEN15,Zooz,,Amazon,39.95,10/13/2021,,,,,,,
|
||||
|
||||
@@ -222,7 +222,7 @@ func (ctrl *V1Controller) HandleCacheWS() errchain.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
ctrl.bus.Subscribe(eventbus.EventTagMutation, factory("tag.mutation"))
|
||||
ctrl.bus.Subscribe(eventbus.EventLabelMutation, factory("label.mutation"))
|
||||
ctrl.bus.Subscribe(eventbus.EventLocationMutation, factory("location.mutation"))
|
||||
ctrl.bus.Subscribe(eventbus.EventItemMutation, factory("item.mutation"))
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ func (ctrl *V1Controller) HandleCreateMissingThumbnails() errchain.HandlerFunc {
|
||||
|
||||
// WipeInventoryOptions represents the options for wiping inventory
|
||||
type WipeInventoryOptions struct {
|
||||
WipeTags bool `json:"wipeTags"`
|
||||
WipeLabels bool `json:"wipeLabels"`
|
||||
WipeLocations bool `json:"wipeLocations"`
|
||||
WipeMaintenance bool `json:"wipeMaintenance"`
|
||||
}
|
||||
@@ -132,13 +132,13 @@ func (ctrl *V1Controller) HandleWipeInventory() errchain.HandlerFunc {
|
||||
if err := server.Decode(r, &options); err != nil {
|
||||
// If no body provided, use default (false for all)
|
||||
options = WipeInventoryOptions{
|
||||
WipeTags: false,
|
||||
WipeLabels: false,
|
||||
WipeLocations: false,
|
||||
WipeMaintenance: false,
|
||||
}
|
||||
}
|
||||
|
||||
totalCompleted, err := ctrl.repo.Items.WipeInventory(ctx, ctx.GID, options.WipeTags, options.WipeLocations, options.WipeMaintenance)
|
||||
totalCompleted, err := ctrl.repo.Items.WipeInventory(ctx, ctx.GID, options.WipeLabels, options.WipeLocations, options.WipeMaintenance)
|
||||
if err != nil {
|
||||
log.Err(err).Str("action_ref", "wipe inventory").Msg("failed to run action")
|
||||
return validate.NewRequestError(err, http.StatusInternalServerError)
|
||||
@@ -146,8 +146,8 @@ func (ctrl *V1Controller) HandleWipeInventory() errchain.HandlerFunc {
|
||||
|
||||
// Publish mutation events for wiped resources
|
||||
if ctrl.bus != nil {
|
||||
if options.WipeTags {
|
||||
ctrl.bus.Publish(eventbus.EventTagMutation, eventbus.GroupMutationEvent{GID: ctx.GID})
|
||||
if options.WipeLabels {
|
||||
ctrl.bus.Publish(eventbus.EventLabelMutation, eventbus.GroupMutationEvent{GID: ctx.GID})
|
||||
}
|
||||
if options.WipeLocations {
|
||||
ctrl.bus.Publish(eventbus.EventLocationMutation, eventbus.GroupMutationEvent{GID: ctx.GID})
|
||||
|
||||
@@ -106,7 +106,7 @@ type ItemTemplateCreateItemRequest struct {
|
||||
Name string `json:"name" validate:"required,min=1,max=255"`
|
||||
Description string `json:"description" validate:"max=1000"`
|
||||
LocationID uuid.UUID `json:"locationId" validate:"required"`
|
||||
TagIDs []uuid.UUID `json:"tagIds"`
|
||||
LabelIDs []uuid.UUID `json:"labelIds"`
|
||||
Quantity *int `json:"quantity"`
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ func (ctrl *V1Controller) HandleItemTemplatesCreateItem() errchain.HandlerFunc {
|
||||
Description: body.Description,
|
||||
Quantity: quantity,
|
||||
LocationID: body.LocationID,
|
||||
TagIDs: body.TagIDs,
|
||||
LabelIDs: body.LabelIDs,
|
||||
Insured: template.DefaultInsured,
|
||||
Manufacturer: template.DefaultManufacturer,
|
||||
ModelNumber: template.DefaultModelNumber,
|
||||
|
||||
@@ -28,7 +28,7 @@ import (
|
||||
// @Param q query string false "search string"
|
||||
// @Param page query int false "page number"
|
||||
// @Param pageSize query int false "items per page"
|
||||
// @Param tags query []string false "tags Ids" collectionFormat(multi)
|
||||
// @Param labels query []string false "label Ids" collectionFormat(multi)
|
||||
// @Param locations query []string false "location Ids" collectionFormat(multi)
|
||||
// @Param parentIds query []string false "parent Ids" collectionFormat(multi)
|
||||
// @Success 200 {object} repo.PaginationResult[repo.ItemSummary]{}
|
||||
@@ -59,8 +59,8 @@ func (ctrl *V1Controller) HandleItemsGetAll() errchain.HandlerFunc {
|
||||
PageSize: queryIntOrNegativeOne(params.Get("pageSize")),
|
||||
Search: params.Get("q"),
|
||||
LocationIDs: queryUUIDList(params, "locations"),
|
||||
TagIDs: queryUUIDList(params, "tags"),
|
||||
NegateTags: queryBool(params.Get("negateTags")),
|
||||
LabelIDs: queryUUIDList(params, "labels"),
|
||||
NegateLabels: queryBool(params.Get("negateLabels")),
|
||||
OnlyWithoutPhoto: queryBool(params.Get("onlyWithoutPhoto")),
|
||||
OnlyWithPhoto: queryBool(params.Get("onlyWithPhoto")),
|
||||
ParentItemIDs: queryUUIDList(params, "parentIds"),
|
||||
|
||||
102
backend/app/api/handlers/v1/v1_ctrl_labels.go
Normal file
102
backend/app/api/handlers/v1/v1_ctrl_labels.go
Normal file
@@ -0,0 +1,102 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/hay-kot/httpkit/errchain"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/core/services"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/repo"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/web/adapters"
|
||||
)
|
||||
|
||||
// HandleLabelsGetAll godoc
|
||||
//
|
||||
// @Summary Get All Labels
|
||||
// @Tags Labels
|
||||
// @Produce json
|
||||
// @Success 200 {object} []repo.LabelOut
|
||||
// @Router /v1/labels [GET]
|
||||
// @Security Bearer
|
||||
func (ctrl *V1Controller) HandleLabelsGetAll() errchain.HandlerFunc {
|
||||
fn := func(r *http.Request) ([]repo.LabelSummary, error) {
|
||||
auth := services.NewContext(r.Context())
|
||||
return ctrl.repo.Labels.GetAll(auth, auth.GID)
|
||||
}
|
||||
|
||||
return adapters.Command(fn, http.StatusOK)
|
||||
}
|
||||
|
||||
// HandleLabelsCreate godoc
|
||||
//
|
||||
// @Summary Create Label
|
||||
// @Tags Labels
|
||||
// @Produce json
|
||||
// @Param payload body repo.LabelCreate true "Label Data"
|
||||
// @Success 200 {object} repo.LabelSummary
|
||||
// @Router /v1/labels [POST]
|
||||
// @Security Bearer
|
||||
func (ctrl *V1Controller) HandleLabelsCreate() errchain.HandlerFunc {
|
||||
fn := func(r *http.Request, data repo.LabelCreate) (repo.LabelOut, error) {
|
||||
auth := services.NewContext(r.Context())
|
||||
return ctrl.repo.Labels.Create(auth, auth.GID, data)
|
||||
}
|
||||
|
||||
return adapters.Action(fn, http.StatusCreated)
|
||||
}
|
||||
|
||||
// HandleLabelDelete godocs
|
||||
//
|
||||
// @Summary Delete Label
|
||||
// @Tags Labels
|
||||
// @Produce json
|
||||
// @Param id path string true "Label ID"
|
||||
// @Success 204
|
||||
// @Router /v1/labels/{id} [DELETE]
|
||||
// @Security Bearer
|
||||
func (ctrl *V1Controller) HandleLabelDelete() errchain.HandlerFunc {
|
||||
fn := func(r *http.Request, ID uuid.UUID) (any, error) {
|
||||
auth := services.NewContext(r.Context())
|
||||
err := ctrl.repo.Labels.DeleteByGroup(auth, auth.GID, ID)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return adapters.CommandID("id", fn, http.StatusNoContent)
|
||||
}
|
||||
|
||||
// HandleLabelGet godocs
|
||||
//
|
||||
// @Summary Get Label
|
||||
// @Tags Labels
|
||||
// @Produce json
|
||||
// @Param id path string true "Label ID"
|
||||
// @Success 200 {object} repo.LabelOut
|
||||
// @Router /v1/labels/{id} [GET]
|
||||
// @Security Bearer
|
||||
func (ctrl *V1Controller) HandleLabelGet() errchain.HandlerFunc {
|
||||
fn := func(r *http.Request, ID uuid.UUID) (repo.LabelOut, error) {
|
||||
auth := services.NewContext(r.Context())
|
||||
return ctrl.repo.Labels.GetOneByGroup(auth, auth.GID, ID)
|
||||
}
|
||||
|
||||
return adapters.CommandID("id", fn, http.StatusOK)
|
||||
}
|
||||
|
||||
// HandleLabelUpdate godocs
|
||||
//
|
||||
// @Summary Update Label
|
||||
// @Tags Labels
|
||||
// @Produce json
|
||||
// @Param id path string true "Label ID"
|
||||
// @Success 200 {object} repo.LabelOut
|
||||
// @Router /v1/labels/{id} [PUT]
|
||||
// @Security Bearer
|
||||
func (ctrl *V1Controller) HandleLabelUpdate() errchain.HandlerFunc {
|
||||
fn := func(r *http.Request, ID uuid.UUID, data repo.LabelUpdate) (repo.LabelOut, error) {
|
||||
auth := services.NewContext(r.Context())
|
||||
data.ID = ID
|
||||
return ctrl.repo.Labels.UpdateByGroup(auth, auth.GID, data)
|
||||
}
|
||||
|
||||
return adapters.ActionID("id", fn, http.StatusOK)
|
||||
}
|
||||
@@ -29,18 +29,18 @@ func (ctrl *V1Controller) HandleGroupStatisticsLocations() errchain.HandlerFunc
|
||||
return adapters.Command(fn, http.StatusOK)
|
||||
}
|
||||
|
||||
// HandleGroupStatisticsTags godoc
|
||||
// HandleGroupStatisticsLabels godoc
|
||||
//
|
||||
// @Summary Get Tags Statistics
|
||||
// @Summary Get Label Statistics
|
||||
// @Tags Statistics
|
||||
// @Produce json
|
||||
// @Success 200 {object} []repo.TotalsByOrganizer
|
||||
// @Router /v1/groups/statistics/tags [GET]
|
||||
// @Router /v1/groups/statistics/labels [GET]
|
||||
// @Security Bearer
|
||||
func (ctrl *V1Controller) HandleGroupStatisticsTags() errchain.HandlerFunc {
|
||||
func (ctrl *V1Controller) HandleGroupStatisticsLabels() errchain.HandlerFunc {
|
||||
fn := func(r *http.Request) ([]repo.TotalsByOrganizer, error) {
|
||||
auth := services.NewContext(r.Context())
|
||||
return ctrl.repo.Groups.StatsTagsByPurchasePrice(auth, auth.GID)
|
||||
return ctrl.repo.Groups.StatsLabelsByPurchasePrice(auth, auth.GID)
|
||||
}
|
||||
|
||||
return adapters.Command(fn, http.StatusOK)
|
||||
|
||||
@@ -1,102 +0,0 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/hay-kot/httpkit/errchain"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/core/services"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/repo"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/web/adapters"
|
||||
)
|
||||
|
||||
// HandleTagsGetAll godoc
|
||||
//
|
||||
// @Summary Get All Tags
|
||||
// @Tags Tags
|
||||
// @Produce json
|
||||
// @Success 200 {object} []repo.TagOut
|
||||
// @Router /v1/tags [GET]
|
||||
// @Security Bearer
|
||||
func (ctrl *V1Controller) HandleTagsGetAll() errchain.HandlerFunc {
|
||||
fn := func(r *http.Request) ([]repo.TagSummary, error) {
|
||||
auth := services.NewContext(r.Context())
|
||||
return ctrl.repo.Tags.GetAll(auth, auth.GID)
|
||||
}
|
||||
|
||||
return adapters.Command(fn, http.StatusOK)
|
||||
}
|
||||
|
||||
// HandleTagsCreate godoc
|
||||
//
|
||||
// @Summary Create Tag
|
||||
// @Tags Tags
|
||||
// @Produce json
|
||||
// @Param payload body repo.TagCreate true "Tag Data"
|
||||
// @Success 200 {object} repo.TagSummary
|
||||
// @Router /v1/tags [POST]
|
||||
// @Security Bearer
|
||||
func (ctrl *V1Controller) HandleTagsCreate() errchain.HandlerFunc {
|
||||
fn := func(r *http.Request, data repo.TagCreate) (repo.TagOut, error) {
|
||||
auth := services.NewContext(r.Context())
|
||||
return ctrl.repo.Tags.Create(auth, auth.GID, data)
|
||||
}
|
||||
|
||||
return adapters.Action(fn, http.StatusCreated)
|
||||
}
|
||||
|
||||
// HandleTagDelete godocs
|
||||
//
|
||||
// @Summary Delete Tag
|
||||
// @Tags Tags
|
||||
// @Produce json
|
||||
// @Param id path string true "Tag ID"
|
||||
// @Success 204
|
||||
// @Router /v1/tags/{id} [DELETE]
|
||||
// @Security Bearer
|
||||
func (ctrl *V1Controller) HandleTagDelete() errchain.HandlerFunc {
|
||||
fn := func(r *http.Request, ID uuid.UUID) (any, error) {
|
||||
auth := services.NewContext(r.Context())
|
||||
err := ctrl.repo.Tags.DeleteByGroup(auth, auth.GID, ID)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return adapters.CommandID("id", fn, http.StatusNoContent)
|
||||
}
|
||||
|
||||
// HandleTagGet godocs
|
||||
//
|
||||
// @Summary Get Tag
|
||||
// @Tags Tags
|
||||
// @Produce json
|
||||
// @Param id path string true "Tag ID"
|
||||
// @Success 200 {object} repo.TagOut
|
||||
// @Router /v1/tags/{id} [GET]
|
||||
// @Security Bearer
|
||||
func (ctrl *V1Controller) HandleTagGet() errchain.HandlerFunc {
|
||||
fn := func(r *http.Request, ID uuid.UUID) (repo.TagOut, error) {
|
||||
auth := services.NewContext(r.Context())
|
||||
return ctrl.repo.Tags.GetOneByGroup(auth, auth.GID, ID)
|
||||
}
|
||||
|
||||
return adapters.CommandID("id", fn, http.StatusOK)
|
||||
}
|
||||
|
||||
// HandleTagUpdate godocs
|
||||
//
|
||||
// @Summary Update Tag
|
||||
// @Tags Tags
|
||||
// @Produce json
|
||||
// @Param id path string true "Tag ID"
|
||||
// @Success 200 {object} repo.TagOut
|
||||
// @Router /v1/tags/{id} [PUT]
|
||||
// @Security Bearer
|
||||
func (ctrl *V1Controller) HandleTagUpdate() errchain.HandlerFunc {
|
||||
fn := func(r *http.Request, ID uuid.UUID, data repo.TagUpdate) (repo.TagOut, error) {
|
||||
auth := services.NewContext(r.Context())
|
||||
data.ID = ID
|
||||
return ctrl.repo.Tags.UpdateByGroup(auth, auth.GID, data)
|
||||
}
|
||||
|
||||
return adapters.ActionID("id", fn, http.StatusOK)
|
||||
}
|
||||
@@ -97,7 +97,7 @@ func (a *app) mountRoutes(r *chi.Mux, chain *errchain.ErrChain, repos *repo.AllR
|
||||
r.Get("/groups/statistics", chain.ToHandlerFunc(v1Ctrl.HandleGroupStatistics(), userMW...))
|
||||
r.Get("/groups/statistics/purchase-price", chain.ToHandlerFunc(v1Ctrl.HandleGroupStatisticsPriceOverTime(), userMW...))
|
||||
r.Get("/groups/statistics/locations", chain.ToHandlerFunc(v1Ctrl.HandleGroupStatisticsLocations(), userMW...))
|
||||
r.Get("/groups/statistics/tags", chain.ToHandlerFunc(v1Ctrl.HandleGroupStatisticsTags(), userMW...))
|
||||
r.Get("/groups/statistics/labels", chain.ToHandlerFunc(v1Ctrl.HandleGroupStatisticsLabels(), userMW...))
|
||||
|
||||
// TODO: I don't like /groups being the URL for users
|
||||
r.Get("/groups", chain.ToHandlerFunc(v1Ctrl.HandleGroupGet(), userMW...))
|
||||
@@ -117,11 +117,11 @@ func (a *app) mountRoutes(r *chi.Mux, chain *errchain.ErrChain, repos *repo.AllR
|
||||
r.Put("/locations/{id}", chain.ToHandlerFunc(v1Ctrl.HandleLocationUpdate(), userMW...))
|
||||
r.Delete("/locations/{id}", chain.ToHandlerFunc(v1Ctrl.HandleLocationDelete(), userMW...))
|
||||
|
||||
r.Get("/tags", chain.ToHandlerFunc(v1Ctrl.HandleTagsGetAll(), userMW...))
|
||||
r.Post("/tags", chain.ToHandlerFunc(v1Ctrl.HandleTagsCreate(), userMW...))
|
||||
r.Get("/tags/{id}", chain.ToHandlerFunc(v1Ctrl.HandleTagGet(), userMW...))
|
||||
r.Put("/tags/{id}", chain.ToHandlerFunc(v1Ctrl.HandleTagUpdate(), userMW...))
|
||||
r.Delete("/tags/{id}", chain.ToHandlerFunc(v1Ctrl.HandleTagDelete(), userMW...))
|
||||
r.Get("/labels", chain.ToHandlerFunc(v1Ctrl.HandleLabelsGetAll(), userMW...))
|
||||
r.Post("/labels", chain.ToHandlerFunc(v1Ctrl.HandleLabelsCreate(), userMW...))
|
||||
r.Get("/labels/{id}", chain.ToHandlerFunc(v1Ctrl.HandleLabelGet(), userMW...))
|
||||
r.Put("/labels/{id}", chain.ToHandlerFunc(v1Ctrl.HandleLabelUpdate(), userMW...))
|
||||
r.Delete("/labels/{id}", chain.ToHandlerFunc(v1Ctrl.HandleLabelDelete(), userMW...))
|
||||
|
||||
r.Get("/items", chain.ToHandlerFunc(v1Ctrl.HandleItemsGetAll(), userMW...))
|
||||
r.Post("/items", chain.ToHandlerFunc(v1Ctrl.HandleItemsCreate(), userMW...))
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -205,6 +205,22 @@ paths:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/repo.GroupStatistics"
|
||||
/v1/groups/statistics/labels:
|
||||
get:
|
||||
security:
|
||||
- Bearer: []
|
||||
tags:
|
||||
- Statistics
|
||||
summary: Get Label Statistics
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/repo.TotalsByOrganizer"
|
||||
/v1/groups/statistics/locations:
|
||||
get:
|
||||
security:
|
||||
@@ -246,22 +262,6 @@ paths:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/repo.ValueOverTime"
|
||||
/v1/groups/statistics/tags:
|
||||
get:
|
||||
security:
|
||||
- Bearer: []
|
||||
tags:
|
||||
- Statistics
|
||||
summary: Get Tags Statistics
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/repo.TotalsByOrganizer"
|
||||
/v1/items:
|
||||
get:
|
||||
security:
|
||||
@@ -285,8 +285,8 @@ paths:
|
||||
in: query
|
||||
schema:
|
||||
type: integer
|
||||
- description: tags Ids
|
||||
name: tags
|
||||
- description: label Ids
|
||||
name: labels
|
||||
in: query
|
||||
explode: true
|
||||
schema:
|
||||
@@ -819,6 +819,99 @@ paths:
|
||||
application/json:
|
||||
schema:
|
||||
type: string
|
||||
/v1/labels:
|
||||
get:
|
||||
security:
|
||||
- Bearer: []
|
||||
tags:
|
||||
- Labels
|
||||
summary: Get All Labels
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/repo.LabelOut"
|
||||
post:
|
||||
security:
|
||||
- Bearer: []
|
||||
tags:
|
||||
- Labels
|
||||
summary: Create Label
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/repo.LabelCreate"
|
||||
description: Label Data
|
||||
required: true
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/repo.LabelSummary"
|
||||
"/v1/labels/{id}":
|
||||
get:
|
||||
security:
|
||||
- Bearer: []
|
||||
tags:
|
||||
- Labels
|
||||
summary: Get Label
|
||||
parameters:
|
||||
- description: Label ID
|
||||
name: id
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/repo.LabelOut"
|
||||
put:
|
||||
security:
|
||||
- Bearer: []
|
||||
tags:
|
||||
- Labels
|
||||
summary: Update Label
|
||||
parameters:
|
||||
- description: Label ID
|
||||
name: id
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/repo.LabelOut"
|
||||
delete:
|
||||
security:
|
||||
- Bearer: []
|
||||
tags:
|
||||
- Labels
|
||||
summary: Delete Label
|
||||
parameters:
|
||||
- description: Label ID
|
||||
name: id
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
"204":
|
||||
description: No Content
|
||||
/v1/locations:
|
||||
get:
|
||||
security:
|
||||
@@ -1185,99 +1278,6 @@ paths:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/v1.APISummary"
|
||||
/v1/tags:
|
||||
get:
|
||||
security:
|
||||
- Bearer: []
|
||||
tags:
|
||||
- Tags
|
||||
summary: Get All Tags
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/repo.TagOut"
|
||||
post:
|
||||
security:
|
||||
- Bearer: []
|
||||
tags:
|
||||
- Tags
|
||||
summary: Create Tag
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/repo.TagCreate"
|
||||
description: Tag Data
|
||||
required: true
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/repo.TagSummary"
|
||||
"/v1/tags/{id}":
|
||||
get:
|
||||
security:
|
||||
- Bearer: []
|
||||
tags:
|
||||
- Tags
|
||||
summary: Get Tag
|
||||
parameters:
|
||||
- description: Tag ID
|
||||
name: id
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/repo.TagOut"
|
||||
put:
|
||||
security:
|
||||
- Bearer: []
|
||||
tags:
|
||||
- Tags
|
||||
summary: Update Tag
|
||||
parameters:
|
||||
- description: Tag ID
|
||||
name: id
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/repo.TagOut"
|
||||
delete:
|
||||
security:
|
||||
- Bearer: []
|
||||
tags:
|
||||
- Tags
|
||||
summary: Delete Tag
|
||||
parameters:
|
||||
- description: Tag ID
|
||||
name: id
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
"204":
|
||||
description: No Content
|
||||
/v1/templates:
|
||||
get:
|
||||
security:
|
||||
@@ -1784,6 +1784,11 @@ components:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/ent.Item"
|
||||
labels:
|
||||
description: Labels holds the value of the labels edge.
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/ent.Label"
|
||||
locations:
|
||||
description: Locations holds the value of the locations edge.
|
||||
type: array
|
||||
@@ -1794,11 +1799,6 @@ components:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/ent.Notifier"
|
||||
tags:
|
||||
description: Tags holds the value of the tags edge.
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/ent.Tag"
|
||||
users:
|
||||
description: Users holds the value of the users edge.
|
||||
type: array
|
||||
@@ -1949,6 +1949,11 @@ components:
|
||||
description: Group holds the value of the group edge.
|
||||
allOf:
|
||||
- $ref: "#/components/schemas/ent.Group"
|
||||
label:
|
||||
description: Label holds the value of the label edge.
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/ent.Label"
|
||||
location:
|
||||
description: Location holds the value of the location edge.
|
||||
allOf:
|
||||
@@ -1962,11 +1967,6 @@ components:
|
||||
description: Parent holds the value of the parent edge.
|
||||
allOf:
|
||||
- $ref: "#/components/schemas/ent.Item"
|
||||
tag:
|
||||
description: Tag holds the value of the tag edge.
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/ent.Tag"
|
||||
ent.ItemField:
|
||||
type: object
|
||||
properties:
|
||||
@@ -2027,6 +2027,11 @@ components:
|
||||
default_insured:
|
||||
description: DefaultInsured holds the value of the "default_insured" field.
|
||||
type: boolean
|
||||
default_label_ids:
|
||||
description: Default label IDs for items created from this template
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
default_lifetime_warranty:
|
||||
description: DefaultLifetimeWarranty holds the value of the
|
||||
"default_lifetime_warranty" field.
|
||||
@@ -2044,11 +2049,6 @@ components:
|
||||
default_quantity:
|
||||
description: DefaultQuantity holds the value of the "default_quantity" field.
|
||||
type: integer
|
||||
default_tag_ids:
|
||||
description: Default tag IDs for items created from this template
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
default_warranty_details:
|
||||
description: DefaultWarrantyDetails holds the value of the
|
||||
"default_warranty_details" field.
|
||||
@@ -2102,6 +2102,46 @@ components:
|
||||
description: Location holds the value of the location edge.
|
||||
allOf:
|
||||
- $ref: "#/components/schemas/ent.Location"
|
||||
ent.Label:
|
||||
type: object
|
||||
properties:
|
||||
color:
|
||||
description: Color holds the value of the "color" field.
|
||||
type: string
|
||||
created_at:
|
||||
description: CreatedAt holds the value of the "created_at" field.
|
||||
type: string
|
||||
description:
|
||||
description: Description holds the value of the "description" field.
|
||||
type: string
|
||||
edges:
|
||||
description: >-
|
||||
Edges holds the relations/edges for other nodes in the graph.
|
||||
|
||||
The values are being populated by the LabelQuery when eager-loading is set.
|
||||
allOf:
|
||||
- $ref: "#/components/schemas/ent.LabelEdges"
|
||||
id:
|
||||
description: ID of the ent.
|
||||
type: string
|
||||
name:
|
||||
description: Name holds the value of the "name" field.
|
||||
type: string
|
||||
updated_at:
|
||||
description: UpdatedAt holds the value of the "updated_at" field.
|
||||
type: string
|
||||
ent.LabelEdges:
|
||||
type: object
|
||||
properties:
|
||||
group:
|
||||
description: Group holds the value of the group edge.
|
||||
allOf:
|
||||
- $ref: "#/components/schemas/ent.Group"
|
||||
items:
|
||||
description: Items holds the value of the items edge.
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/ent.Item"
|
||||
ent.Location:
|
||||
type: object
|
||||
properties:
|
||||
@@ -2234,46 +2274,6 @@ components:
|
||||
description: User holds the value of the user edge.
|
||||
allOf:
|
||||
- $ref: "#/components/schemas/ent.User"
|
||||
ent.Tag:
|
||||
type: object
|
||||
properties:
|
||||
color:
|
||||
description: Color holds the value of the "color" field.
|
||||
type: string
|
||||
created_at:
|
||||
description: CreatedAt holds the value of the "created_at" field.
|
||||
type: string
|
||||
description:
|
||||
description: Description holds the value of the "description" field.
|
||||
type: string
|
||||
edges:
|
||||
description: >-
|
||||
Edges holds the relations/edges for other nodes in the graph.
|
||||
|
||||
The values are being populated by the TagQuery when eager-loading is set.
|
||||
allOf:
|
||||
- $ref: "#/components/schemas/ent.TagEdges"
|
||||
id:
|
||||
description: ID of the ent.
|
||||
type: string
|
||||
name:
|
||||
description: Name holds the value of the "name" field.
|
||||
type: string
|
||||
updated_at:
|
||||
description: UpdatedAt holds the value of the "updated_at" field.
|
||||
type: string
|
||||
ent.TagEdges:
|
||||
type: object
|
||||
properties:
|
||||
group:
|
||||
description: Group holds the value of the group edge.
|
||||
allOf:
|
||||
- $ref: "#/components/schemas/ent.Group"
|
||||
items:
|
||||
description: Items holds the value of the items edge.
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/ent.Item"
|
||||
ent.TemplateField:
|
||||
type: object
|
||||
properties:
|
||||
@@ -2438,9 +2438,9 @@ components:
|
||||
type: number
|
||||
totalItems:
|
||||
type: integer
|
||||
totalLocations:
|
||||
totalLabels:
|
||||
type: integer
|
||||
totalTags:
|
||||
totalLocations:
|
||||
type: integer
|
||||
totalUsers:
|
||||
type: integer
|
||||
@@ -2491,6 +2491,10 @@ components:
|
||||
description:
|
||||
type: string
|
||||
maxLength: 1000
|
||||
labelIds:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
locationId:
|
||||
description: Edges
|
||||
type: string
|
||||
@@ -2503,10 +2507,6 @@ components:
|
||||
nullable: true
|
||||
quantity:
|
||||
type: integer
|
||||
tagIds:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
repo.ItemField:
|
||||
type: object
|
||||
properties:
|
||||
@@ -2550,6 +2550,10 @@ components:
|
||||
nullable: true
|
||||
insured:
|
||||
type: boolean
|
||||
labels:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/repo.LabelSummary"
|
||||
lifetimeWarranty:
|
||||
description: Warranty
|
||||
type: boolean
|
||||
@@ -2595,10 +2599,6 @@ components:
|
||||
type: string
|
||||
syncChildItemsLocations:
|
||||
type: boolean
|
||||
tags:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/repo.TagSummary"
|
||||
thumbnailId:
|
||||
type: string
|
||||
x-omitempty: true
|
||||
@@ -2614,6 +2614,12 @@ components:
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
labelIds:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
x-omitempty: true
|
||||
nullable: true
|
||||
locationId:
|
||||
type: string
|
||||
x-omitempty: true
|
||||
@@ -2622,12 +2628,6 @@ components:
|
||||
type: integer
|
||||
x-omitempty: true
|
||||
nullable: true
|
||||
tagIds:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
x-omitempty: true
|
||||
nullable: true
|
||||
repo.ItemPath:
|
||||
type: object
|
||||
properties:
|
||||
@@ -2657,6 +2657,10 @@ components:
|
||||
nullable: true
|
||||
insured:
|
||||
type: boolean
|
||||
labels:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/repo.LabelSummary"
|
||||
location:
|
||||
description: Edges
|
||||
allOf:
|
||||
@@ -2672,10 +2676,6 @@ components:
|
||||
soldTime:
|
||||
description: Sale details
|
||||
type: string
|
||||
tags:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/repo.TagSummary"
|
||||
thumbnailId:
|
||||
type: string
|
||||
x-omitempty: true
|
||||
@@ -2693,10 +2693,15 @@ components:
|
||||
nullable: true
|
||||
defaultInsured:
|
||||
type: boolean
|
||||
defaultLabelIds:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
nullable: true
|
||||
defaultLifetimeWarranty:
|
||||
type: boolean
|
||||
defaultLocationId:
|
||||
description: Default location and tags
|
||||
description: Default location and labels
|
||||
type: string
|
||||
nullable: true
|
||||
defaultManufacturer:
|
||||
@@ -2715,11 +2720,6 @@ components:
|
||||
description: Default values for items
|
||||
type: integer
|
||||
nullable: true
|
||||
defaultTagIds:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
nullable: true
|
||||
defaultWarrantyDetails:
|
||||
type: string
|
||||
maxLength: 1000
|
||||
@@ -2755,10 +2755,14 @@ components:
|
||||
type: string
|
||||
defaultInsured:
|
||||
type: boolean
|
||||
defaultLabels:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/repo.TemplateLabelSummary"
|
||||
defaultLifetimeWarranty:
|
||||
type: boolean
|
||||
defaultLocation:
|
||||
description: Default location and tags
|
||||
description: Default location and labels
|
||||
allOf:
|
||||
- $ref: "#/components/schemas/repo.TemplateLocationSummary"
|
||||
defaultManufacturer:
|
||||
@@ -2770,10 +2774,6 @@ components:
|
||||
defaultQuantity:
|
||||
description: Default values for items
|
||||
type: integer
|
||||
defaultTags:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/repo.TemplateTagSummary"
|
||||
defaultWarrantyDetails:
|
||||
type: string
|
||||
description:
|
||||
@@ -2822,10 +2822,15 @@ components:
|
||||
nullable: true
|
||||
defaultInsured:
|
||||
type: boolean
|
||||
defaultLabelIds:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
nullable: true
|
||||
defaultLifetimeWarranty:
|
||||
type: boolean
|
||||
defaultLocationId:
|
||||
description: Default location and tags
|
||||
description: Default location and labels
|
||||
type: string
|
||||
nullable: true
|
||||
defaultManufacturer:
|
||||
@@ -2844,11 +2849,6 @@ components:
|
||||
description: Default values for items
|
||||
type: integer
|
||||
nullable: true
|
||||
defaultTagIds:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
nullable: true
|
||||
defaultWarrantyDetails:
|
||||
type: string
|
||||
maxLength: 1000
|
||||
@@ -2905,6 +2905,10 @@ components:
|
||||
type: string
|
||||
insured:
|
||||
type: boolean
|
||||
labelIds:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
lifetimeWarranty:
|
||||
description: Warranty
|
||||
type: boolean
|
||||
@@ -2955,14 +2959,54 @@ components:
|
||||
maxLength: 255
|
||||
syncChildItemsLocations:
|
||||
type: boolean
|
||||
tagIds:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
warrantyDetails:
|
||||
type: string
|
||||
warrantyExpires:
|
||||
type: string
|
||||
repo.LabelCreate:
|
||||
type: object
|
||||
required:
|
||||
- name
|
||||
properties:
|
||||
color:
|
||||
type: string
|
||||
description:
|
||||
type: string
|
||||
maxLength: 1000
|
||||
name:
|
||||
type: string
|
||||
maxLength: 255
|
||||
minLength: 1
|
||||
repo.LabelOut:
|
||||
type: object
|
||||
properties:
|
||||
color:
|
||||
type: string
|
||||
createdAt:
|
||||
type: string
|
||||
description:
|
||||
type: string
|
||||
id:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
updatedAt:
|
||||
type: string
|
||||
repo.LabelSummary:
|
||||
type: object
|
||||
properties:
|
||||
color:
|
||||
type: string
|
||||
createdAt:
|
||||
type: string
|
||||
description:
|
||||
type: string
|
||||
id:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
updatedAt:
|
||||
type: string
|
||||
repo.LocationCreate:
|
||||
type: object
|
||||
properties:
|
||||
@@ -3170,50 +3214,6 @@ components:
|
||||
type: integer
|
||||
total:
|
||||
type: integer
|
||||
repo.TagCreate:
|
||||
type: object
|
||||
required:
|
||||
- name
|
||||
properties:
|
||||
color:
|
||||
type: string
|
||||
description:
|
||||
type: string
|
||||
maxLength: 1000
|
||||
name:
|
||||
type: string
|
||||
maxLength: 255
|
||||
minLength: 1
|
||||
repo.TagOut:
|
||||
type: object
|
||||
properties:
|
||||
color:
|
||||
type: string
|
||||
createdAt:
|
||||
type: string
|
||||
description:
|
||||
type: string
|
||||
id:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
updatedAt:
|
||||
type: string
|
||||
repo.TagSummary:
|
||||
type: object
|
||||
properties:
|
||||
color:
|
||||
type: string
|
||||
createdAt:
|
||||
type: string
|
||||
description:
|
||||
type: string
|
||||
id:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
updatedAt:
|
||||
type: string
|
||||
repo.TemplateField:
|
||||
type: object
|
||||
properties:
|
||||
@@ -3225,14 +3225,14 @@ components:
|
||||
type: string
|
||||
type:
|
||||
type: string
|
||||
repo.TemplateLocationSummary:
|
||||
repo.TemplateLabelSummary:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
repo.TemplateTagSummary:
|
||||
repo.TemplateLocationSummary:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
@@ -3427,6 +3427,10 @@ components:
|
||||
description:
|
||||
type: string
|
||||
maxLength: 1000
|
||||
labelIds:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
locationId:
|
||||
type: string
|
||||
name:
|
||||
@@ -3435,10 +3439,6 @@ components:
|
||||
minLength: 1
|
||||
quantity:
|
||||
type: integer
|
||||
tagIds:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
v1.LoginForm:
|
||||
type: object
|
||||
properties:
|
||||
@@ -3473,12 +3473,12 @@ components:
|
||||
v1.WipeInventoryOptions:
|
||||
type: object
|
||||
properties:
|
||||
wipeLabels:
|
||||
type: boolean
|
||||
wipeLocations:
|
||||
type: boolean
|
||||
wipeMaintenance:
|
||||
type: boolean
|
||||
wipeTags:
|
||||
type: boolean
|
||||
v1.Wrapped:
|
||||
type: object
|
||||
properties:
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -189,6 +189,11 @@ definitions:
|
||||
items:
|
||||
$ref: '#/definitions/ent.Item'
|
||||
type: array
|
||||
labels:
|
||||
description: Labels holds the value of the labels edge.
|
||||
items:
|
||||
$ref: '#/definitions/ent.Label'
|
||||
type: array
|
||||
locations:
|
||||
description: Locations holds the value of the locations edge.
|
||||
items:
|
||||
@@ -199,11 +204,6 @@ definitions:
|
||||
items:
|
||||
$ref: '#/definitions/ent.Notifier'
|
||||
type: array
|
||||
tags:
|
||||
description: Tags holds the value of the tags edge.
|
||||
items:
|
||||
$ref: '#/definitions/ent.Tag'
|
||||
type: array
|
||||
users:
|
||||
description: Users holds the value of the users edge.
|
||||
items:
|
||||
@@ -352,6 +352,11 @@ definitions:
|
||||
allOf:
|
||||
- $ref: '#/definitions/ent.Group'
|
||||
description: Group holds the value of the group edge.
|
||||
label:
|
||||
description: Label holds the value of the label edge.
|
||||
items:
|
||||
$ref: '#/definitions/ent.Label'
|
||||
type: array
|
||||
location:
|
||||
allOf:
|
||||
- $ref: '#/definitions/ent.Location'
|
||||
@@ -366,11 +371,6 @@ definitions:
|
||||
allOf:
|
||||
- $ref: '#/definitions/ent.Item'
|
||||
description: Parent holds the value of the parent edge.
|
||||
tag:
|
||||
description: Tag holds the value of the tag edge.
|
||||
items:
|
||||
$ref: '#/definitions/ent.Tag'
|
||||
type: array
|
||||
type: object
|
||||
ent.ItemField:
|
||||
properties:
|
||||
@@ -430,6 +430,11 @@ definitions:
|
||||
default_insured:
|
||||
description: DefaultInsured holds the value of the "default_insured" field.
|
||||
type: boolean
|
||||
default_label_ids:
|
||||
description: Default label IDs for items created from this template
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
default_lifetime_warranty:
|
||||
description: DefaultLifetimeWarranty holds the value of the "default_lifetime_warranty"
|
||||
field.
|
||||
@@ -447,11 +452,6 @@ definitions:
|
||||
default_quantity:
|
||||
description: DefaultQuantity holds the value of the "default_quantity" field.
|
||||
type: integer
|
||||
default_tag_ids:
|
||||
description: Default tag IDs for items created from this template
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
default_warranty_details:
|
||||
description: DefaultWarrantyDetails holds the value of the "default_warranty_details"
|
||||
field.
|
||||
@@ -505,6 +505,45 @@ definitions:
|
||||
- $ref: '#/definitions/ent.Location'
|
||||
description: Location holds the value of the location edge.
|
||||
type: object
|
||||
ent.Label:
|
||||
properties:
|
||||
color:
|
||||
description: Color holds the value of the "color" field.
|
||||
type: string
|
||||
created_at:
|
||||
description: CreatedAt holds the value of the "created_at" field.
|
||||
type: string
|
||||
description:
|
||||
description: Description holds the value of the "description" field.
|
||||
type: string
|
||||
edges:
|
||||
allOf:
|
||||
- $ref: '#/definitions/ent.LabelEdges'
|
||||
description: |-
|
||||
Edges holds the relations/edges for other nodes in the graph.
|
||||
The values are being populated by the LabelQuery when eager-loading is set.
|
||||
id:
|
||||
description: ID of the ent.
|
||||
type: string
|
||||
name:
|
||||
description: Name holds the value of the "name" field.
|
||||
type: string
|
||||
updated_at:
|
||||
description: UpdatedAt holds the value of the "updated_at" field.
|
||||
type: string
|
||||
type: object
|
||||
ent.LabelEdges:
|
||||
properties:
|
||||
group:
|
||||
allOf:
|
||||
- $ref: '#/definitions/ent.Group'
|
||||
description: Group holds the value of the group edge.
|
||||
items:
|
||||
description: Items holds the value of the items edge.
|
||||
items:
|
||||
$ref: '#/definitions/ent.Item'
|
||||
type: array
|
||||
type: object
|
||||
ent.Location:
|
||||
properties:
|
||||
created_at:
|
||||
@@ -634,45 +673,6 @@ definitions:
|
||||
- $ref: '#/definitions/ent.User'
|
||||
description: User holds the value of the user edge.
|
||||
type: object
|
||||
ent.Tag:
|
||||
properties:
|
||||
color:
|
||||
description: Color holds the value of the "color" field.
|
||||
type: string
|
||||
created_at:
|
||||
description: CreatedAt holds the value of the "created_at" field.
|
||||
type: string
|
||||
description:
|
||||
description: Description holds the value of the "description" field.
|
||||
type: string
|
||||
edges:
|
||||
allOf:
|
||||
- $ref: '#/definitions/ent.TagEdges'
|
||||
description: |-
|
||||
Edges holds the relations/edges for other nodes in the graph.
|
||||
The values are being populated by the TagQuery when eager-loading is set.
|
||||
id:
|
||||
description: ID of the ent.
|
||||
type: string
|
||||
name:
|
||||
description: Name holds the value of the "name" field.
|
||||
type: string
|
||||
updated_at:
|
||||
description: UpdatedAt holds the value of the "updated_at" field.
|
||||
type: string
|
||||
type: object
|
||||
ent.TagEdges:
|
||||
properties:
|
||||
group:
|
||||
allOf:
|
||||
- $ref: '#/definitions/ent.Group'
|
||||
description: Group holds the value of the group edge.
|
||||
items:
|
||||
description: Items holds the value of the items edge.
|
||||
items:
|
||||
$ref: '#/definitions/ent.Item'
|
||||
type: array
|
||||
type: object
|
||||
ent.TemplateField:
|
||||
properties:
|
||||
created_at:
|
||||
@@ -834,9 +834,9 @@ definitions:
|
||||
type: number
|
||||
totalItems:
|
||||
type: integer
|
||||
totalLocations:
|
||||
totalLabels:
|
||||
type: integer
|
||||
totalTags:
|
||||
totalLocations:
|
||||
type: integer
|
||||
totalUsers:
|
||||
type: integer
|
||||
@@ -885,6 +885,10 @@ definitions:
|
||||
description:
|
||||
maxLength: 1000
|
||||
type: string
|
||||
labelIds:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
locationId:
|
||||
description: Edges
|
||||
type: string
|
||||
@@ -897,10 +901,6 @@ definitions:
|
||||
x-nullable: true
|
||||
quantity:
|
||||
type: integer
|
||||
tagIds:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
required:
|
||||
- name
|
||||
type: object
|
||||
@@ -946,6 +946,10 @@ definitions:
|
||||
x-omitempty: true
|
||||
insured:
|
||||
type: boolean
|
||||
labels:
|
||||
items:
|
||||
$ref: '#/definitions/repo.LabelSummary'
|
||||
type: array
|
||||
lifetimeWarranty:
|
||||
description: Warranty
|
||||
type: boolean
|
||||
@@ -991,10 +995,6 @@ definitions:
|
||||
type: string
|
||||
syncChildItemsLocations:
|
||||
type: boolean
|
||||
tags:
|
||||
items:
|
||||
$ref: '#/definitions/repo.TagSummary'
|
||||
type: array
|
||||
thumbnailId:
|
||||
type: string
|
||||
x-nullable: true
|
||||
@@ -1010,6 +1010,12 @@ definitions:
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
labelIds:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
x-nullable: true
|
||||
x-omitempty: true
|
||||
locationId:
|
||||
type: string
|
||||
x-nullable: true
|
||||
@@ -1018,12 +1024,6 @@ definitions:
|
||||
type: integer
|
||||
x-nullable: true
|
||||
x-omitempty: true
|
||||
tagIds:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
x-nullable: true
|
||||
x-omitempty: true
|
||||
type: object
|
||||
repo.ItemPath:
|
||||
properties:
|
||||
@@ -1053,6 +1053,10 @@ definitions:
|
||||
x-omitempty: true
|
||||
insured:
|
||||
type: boolean
|
||||
labels:
|
||||
items:
|
||||
$ref: '#/definitions/repo.LabelSummary'
|
||||
type: array
|
||||
location:
|
||||
allOf:
|
||||
- $ref: '#/definitions/repo.LocationSummary'
|
||||
@@ -1068,10 +1072,6 @@ definitions:
|
||||
soldTime:
|
||||
description: Sale details
|
||||
type: string
|
||||
tags:
|
||||
items:
|
||||
$ref: '#/definitions/repo.TagSummary'
|
||||
type: array
|
||||
thumbnailId:
|
||||
type: string
|
||||
x-nullable: true
|
||||
@@ -1087,10 +1087,15 @@ definitions:
|
||||
x-nullable: true
|
||||
defaultInsured:
|
||||
type: boolean
|
||||
defaultLabelIds:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
x-nullable: true
|
||||
defaultLifetimeWarranty:
|
||||
type: boolean
|
||||
defaultLocationId:
|
||||
description: Default location and tags
|
||||
description: Default location and labels
|
||||
type: string
|
||||
x-nullable: true
|
||||
defaultManufacturer:
|
||||
@@ -1109,11 +1114,6 @@ definitions:
|
||||
description: Default values for items
|
||||
type: integer
|
||||
x-nullable: true
|
||||
defaultTagIds:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
x-nullable: true
|
||||
defaultWarrantyDetails:
|
||||
maxLength: 1000
|
||||
type: string
|
||||
@@ -1151,12 +1151,16 @@ definitions:
|
||||
type: string
|
||||
defaultInsured:
|
||||
type: boolean
|
||||
defaultLabels:
|
||||
items:
|
||||
$ref: '#/definitions/repo.TemplateLabelSummary'
|
||||
type: array
|
||||
defaultLifetimeWarranty:
|
||||
type: boolean
|
||||
defaultLocation:
|
||||
allOf:
|
||||
- $ref: '#/definitions/repo.TemplateLocationSummary'
|
||||
description: Default location and tags
|
||||
description: Default location and labels
|
||||
defaultManufacturer:
|
||||
type: string
|
||||
defaultModelNumber:
|
||||
@@ -1166,10 +1170,6 @@ definitions:
|
||||
defaultQuantity:
|
||||
description: Default values for items
|
||||
type: integer
|
||||
defaultTags:
|
||||
items:
|
||||
$ref: '#/definitions/repo.TemplateTagSummary'
|
||||
type: array
|
||||
defaultWarrantyDetails:
|
||||
type: string
|
||||
description:
|
||||
@@ -1216,10 +1216,15 @@ definitions:
|
||||
x-nullable: true
|
||||
defaultInsured:
|
||||
type: boolean
|
||||
defaultLabelIds:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
x-nullable: true
|
||||
defaultLifetimeWarranty:
|
||||
type: boolean
|
||||
defaultLocationId:
|
||||
description: Default location and tags
|
||||
description: Default location and labels
|
||||
type: string
|
||||
x-nullable: true
|
||||
defaultManufacturer:
|
||||
@@ -1238,11 +1243,6 @@ definitions:
|
||||
description: Default values for items
|
||||
type: integer
|
||||
x-nullable: true
|
||||
defaultTagIds:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
x-nullable: true
|
||||
defaultWarrantyDetails:
|
||||
maxLength: 1000
|
||||
type: string
|
||||
@@ -1299,6 +1299,10 @@ definitions:
|
||||
type: string
|
||||
insured:
|
||||
type: boolean
|
||||
labelIds:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
lifetimeWarranty:
|
||||
description: Warranty
|
||||
type: boolean
|
||||
@@ -1349,10 +1353,6 @@ definitions:
|
||||
type: string
|
||||
syncChildItemsLocations:
|
||||
type: boolean
|
||||
tagIds:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
warrantyDetails:
|
||||
type: string
|
||||
warrantyExpires:
|
||||
@@ -1360,6 +1360,50 @@ definitions:
|
||||
required:
|
||||
- name
|
||||
type: object
|
||||
repo.LabelCreate:
|
||||
properties:
|
||||
color:
|
||||
type: string
|
||||
description:
|
||||
maxLength: 1000
|
||||
type: string
|
||||
name:
|
||||
maxLength: 255
|
||||
minLength: 1
|
||||
type: string
|
||||
required:
|
||||
- name
|
||||
type: object
|
||||
repo.LabelOut:
|
||||
properties:
|
||||
color:
|
||||
type: string
|
||||
createdAt:
|
||||
type: string
|
||||
description:
|
||||
type: string
|
||||
id:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
updatedAt:
|
||||
type: string
|
||||
type: object
|
||||
repo.LabelSummary:
|
||||
properties:
|
||||
color:
|
||||
type: string
|
||||
createdAt:
|
||||
type: string
|
||||
description:
|
||||
type: string
|
||||
id:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
updatedAt:
|
||||
type: string
|
||||
type: object
|
||||
repo.LocationCreate:
|
||||
properties:
|
||||
description:
|
||||
@@ -1567,50 +1611,6 @@ definitions:
|
||||
total:
|
||||
type: integer
|
||||
type: object
|
||||
repo.TagCreate:
|
||||
properties:
|
||||
color:
|
||||
type: string
|
||||
description:
|
||||
maxLength: 1000
|
||||
type: string
|
||||
name:
|
||||
maxLength: 255
|
||||
minLength: 1
|
||||
type: string
|
||||
required:
|
||||
- name
|
||||
type: object
|
||||
repo.TagOut:
|
||||
properties:
|
||||
color:
|
||||
type: string
|
||||
createdAt:
|
||||
type: string
|
||||
description:
|
||||
type: string
|
||||
id:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
updatedAt:
|
||||
type: string
|
||||
type: object
|
||||
repo.TagSummary:
|
||||
properties:
|
||||
color:
|
||||
type: string
|
||||
createdAt:
|
||||
type: string
|
||||
description:
|
||||
type: string
|
||||
id:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
updatedAt:
|
||||
type: string
|
||||
type: object
|
||||
repo.TemplateField:
|
||||
properties:
|
||||
id:
|
||||
@@ -1622,14 +1622,14 @@ definitions:
|
||||
type:
|
||||
type: string
|
||||
type: object
|
||||
repo.TemplateLocationSummary:
|
||||
repo.TemplateLabelSummary:
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
type: object
|
||||
repo.TemplateTagSummary:
|
||||
repo.TemplateLocationSummary:
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
@@ -1820,6 +1820,10 @@ definitions:
|
||||
description:
|
||||
maxLength: 1000
|
||||
type: string
|
||||
labelIds:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
locationId:
|
||||
type: string
|
||||
name:
|
||||
@@ -1828,10 +1832,6 @@ definitions:
|
||||
type: string
|
||||
quantity:
|
||||
type: integer
|
||||
tagIds:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
required:
|
||||
- locationId
|
||||
- name
|
||||
@@ -1869,12 +1869,12 @@ definitions:
|
||||
type: object
|
||||
v1.WipeInventoryOptions:
|
||||
properties:
|
||||
wipeLabels:
|
||||
type: boolean
|
||||
wipeLocations:
|
||||
type: boolean
|
||||
wipeMaintenance:
|
||||
type: boolean
|
||||
wipeTags:
|
||||
type: boolean
|
||||
type: object
|
||||
v1.Wrapped:
|
||||
properties:
|
||||
@@ -2093,6 +2093,22 @@ paths:
|
||||
summary: Get Group Statistics
|
||||
tags:
|
||||
- Statistics
|
||||
/v1/groups/statistics/labels:
|
||||
get:
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
items:
|
||||
$ref: '#/definitions/repo.TotalsByOrganizer'
|
||||
type: array
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: Get Label Statistics
|
||||
tags:
|
||||
- Statistics
|
||||
/v1/groups/statistics/locations:
|
||||
get:
|
||||
produces:
|
||||
@@ -2132,22 +2148,6 @@ paths:
|
||||
summary: Get Purchase Price Statistics
|
||||
tags:
|
||||
- Statistics
|
||||
/v1/groups/statistics/tags:
|
||||
get:
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
items:
|
||||
$ref: '#/definitions/repo.TotalsByOrganizer'
|
||||
type: array
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: Get Tags Statistics
|
||||
tags:
|
||||
- Statistics
|
||||
/v1/items:
|
||||
get:
|
||||
parameters:
|
||||
@@ -2164,11 +2164,11 @@ paths:
|
||||
name: pageSize
|
||||
type: integer
|
||||
- collectionFormat: multi
|
||||
description: tags Ids
|
||||
description: label Ids
|
||||
in: query
|
||||
items:
|
||||
type: string
|
||||
name: tags
|
||||
name: labels
|
||||
type: array
|
||||
- collectionFormat: multi
|
||||
description: location Ids
|
||||
@@ -2662,6 +2662,98 @@ paths:
|
||||
summary: Get Location label
|
||||
tags:
|
||||
- Locations
|
||||
/v1/labels:
|
||||
get:
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
items:
|
||||
$ref: '#/definitions/repo.LabelOut'
|
||||
type: array
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: Get All Labels
|
||||
tags:
|
||||
- Labels
|
||||
post:
|
||||
parameters:
|
||||
- description: Label Data
|
||||
in: body
|
||||
name: payload
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/repo.LabelCreate'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/repo.LabelSummary'
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: Create Label
|
||||
tags:
|
||||
- Labels
|
||||
/v1/labels/{id}:
|
||||
delete:
|
||||
parameters:
|
||||
- description: Label ID
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: string
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"204":
|
||||
description: No Content
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: Delete Label
|
||||
tags:
|
||||
- Labels
|
||||
get:
|
||||
parameters:
|
||||
- description: Label ID
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: string
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/repo.LabelOut'
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: Get Label
|
||||
tags:
|
||||
- Labels
|
||||
put:
|
||||
parameters:
|
||||
- description: Label ID
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: string
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/repo.LabelOut'
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: Update Label
|
||||
tags:
|
||||
- Labels
|
||||
/v1/locations:
|
||||
get:
|
||||
parameters:
|
||||
@@ -3016,98 +3108,6 @@ paths:
|
||||
summary: Application Info
|
||||
tags:
|
||||
- Base
|
||||
/v1/tags:
|
||||
get:
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
items:
|
||||
$ref: '#/definitions/repo.TagOut'
|
||||
type: array
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: Get All Tags
|
||||
tags:
|
||||
- Tags
|
||||
post:
|
||||
parameters:
|
||||
- description: Tag Data
|
||||
in: body
|
||||
name: payload
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/repo.TagCreate'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/repo.TagSummary'
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: Create Tag
|
||||
tags:
|
||||
- Tags
|
||||
/v1/tags/{id}:
|
||||
delete:
|
||||
parameters:
|
||||
- description: Tag ID
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: string
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"204":
|
||||
description: No Content
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: Delete Tag
|
||||
tags:
|
||||
- Tags
|
||||
get:
|
||||
parameters:
|
||||
- description: Tag ID
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: string
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/repo.TagOut'
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: Get Tag
|
||||
tags:
|
||||
- Tags
|
||||
put:
|
||||
parameters:
|
||||
- description: Tag ID
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: string
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/repo.TagOut'
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: Update Tag
|
||||
tags:
|
||||
- Tags
|
||||
/v1/templates:
|
||||
get:
|
||||
produces:
|
||||
|
||||
@@ -325,8 +325,6 @@ github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/
|
||||
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
|
||||
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
|
||||
github.com/mattn/go-sqlite3 v1.14.32 h1:JD12Ag3oLy1zQA+BNn74xRgaBbdhbNIDYvQUEuuErjs=
|
||||
github.com/mattn/go-sqlite3 v1.14.32/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
|
||||
github.com/mfridman/interpolate v0.0.2 h1:pnuTK7MQIxxFz1Gr+rjSIx9u7qVjf5VOoM/u6BbAxPY=
|
||||
@@ -349,8 +347,6 @@ github.com/ncruces/go-strftime v1.0.0 h1:HMFp8mLCTPp341M/ZnA4qaf7ZlsbTc+miZjCLOF
|
||||
github.com/ncruces/go-strftime v1.0.0/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
|
||||
github.com/olahol/melody v1.4.0 h1:Pa5SdeZL/zXPi1tJuMAPDbl4n3gQOThSL6G1p4qZ4SI=
|
||||
github.com/olahol/melody v1.4.0/go.mod h1:GgkTl6Y7yWj/HtfD48Q5vLKPVoZOH+Qqgfa7CvJgJM4=
|
||||
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
|
||||
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
|
||||
github.com/onsi/ginkgo/v2 v2.9.2 h1:BA2GMJOtfGAfagzYtrAlufIP0lq6QERkFmHLMLPwFSU=
|
||||
github.com/onsi/ginkgo/v2 v2.9.2/go.mod h1:WHcJJG2dIlcCqVfBAwUCrJxSPFb6v4azBwgxeMeDuts=
|
||||
github.com/onsi/gomega v1.27.6 h1:ENqfyGeS5AX/rlXDd/ETokDz93u0YufY1Pgxuy/PvWE=
|
||||
@@ -393,10 +389,6 @@ github.com/shirou/gopsutil/v4 v4.25.11 h1:X53gB7muL9Gnwwo2evPSE+SfOrltMoR6V3xJAX
|
||||
github.com/shirou/gopsutil/v4 v4.25.11/go.mod h1:EivAfP5x2EhLp2ovdpKSozecVXn1TmuG7SMzs/Wh4PU=
|
||||
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e h1:MRM5ITcdelLK2j1vwZ3Je0FKVCfqOLp5zO6trqMLYs0=
|
||||
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e/go.mod h1:XV66xRDqSt+GTGFMVlhk3ULuV0y9ZmzeVGR4mloJI3M=
|
||||
github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I=
|
||||
github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0=
|
||||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
||||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
github.com/spiffe/go-spiffe/v2 v2.6.0 h1:l+DolpxNWYgruGQVV0xsfeya3CsC7m8iBzDnMpsbLuo=
|
||||
github.com/spiffe/go-spiffe/v2 v2.6.0/go.mod h1:gm2SeUoMZEtpnzPNs2Csc0D/gX33k1xIx7lEzqblHEs=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
HB.name,HB.asset_id,HB.location,HB.tags
|
||||
HB.name,HB.asset_id,HB.location,HB.labels
|
||||
Item 1,1,Path / To / Location 1,L1 ; L2 ; L3
|
||||
Item 2,000-002,Path /To/ Location 2,L1;L2;L3
|
||||
Item 3,1000-003,Path / To /Location 3 , L1;L2; L3
|
||||
|
@@ -11,7 +11,7 @@ import (
|
||||
type Event string
|
||||
|
||||
const (
|
||||
EventTagMutation Event = "tags.mutation"
|
||||
EventLabelMutation Event = "label.mutation"
|
||||
EventLocationMutation Event = "location.mutation"
|
||||
EventItemMutation Event = "item.mutation"
|
||||
)
|
||||
@@ -37,7 +37,7 @@ func New() *EventBus {
|
||||
return &EventBus{
|
||||
ch: make(chan eventData, 100),
|
||||
subscribers: map[Event][]func(any){
|
||||
EventTagMutation: {},
|
||||
EventLabelMutation: {},
|
||||
EventLocationMutation: {},
|
||||
EventItemMutation: {},
|
||||
},
|
||||
|
||||
@@ -15,7 +15,7 @@ type ExportItemFields struct {
|
||||
type ExportCSVRow struct {
|
||||
ImportRef string `csv:"HB.import_ref"`
|
||||
Location LocationString `csv:"HB.location"`
|
||||
TagStr TagString `csv:"HB.tags|HB.labels"`
|
||||
LabelStr LabelString `csv:"HB.labels"`
|
||||
AssetID repo.AssetID `csv:"HB.asset_id"`
|
||||
Archived bool `csv:"HB.archived"`
|
||||
URL string `csv:"HB.url"`
|
||||
@@ -48,20 +48,20 @@ type ExportCSVRow struct {
|
||||
|
||||
// ============================================================================
|
||||
|
||||
// TagString is a string slice that is used to represent a list of tags.
|
||||
// LabelString is a string slice that is used to represent a list of labels.
|
||||
//
|
||||
// For example, a list of tags "Important; Work" would be represented as a
|
||||
// TagString with the following values:
|
||||
// For example, a list of labels "Important; Work" would be represented as a
|
||||
// LabelString with the following values:
|
||||
//
|
||||
// TagString{"Important", "Work"}
|
||||
type TagString []string
|
||||
// LabelString{"Important", "Work"}
|
||||
type LabelString []string
|
||||
|
||||
func parseTagString(s string) TagString {
|
||||
func parseLabelString(s string) LabelString {
|
||||
v, _ := parseSeparatedString(s, ";")
|
||||
return v
|
||||
}
|
||||
|
||||
func (ls TagString) String() string {
|
||||
func (ls LabelString) String() string {
|
||||
return strings.Join(ls, "; ")
|
||||
}
|
||||
|
||||
|
||||
@@ -41,54 +41,6 @@ func (s *IOSheet) indexHeaders() {
|
||||
}
|
||||
}
|
||||
|
||||
// primaryCSVTag returns the primary header name from a csv struct tag which
|
||||
// may contain alternatives separated by '|'. For example: "HB.tags|HB.labels"
|
||||
// will return "HB.tags".
|
||||
func primaryCSVTag(tag string) string {
|
||||
if tag == "" {
|
||||
return ""
|
||||
}
|
||||
if i := strings.Index(tag, "|"); i >= 0 {
|
||||
return strings.TrimSpace(tag[:i])
|
||||
}
|
||||
return tag
|
||||
}
|
||||
|
||||
// csvTagAlternatives splits a tag with alternatives separated by '|'.
|
||||
func csvTagAlternatives(tag string) []string {
|
||||
if tag == "" {
|
||||
return nil
|
||||
}
|
||||
parts := strings.Split(tag, "|")
|
||||
for i := range parts {
|
||||
parts[i] = strings.TrimSpace(parts[i])
|
||||
}
|
||||
return parts
|
||||
}
|
||||
|
||||
// findColumnForTag tries to find a column index for a csv tag. The tag may
|
||||
// contain multiple alternatives separated by '|'. It will return the first
|
||||
// matching column index it finds.
|
||||
func (s *IOSheet) findColumnForTag(tag string) (int, bool) {
|
||||
if s.index == nil {
|
||||
s.indexHeaders()
|
||||
}
|
||||
|
||||
// Try primary tag first and then alternatives.
|
||||
alts := csvTagAlternatives(tag)
|
||||
if len(alts) == 0 {
|
||||
return s.GetColumn(tag)
|
||||
}
|
||||
|
||||
for _, t := range alts {
|
||||
if col, ok := s.GetColumn(t); ok {
|
||||
return col, true
|
||||
}
|
||||
}
|
||||
|
||||
return 0, false
|
||||
}
|
||||
|
||||
func (s *IOSheet) GetColumn(str string) (col int, ok bool) {
|
||||
if s.index == nil {
|
||||
s.indexHeaders()
|
||||
@@ -136,7 +88,7 @@ func (s *IOSheet) Read(data io.Reader) error {
|
||||
continue
|
||||
}
|
||||
|
||||
col, ok := s.findColumnForTag(tag)
|
||||
col, ok := s.GetColumn(tag)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
@@ -162,8 +114,8 @@ func (s *IOSheet) Read(data io.Reader) error {
|
||||
v, _ = repo.ParseAssetID(val)
|
||||
case reflect.TypeOf(LocationString{}):
|
||||
v = parseLocationString(val)
|
||||
case reflect.TypeOf(TagString{}):
|
||||
v = parseTagString(val)
|
||||
case reflect.TypeOf(LabelString{}):
|
||||
v = parseLabelString(val)
|
||||
}
|
||||
|
||||
log.Debug().
|
||||
@@ -220,10 +172,10 @@ func (s *IOSheet) ReadItems(ctx context.Context, items []repo.ItemOut, gid uuid.
|
||||
|
||||
locString := fromPathSlice(locPaths)
|
||||
|
||||
tagString := make([]string, len(item.Tags))
|
||||
labelString := make([]string, len(item.Labels))
|
||||
|
||||
for i, l := range item.Tags {
|
||||
tagString[i] = l.Name
|
||||
for i, l := range item.Labels {
|
||||
labelString[i] = l.Name
|
||||
}
|
||||
|
||||
url := generateItemURL(item, hbURL)
|
||||
@@ -242,7 +194,7 @@ func (s *IOSheet) ReadItems(ctx context.Context, items []repo.ItemOut, gid uuid.
|
||||
s.Rows[i] = ExportCSVRow{
|
||||
// fill struct
|
||||
Location: locString,
|
||||
TagStr: tagString,
|
||||
LabelStr: labelString,
|
||||
|
||||
ImportRef: item.ImportRef,
|
||||
AssetID: item.AssetID,
|
||||
@@ -286,7 +238,7 @@ func (s *IOSheet) ReadItems(ctx context.Context, items []repo.ItemOut, gid uuid.
|
||||
|
||||
st := reflect.TypeOf(ExportCSVRow{})
|
||||
|
||||
// Write headers (use the primary tag when alternatives are provided)
|
||||
// Write headers
|
||||
for i := 0; i < st.NumField(); i++ {
|
||||
field := st.Field(i)
|
||||
tag := field.Tag.Get("csv")
|
||||
@@ -294,7 +246,7 @@ func (s *IOSheet) ReadItems(ctx context.Context, items []repo.ItemOut, gid uuid.
|
||||
continue
|
||||
}
|
||||
|
||||
s.headers = append(s.headers, primaryCSVTag(tag))
|
||||
s.headers = append(s.headers, tag)
|
||||
}
|
||||
|
||||
for _, h := range customHeaders {
|
||||
@@ -333,7 +285,7 @@ func (s *IOSheet) CSV() ([][]string, error) {
|
||||
continue
|
||||
}
|
||||
|
||||
col, ok := s.findColumnForTag(tag)
|
||||
col, ok := s.GetColumn(tag)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
@@ -359,8 +311,8 @@ func (s *IOSheet) CSV() ([][]string, error) {
|
||||
v = val.Interface().(repo.AssetID).String()
|
||||
case reflect.TypeOf(LocationString{}):
|
||||
v = val.Interface().(LocationString).String()
|
||||
case reflect.TypeOf(TagString{}):
|
||||
v = val.Interface().(TagString).String()
|
||||
case reflect.TypeOf(LabelString{}):
|
||||
v = val.Interface().(LabelString).String()
|
||||
default:
|
||||
log.Debug().Str("type", field.Type.String()).Msg("unknown type")
|
||||
}
|
||||
|
||||
@@ -77,19 +77,19 @@ func TestSheet_Read(t *testing.T) {
|
||||
Name: "Item 1",
|
||||
AssetID: repo.AssetID(1),
|
||||
Location: LocationString{"Path", "To", "Location 1"},
|
||||
TagStr: TagString{"L1", "L2", "L3"},
|
||||
LabelStr: LabelString{"L1", "L2", "L3"},
|
||||
},
|
||||
{
|
||||
Name: "Item 2",
|
||||
AssetID: repo.AssetID(2),
|
||||
Location: LocationString{"Path", "To", "Location 2"},
|
||||
TagStr: TagString{"L1", "L2", "L3"},
|
||||
LabelStr: LabelString{"L1", "L2", "L3"},
|
||||
},
|
||||
{
|
||||
Name: "Item 3",
|
||||
AssetID: repo.AssetID(1000003),
|
||||
Location: LocationString{"Path", "To", "Location 3"},
|
||||
TagStr: TagString{"L1", "L2", "L3"},
|
||||
LabelStr: LabelString{"L1", "L2", "L3"},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -99,7 +99,7 @@ func serializeLocation[T ~[]string](location T) string {
|
||||
//
|
||||
// 1. If the item does not exist, it is created.
|
||||
// 2. If the item has a ImportRef and it exists it is skipped
|
||||
// 3. Locations and Tags are created if they do not exist.
|
||||
// 3. Locations and Labels are created if they do not exist.
|
||||
func (svc *ItemService) CsvImport(ctx context.Context, gid uuid.UUID, data io.Reader) (int, error) {
|
||||
sheet := reporting.IOSheet{}
|
||||
|
||||
@@ -109,17 +109,17 @@ func (svc *ItemService) CsvImport(ctx context.Context, gid uuid.UUID, data io.Re
|
||||
}
|
||||
|
||||
// ========================================
|
||||
// Tags
|
||||
// Labels
|
||||
|
||||
tagMap := make(map[string]uuid.UUID)
|
||||
labelMap := make(map[string]uuid.UUID)
|
||||
{
|
||||
tags, err := svc.repo.Tags.GetAll(ctx, gid)
|
||||
labels, err := svc.repo.Labels.GetAll(ctx, gid)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
for _, tag := range tags {
|
||||
tagMap[tag.Name] = tag.ID
|
||||
for _, label := range labels {
|
||||
labelMap[label.Name] = label.ID
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,23 +184,23 @@ func (svc *ItemService) CsvImport(ctx context.Context, gid uuid.UUID, data io.Re
|
||||
}
|
||||
|
||||
// ========================================
|
||||
// Pre-Create tags as necessary
|
||||
tagIds := make([]uuid.UUID, len(row.TagStr))
|
||||
// Pre-Create Labels as necessary
|
||||
labelIds := make([]uuid.UUID, len(row.LabelStr))
|
||||
|
||||
for j := range row.TagStr {
|
||||
tag := row.TagStr[j]
|
||||
for j := range row.LabelStr {
|
||||
label := row.LabelStr[j]
|
||||
|
||||
id, ok := tagMap[tag]
|
||||
id, ok := labelMap[label]
|
||||
if !ok {
|
||||
newTag, err := svc.repo.Tags.Create(ctx, gid, repo.TagCreate{Name: tag})
|
||||
newLabel, err := svc.repo.Labels.Create(ctx, gid, repo.LabelCreate{Name: label})
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
id = newTag.ID
|
||||
id = newLabel.ID
|
||||
}
|
||||
|
||||
tagIds[j] = id
|
||||
tagMap[tag] = id
|
||||
labelIds[j] = id
|
||||
labelMap[label] = id
|
||||
}
|
||||
|
||||
// ========================================
|
||||
@@ -262,7 +262,7 @@ func (svc *ItemService) CsvImport(ctx context.Context, gid uuid.UUID, data io.Re
|
||||
Description: row.Description,
|
||||
AssetID: effAID,
|
||||
LocationID: locationID,
|
||||
TagIDs: tagIds,
|
||||
LabelIDs: labelIds,
|
||||
}
|
||||
|
||||
item, err = svc.repo.Items.Create(ctx, gid, newItem)
|
||||
@@ -291,7 +291,7 @@ func (svc *ItemService) CsvImport(ctx context.Context, gid uuid.UUID, data io.Re
|
||||
|
||||
updateItem := repo.ItemUpdate{
|
||||
ID: item.ID,
|
||||
TagIDs: tagIds,
|
||||
LabelIDs: labelIds,
|
||||
LocationID: locationID,
|
||||
|
||||
Name: row.Name,
|
||||
|
||||
@@ -43,7 +43,7 @@ type (
|
||||
)
|
||||
|
||||
// RegisterUser creates a new user and group in the data with the provided data. It also bootstraps the user's group
|
||||
// with default Tags and Locations.
|
||||
// with default Labels and Locations.
|
||||
func (svc *UserService) RegisterUser(ctx context.Context, data UserRegistration) (repo.UserOut, error) {
|
||||
log.Debug().
|
||||
Str("name", data.Name).
|
||||
@@ -95,11 +95,11 @@ func (svc *UserService) RegisterUser(ctx context.Context, data UserRegistration)
|
||||
}
|
||||
log.Debug().Msg("user created")
|
||||
|
||||
// Create the default tags and locations for the group.
|
||||
// Create the default labels and locations for the group.
|
||||
if creatingGroup {
|
||||
log.Debug().Msg("creating default tags")
|
||||
for _, tag := range defaultTags() {
|
||||
_, err := svc.repos.Tags.Create(ctx, usr.GroupID, tag)
|
||||
log.Debug().Msg("creating default labels")
|
||||
for _, label := range defaultLabels() {
|
||||
_, err := svc.repos.Labels.Create(ctx, usr.GroupID, label)
|
||||
if err != nil {
|
||||
return repo.UserOut{}, err
|
||||
}
|
||||
@@ -300,11 +300,11 @@ func (svc *UserService) registerOIDCUser(ctx context.Context, issuer, subject, e
|
||||
return repo.UserOut{}, err
|
||||
}
|
||||
|
||||
log.Debug().Str("issuer", issuer).Str("subject", subject).Msg("creating default tags for OIDC user")
|
||||
for _, tag := range defaultTags() {
|
||||
_, err := svc.repos.Tags.Create(ctx, group.ID, tag)
|
||||
log.Debug().Str("issuer", issuer).Str("subject", subject).Msg("creating default labels for OIDC user")
|
||||
for _, label := range defaultLabels() {
|
||||
_, err := svc.repos.Labels.Create(ctx, group.ID, label)
|
||||
if err != nil {
|
||||
log.Err(err).Msg("Failed to create default tag")
|
||||
log.Err(err).Msg("Failed to create default label")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,8 +33,8 @@ func defaultLocations() []repo.LocationCreate {
|
||||
}
|
||||
}
|
||||
|
||||
func defaultTags() []repo.TagCreate {
|
||||
return []repo.TagCreate{
|
||||
func defaultLabels() []repo.LabelCreate {
|
||||
return []repo.LabelCreate{
|
||||
{
|
||||
Name: "Appliances",
|
||||
},
|
||||
|
||||
378
backend/internal/data/ent/client.go
generated
378
backend/internal/data/ent/client.go
generated
@@ -24,10 +24,10 @@ import (
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemfield"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/label"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/location"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/maintenanceentry"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/notifier"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/tag"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/templatefield"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/user"
|
||||
)
|
||||
@@ -53,14 +53,14 @@ type Client struct {
|
||||
ItemField *ItemFieldClient
|
||||
// ItemTemplate is the client for interacting with the ItemTemplate builders.
|
||||
ItemTemplate *ItemTemplateClient
|
||||
// Label is the client for interacting with the Label builders.
|
||||
Label *LabelClient
|
||||
// Location is the client for interacting with the Location builders.
|
||||
Location *LocationClient
|
||||
// MaintenanceEntry is the client for interacting with the MaintenanceEntry builders.
|
||||
MaintenanceEntry *MaintenanceEntryClient
|
||||
// Notifier is the client for interacting with the Notifier builders.
|
||||
Notifier *NotifierClient
|
||||
// Tag is the client for interacting with the Tag builders.
|
||||
Tag *TagClient
|
||||
// TemplateField is the client for interacting with the TemplateField builders.
|
||||
TemplateField *TemplateFieldClient
|
||||
// User is the client for interacting with the User builders.
|
||||
@@ -84,10 +84,10 @@ func (c *Client) init() {
|
||||
c.Item = NewItemClient(c.config)
|
||||
c.ItemField = NewItemFieldClient(c.config)
|
||||
c.ItemTemplate = NewItemTemplateClient(c.config)
|
||||
c.Label = NewLabelClient(c.config)
|
||||
c.Location = NewLocationClient(c.config)
|
||||
c.MaintenanceEntry = NewMaintenanceEntryClient(c.config)
|
||||
c.Notifier = NewNotifierClient(c.config)
|
||||
c.Tag = NewTagClient(c.config)
|
||||
c.TemplateField = NewTemplateFieldClient(c.config)
|
||||
c.User = NewUserClient(c.config)
|
||||
}
|
||||
@@ -190,10 +190,10 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) {
|
||||
Item: NewItemClient(cfg),
|
||||
ItemField: NewItemFieldClient(cfg),
|
||||
ItemTemplate: NewItemTemplateClient(cfg),
|
||||
Label: NewLabelClient(cfg),
|
||||
Location: NewLocationClient(cfg),
|
||||
MaintenanceEntry: NewMaintenanceEntryClient(cfg),
|
||||
Notifier: NewNotifierClient(cfg),
|
||||
Tag: NewTagClient(cfg),
|
||||
TemplateField: NewTemplateFieldClient(cfg),
|
||||
User: NewUserClient(cfg),
|
||||
}, nil
|
||||
@@ -223,10 +223,10 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)
|
||||
Item: NewItemClient(cfg),
|
||||
ItemField: NewItemFieldClient(cfg),
|
||||
ItemTemplate: NewItemTemplateClient(cfg),
|
||||
Label: NewLabelClient(cfg),
|
||||
Location: NewLocationClient(cfg),
|
||||
MaintenanceEntry: NewMaintenanceEntryClient(cfg),
|
||||
Notifier: NewNotifierClient(cfg),
|
||||
Tag: NewTagClient(cfg),
|
||||
TemplateField: NewTemplateFieldClient(cfg),
|
||||
User: NewUserClient(cfg),
|
||||
}, nil
|
||||
@@ -259,8 +259,8 @@ func (c *Client) Close() error {
|
||||
func (c *Client) Use(hooks ...Hook) {
|
||||
for _, n := range []interface{ Use(...Hook) }{
|
||||
c.Attachment, c.AuthRoles, c.AuthTokens, c.Group, c.GroupInvitationToken,
|
||||
c.Item, c.ItemField, c.ItemTemplate, c.Location, c.MaintenanceEntry,
|
||||
c.Notifier, c.Tag, c.TemplateField, c.User,
|
||||
c.Item, c.ItemField, c.ItemTemplate, c.Label, c.Location, c.MaintenanceEntry,
|
||||
c.Notifier, c.TemplateField, c.User,
|
||||
} {
|
||||
n.Use(hooks...)
|
||||
}
|
||||
@@ -271,8 +271,8 @@ func (c *Client) Use(hooks ...Hook) {
|
||||
func (c *Client) Intercept(interceptors ...Interceptor) {
|
||||
for _, n := range []interface{ Intercept(...Interceptor) }{
|
||||
c.Attachment, c.AuthRoles, c.AuthTokens, c.Group, c.GroupInvitationToken,
|
||||
c.Item, c.ItemField, c.ItemTemplate, c.Location, c.MaintenanceEntry,
|
||||
c.Notifier, c.Tag, c.TemplateField, c.User,
|
||||
c.Item, c.ItemField, c.ItemTemplate, c.Label, c.Location, c.MaintenanceEntry,
|
||||
c.Notifier, c.TemplateField, c.User,
|
||||
} {
|
||||
n.Intercept(interceptors...)
|
||||
}
|
||||
@@ -297,14 +297,14 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) {
|
||||
return c.ItemField.mutate(ctx, m)
|
||||
case *ItemTemplateMutation:
|
||||
return c.ItemTemplate.mutate(ctx, m)
|
||||
case *LabelMutation:
|
||||
return c.Label.mutate(ctx, m)
|
||||
case *LocationMutation:
|
||||
return c.Location.mutate(ctx, m)
|
||||
case *MaintenanceEntryMutation:
|
||||
return c.MaintenanceEntry.mutate(ctx, m)
|
||||
case *NotifierMutation:
|
||||
return c.Notifier.mutate(ctx, m)
|
||||
case *TagMutation:
|
||||
return c.Tag.mutate(ctx, m)
|
||||
case *TemplateFieldMutation:
|
||||
return c.TemplateField.mutate(ctx, m)
|
||||
case *UserMutation:
|
||||
@@ -949,15 +949,15 @@ func (c *GroupClient) QueryItems(_m *Group) *ItemQuery {
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryTags queries the tags edge of a Group.
|
||||
func (c *GroupClient) QueryTags(_m *Group) *TagQuery {
|
||||
query := (&TagClient{config: c.config}).Query()
|
||||
// QueryLabels queries the labels edge of a Group.
|
||||
func (c *GroupClient) QueryLabels(_m *Group) *LabelQuery {
|
||||
query := (&LabelClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(group.Table, group.FieldID, id),
|
||||
sqlgraph.To(tag.Table, tag.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, group.TagsTable, group.TagsColumn),
|
||||
sqlgraph.To(label.Table, label.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, group.LabelsTable, group.LabelsColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
@@ -1343,15 +1343,15 @@ func (c *ItemClient) QueryChildren(_m *Item) *ItemQuery {
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryTag queries the tag edge of a Item.
|
||||
func (c *ItemClient) QueryTag(_m *Item) *TagQuery {
|
||||
query := (&TagClient{config: c.config}).Query()
|
||||
// QueryLabel queries the label edge of a Item.
|
||||
func (c *ItemClient) QueryLabel(_m *Item) *LabelQuery {
|
||||
query := (&LabelClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(item.Table, item.FieldID, id),
|
||||
sqlgraph.To(tag.Table, tag.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2M, true, item.TagTable, item.TagPrimaryKey...),
|
||||
sqlgraph.To(label.Table, label.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2M, true, item.LabelTable, item.LabelPrimaryKey...),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
@@ -1778,6 +1778,171 @@ func (c *ItemTemplateClient) mutate(ctx context.Context, m *ItemTemplateMutation
|
||||
}
|
||||
}
|
||||
|
||||
// LabelClient is a client for the Label schema.
|
||||
type LabelClient struct {
|
||||
config
|
||||
}
|
||||
|
||||
// NewLabelClient returns a client for the Label from the given config.
|
||||
func NewLabelClient(c config) *LabelClient {
|
||||
return &LabelClient{config: c}
|
||||
}
|
||||
|
||||
// Use adds a list of mutation hooks to the hooks stack.
|
||||
// A call to `Use(f, g, h)` equals to `label.Hooks(f(g(h())))`.
|
||||
func (c *LabelClient) Use(hooks ...Hook) {
|
||||
c.hooks.Label = append(c.hooks.Label, hooks...)
|
||||
}
|
||||
|
||||
// Intercept adds a list of query interceptors to the interceptors stack.
|
||||
// A call to `Intercept(f, g, h)` equals to `label.Intercept(f(g(h())))`.
|
||||
func (c *LabelClient) Intercept(interceptors ...Interceptor) {
|
||||
c.inters.Label = append(c.inters.Label, interceptors...)
|
||||
}
|
||||
|
||||
// Create returns a builder for creating a Label entity.
|
||||
func (c *LabelClient) Create() *LabelCreate {
|
||||
mutation := newLabelMutation(c.config, OpCreate)
|
||||
return &LabelCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// CreateBulk returns a builder for creating a bulk of Label entities.
|
||||
func (c *LabelClient) CreateBulk(builders ...*LabelCreate) *LabelCreateBulk {
|
||||
return &LabelCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
|
||||
// a builder and applies setFunc on it.
|
||||
func (c *LabelClient) MapCreateBulk(slice any, setFunc func(*LabelCreate, int)) *LabelCreateBulk {
|
||||
rv := reflect.ValueOf(slice)
|
||||
if rv.Kind() != reflect.Slice {
|
||||
return &LabelCreateBulk{err: fmt.Errorf("calling to LabelClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
||||
}
|
||||
builders := make([]*LabelCreate, rv.Len())
|
||||
for i := 0; i < rv.Len(); i++ {
|
||||
builders[i] = c.Create()
|
||||
setFunc(builders[i], i)
|
||||
}
|
||||
return &LabelCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// Update returns an update builder for Label.
|
||||
func (c *LabelClient) Update() *LabelUpdate {
|
||||
mutation := newLabelMutation(c.config, OpUpdate)
|
||||
return &LabelUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOne returns an update builder for the given entity.
|
||||
func (c *LabelClient) UpdateOne(_m *Label) *LabelUpdateOne {
|
||||
mutation := newLabelMutation(c.config, OpUpdateOne, withLabel(_m))
|
||||
return &LabelUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOneID returns an update builder for the given id.
|
||||
func (c *LabelClient) UpdateOneID(id uuid.UUID) *LabelUpdateOne {
|
||||
mutation := newLabelMutation(c.config, OpUpdateOne, withLabelID(id))
|
||||
return &LabelUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// Delete returns a delete builder for Label.
|
||||
func (c *LabelClient) Delete() *LabelDelete {
|
||||
mutation := newLabelMutation(c.config, OpDelete)
|
||||
return &LabelDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity.
|
||||
func (c *LabelClient) DeleteOne(_m *Label) *LabelDeleteOne {
|
||||
return c.DeleteOneID(_m.ID)
|
||||
}
|
||||
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
func (c *LabelClient) DeleteOneID(id uuid.UUID) *LabelDeleteOne {
|
||||
builder := c.Delete().Where(label.ID(id))
|
||||
builder.mutation.id = &id
|
||||
builder.mutation.op = OpDeleteOne
|
||||
return &LabelDeleteOne{builder}
|
||||
}
|
||||
|
||||
// Query returns a query builder for Label.
|
||||
func (c *LabelClient) Query() *LabelQuery {
|
||||
return &LabelQuery{
|
||||
config: c.config,
|
||||
ctx: &QueryContext{Type: TypeLabel},
|
||||
inters: c.Interceptors(),
|
||||
}
|
||||
}
|
||||
|
||||
// Get returns a Label entity by its id.
|
||||
func (c *LabelClient) Get(ctx context.Context, id uuid.UUID) (*Label, error) {
|
||||
return c.Query().Where(label.ID(id)).Only(ctx)
|
||||
}
|
||||
|
||||
// GetX is like Get, but panics if an error occurs.
|
||||
func (c *LabelClient) GetX(ctx context.Context, id uuid.UUID) *Label {
|
||||
obj, err := c.Get(ctx, id)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return obj
|
||||
}
|
||||
|
||||
// QueryGroup queries the group edge of a Label.
|
||||
func (c *LabelClient) QueryGroup(_m *Label) *GroupQuery {
|
||||
query := (&GroupClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(label.Table, label.FieldID, id),
|
||||
sqlgraph.To(group.Table, group.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, label.GroupTable, label.GroupColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryItems queries the items edge of a Label.
|
||||
func (c *LabelClient) QueryItems(_m *Label) *ItemQuery {
|
||||
query := (&ItemClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(label.Table, label.FieldID, id),
|
||||
sqlgraph.To(item.Table, item.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2M, false, label.ItemsTable, label.ItemsPrimaryKey...),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// Hooks returns the client hooks.
|
||||
func (c *LabelClient) Hooks() []Hook {
|
||||
return c.hooks.Label
|
||||
}
|
||||
|
||||
// Interceptors returns the client interceptors.
|
||||
func (c *LabelClient) Interceptors() []Interceptor {
|
||||
return c.inters.Label
|
||||
}
|
||||
|
||||
func (c *LabelClient) mutate(ctx context.Context, m *LabelMutation) (Value, error) {
|
||||
switch m.Op() {
|
||||
case OpCreate:
|
||||
return (&LabelCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpUpdate:
|
||||
return (&LabelUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpUpdateOne:
|
||||
return (&LabelUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpDelete, OpDeleteOne:
|
||||
return (&LabelDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
||||
default:
|
||||
return nil, fmt.Errorf("ent: unknown Label mutation op: %q", m.Op())
|
||||
}
|
||||
}
|
||||
|
||||
// LocationClient is a client for the Location schema.
|
||||
type LocationClient struct {
|
||||
config
|
||||
@@ -2289,171 +2454,6 @@ func (c *NotifierClient) mutate(ctx context.Context, m *NotifierMutation) (Value
|
||||
}
|
||||
}
|
||||
|
||||
// TagClient is a client for the Tag schema.
|
||||
type TagClient struct {
|
||||
config
|
||||
}
|
||||
|
||||
// NewTagClient returns a client for the Tag from the given config.
|
||||
func NewTagClient(c config) *TagClient {
|
||||
return &TagClient{config: c}
|
||||
}
|
||||
|
||||
// Use adds a list of mutation hooks to the hooks stack.
|
||||
// A call to `Use(f, g, h)` equals to `tag.Hooks(f(g(h())))`.
|
||||
func (c *TagClient) Use(hooks ...Hook) {
|
||||
c.hooks.Tag = append(c.hooks.Tag, hooks...)
|
||||
}
|
||||
|
||||
// Intercept adds a list of query interceptors to the interceptors stack.
|
||||
// A call to `Intercept(f, g, h)` equals to `tag.Intercept(f(g(h())))`.
|
||||
func (c *TagClient) Intercept(interceptors ...Interceptor) {
|
||||
c.inters.Tag = append(c.inters.Tag, interceptors...)
|
||||
}
|
||||
|
||||
// Create returns a builder for creating a Tag entity.
|
||||
func (c *TagClient) Create() *TagCreate {
|
||||
mutation := newTagMutation(c.config, OpCreate)
|
||||
return &TagCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// CreateBulk returns a builder for creating a bulk of Tag entities.
|
||||
func (c *TagClient) CreateBulk(builders ...*TagCreate) *TagCreateBulk {
|
||||
return &TagCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
|
||||
// a builder and applies setFunc on it.
|
||||
func (c *TagClient) MapCreateBulk(slice any, setFunc func(*TagCreate, int)) *TagCreateBulk {
|
||||
rv := reflect.ValueOf(slice)
|
||||
if rv.Kind() != reflect.Slice {
|
||||
return &TagCreateBulk{err: fmt.Errorf("calling to TagClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
||||
}
|
||||
builders := make([]*TagCreate, rv.Len())
|
||||
for i := 0; i < rv.Len(); i++ {
|
||||
builders[i] = c.Create()
|
||||
setFunc(builders[i], i)
|
||||
}
|
||||
return &TagCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// Update returns an update builder for Tag.
|
||||
func (c *TagClient) Update() *TagUpdate {
|
||||
mutation := newTagMutation(c.config, OpUpdate)
|
||||
return &TagUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOne returns an update builder for the given entity.
|
||||
func (c *TagClient) UpdateOne(_m *Tag) *TagUpdateOne {
|
||||
mutation := newTagMutation(c.config, OpUpdateOne, withTag(_m))
|
||||
return &TagUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOneID returns an update builder for the given id.
|
||||
func (c *TagClient) UpdateOneID(id uuid.UUID) *TagUpdateOne {
|
||||
mutation := newTagMutation(c.config, OpUpdateOne, withTagID(id))
|
||||
return &TagUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// Delete returns a delete builder for Tag.
|
||||
func (c *TagClient) Delete() *TagDelete {
|
||||
mutation := newTagMutation(c.config, OpDelete)
|
||||
return &TagDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity.
|
||||
func (c *TagClient) DeleteOne(_m *Tag) *TagDeleteOne {
|
||||
return c.DeleteOneID(_m.ID)
|
||||
}
|
||||
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
func (c *TagClient) DeleteOneID(id uuid.UUID) *TagDeleteOne {
|
||||
builder := c.Delete().Where(tag.ID(id))
|
||||
builder.mutation.id = &id
|
||||
builder.mutation.op = OpDeleteOne
|
||||
return &TagDeleteOne{builder}
|
||||
}
|
||||
|
||||
// Query returns a query builder for Tag.
|
||||
func (c *TagClient) Query() *TagQuery {
|
||||
return &TagQuery{
|
||||
config: c.config,
|
||||
ctx: &QueryContext{Type: TypeTag},
|
||||
inters: c.Interceptors(),
|
||||
}
|
||||
}
|
||||
|
||||
// Get returns a Tag entity by its id.
|
||||
func (c *TagClient) Get(ctx context.Context, id uuid.UUID) (*Tag, error) {
|
||||
return c.Query().Where(tag.ID(id)).Only(ctx)
|
||||
}
|
||||
|
||||
// GetX is like Get, but panics if an error occurs.
|
||||
func (c *TagClient) GetX(ctx context.Context, id uuid.UUID) *Tag {
|
||||
obj, err := c.Get(ctx, id)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return obj
|
||||
}
|
||||
|
||||
// QueryGroup queries the group edge of a Tag.
|
||||
func (c *TagClient) QueryGroup(_m *Tag) *GroupQuery {
|
||||
query := (&GroupClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(tag.Table, tag.FieldID, id),
|
||||
sqlgraph.To(group.Table, group.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, tag.GroupTable, tag.GroupColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryItems queries the items edge of a Tag.
|
||||
func (c *TagClient) QueryItems(_m *Tag) *ItemQuery {
|
||||
query := (&ItemClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(tag.Table, tag.FieldID, id),
|
||||
sqlgraph.To(item.Table, item.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2M, false, tag.ItemsTable, tag.ItemsPrimaryKey...),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// Hooks returns the client hooks.
|
||||
func (c *TagClient) Hooks() []Hook {
|
||||
return c.hooks.Tag
|
||||
}
|
||||
|
||||
// Interceptors returns the client interceptors.
|
||||
func (c *TagClient) Interceptors() []Interceptor {
|
||||
return c.inters.Tag
|
||||
}
|
||||
|
||||
func (c *TagClient) mutate(ctx context.Context, m *TagMutation) (Value, error) {
|
||||
switch m.Op() {
|
||||
case OpCreate:
|
||||
return (&TagCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpUpdate:
|
||||
return (&TagUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpUpdateOne:
|
||||
return (&TagUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpDelete, OpDeleteOne:
|
||||
return (&TagDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
||||
default:
|
||||
return nil, fmt.Errorf("ent: unknown Tag mutation op: %q", m.Op())
|
||||
}
|
||||
}
|
||||
|
||||
// TemplateFieldClient is a client for the TemplateField schema.
|
||||
type TemplateFieldClient struct {
|
||||
config
|
||||
@@ -2788,12 +2788,12 @@ func (c *UserClient) mutate(ctx context.Context, m *UserMutation) (Value, error)
|
||||
type (
|
||||
hooks struct {
|
||||
Attachment, AuthRoles, AuthTokens, Group, GroupInvitationToken, Item, ItemField,
|
||||
ItemTemplate, Location, MaintenanceEntry, Notifier, Tag, TemplateField,
|
||||
ItemTemplate, Label, Location, MaintenanceEntry, Notifier, TemplateField,
|
||||
User []ent.Hook
|
||||
}
|
||||
inters struct {
|
||||
Attachment, AuthRoles, AuthTokens, Group, GroupInvitationToken, Item, ItemField,
|
||||
ItemTemplate, Location, MaintenanceEntry, Notifier, Tag, TemplateField,
|
||||
ItemTemplate, Label, Location, MaintenanceEntry, Notifier, TemplateField,
|
||||
User []ent.Interceptor
|
||||
}
|
||||
)
|
||||
|
||||
4
backend/internal/data/ent/ent.go
generated
4
backend/internal/data/ent/ent.go
generated
@@ -20,10 +20,10 @@ import (
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemfield"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/label"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/location"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/maintenanceentry"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/notifier"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/tag"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/templatefield"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/user"
|
||||
)
|
||||
@@ -94,10 +94,10 @@ func checkColumn(t, c string) error {
|
||||
item.Table: item.ValidColumn,
|
||||
itemfield.Table: itemfield.ValidColumn,
|
||||
itemtemplate.Table: itemtemplate.ValidColumn,
|
||||
label.Table: label.ValidColumn,
|
||||
location.Table: location.ValidColumn,
|
||||
maintenanceentry.Table: maintenanceentry.ValidColumn,
|
||||
notifier.Table: notifier.ValidColumn,
|
||||
tag.Table: tag.ValidColumn,
|
||||
templatefield.Table: templatefield.ValidColumn,
|
||||
user.Table: user.ValidColumn,
|
||||
})
|
||||
|
||||
18
backend/internal/data/ent/group.go
generated
18
backend/internal/data/ent/group.go
generated
@@ -40,8 +40,8 @@ type GroupEdges struct {
|
||||
Locations []*Location `json:"locations,omitempty"`
|
||||
// Items holds the value of the items edge.
|
||||
Items []*Item `json:"items,omitempty"`
|
||||
// Tags holds the value of the tags edge.
|
||||
Tags []*Tag `json:"tags,omitempty"`
|
||||
// Labels holds the value of the labels edge.
|
||||
Labels []*Label `json:"labels,omitempty"`
|
||||
// InvitationTokens holds the value of the invitation_tokens edge.
|
||||
InvitationTokens []*GroupInvitationToken `json:"invitation_tokens,omitempty"`
|
||||
// Notifiers holds the value of the notifiers edge.
|
||||
@@ -80,13 +80,13 @@ func (e GroupEdges) ItemsOrErr() ([]*Item, error) {
|
||||
return nil, &NotLoadedError{edge: "items"}
|
||||
}
|
||||
|
||||
// TagsOrErr returns the Tags value or an error if the edge
|
||||
// LabelsOrErr returns the Labels value or an error if the edge
|
||||
// was not loaded in eager-loading.
|
||||
func (e GroupEdges) TagsOrErr() ([]*Tag, error) {
|
||||
func (e GroupEdges) LabelsOrErr() ([]*Label, error) {
|
||||
if e.loadedTypes[3] {
|
||||
return e.Tags, nil
|
||||
return e.Labels, nil
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "tags"}
|
||||
return nil, &NotLoadedError{edge: "labels"}
|
||||
}
|
||||
|
||||
// InvitationTokensOrErr returns the InvitationTokens value or an error if the edge
|
||||
@@ -200,9 +200,9 @@ func (_m *Group) QueryItems() *ItemQuery {
|
||||
return NewGroupClient(_m.config).QueryItems(_m)
|
||||
}
|
||||
|
||||
// QueryTags queries the "tags" edge of the Group entity.
|
||||
func (_m *Group) QueryTags() *TagQuery {
|
||||
return NewGroupClient(_m.config).QueryTags(_m)
|
||||
// QueryLabels queries the "labels" edge of the Group entity.
|
||||
func (_m *Group) QueryLabels() *LabelQuery {
|
||||
return NewGroupClient(_m.config).QueryLabels(_m)
|
||||
}
|
||||
|
||||
// QueryInvitationTokens queries the "invitation_tokens" edge of the Group entity.
|
||||
|
||||
36
backend/internal/data/ent/group/group.go
generated
36
backend/internal/data/ent/group/group.go
generated
@@ -29,8 +29,8 @@ const (
|
||||
EdgeLocations = "locations"
|
||||
// EdgeItems holds the string denoting the items edge name in mutations.
|
||||
EdgeItems = "items"
|
||||
// EdgeTags holds the string denoting the tags edge name in mutations.
|
||||
EdgeTags = "tags"
|
||||
// EdgeLabels holds the string denoting the labels edge name in mutations.
|
||||
EdgeLabels = "labels"
|
||||
// EdgeInvitationTokens holds the string denoting the invitation_tokens edge name in mutations.
|
||||
EdgeInvitationTokens = "invitation_tokens"
|
||||
// EdgeNotifiers holds the string denoting the notifiers edge name in mutations.
|
||||
@@ -60,13 +60,13 @@ const (
|
||||
ItemsInverseTable = "items"
|
||||
// ItemsColumn is the table column denoting the items relation/edge.
|
||||
ItemsColumn = "group_items"
|
||||
// TagsTable is the table that holds the tags relation/edge.
|
||||
TagsTable = "tags"
|
||||
// TagsInverseTable is the table name for the Tag entity.
|
||||
// It exists in this package in order to avoid circular dependency with the "tag" package.
|
||||
TagsInverseTable = "tags"
|
||||
// TagsColumn is the table column denoting the tags relation/edge.
|
||||
TagsColumn = "group_tags"
|
||||
// LabelsTable is the table that holds the labels relation/edge.
|
||||
LabelsTable = "labels"
|
||||
// LabelsInverseTable is the table name for the Label entity.
|
||||
// It exists in this package in order to avoid circular dependency with the "label" package.
|
||||
LabelsInverseTable = "labels"
|
||||
// LabelsColumn is the table column denoting the labels relation/edge.
|
||||
LabelsColumn = "group_labels"
|
||||
// InvitationTokensTable is the table that holds the invitation_tokens relation/edge.
|
||||
InvitationTokensTable = "group_invitation_tokens"
|
||||
// InvitationTokensInverseTable is the table name for the GroupInvitationToken entity.
|
||||
@@ -194,17 +194,17 @@ func ByItems(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
|
||||
}
|
||||
}
|
||||
|
||||
// ByTagsCount orders the results by tags count.
|
||||
func ByTagsCount(opts ...sql.OrderTermOption) OrderOption {
|
||||
// ByLabelsCount orders the results by labels count.
|
||||
func ByLabelsCount(opts ...sql.OrderTermOption) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborsCount(s, newTagsStep(), opts...)
|
||||
sqlgraph.OrderByNeighborsCount(s, newLabelsStep(), opts...)
|
||||
}
|
||||
}
|
||||
|
||||
// ByTags orders the results by tags terms.
|
||||
func ByTags(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
|
||||
// ByLabels orders the results by labels terms.
|
||||
func ByLabels(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborTerms(s, newTagsStep(), append([]sql.OrderTerm{term}, terms...)...)
|
||||
sqlgraph.OrderByNeighborTerms(s, newLabelsStep(), append([]sql.OrderTerm{term}, terms...)...)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -270,11 +270,11 @@ func newItemsStep() *sqlgraph.Step {
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, ItemsTable, ItemsColumn),
|
||||
)
|
||||
}
|
||||
func newTagsStep() *sqlgraph.Step {
|
||||
func newLabelsStep() *sqlgraph.Step {
|
||||
return sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(TagsInverseTable, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, TagsTable, TagsColumn),
|
||||
sqlgraph.To(LabelsInverseTable, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, LabelsTable, LabelsColumn),
|
||||
)
|
||||
}
|
||||
func newInvitationTokensStep() *sqlgraph.Step {
|
||||
|
||||
12
backend/internal/data/ent/group/where.go
generated
12
backend/internal/data/ent/group/where.go
generated
@@ -355,21 +355,21 @@ func HasItemsWith(preds ...predicate.Item) predicate.Group {
|
||||
})
|
||||
}
|
||||
|
||||
// HasTags applies the HasEdge predicate on the "tags" edge.
|
||||
func HasTags() predicate.Group {
|
||||
// HasLabels applies the HasEdge predicate on the "labels" edge.
|
||||
func HasLabels() predicate.Group {
|
||||
return predicate.Group(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, TagsTable, TagsColumn),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, LabelsTable, LabelsColumn),
|
||||
)
|
||||
sqlgraph.HasNeighbors(s, step)
|
||||
})
|
||||
}
|
||||
|
||||
// HasTagsWith applies the HasEdge predicate on the "tags" edge with a given conditions (other predicates).
|
||||
func HasTagsWith(preds ...predicate.Tag) predicate.Group {
|
||||
// HasLabelsWith applies the HasEdge predicate on the "labels" edge with a given conditions (other predicates).
|
||||
func HasLabelsWith(preds ...predicate.Label) predicate.Group {
|
||||
return predicate.Group(func(s *sql.Selector) {
|
||||
step := newTagsStep()
|
||||
step := newLabelsStep()
|
||||
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
for _, p := range preds {
|
||||
p(s)
|
||||
|
||||
22
backend/internal/data/ent/group_create.go
generated
22
backend/internal/data/ent/group_create.go
generated
@@ -15,9 +15,9 @@ import (
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/groupinvitationtoken"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/label"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/location"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/notifier"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/tag"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/user"
|
||||
)
|
||||
|
||||
@@ -135,19 +135,19 @@ func (_c *GroupCreate) AddItems(v ...*Item) *GroupCreate {
|
||||
return _c.AddItemIDs(ids...)
|
||||
}
|
||||
|
||||
// AddTagIDs adds the "tags" edge to the Tag entity by IDs.
|
||||
func (_c *GroupCreate) AddTagIDs(ids ...uuid.UUID) *GroupCreate {
|
||||
_c.mutation.AddTagIDs(ids...)
|
||||
// AddLabelIDs adds the "labels" edge to the Label entity by IDs.
|
||||
func (_c *GroupCreate) AddLabelIDs(ids ...uuid.UUID) *GroupCreate {
|
||||
_c.mutation.AddLabelIDs(ids...)
|
||||
return _c
|
||||
}
|
||||
|
||||
// AddTags adds the "tags" edges to the Tag entity.
|
||||
func (_c *GroupCreate) AddTags(v ...*Tag) *GroupCreate {
|
||||
// AddLabels adds the "labels" edges to the Label entity.
|
||||
func (_c *GroupCreate) AddLabels(v ...*Label) *GroupCreate {
|
||||
ids := make([]uuid.UUID, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
}
|
||||
return _c.AddTagIDs(ids...)
|
||||
return _c.AddLabelIDs(ids...)
|
||||
}
|
||||
|
||||
// AddInvitationTokenIDs adds the "invitation_tokens" edge to the GroupInvitationToken entity by IDs.
|
||||
@@ -366,15 +366,15 @@ func (_c *GroupCreate) createSpec() (*Group, *sqlgraph.CreateSpec) {
|
||||
}
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
if nodes := _c.mutation.TagsIDs(); len(nodes) > 0 {
|
||||
if nodes := _c.mutation.LabelsIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: group.TagsTable,
|
||||
Columns: []string{group.TagsColumn},
|
||||
Table: group.LabelsTable,
|
||||
Columns: []string{group.LabelsColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(tag.FieldID, field.TypeUUID),
|
||||
IDSpec: sqlgraph.NewFieldSpec(label.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
|
||||
48
backend/internal/data/ent/group_query.go
generated
48
backend/internal/data/ent/group_query.go
generated
@@ -17,10 +17,10 @@ import (
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/groupinvitationtoken"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/label"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/location"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/notifier"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/tag"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/user"
|
||||
)
|
||||
|
||||
@@ -34,7 +34,7 @@ type GroupQuery struct {
|
||||
withUsers *UserQuery
|
||||
withLocations *LocationQuery
|
||||
withItems *ItemQuery
|
||||
withTags *TagQuery
|
||||
withLabels *LabelQuery
|
||||
withInvitationTokens *GroupInvitationTokenQuery
|
||||
withNotifiers *NotifierQuery
|
||||
withItemTemplates *ItemTemplateQuery
|
||||
@@ -140,9 +140,9 @@ func (_q *GroupQuery) QueryItems() *ItemQuery {
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryTags chains the current query on the "tags" edge.
|
||||
func (_q *GroupQuery) QueryTags() *TagQuery {
|
||||
query := (&TagClient{config: _q.config}).Query()
|
||||
// QueryLabels chains the current query on the "labels" edge.
|
||||
func (_q *GroupQuery) QueryLabels() *LabelQuery {
|
||||
query := (&LabelClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
@@ -153,8 +153,8 @@ func (_q *GroupQuery) QueryTags() *TagQuery {
|
||||
}
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(group.Table, group.FieldID, selector),
|
||||
sqlgraph.To(tag.Table, tag.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, group.TagsTable, group.TagsColumn),
|
||||
sqlgraph.To(label.Table, label.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, group.LabelsTable, group.LabelsColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
@@ -423,7 +423,7 @@ func (_q *GroupQuery) Clone() *GroupQuery {
|
||||
withUsers: _q.withUsers.Clone(),
|
||||
withLocations: _q.withLocations.Clone(),
|
||||
withItems: _q.withItems.Clone(),
|
||||
withTags: _q.withTags.Clone(),
|
||||
withLabels: _q.withLabels.Clone(),
|
||||
withInvitationTokens: _q.withInvitationTokens.Clone(),
|
||||
withNotifiers: _q.withNotifiers.Clone(),
|
||||
withItemTemplates: _q.withItemTemplates.Clone(),
|
||||
@@ -466,14 +466,14 @@ func (_q *GroupQuery) WithItems(opts ...func(*ItemQuery)) *GroupQuery {
|
||||
return _q
|
||||
}
|
||||
|
||||
// WithTags tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "tags" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (_q *GroupQuery) WithTags(opts ...func(*TagQuery)) *GroupQuery {
|
||||
query := (&TagClient{config: _q.config}).Query()
|
||||
// WithLabels tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "labels" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (_q *GroupQuery) WithLabels(opts ...func(*LabelQuery)) *GroupQuery {
|
||||
query := (&LabelClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
_q.withTags = query
|
||||
_q.withLabels = query
|
||||
return _q
|
||||
}
|
||||
|
||||
@@ -592,7 +592,7 @@ func (_q *GroupQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Group,
|
||||
_q.withUsers != nil,
|
||||
_q.withLocations != nil,
|
||||
_q.withItems != nil,
|
||||
_q.withTags != nil,
|
||||
_q.withLabels != nil,
|
||||
_q.withInvitationTokens != nil,
|
||||
_q.withNotifiers != nil,
|
||||
_q.withItemTemplates != nil,
|
||||
@@ -637,10 +637,10 @@ func (_q *GroupQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Group,
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if query := _q.withTags; query != nil {
|
||||
if err := _q.loadTags(ctx, query, nodes,
|
||||
func(n *Group) { n.Edges.Tags = []*Tag{} },
|
||||
func(n *Group, e *Tag) { n.Edges.Tags = append(n.Edges.Tags, e) }); err != nil {
|
||||
if query := _q.withLabels; query != nil {
|
||||
if err := _q.loadLabels(ctx, query, nodes,
|
||||
func(n *Group) { n.Edges.Labels = []*Label{} },
|
||||
func(n *Group, e *Label) { n.Edges.Labels = append(n.Edges.Labels, e) }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
@@ -763,7 +763,7 @@ func (_q *GroupQuery) loadItems(ctx context.Context, query *ItemQuery, nodes []*
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (_q *GroupQuery) loadTags(ctx context.Context, query *TagQuery, nodes []*Group, init func(*Group), assign func(*Group, *Tag)) error {
|
||||
func (_q *GroupQuery) loadLabels(ctx context.Context, query *LabelQuery, nodes []*Group, init func(*Group), assign func(*Group, *Label)) error {
|
||||
fks := make([]driver.Value, 0, len(nodes))
|
||||
nodeids := make(map[uuid.UUID]*Group)
|
||||
for i := range nodes {
|
||||
@@ -774,21 +774,21 @@ func (_q *GroupQuery) loadTags(ctx context.Context, query *TagQuery, nodes []*Gr
|
||||
}
|
||||
}
|
||||
query.withFKs = true
|
||||
query.Where(predicate.Tag(func(s *sql.Selector) {
|
||||
s.Where(sql.InValues(s.C(group.TagsColumn), fks...))
|
||||
query.Where(predicate.Label(func(s *sql.Selector) {
|
||||
s.Where(sql.InValues(s.C(group.LabelsColumn), fks...))
|
||||
}))
|
||||
neighbors, err := query.All(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, n := range neighbors {
|
||||
fk := n.group_tags
|
||||
fk := n.group_labels
|
||||
if fk == nil {
|
||||
return fmt.Errorf(`foreign-key "group_tags" is nil for node %v`, n.ID)
|
||||
return fmt.Errorf(`foreign-key "group_labels" is nil for node %v`, n.ID)
|
||||
}
|
||||
node, ok := nodeids[*fk]
|
||||
if !ok {
|
||||
return fmt.Errorf(`unexpected referenced foreign-key "group_tags" returned %v for node %v`, *fk, n.ID)
|
||||
return fmt.Errorf(`unexpected referenced foreign-key "group_labels" returned %v for node %v`, *fk, n.ID)
|
||||
}
|
||||
assign(node, n)
|
||||
}
|
||||
|
||||
110
backend/internal/data/ent/group_update.go
generated
110
backend/internal/data/ent/group_update.go
generated
@@ -16,10 +16,10 @@ import (
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/groupinvitationtoken"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/label"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/location"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/notifier"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/tag"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/user"
|
||||
)
|
||||
|
||||
@@ -115,19 +115,19 @@ func (_u *GroupUpdate) AddItems(v ...*Item) *GroupUpdate {
|
||||
return _u.AddItemIDs(ids...)
|
||||
}
|
||||
|
||||
// AddTagIDs adds the "tags" edge to the Tag entity by IDs.
|
||||
func (_u *GroupUpdate) AddTagIDs(ids ...uuid.UUID) *GroupUpdate {
|
||||
_u.mutation.AddTagIDs(ids...)
|
||||
// AddLabelIDs adds the "labels" edge to the Label entity by IDs.
|
||||
func (_u *GroupUpdate) AddLabelIDs(ids ...uuid.UUID) *GroupUpdate {
|
||||
_u.mutation.AddLabelIDs(ids...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddTags adds the "tags" edges to the Tag entity.
|
||||
func (_u *GroupUpdate) AddTags(v ...*Tag) *GroupUpdate {
|
||||
// AddLabels adds the "labels" edges to the Label entity.
|
||||
func (_u *GroupUpdate) AddLabels(v ...*Label) *GroupUpdate {
|
||||
ids := make([]uuid.UUID, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
}
|
||||
return _u.AddTagIDs(ids...)
|
||||
return _u.AddLabelIDs(ids...)
|
||||
}
|
||||
|
||||
// AddInvitationTokenIDs adds the "invitation_tokens" edge to the GroupInvitationToken entity by IDs.
|
||||
@@ -243,25 +243,25 @@ func (_u *GroupUpdate) RemoveItems(v ...*Item) *GroupUpdate {
|
||||
return _u.RemoveItemIDs(ids...)
|
||||
}
|
||||
|
||||
// ClearTags clears all "tags" edges to the Tag entity.
|
||||
func (_u *GroupUpdate) ClearTags() *GroupUpdate {
|
||||
_u.mutation.ClearTags()
|
||||
// ClearLabels clears all "labels" edges to the Label entity.
|
||||
func (_u *GroupUpdate) ClearLabels() *GroupUpdate {
|
||||
_u.mutation.ClearLabels()
|
||||
return _u
|
||||
}
|
||||
|
||||
// RemoveTagIDs removes the "tags" edge to Tag entities by IDs.
|
||||
func (_u *GroupUpdate) RemoveTagIDs(ids ...uuid.UUID) *GroupUpdate {
|
||||
_u.mutation.RemoveTagIDs(ids...)
|
||||
// RemoveLabelIDs removes the "labels" edge to Label entities by IDs.
|
||||
func (_u *GroupUpdate) RemoveLabelIDs(ids ...uuid.UUID) *GroupUpdate {
|
||||
_u.mutation.RemoveLabelIDs(ids...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// RemoveTags removes "tags" edges to Tag entities.
|
||||
func (_u *GroupUpdate) RemoveTags(v ...*Tag) *GroupUpdate {
|
||||
// RemoveLabels removes "labels" edges to Label entities.
|
||||
func (_u *GroupUpdate) RemoveLabels(v ...*Label) *GroupUpdate {
|
||||
ids := make([]uuid.UUID, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
}
|
||||
return _u.RemoveTagIDs(ids...)
|
||||
return _u.RemoveLabelIDs(ids...)
|
||||
}
|
||||
|
||||
// ClearInvitationTokens clears all "invitation_tokens" edges to the GroupInvitationToken entity.
|
||||
@@ -529,28 +529,28 @@ func (_u *GroupUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if _u.mutation.TagsCleared() {
|
||||
if _u.mutation.LabelsCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: group.TagsTable,
|
||||
Columns: []string{group.TagsColumn},
|
||||
Table: group.LabelsTable,
|
||||
Columns: []string{group.LabelsColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(tag.FieldID, field.TypeUUID),
|
||||
IDSpec: sqlgraph.NewFieldSpec(label.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := _u.mutation.RemovedTagsIDs(); len(nodes) > 0 && !_u.mutation.TagsCleared() {
|
||||
if nodes := _u.mutation.RemovedLabelsIDs(); len(nodes) > 0 && !_u.mutation.LabelsCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: group.TagsTable,
|
||||
Columns: []string{group.TagsColumn},
|
||||
Table: group.LabelsTable,
|
||||
Columns: []string{group.LabelsColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(tag.FieldID, field.TypeUUID),
|
||||
IDSpec: sqlgraph.NewFieldSpec(label.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
@@ -558,15 +558,15 @@ func (_u *GroupUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := _u.mutation.TagsIDs(); len(nodes) > 0 {
|
||||
if nodes := _u.mutation.LabelsIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: group.TagsTable,
|
||||
Columns: []string{group.TagsColumn},
|
||||
Table: group.LabelsTable,
|
||||
Columns: []string{group.LabelsColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(tag.FieldID, field.TypeUUID),
|
||||
IDSpec: sqlgraph.NewFieldSpec(label.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
@@ -808,19 +808,19 @@ func (_u *GroupUpdateOne) AddItems(v ...*Item) *GroupUpdateOne {
|
||||
return _u.AddItemIDs(ids...)
|
||||
}
|
||||
|
||||
// AddTagIDs adds the "tags" edge to the Tag entity by IDs.
|
||||
func (_u *GroupUpdateOne) AddTagIDs(ids ...uuid.UUID) *GroupUpdateOne {
|
||||
_u.mutation.AddTagIDs(ids...)
|
||||
// AddLabelIDs adds the "labels" edge to the Label entity by IDs.
|
||||
func (_u *GroupUpdateOne) AddLabelIDs(ids ...uuid.UUID) *GroupUpdateOne {
|
||||
_u.mutation.AddLabelIDs(ids...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddTags adds the "tags" edges to the Tag entity.
|
||||
func (_u *GroupUpdateOne) AddTags(v ...*Tag) *GroupUpdateOne {
|
||||
// AddLabels adds the "labels" edges to the Label entity.
|
||||
func (_u *GroupUpdateOne) AddLabels(v ...*Label) *GroupUpdateOne {
|
||||
ids := make([]uuid.UUID, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
}
|
||||
return _u.AddTagIDs(ids...)
|
||||
return _u.AddLabelIDs(ids...)
|
||||
}
|
||||
|
||||
// AddInvitationTokenIDs adds the "invitation_tokens" edge to the GroupInvitationToken entity by IDs.
|
||||
@@ -936,25 +936,25 @@ func (_u *GroupUpdateOne) RemoveItems(v ...*Item) *GroupUpdateOne {
|
||||
return _u.RemoveItemIDs(ids...)
|
||||
}
|
||||
|
||||
// ClearTags clears all "tags" edges to the Tag entity.
|
||||
func (_u *GroupUpdateOne) ClearTags() *GroupUpdateOne {
|
||||
_u.mutation.ClearTags()
|
||||
// ClearLabels clears all "labels" edges to the Label entity.
|
||||
func (_u *GroupUpdateOne) ClearLabels() *GroupUpdateOne {
|
||||
_u.mutation.ClearLabels()
|
||||
return _u
|
||||
}
|
||||
|
||||
// RemoveTagIDs removes the "tags" edge to Tag entities by IDs.
|
||||
func (_u *GroupUpdateOne) RemoveTagIDs(ids ...uuid.UUID) *GroupUpdateOne {
|
||||
_u.mutation.RemoveTagIDs(ids...)
|
||||
// RemoveLabelIDs removes the "labels" edge to Label entities by IDs.
|
||||
func (_u *GroupUpdateOne) RemoveLabelIDs(ids ...uuid.UUID) *GroupUpdateOne {
|
||||
_u.mutation.RemoveLabelIDs(ids...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// RemoveTags removes "tags" edges to Tag entities.
|
||||
func (_u *GroupUpdateOne) RemoveTags(v ...*Tag) *GroupUpdateOne {
|
||||
// RemoveLabels removes "labels" edges to Label entities.
|
||||
func (_u *GroupUpdateOne) RemoveLabels(v ...*Label) *GroupUpdateOne {
|
||||
ids := make([]uuid.UUID, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
}
|
||||
return _u.RemoveTagIDs(ids...)
|
||||
return _u.RemoveLabelIDs(ids...)
|
||||
}
|
||||
|
||||
// ClearInvitationTokens clears all "invitation_tokens" edges to the GroupInvitationToken entity.
|
||||
@@ -1252,28 +1252,28 @@ func (_u *GroupUpdateOne) sqlSave(ctx context.Context) (_node *Group, err error)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if _u.mutation.TagsCleared() {
|
||||
if _u.mutation.LabelsCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: group.TagsTable,
|
||||
Columns: []string{group.TagsColumn},
|
||||
Table: group.LabelsTable,
|
||||
Columns: []string{group.LabelsColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(tag.FieldID, field.TypeUUID),
|
||||
IDSpec: sqlgraph.NewFieldSpec(label.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := _u.mutation.RemovedTagsIDs(); len(nodes) > 0 && !_u.mutation.TagsCleared() {
|
||||
if nodes := _u.mutation.RemovedLabelsIDs(); len(nodes) > 0 && !_u.mutation.LabelsCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: group.TagsTable,
|
||||
Columns: []string{group.TagsColumn},
|
||||
Table: group.LabelsTable,
|
||||
Columns: []string{group.LabelsColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(tag.FieldID, field.TypeUUID),
|
||||
IDSpec: sqlgraph.NewFieldSpec(label.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
@@ -1281,15 +1281,15 @@ func (_u *GroupUpdateOne) sqlSave(ctx context.Context) (_node *Group, err error)
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := _u.mutation.TagsIDs(); len(nodes) > 0 {
|
||||
if nodes := _u.mutation.LabelsIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: group.TagsTable,
|
||||
Columns: []string{group.TagsColumn},
|
||||
Table: group.LabelsTable,
|
||||
Columns: []string{group.LabelsColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(tag.FieldID, field.TypeUUID),
|
||||
IDSpec: sqlgraph.NewFieldSpec(label.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
|
||||
8
backend/internal/data/ent/has_id.go
generated
8
backend/internal/data/ent/has_id.go
generated
@@ -36,6 +36,10 @@ func (_m *ItemTemplate) GetID() uuid.UUID {
|
||||
return _m.ID
|
||||
}
|
||||
|
||||
func (_m *Label) GetID() uuid.UUID {
|
||||
return _m.ID
|
||||
}
|
||||
|
||||
func (_m *Location) GetID() uuid.UUID {
|
||||
return _m.ID
|
||||
}
|
||||
@@ -48,10 +52,6 @@ func (_m *Notifier) GetID() uuid.UUID {
|
||||
return _m.ID
|
||||
}
|
||||
|
||||
func (_m *Tag) GetID() uuid.UUID {
|
||||
return _m.ID
|
||||
}
|
||||
|
||||
func (_m *TemplateField) GetID() uuid.UUID {
|
||||
return _m.ID
|
||||
}
|
||||
|
||||
24
backend/internal/data/ent/hook/hook.go
generated
24
backend/internal/data/ent/hook/hook.go
generated
@@ -105,6 +105,18 @@ func (f ItemTemplateFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ItemTemplateMutation", m)
|
||||
}
|
||||
|
||||
// The LabelFunc type is an adapter to allow the use of ordinary
|
||||
// function as Label mutator.
|
||||
type LabelFunc func(context.Context, *ent.LabelMutation) (ent.Value, error)
|
||||
|
||||
// Mutate calls f(ctx, m).
|
||||
func (f LabelFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
|
||||
if mv, ok := m.(*ent.LabelMutation); ok {
|
||||
return f(ctx, mv)
|
||||
}
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.LabelMutation", m)
|
||||
}
|
||||
|
||||
// The LocationFunc type is an adapter to allow the use of ordinary
|
||||
// function as Location mutator.
|
||||
type LocationFunc func(context.Context, *ent.LocationMutation) (ent.Value, error)
|
||||
@@ -141,18 +153,6 @@ func (f NotifierFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, er
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.NotifierMutation", m)
|
||||
}
|
||||
|
||||
// The TagFunc type is an adapter to allow the use of ordinary
|
||||
// function as Tag mutator.
|
||||
type TagFunc func(context.Context, *ent.TagMutation) (ent.Value, error)
|
||||
|
||||
// Mutate calls f(ctx, m).
|
||||
func (f TagFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
|
||||
if mv, ok := m.(*ent.TagMutation); ok {
|
||||
return f(ctx, mv)
|
||||
}
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.TagMutation", m)
|
||||
}
|
||||
|
||||
// The TemplateFieldFunc type is an adapter to allow the use of ordinary
|
||||
// function as TemplateField mutator.
|
||||
type TemplateFieldFunc func(context.Context, *ent.TemplateFieldMutation) (ent.Value, error)
|
||||
|
||||
18
backend/internal/data/ent/item.go
generated
18
backend/internal/data/ent/item.go
generated
@@ -85,8 +85,8 @@ type ItemEdges struct {
|
||||
Parent *Item `json:"parent,omitempty"`
|
||||
// Children holds the value of the children edge.
|
||||
Children []*Item `json:"children,omitempty"`
|
||||
// Tag holds the value of the tag edge.
|
||||
Tag []*Tag `json:"tag,omitempty"`
|
||||
// Label holds the value of the label edge.
|
||||
Label []*Label `json:"label,omitempty"`
|
||||
// Location holds the value of the location edge.
|
||||
Location *Location `json:"location,omitempty"`
|
||||
// Fields holds the value of the fields edge.
|
||||
@@ -131,13 +131,13 @@ func (e ItemEdges) ChildrenOrErr() ([]*Item, error) {
|
||||
return nil, &NotLoadedError{edge: "children"}
|
||||
}
|
||||
|
||||
// TagOrErr returns the Tag value or an error if the edge
|
||||
// LabelOrErr returns the Label value or an error if the edge
|
||||
// was not loaded in eager-loading.
|
||||
func (e ItemEdges) TagOrErr() ([]*Tag, error) {
|
||||
func (e ItemEdges) LabelOrErr() ([]*Label, error) {
|
||||
if e.loadedTypes[3] {
|
||||
return e.Tag, nil
|
||||
return e.Label, nil
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "tag"}
|
||||
return nil, &NotLoadedError{edge: "label"}
|
||||
}
|
||||
|
||||
// LocationOrErr returns the Location value or an error if the edge
|
||||
@@ -415,9 +415,9 @@ func (_m *Item) QueryChildren() *ItemQuery {
|
||||
return NewItemClient(_m.config).QueryChildren(_m)
|
||||
}
|
||||
|
||||
// QueryTag queries the "tag" edge of the Item entity.
|
||||
func (_m *Item) QueryTag() *TagQuery {
|
||||
return NewItemClient(_m.config).QueryTag(_m)
|
||||
// QueryLabel queries the "label" edge of the Item entity.
|
||||
func (_m *Item) QueryLabel() *LabelQuery {
|
||||
return NewItemClient(_m.config).QueryLabel(_m)
|
||||
}
|
||||
|
||||
// QueryLocation queries the "location" edge of the Item entity.
|
||||
|
||||
38
backend/internal/data/ent/item/item.go
generated
38
backend/internal/data/ent/item/item.go
generated
@@ -69,8 +69,8 @@ const (
|
||||
EdgeParent = "parent"
|
||||
// EdgeChildren holds the string denoting the children edge name in mutations.
|
||||
EdgeChildren = "children"
|
||||
// EdgeTag holds the string denoting the tag edge name in mutations.
|
||||
EdgeTag = "tag"
|
||||
// EdgeLabel holds the string denoting the label edge name in mutations.
|
||||
EdgeLabel = "label"
|
||||
// EdgeLocation holds the string denoting the location edge name in mutations.
|
||||
EdgeLocation = "location"
|
||||
// EdgeFields holds the string denoting the fields edge name in mutations.
|
||||
@@ -96,11 +96,11 @@ const (
|
||||
ChildrenTable = "items"
|
||||
// ChildrenColumn is the table column denoting the children relation/edge.
|
||||
ChildrenColumn = "item_children"
|
||||
// TagTable is the table that holds the tag relation/edge. The primary key declared below.
|
||||
TagTable = "tag_items"
|
||||
// TagInverseTable is the table name for the Tag entity.
|
||||
// It exists in this package in order to avoid circular dependency with the "tag" package.
|
||||
TagInverseTable = "tags"
|
||||
// LabelTable is the table that holds the label relation/edge. The primary key declared below.
|
||||
LabelTable = "label_items"
|
||||
// LabelInverseTable is the table name for the Label entity.
|
||||
// It exists in this package in order to avoid circular dependency with the "label" package.
|
||||
LabelInverseTable = "labels"
|
||||
// LocationTable is the table that holds the location relation/edge.
|
||||
LocationTable = "items"
|
||||
// LocationInverseTable is the table name for the Location entity.
|
||||
@@ -169,9 +169,9 @@ var ForeignKeys = []string{
|
||||
}
|
||||
|
||||
var (
|
||||
// TagPrimaryKey and TagColumn2 are the table columns denoting the
|
||||
// primary key for the tag relation (M2M).
|
||||
TagPrimaryKey = []string{"tag_id", "item_id"}
|
||||
// LabelPrimaryKey and LabelColumn2 are the table columns denoting the
|
||||
// primary key for the label relation (M2M).
|
||||
LabelPrimaryKey = []string{"label_id", "item_id"}
|
||||
)
|
||||
|
||||
// ValidColumn reports if the column name is valid (part of the table columns).
|
||||
@@ -390,17 +390,17 @@ func ByChildren(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
|
||||
}
|
||||
}
|
||||
|
||||
// ByTagCount orders the results by tag count.
|
||||
func ByTagCount(opts ...sql.OrderTermOption) OrderOption {
|
||||
// ByLabelCount orders the results by label count.
|
||||
func ByLabelCount(opts ...sql.OrderTermOption) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborsCount(s, newTagStep(), opts...)
|
||||
sqlgraph.OrderByNeighborsCount(s, newLabelStep(), opts...)
|
||||
}
|
||||
}
|
||||
|
||||
// ByTag orders the results by tag terms.
|
||||
func ByTag(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
|
||||
// ByLabel orders the results by label terms.
|
||||
func ByLabel(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborTerms(s, newTagStep(), append([]sql.OrderTerm{term}, terms...)...)
|
||||
sqlgraph.OrderByNeighborTerms(s, newLabelStep(), append([]sql.OrderTerm{term}, terms...)...)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -473,11 +473,11 @@ func newChildrenStep() *sqlgraph.Step {
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, ChildrenTable, ChildrenColumn),
|
||||
)
|
||||
}
|
||||
func newTagStep() *sqlgraph.Step {
|
||||
func newLabelStep() *sqlgraph.Step {
|
||||
return sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(TagInverseTable, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2M, true, TagTable, TagPrimaryKey...),
|
||||
sqlgraph.To(LabelInverseTable, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2M, true, LabelTable, LabelPrimaryKey...),
|
||||
)
|
||||
}
|
||||
func newLocationStep() *sqlgraph.Step {
|
||||
|
||||
12
backend/internal/data/ent/item/where.go
generated
12
backend/internal/data/ent/item/where.go
generated
@@ -1490,21 +1490,21 @@ func HasChildrenWith(preds ...predicate.Item) predicate.Item {
|
||||
})
|
||||
}
|
||||
|
||||
// HasTag applies the HasEdge predicate on the "tag" edge.
|
||||
func HasTag() predicate.Item {
|
||||
// HasLabel applies the HasEdge predicate on the "label" edge.
|
||||
func HasLabel() predicate.Item {
|
||||
return predicate.Item(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2M, true, TagTable, TagPrimaryKey...),
|
||||
sqlgraph.Edge(sqlgraph.M2M, true, LabelTable, LabelPrimaryKey...),
|
||||
)
|
||||
sqlgraph.HasNeighbors(s, step)
|
||||
})
|
||||
}
|
||||
|
||||
// HasTagWith applies the HasEdge predicate on the "tag" edge with a given conditions (other predicates).
|
||||
func HasTagWith(preds ...predicate.Tag) predicate.Item {
|
||||
// HasLabelWith applies the HasEdge predicate on the "label" edge with a given conditions (other predicates).
|
||||
func HasLabelWith(preds ...predicate.Label) predicate.Item {
|
||||
return predicate.Item(func(s *sql.Selector) {
|
||||
step := newTagStep()
|
||||
step := newLabelStep()
|
||||
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
for _, p := range preds {
|
||||
p(s)
|
||||
|
||||
22
backend/internal/data/ent/item_create.go
generated
22
backend/internal/data/ent/item_create.go
generated
@@ -15,9 +15,9 @@ import (
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemfield"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/label"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/location"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/maintenanceentry"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/tag"
|
||||
)
|
||||
|
||||
// ItemCreate is the builder for creating a Item entity.
|
||||
@@ -414,19 +414,19 @@ func (_c *ItemCreate) AddChildren(v ...*Item) *ItemCreate {
|
||||
return _c.AddChildIDs(ids...)
|
||||
}
|
||||
|
||||
// AddTagIDs adds the "tag" edge to the Tag entity by IDs.
|
||||
func (_c *ItemCreate) AddTagIDs(ids ...uuid.UUID) *ItemCreate {
|
||||
_c.mutation.AddTagIDs(ids...)
|
||||
// AddLabelIDs adds the "label" edge to the Label entity by IDs.
|
||||
func (_c *ItemCreate) AddLabelIDs(ids ...uuid.UUID) *ItemCreate {
|
||||
_c.mutation.AddLabelIDs(ids...)
|
||||
return _c
|
||||
}
|
||||
|
||||
// AddTag adds the "tag" edges to the Tag entity.
|
||||
func (_c *ItemCreate) AddTag(v ...*Tag) *ItemCreate {
|
||||
// AddLabel adds the "label" edges to the Label entity.
|
||||
func (_c *ItemCreate) AddLabel(v ...*Label) *ItemCreate {
|
||||
ids := make([]uuid.UUID, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
}
|
||||
return _c.AddTagIDs(ids...)
|
||||
return _c.AddLabelIDs(ids...)
|
||||
}
|
||||
|
||||
// SetLocationID sets the "location" edge to the Location entity by ID.
|
||||
@@ -838,15 +838,15 @@ func (_c *ItemCreate) createSpec() (*Item, *sqlgraph.CreateSpec) {
|
||||
}
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
if nodes := _c.mutation.TagIDs(); len(nodes) > 0 {
|
||||
if nodes := _c.mutation.LabelIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2M,
|
||||
Inverse: true,
|
||||
Table: item.TagTable,
|
||||
Columns: item.TagPrimaryKey,
|
||||
Table: item.LabelTable,
|
||||
Columns: item.LabelPrimaryKey,
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(tag.FieldID, field.TypeUUID),
|
||||
IDSpec: sqlgraph.NewFieldSpec(label.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
|
||||
50
backend/internal/data/ent/item_query.go
generated
50
backend/internal/data/ent/item_query.go
generated
@@ -17,10 +17,10 @@ import (
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemfield"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/label"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/location"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/maintenanceentry"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/tag"
|
||||
)
|
||||
|
||||
// ItemQuery is the builder for querying Item entities.
|
||||
@@ -33,7 +33,7 @@ type ItemQuery struct {
|
||||
withGroup *GroupQuery
|
||||
withParent *ItemQuery
|
||||
withChildren *ItemQuery
|
||||
withTag *TagQuery
|
||||
withLabel *LabelQuery
|
||||
withLocation *LocationQuery
|
||||
withFields *ItemFieldQuery
|
||||
withMaintenanceEntries *MaintenanceEntryQuery
|
||||
@@ -141,9 +141,9 @@ func (_q *ItemQuery) QueryChildren() *ItemQuery {
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryTag chains the current query on the "tag" edge.
|
||||
func (_q *ItemQuery) QueryTag() *TagQuery {
|
||||
query := (&TagClient{config: _q.config}).Query()
|
||||
// QueryLabel chains the current query on the "label" edge.
|
||||
func (_q *ItemQuery) QueryLabel() *LabelQuery {
|
||||
query := (&LabelClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
@@ -154,8 +154,8 @@ func (_q *ItemQuery) QueryTag() *TagQuery {
|
||||
}
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(item.Table, item.FieldID, selector),
|
||||
sqlgraph.To(tag.Table, tag.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2M, true, item.TagTable, item.TagPrimaryKey...),
|
||||
sqlgraph.To(label.Table, label.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2M, true, item.LabelTable, item.LabelPrimaryKey...),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
@@ -446,7 +446,7 @@ func (_q *ItemQuery) Clone() *ItemQuery {
|
||||
withGroup: _q.withGroup.Clone(),
|
||||
withParent: _q.withParent.Clone(),
|
||||
withChildren: _q.withChildren.Clone(),
|
||||
withTag: _q.withTag.Clone(),
|
||||
withLabel: _q.withLabel.Clone(),
|
||||
withLocation: _q.withLocation.Clone(),
|
||||
withFields: _q.withFields.Clone(),
|
||||
withMaintenanceEntries: _q.withMaintenanceEntries.Clone(),
|
||||
@@ -490,14 +490,14 @@ func (_q *ItemQuery) WithChildren(opts ...func(*ItemQuery)) *ItemQuery {
|
||||
return _q
|
||||
}
|
||||
|
||||
// WithTag tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "tag" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (_q *ItemQuery) WithTag(opts ...func(*TagQuery)) *ItemQuery {
|
||||
query := (&TagClient{config: _q.config}).Query()
|
||||
// WithLabel tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "label" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (_q *ItemQuery) WithLabel(opts ...func(*LabelQuery)) *ItemQuery {
|
||||
query := (&LabelClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
_q.withTag = query
|
||||
_q.withLabel = query
|
||||
return _q
|
||||
}
|
||||
|
||||
@@ -628,7 +628,7 @@ func (_q *ItemQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Item, e
|
||||
_q.withGroup != nil,
|
||||
_q.withParent != nil,
|
||||
_q.withChildren != nil,
|
||||
_q.withTag != nil,
|
||||
_q.withLabel != nil,
|
||||
_q.withLocation != nil,
|
||||
_q.withFields != nil,
|
||||
_q.withMaintenanceEntries != nil,
|
||||
@@ -678,10 +678,10 @@ func (_q *ItemQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Item, e
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if query := _q.withTag; query != nil {
|
||||
if err := _q.loadTag(ctx, query, nodes,
|
||||
func(n *Item) { n.Edges.Tag = []*Tag{} },
|
||||
func(n *Item, e *Tag) { n.Edges.Tag = append(n.Edges.Tag, e) }); err != nil {
|
||||
if query := _q.withLabel; query != nil {
|
||||
if err := _q.loadLabel(ctx, query, nodes,
|
||||
func(n *Item) { n.Edges.Label = []*Label{} },
|
||||
func(n *Item, e *Label) { n.Edges.Label = append(n.Edges.Label, e) }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
@@ -810,7 +810,7 @@ func (_q *ItemQuery) loadChildren(ctx context.Context, query *ItemQuery, nodes [
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (_q *ItemQuery) loadTag(ctx context.Context, query *TagQuery, nodes []*Item, init func(*Item), assign func(*Item, *Tag)) error {
|
||||
func (_q *ItemQuery) loadLabel(ctx context.Context, query *LabelQuery, nodes []*Item, init func(*Item), assign func(*Item, *Label)) error {
|
||||
edgeIDs := make([]driver.Value, len(nodes))
|
||||
byID := make(map[uuid.UUID]*Item)
|
||||
nids := make(map[uuid.UUID]map[*Item]struct{})
|
||||
@@ -822,11 +822,11 @@ func (_q *ItemQuery) loadTag(ctx context.Context, query *TagQuery, nodes []*Item
|
||||
}
|
||||
}
|
||||
query.Where(func(s *sql.Selector) {
|
||||
joinT := sql.Table(item.TagTable)
|
||||
s.Join(joinT).On(s.C(tag.FieldID), joinT.C(item.TagPrimaryKey[0]))
|
||||
s.Where(sql.InValues(joinT.C(item.TagPrimaryKey[1]), edgeIDs...))
|
||||
joinT := sql.Table(item.LabelTable)
|
||||
s.Join(joinT).On(s.C(label.FieldID), joinT.C(item.LabelPrimaryKey[0]))
|
||||
s.Where(sql.InValues(joinT.C(item.LabelPrimaryKey[1]), edgeIDs...))
|
||||
columns := s.SelectedColumns()
|
||||
s.Select(joinT.C(item.TagPrimaryKey[1]))
|
||||
s.Select(joinT.C(item.LabelPrimaryKey[1]))
|
||||
s.AppendSelect(columns...)
|
||||
s.SetDistinct(false)
|
||||
})
|
||||
@@ -856,14 +856,14 @@ func (_q *ItemQuery) loadTag(ctx context.Context, query *TagQuery, nodes []*Item
|
||||
}
|
||||
})
|
||||
})
|
||||
neighbors, err := withInterceptors[[]*Tag](ctx, query, qr, query.inters)
|
||||
neighbors, err := withInterceptors[[]*Label](ctx, query, qr, query.inters)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, n := range neighbors {
|
||||
nodes, ok := nids[n.ID]
|
||||
if !ok {
|
||||
return fmt.Errorf(`unexpected "tag" node returned %v`, n.ID)
|
||||
return fmt.Errorf(`unexpected "label" node returned %v`, n.ID)
|
||||
}
|
||||
for kn := range nodes {
|
||||
assign(kn, n)
|
||||
|
||||
110
backend/internal/data/ent/item_update.go
generated
110
backend/internal/data/ent/item_update.go
generated
@@ -16,10 +16,10 @@ import (
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemfield"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/label"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/location"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/maintenanceentry"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/tag"
|
||||
)
|
||||
|
||||
// ItemUpdate is the builder for updating Item entities.
|
||||
@@ -500,19 +500,19 @@ func (_u *ItemUpdate) AddChildren(v ...*Item) *ItemUpdate {
|
||||
return _u.AddChildIDs(ids...)
|
||||
}
|
||||
|
||||
// AddTagIDs adds the "tag" edge to the Tag entity by IDs.
|
||||
func (_u *ItemUpdate) AddTagIDs(ids ...uuid.UUID) *ItemUpdate {
|
||||
_u.mutation.AddTagIDs(ids...)
|
||||
// AddLabelIDs adds the "label" edge to the Label entity by IDs.
|
||||
func (_u *ItemUpdate) AddLabelIDs(ids ...uuid.UUID) *ItemUpdate {
|
||||
_u.mutation.AddLabelIDs(ids...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddTag adds the "tag" edges to the Tag entity.
|
||||
func (_u *ItemUpdate) AddTag(v ...*Tag) *ItemUpdate {
|
||||
// AddLabel adds the "label" edges to the Label entity.
|
||||
func (_u *ItemUpdate) AddLabel(v ...*Label) *ItemUpdate {
|
||||
ids := make([]uuid.UUID, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
}
|
||||
return _u.AddTagIDs(ids...)
|
||||
return _u.AddLabelIDs(ids...)
|
||||
}
|
||||
|
||||
// SetLocationID sets the "location" edge to the Location entity by ID.
|
||||
@@ -617,25 +617,25 @@ func (_u *ItemUpdate) RemoveChildren(v ...*Item) *ItemUpdate {
|
||||
return _u.RemoveChildIDs(ids...)
|
||||
}
|
||||
|
||||
// ClearTag clears all "tag" edges to the Tag entity.
|
||||
func (_u *ItemUpdate) ClearTag() *ItemUpdate {
|
||||
_u.mutation.ClearTag()
|
||||
// ClearLabel clears all "label" edges to the Label entity.
|
||||
func (_u *ItemUpdate) ClearLabel() *ItemUpdate {
|
||||
_u.mutation.ClearLabel()
|
||||
return _u
|
||||
}
|
||||
|
||||
// RemoveTagIDs removes the "tag" edge to Tag entities by IDs.
|
||||
func (_u *ItemUpdate) RemoveTagIDs(ids ...uuid.UUID) *ItemUpdate {
|
||||
_u.mutation.RemoveTagIDs(ids...)
|
||||
// RemoveLabelIDs removes the "label" edge to Label entities by IDs.
|
||||
func (_u *ItemUpdate) RemoveLabelIDs(ids ...uuid.UUID) *ItemUpdate {
|
||||
_u.mutation.RemoveLabelIDs(ids...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// RemoveTag removes "tag" edges to Tag entities.
|
||||
func (_u *ItemUpdate) RemoveTag(v ...*Tag) *ItemUpdate {
|
||||
// RemoveLabel removes "label" edges to Label entities.
|
||||
func (_u *ItemUpdate) RemoveLabel(v ...*Label) *ItemUpdate {
|
||||
ids := make([]uuid.UUID, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
}
|
||||
return _u.RemoveTagIDs(ids...)
|
||||
return _u.RemoveLabelIDs(ids...)
|
||||
}
|
||||
|
||||
// ClearLocation clears the "location" edge to the Location entity.
|
||||
@@ -1031,28 +1031,28 @@ func (_u *ItemUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if _u.mutation.TagCleared() {
|
||||
if _u.mutation.LabelCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2M,
|
||||
Inverse: true,
|
||||
Table: item.TagTable,
|
||||
Columns: item.TagPrimaryKey,
|
||||
Table: item.LabelTable,
|
||||
Columns: item.LabelPrimaryKey,
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(tag.FieldID, field.TypeUUID),
|
||||
IDSpec: sqlgraph.NewFieldSpec(label.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := _u.mutation.RemovedTagIDs(); len(nodes) > 0 && !_u.mutation.TagCleared() {
|
||||
if nodes := _u.mutation.RemovedLabelIDs(); len(nodes) > 0 && !_u.mutation.LabelCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2M,
|
||||
Inverse: true,
|
||||
Table: item.TagTable,
|
||||
Columns: item.TagPrimaryKey,
|
||||
Table: item.LabelTable,
|
||||
Columns: item.LabelPrimaryKey,
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(tag.FieldID, field.TypeUUID),
|
||||
IDSpec: sqlgraph.NewFieldSpec(label.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
@@ -1060,15 +1060,15 @@ func (_u *ItemUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := _u.mutation.TagIDs(); len(nodes) > 0 {
|
||||
if nodes := _u.mutation.LabelIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2M,
|
||||
Inverse: true,
|
||||
Table: item.TagTable,
|
||||
Columns: item.TagPrimaryKey,
|
||||
Table: item.LabelTable,
|
||||
Columns: item.LabelPrimaryKey,
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(tag.FieldID, field.TypeUUID),
|
||||
IDSpec: sqlgraph.NewFieldSpec(label.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
@@ -1725,19 +1725,19 @@ func (_u *ItemUpdateOne) AddChildren(v ...*Item) *ItemUpdateOne {
|
||||
return _u.AddChildIDs(ids...)
|
||||
}
|
||||
|
||||
// AddTagIDs adds the "tag" edge to the Tag entity by IDs.
|
||||
func (_u *ItemUpdateOne) AddTagIDs(ids ...uuid.UUID) *ItemUpdateOne {
|
||||
_u.mutation.AddTagIDs(ids...)
|
||||
// AddLabelIDs adds the "label" edge to the Label entity by IDs.
|
||||
func (_u *ItemUpdateOne) AddLabelIDs(ids ...uuid.UUID) *ItemUpdateOne {
|
||||
_u.mutation.AddLabelIDs(ids...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddTag adds the "tag" edges to the Tag entity.
|
||||
func (_u *ItemUpdateOne) AddTag(v ...*Tag) *ItemUpdateOne {
|
||||
// AddLabel adds the "label" edges to the Label entity.
|
||||
func (_u *ItemUpdateOne) AddLabel(v ...*Label) *ItemUpdateOne {
|
||||
ids := make([]uuid.UUID, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
}
|
||||
return _u.AddTagIDs(ids...)
|
||||
return _u.AddLabelIDs(ids...)
|
||||
}
|
||||
|
||||
// SetLocationID sets the "location" edge to the Location entity by ID.
|
||||
@@ -1842,25 +1842,25 @@ func (_u *ItemUpdateOne) RemoveChildren(v ...*Item) *ItemUpdateOne {
|
||||
return _u.RemoveChildIDs(ids...)
|
||||
}
|
||||
|
||||
// ClearTag clears all "tag" edges to the Tag entity.
|
||||
func (_u *ItemUpdateOne) ClearTag() *ItemUpdateOne {
|
||||
_u.mutation.ClearTag()
|
||||
// ClearLabel clears all "label" edges to the Label entity.
|
||||
func (_u *ItemUpdateOne) ClearLabel() *ItemUpdateOne {
|
||||
_u.mutation.ClearLabel()
|
||||
return _u
|
||||
}
|
||||
|
||||
// RemoveTagIDs removes the "tag" edge to Tag entities by IDs.
|
||||
func (_u *ItemUpdateOne) RemoveTagIDs(ids ...uuid.UUID) *ItemUpdateOne {
|
||||
_u.mutation.RemoveTagIDs(ids...)
|
||||
// RemoveLabelIDs removes the "label" edge to Label entities by IDs.
|
||||
func (_u *ItemUpdateOne) RemoveLabelIDs(ids ...uuid.UUID) *ItemUpdateOne {
|
||||
_u.mutation.RemoveLabelIDs(ids...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// RemoveTag removes "tag" edges to Tag entities.
|
||||
func (_u *ItemUpdateOne) RemoveTag(v ...*Tag) *ItemUpdateOne {
|
||||
// RemoveLabel removes "label" edges to Label entities.
|
||||
func (_u *ItemUpdateOne) RemoveLabel(v ...*Label) *ItemUpdateOne {
|
||||
ids := make([]uuid.UUID, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
}
|
||||
return _u.RemoveTagIDs(ids...)
|
||||
return _u.RemoveLabelIDs(ids...)
|
||||
}
|
||||
|
||||
// ClearLocation clears the "location" edge to the Location entity.
|
||||
@@ -2286,28 +2286,28 @@ func (_u *ItemUpdateOne) sqlSave(ctx context.Context) (_node *Item, err error) {
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if _u.mutation.TagCleared() {
|
||||
if _u.mutation.LabelCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2M,
|
||||
Inverse: true,
|
||||
Table: item.TagTable,
|
||||
Columns: item.TagPrimaryKey,
|
||||
Table: item.LabelTable,
|
||||
Columns: item.LabelPrimaryKey,
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(tag.FieldID, field.TypeUUID),
|
||||
IDSpec: sqlgraph.NewFieldSpec(label.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := _u.mutation.RemovedTagIDs(); len(nodes) > 0 && !_u.mutation.TagCleared() {
|
||||
if nodes := _u.mutation.RemovedLabelIDs(); len(nodes) > 0 && !_u.mutation.LabelCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2M,
|
||||
Inverse: true,
|
||||
Table: item.TagTable,
|
||||
Columns: item.TagPrimaryKey,
|
||||
Table: item.LabelTable,
|
||||
Columns: item.LabelPrimaryKey,
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(tag.FieldID, field.TypeUUID),
|
||||
IDSpec: sqlgraph.NewFieldSpec(label.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
@@ -2315,15 +2315,15 @@ func (_u *ItemUpdateOne) sqlSave(ctx context.Context) (_node *Item, err error) {
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := _u.mutation.TagIDs(); len(nodes) > 0 {
|
||||
if nodes := _u.mutation.LabelIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2M,
|
||||
Inverse: true,
|
||||
Table: item.TagTable,
|
||||
Columns: item.TagPrimaryKey,
|
||||
Table: item.LabelTable,
|
||||
Columns: item.LabelPrimaryKey,
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(tag.FieldID, field.TypeUUID),
|
||||
IDSpec: sqlgraph.NewFieldSpec(label.FieldID, field.TypeUUID),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
|
||||
18
backend/internal/data/ent/itemtemplate.go
generated
18
backend/internal/data/ent/itemtemplate.go
generated
@@ -53,8 +53,8 @@ type ItemTemplate struct {
|
||||
IncludePurchaseFields bool `json:"include_purchase_fields,omitempty"`
|
||||
// Whether to include sold fields in items created from this template
|
||||
IncludeSoldFields bool `json:"include_sold_fields,omitempty"`
|
||||
// Default tag IDs for items created from this template
|
||||
DefaultTagIds []uuid.UUID `json:"default_tag_ids,omitempty"`
|
||||
// Default label IDs for items created from this template
|
||||
DefaultLabelIds []uuid.UUID `json:"default_label_ids,omitempty"`
|
||||
// Edges holds the relations/edges for other nodes in the graph.
|
||||
// The values are being populated by the ItemTemplateQuery when eager-loading is set.
|
||||
Edges ItemTemplateEdges `json:"edges"`
|
||||
@@ -112,7 +112,7 @@ func (*ItemTemplate) scanValues(columns []string) ([]any, error) {
|
||||
values := make([]any, len(columns))
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case itemtemplate.FieldDefaultTagIds:
|
||||
case itemtemplate.FieldDefaultLabelIds:
|
||||
values[i] = new([]byte)
|
||||
case itemtemplate.FieldDefaultInsured, itemtemplate.FieldDefaultLifetimeWarranty, itemtemplate.FieldIncludeWarrantyFields, itemtemplate.FieldIncludePurchaseFields, itemtemplate.FieldIncludeSoldFields:
|
||||
values[i] = new(sql.NullBool)
|
||||
@@ -245,12 +245,12 @@ func (_m *ItemTemplate) assignValues(columns []string, values []any) error {
|
||||
} else if value.Valid {
|
||||
_m.IncludeSoldFields = value.Bool
|
||||
}
|
||||
case itemtemplate.FieldDefaultTagIds:
|
||||
case itemtemplate.FieldDefaultLabelIds:
|
||||
if value, ok := values[i].(*[]byte); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field default_tag_ids", values[i])
|
||||
return fmt.Errorf("unexpected type %T for field default_label_ids", values[i])
|
||||
} else if value != nil && len(*value) > 0 {
|
||||
if err := json.Unmarshal(*value, &_m.DefaultTagIds); err != nil {
|
||||
return fmt.Errorf("unmarshal field default_tag_ids: %w", err)
|
||||
if err := json.Unmarshal(*value, &_m.DefaultLabelIds); err != nil {
|
||||
return fmt.Errorf("unmarshal field default_label_ids: %w", err)
|
||||
}
|
||||
}
|
||||
case itemtemplate.ForeignKeys[0]:
|
||||
@@ -366,8 +366,8 @@ func (_m *ItemTemplate) String() string {
|
||||
builder.WriteString("include_sold_fields=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.IncludeSoldFields))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("default_tag_ids=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.DefaultTagIds))
|
||||
builder.WriteString("default_label_ids=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.DefaultLabelIds))
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
@@ -47,8 +47,8 @@ const (
|
||||
FieldIncludePurchaseFields = "include_purchase_fields"
|
||||
// FieldIncludeSoldFields holds the string denoting the include_sold_fields field in the database.
|
||||
FieldIncludeSoldFields = "include_sold_fields"
|
||||
// FieldDefaultTagIds holds the string denoting the default_tag_ids field in the database.
|
||||
FieldDefaultTagIds = "default_tag_ids"
|
||||
// FieldDefaultLabelIds holds the string denoting the default_label_ids field in the database.
|
||||
FieldDefaultLabelIds = "default_label_ids"
|
||||
// EdgeGroup holds the string denoting the group edge name in mutations.
|
||||
EdgeGroup = "group"
|
||||
// EdgeFields holds the string denoting the fields edge name in mutations.
|
||||
@@ -99,7 +99,7 @@ var Columns = []string{
|
||||
FieldIncludeWarrantyFields,
|
||||
FieldIncludePurchaseFields,
|
||||
FieldIncludeSoldFields,
|
||||
FieldDefaultTagIds,
|
||||
FieldDefaultLabelIds,
|
||||
}
|
||||
|
||||
// ForeignKeys holds the SQL foreign-keys that are owned by the "item_templates"
|
||||
|
||||
12
backend/internal/data/ent/itemtemplate/where.go
generated
12
backend/internal/data/ent/itemtemplate/where.go
generated
@@ -896,14 +896,14 @@ func IncludeSoldFieldsNEQ(v bool) predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldNEQ(FieldIncludeSoldFields, v))
|
||||
}
|
||||
|
||||
// DefaultTagIdsIsNil applies the IsNil predicate on the "default_tag_ids" field.
|
||||
func DefaultTagIdsIsNil() predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldIsNull(FieldDefaultTagIds))
|
||||
// DefaultLabelIdsIsNil applies the IsNil predicate on the "default_label_ids" field.
|
||||
func DefaultLabelIdsIsNil() predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldIsNull(FieldDefaultLabelIds))
|
||||
}
|
||||
|
||||
// DefaultTagIdsNotNil applies the NotNil predicate on the "default_tag_ids" field.
|
||||
func DefaultTagIdsNotNil() predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldNotNull(FieldDefaultTagIds))
|
||||
// DefaultLabelIdsNotNil applies the NotNil predicate on the "default_label_ids" field.
|
||||
func DefaultLabelIdsNotNil() predicate.ItemTemplate {
|
||||
return predicate.ItemTemplate(sql.FieldNotNull(FieldDefaultLabelIds))
|
||||
}
|
||||
|
||||
// HasGroup applies the HasEdge predicate on the "group" edge.
|
||||
|
||||
12
backend/internal/data/ent/itemtemplate_create.go
generated
12
backend/internal/data/ent/itemtemplate_create.go
generated
@@ -240,9 +240,9 @@ func (_c *ItemTemplateCreate) SetNillableIncludeSoldFields(v *bool) *ItemTemplat
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetDefaultTagIds sets the "default_tag_ids" field.
|
||||
func (_c *ItemTemplateCreate) SetDefaultTagIds(v []uuid.UUID) *ItemTemplateCreate {
|
||||
_c.mutation.SetDefaultTagIds(v)
|
||||
// SetDefaultLabelIds sets the "default_label_ids" field.
|
||||
func (_c *ItemTemplateCreate) SetDefaultLabelIds(v []uuid.UUID) *ItemTemplateCreate {
|
||||
_c.mutation.SetDefaultLabelIds(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
@@ -549,9 +549,9 @@ func (_c *ItemTemplateCreate) createSpec() (*ItemTemplate, *sqlgraph.CreateSpec)
|
||||
_spec.SetField(itemtemplate.FieldIncludeSoldFields, field.TypeBool, value)
|
||||
_node.IncludeSoldFields = value
|
||||
}
|
||||
if value, ok := _c.mutation.DefaultTagIds(); ok {
|
||||
_spec.SetField(itemtemplate.FieldDefaultTagIds, field.TypeJSON, value)
|
||||
_node.DefaultTagIds = value
|
||||
if value, ok := _c.mutation.DefaultLabelIds(); ok {
|
||||
_spec.SetField(itemtemplate.FieldDefaultLabelIds, field.TypeJSON, value)
|
||||
_node.DefaultLabelIds = value
|
||||
}
|
||||
if nodes := _c.mutation.GroupIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
|
||||
60
backend/internal/data/ent/itemtemplate_update.go
generated
60
backend/internal/data/ent/itemtemplate_update.go
generated
@@ -284,21 +284,21 @@ func (_u *ItemTemplateUpdate) SetNillableIncludeSoldFields(v *bool) *ItemTemplat
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetDefaultTagIds sets the "default_tag_ids" field.
|
||||
func (_u *ItemTemplateUpdate) SetDefaultTagIds(v []uuid.UUID) *ItemTemplateUpdate {
|
||||
_u.mutation.SetDefaultTagIds(v)
|
||||
// SetDefaultLabelIds sets the "default_label_ids" field.
|
||||
func (_u *ItemTemplateUpdate) SetDefaultLabelIds(v []uuid.UUID) *ItemTemplateUpdate {
|
||||
_u.mutation.SetDefaultLabelIds(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// AppendDefaultTagIds appends value to the "default_tag_ids" field.
|
||||
func (_u *ItemTemplateUpdate) AppendDefaultTagIds(v []uuid.UUID) *ItemTemplateUpdate {
|
||||
_u.mutation.AppendDefaultTagIds(v)
|
||||
// AppendDefaultLabelIds appends value to the "default_label_ids" field.
|
||||
func (_u *ItemTemplateUpdate) AppendDefaultLabelIds(v []uuid.UUID) *ItemTemplateUpdate {
|
||||
_u.mutation.AppendDefaultLabelIds(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearDefaultTagIds clears the value of the "default_tag_ids" field.
|
||||
func (_u *ItemTemplateUpdate) ClearDefaultTagIds() *ItemTemplateUpdate {
|
||||
_u.mutation.ClearDefaultTagIds()
|
||||
// ClearDefaultLabelIds clears the value of the "default_label_ids" field.
|
||||
func (_u *ItemTemplateUpdate) ClearDefaultLabelIds() *ItemTemplateUpdate {
|
||||
_u.mutation.ClearDefaultLabelIds()
|
||||
return _u
|
||||
}
|
||||
|
||||
@@ -550,16 +550,16 @@ func (_u *ItemTemplateUpdate) sqlSave(ctx context.Context) (_node int, err error
|
||||
if value, ok := _u.mutation.IncludeSoldFields(); ok {
|
||||
_spec.SetField(itemtemplate.FieldIncludeSoldFields, field.TypeBool, value)
|
||||
}
|
||||
if value, ok := _u.mutation.DefaultTagIds(); ok {
|
||||
_spec.SetField(itemtemplate.FieldDefaultTagIds, field.TypeJSON, value)
|
||||
if value, ok := _u.mutation.DefaultLabelIds(); ok {
|
||||
_spec.SetField(itemtemplate.FieldDefaultLabelIds, field.TypeJSON, value)
|
||||
}
|
||||
if value, ok := _u.mutation.AppendedDefaultTagIds(); ok {
|
||||
if value, ok := _u.mutation.AppendedDefaultLabelIds(); ok {
|
||||
_spec.AddModifier(func(u *sql.UpdateBuilder) {
|
||||
sqljson.Append(u, itemtemplate.FieldDefaultTagIds, value)
|
||||
sqljson.Append(u, itemtemplate.FieldDefaultLabelIds, value)
|
||||
})
|
||||
}
|
||||
if _u.mutation.DefaultTagIdsCleared() {
|
||||
_spec.ClearField(itemtemplate.FieldDefaultTagIds, field.TypeJSON)
|
||||
if _u.mutation.DefaultLabelIdsCleared() {
|
||||
_spec.ClearField(itemtemplate.FieldDefaultLabelIds, field.TypeJSON)
|
||||
}
|
||||
if _u.mutation.GroupCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
@@ -935,21 +935,21 @@ func (_u *ItemTemplateUpdateOne) SetNillableIncludeSoldFields(v *bool) *ItemTemp
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetDefaultTagIds sets the "default_tag_ids" field.
|
||||
func (_u *ItemTemplateUpdateOne) SetDefaultTagIds(v []uuid.UUID) *ItemTemplateUpdateOne {
|
||||
_u.mutation.SetDefaultTagIds(v)
|
||||
// SetDefaultLabelIds sets the "default_label_ids" field.
|
||||
func (_u *ItemTemplateUpdateOne) SetDefaultLabelIds(v []uuid.UUID) *ItemTemplateUpdateOne {
|
||||
_u.mutation.SetDefaultLabelIds(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// AppendDefaultTagIds appends value to the "default_tag_ids" field.
|
||||
func (_u *ItemTemplateUpdateOne) AppendDefaultTagIds(v []uuid.UUID) *ItemTemplateUpdateOne {
|
||||
_u.mutation.AppendDefaultTagIds(v)
|
||||
// AppendDefaultLabelIds appends value to the "default_label_ids" field.
|
||||
func (_u *ItemTemplateUpdateOne) AppendDefaultLabelIds(v []uuid.UUID) *ItemTemplateUpdateOne {
|
||||
_u.mutation.AppendDefaultLabelIds(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearDefaultTagIds clears the value of the "default_tag_ids" field.
|
||||
func (_u *ItemTemplateUpdateOne) ClearDefaultTagIds() *ItemTemplateUpdateOne {
|
||||
_u.mutation.ClearDefaultTagIds()
|
||||
// ClearDefaultLabelIds clears the value of the "default_label_ids" field.
|
||||
func (_u *ItemTemplateUpdateOne) ClearDefaultLabelIds() *ItemTemplateUpdateOne {
|
||||
_u.mutation.ClearDefaultLabelIds()
|
||||
return _u
|
||||
}
|
||||
|
||||
@@ -1231,16 +1231,16 @@ func (_u *ItemTemplateUpdateOne) sqlSave(ctx context.Context) (_node *ItemTempla
|
||||
if value, ok := _u.mutation.IncludeSoldFields(); ok {
|
||||
_spec.SetField(itemtemplate.FieldIncludeSoldFields, field.TypeBool, value)
|
||||
}
|
||||
if value, ok := _u.mutation.DefaultTagIds(); ok {
|
||||
_spec.SetField(itemtemplate.FieldDefaultTagIds, field.TypeJSON, value)
|
||||
if value, ok := _u.mutation.DefaultLabelIds(); ok {
|
||||
_spec.SetField(itemtemplate.FieldDefaultLabelIds, field.TypeJSON, value)
|
||||
}
|
||||
if value, ok := _u.mutation.AppendedDefaultTagIds(); ok {
|
||||
if value, ok := _u.mutation.AppendedDefaultLabelIds(); ok {
|
||||
_spec.AddModifier(func(u *sql.UpdateBuilder) {
|
||||
sqljson.Append(u, itemtemplate.FieldDefaultTagIds, value)
|
||||
sqljson.Append(u, itemtemplate.FieldDefaultLabelIds, value)
|
||||
})
|
||||
}
|
||||
if _u.mutation.DefaultTagIdsCleared() {
|
||||
_spec.ClearField(itemtemplate.FieldDefaultTagIds, field.TypeJSON)
|
||||
if _u.mutation.DefaultLabelIdsCleared() {
|
||||
_spec.ClearField(itemtemplate.FieldDefaultLabelIds, field.TypeJSON)
|
||||
}
|
||||
if _u.mutation.GroupCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
|
||||
@@ -11,11 +11,11 @@ import (
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"github.com/google/uuid"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/tag"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/label"
|
||||
)
|
||||
|
||||
// Tag is the model entity for the Tag schema.
|
||||
type Tag struct {
|
||||
// Label is the model entity for the Label schema.
|
||||
type Label struct {
|
||||
config `json:"-"`
|
||||
// ID of the ent.
|
||||
ID uuid.UUID `json:"id,omitempty"`
|
||||
@@ -30,14 +30,14 @@ type Tag struct {
|
||||
// Color holds the value of the "color" field.
|
||||
Color string `json:"color,omitempty"`
|
||||
// Edges holds the relations/edges for other nodes in the graph.
|
||||
// The values are being populated by the TagQuery when eager-loading is set.
|
||||
Edges TagEdges `json:"edges"`
|
||||
group_tags *uuid.UUID
|
||||
// The values are being populated by the LabelQuery when eager-loading is set.
|
||||
Edges LabelEdges `json:"edges"`
|
||||
group_labels *uuid.UUID
|
||||
selectValues sql.SelectValues
|
||||
}
|
||||
|
||||
// TagEdges holds the relations/edges for other nodes in the graph.
|
||||
type TagEdges struct {
|
||||
// LabelEdges holds the relations/edges for other nodes in the graph.
|
||||
type LabelEdges struct {
|
||||
// Group holds the value of the group edge.
|
||||
Group *Group `json:"group,omitempty"`
|
||||
// Items holds the value of the items edge.
|
||||
@@ -49,7 +49,7 @@ type TagEdges struct {
|
||||
|
||||
// GroupOrErr returns the Group value or an error if the edge
|
||||
// was not loaded in eager-loading, or loaded but was not found.
|
||||
func (e TagEdges) GroupOrErr() (*Group, error) {
|
||||
func (e LabelEdges) GroupOrErr() (*Group, error) {
|
||||
if e.Group != nil {
|
||||
return e.Group, nil
|
||||
} else if e.loadedTypes[0] {
|
||||
@@ -60,7 +60,7 @@ func (e TagEdges) GroupOrErr() (*Group, error) {
|
||||
|
||||
// ItemsOrErr returns the Items value or an error if the edge
|
||||
// was not loaded in eager-loading.
|
||||
func (e TagEdges) ItemsOrErr() ([]*Item, error) {
|
||||
func (e LabelEdges) ItemsOrErr() ([]*Item, error) {
|
||||
if e.loadedTypes[1] {
|
||||
return e.Items, nil
|
||||
}
|
||||
@@ -68,17 +68,17 @@ func (e TagEdges) ItemsOrErr() ([]*Item, error) {
|
||||
}
|
||||
|
||||
// scanValues returns the types for scanning values from sql.Rows.
|
||||
func (*Tag) scanValues(columns []string) ([]any, error) {
|
||||
func (*Label) scanValues(columns []string) ([]any, error) {
|
||||
values := make([]any, len(columns))
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case tag.FieldName, tag.FieldDescription, tag.FieldColor:
|
||||
case label.FieldName, label.FieldDescription, label.FieldColor:
|
||||
values[i] = new(sql.NullString)
|
||||
case tag.FieldCreatedAt, tag.FieldUpdatedAt:
|
||||
case label.FieldCreatedAt, label.FieldUpdatedAt:
|
||||
values[i] = new(sql.NullTime)
|
||||
case tag.FieldID:
|
||||
case label.FieldID:
|
||||
values[i] = new(uuid.UUID)
|
||||
case tag.ForeignKeys[0]: // group_tags
|
||||
case label.ForeignKeys[0]: // group_labels
|
||||
values[i] = &sql.NullScanner{S: new(uuid.UUID)}
|
||||
default:
|
||||
values[i] = new(sql.UnknownType)
|
||||
@@ -88,55 +88,55 @@ func (*Tag) scanValues(columns []string) ([]any, error) {
|
||||
}
|
||||
|
||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||
// to the Tag fields.
|
||||
func (_m *Tag) assignValues(columns []string, values []any) error {
|
||||
// to the Label fields.
|
||||
func (_m *Label) assignValues(columns []string, values []any) error {
|
||||
if m, n := len(values), len(columns); m < n {
|
||||
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||
}
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case tag.FieldID:
|
||||
case label.FieldID:
|
||||
if value, ok := values[i].(*uuid.UUID); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", values[i])
|
||||
} else if value != nil {
|
||||
_m.ID = *value
|
||||
}
|
||||
case tag.FieldCreatedAt:
|
||||
case label.FieldCreatedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field created_at", values[i])
|
||||
} else if value.Valid {
|
||||
_m.CreatedAt = value.Time
|
||||
}
|
||||
case tag.FieldUpdatedAt:
|
||||
case label.FieldUpdatedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
|
||||
} else if value.Valid {
|
||||
_m.UpdatedAt = value.Time
|
||||
}
|
||||
case tag.FieldName:
|
||||
case label.FieldName:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field name", values[i])
|
||||
} else if value.Valid {
|
||||
_m.Name = value.String
|
||||
}
|
||||
case tag.FieldDescription:
|
||||
case label.FieldDescription:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field description", values[i])
|
||||
} else if value.Valid {
|
||||
_m.Description = value.String
|
||||
}
|
||||
case tag.FieldColor:
|
||||
case label.FieldColor:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field color", values[i])
|
||||
} else if value.Valid {
|
||||
_m.Color = value.String
|
||||
}
|
||||
case tag.ForeignKeys[0]:
|
||||
case label.ForeignKeys[0]:
|
||||
if value, ok := values[i].(*sql.NullScanner); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field group_tags", values[i])
|
||||
return fmt.Errorf("unexpected type %T for field group_labels", values[i])
|
||||
} else if value.Valid {
|
||||
_m.group_tags = new(uuid.UUID)
|
||||
*_m.group_tags = *value.S.(*uuid.UUID)
|
||||
_m.group_labels = new(uuid.UUID)
|
||||
*_m.group_labels = *value.S.(*uuid.UUID)
|
||||
}
|
||||
default:
|
||||
_m.selectValues.Set(columns[i], values[i])
|
||||
@@ -145,44 +145,44 @@ func (_m *Tag) assignValues(columns []string, values []any) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Value returns the ent.Value that was dynamically selected and assigned to the Tag.
|
||||
// Value returns the ent.Value that was dynamically selected and assigned to the Label.
|
||||
// This includes values selected through modifiers, order, etc.
|
||||
func (_m *Tag) Value(name string) (ent.Value, error) {
|
||||
func (_m *Label) Value(name string) (ent.Value, error) {
|
||||
return _m.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// QueryGroup queries the "group" edge of the Tag entity.
|
||||
func (_m *Tag) QueryGroup() *GroupQuery {
|
||||
return NewTagClient(_m.config).QueryGroup(_m)
|
||||
// QueryGroup queries the "group" edge of the Label entity.
|
||||
func (_m *Label) QueryGroup() *GroupQuery {
|
||||
return NewLabelClient(_m.config).QueryGroup(_m)
|
||||
}
|
||||
|
||||
// QueryItems queries the "items" edge of the Tag entity.
|
||||
func (_m *Tag) QueryItems() *ItemQuery {
|
||||
return NewTagClient(_m.config).QueryItems(_m)
|
||||
// QueryItems queries the "items" edge of the Label entity.
|
||||
func (_m *Label) QueryItems() *ItemQuery {
|
||||
return NewLabelClient(_m.config).QueryItems(_m)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this Tag.
|
||||
// Note that you need to call Tag.Unwrap() before calling this method if this Tag
|
||||
// Update returns a builder for updating this Label.
|
||||
// Note that you need to call Label.Unwrap() before calling this method if this Label
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (_m *Tag) Update() *TagUpdateOne {
|
||||
return NewTagClient(_m.config).UpdateOne(_m)
|
||||
func (_m *Label) Update() *LabelUpdateOne {
|
||||
return NewLabelClient(_m.config).UpdateOne(_m)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the Tag entity that was returned from a transaction after it was closed,
|
||||
// Unwrap unwraps the Label entity that was returned from a transaction after it was closed,
|
||||
// so that all future queries will be executed through the driver which created the transaction.
|
||||
func (_m *Tag) Unwrap() *Tag {
|
||||
func (_m *Label) Unwrap() *Label {
|
||||
_tx, ok := _m.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("ent: Tag is not a transactional entity")
|
||||
panic("ent: Label is not a transactional entity")
|
||||
}
|
||||
_m.config.driver = _tx.drv
|
||||
return _m
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (_m *Tag) String() string {
|
||||
func (_m *Label) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("Tag(")
|
||||
builder.WriteString("Label(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
||||
builder.WriteString("created_at=")
|
||||
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
|
||||
@@ -202,5 +202,5 @@ func (_m *Tag) String() string {
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
// Tags is a parsable slice of Tag.
|
||||
type Tags []*Tag
|
||||
// Labels is a parsable slice of Label.
|
||||
type Labels []*Label
|
||||
@@ -1,6 +1,6 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package tag
|
||||
package label
|
||||
|
||||
import (
|
||||
"time"
|
||||
@@ -11,8 +11,8 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
// Label holds the string label denoting the tag type in the database.
|
||||
Label = "tag"
|
||||
// Label holds the string label denoting the label type in the database.
|
||||
Label = "label"
|
||||
// FieldID holds the string denoting the id field in the database.
|
||||
FieldID = "id"
|
||||
// FieldCreatedAt holds the string denoting the created_at field in the database.
|
||||
@@ -29,23 +29,23 @@ const (
|
||||
EdgeGroup = "group"
|
||||
// EdgeItems holds the string denoting the items edge name in mutations.
|
||||
EdgeItems = "items"
|
||||
// Table holds the table name of the tag in the database.
|
||||
Table = "tags"
|
||||
// Table holds the table name of the label in the database.
|
||||
Table = "labels"
|
||||
// GroupTable is the table that holds the group relation/edge.
|
||||
GroupTable = "tags"
|
||||
GroupTable = "labels"
|
||||
// GroupInverseTable is the table name for the Group entity.
|
||||
// It exists in this package in order to avoid circular dependency with the "group" package.
|
||||
GroupInverseTable = "groups"
|
||||
// GroupColumn is the table column denoting the group relation/edge.
|
||||
GroupColumn = "group_tags"
|
||||
GroupColumn = "group_labels"
|
||||
// ItemsTable is the table that holds the items relation/edge. The primary key declared below.
|
||||
ItemsTable = "tag_items"
|
||||
ItemsTable = "label_items"
|
||||
// ItemsInverseTable is the table name for the Item entity.
|
||||
// It exists in this package in order to avoid circular dependency with the "item" package.
|
||||
ItemsInverseTable = "items"
|
||||
)
|
||||
|
||||
// Columns holds all SQL columns for tag fields.
|
||||
// Columns holds all SQL columns for label fields.
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldCreatedAt,
|
||||
@@ -55,16 +55,16 @@ var Columns = []string{
|
||||
FieldColor,
|
||||
}
|
||||
|
||||
// ForeignKeys holds the SQL foreign-keys that are owned by the "tags"
|
||||
// ForeignKeys holds the SQL foreign-keys that are owned by the "labels"
|
||||
// table and are not defined as standalone fields in the schema.
|
||||
var ForeignKeys = []string{
|
||||
"group_tags",
|
||||
"group_labels",
|
||||
}
|
||||
|
||||
var (
|
||||
// ItemsPrimaryKey and ItemsColumn2 are the table columns denoting the
|
||||
// primary key for the items relation (M2M).
|
||||
ItemsPrimaryKey = []string{"tag_id", "item_id"}
|
||||
ItemsPrimaryKey = []string{"label_id", "item_id"}
|
||||
)
|
||||
|
||||
// ValidColumn reports if the column name is valid (part of the table columns).
|
||||
@@ -99,7 +99,7 @@ var (
|
||||
DefaultID func() uuid.UUID
|
||||
)
|
||||
|
||||
// OrderOption defines the ordering options for the Tag queries.
|
||||
// OrderOption defines the ordering options for the Label queries.
|
||||
type OrderOption func(*sql.Selector)
|
||||
|
||||
// ByID orders the results by the id field.
|
||||
438
backend/internal/data/ent/label/where.go
generated
Normal file
438
backend/internal/data/ent/label/where.go
generated
Normal file
@@ -0,0 +1,438 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package label
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"github.com/google/uuid"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
|
||||
)
|
||||
|
||||
// ID filters vertices based on their ID field.
|
||||
func ID(id uuid.UUID) predicate.Label {
|
||||
return predicate.Label(sql.FieldEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDEQ applies the EQ predicate on the ID field.
|
||||
func IDEQ(id uuid.UUID) predicate.Label {
|
||||
return predicate.Label(sql.FieldEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDNEQ applies the NEQ predicate on the ID field.
|
||||
func IDNEQ(id uuid.UUID) predicate.Label {
|
||||
return predicate.Label(sql.FieldNEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDIn applies the In predicate on the ID field.
|
||||
func IDIn(ids ...uuid.UUID) predicate.Label {
|
||||
return predicate.Label(sql.FieldIn(FieldID, ids...))
|
||||
}
|
||||
|
||||
// IDNotIn applies the NotIn predicate on the ID field.
|
||||
func IDNotIn(ids ...uuid.UUID) predicate.Label {
|
||||
return predicate.Label(sql.FieldNotIn(FieldID, ids...))
|
||||
}
|
||||
|
||||
// IDGT applies the GT predicate on the ID field.
|
||||
func IDGT(id uuid.UUID) predicate.Label {
|
||||
return predicate.Label(sql.FieldGT(FieldID, id))
|
||||
}
|
||||
|
||||
// IDGTE applies the GTE predicate on the ID field.
|
||||
func IDGTE(id uuid.UUID) predicate.Label {
|
||||
return predicate.Label(sql.FieldGTE(FieldID, id))
|
||||
}
|
||||
|
||||
// IDLT applies the LT predicate on the ID field.
|
||||
func IDLT(id uuid.UUID) predicate.Label {
|
||||
return predicate.Label(sql.FieldLT(FieldID, id))
|
||||
}
|
||||
|
||||
// IDLTE applies the LTE predicate on the ID field.
|
||||
func IDLTE(id uuid.UUID) predicate.Label {
|
||||
return predicate.Label(sql.FieldLTE(FieldID, id))
|
||||
}
|
||||
|
||||
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
|
||||
func CreatedAt(v time.Time) predicate.Label {
|
||||
return predicate.Label(sql.FieldEQ(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ.
|
||||
func UpdatedAt(v time.Time) predicate.Label {
|
||||
return predicate.Label(sql.FieldEQ(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// Name applies equality check predicate on the "name" field. It's identical to NameEQ.
|
||||
func Name(v string) predicate.Label {
|
||||
return predicate.Label(sql.FieldEQ(FieldName, v))
|
||||
}
|
||||
|
||||
// Description applies equality check predicate on the "description" field. It's identical to DescriptionEQ.
|
||||
func Description(v string) predicate.Label {
|
||||
return predicate.Label(sql.FieldEQ(FieldDescription, v))
|
||||
}
|
||||
|
||||
// Color applies equality check predicate on the "color" field. It's identical to ColorEQ.
|
||||
func Color(v string) predicate.Label {
|
||||
return predicate.Label(sql.FieldEQ(FieldColor, v))
|
||||
}
|
||||
|
||||
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
|
||||
func CreatedAtEQ(v time.Time) predicate.Label {
|
||||
return predicate.Label(sql.FieldEQ(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
|
||||
func CreatedAtNEQ(v time.Time) predicate.Label {
|
||||
return predicate.Label(sql.FieldNEQ(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtIn applies the In predicate on the "created_at" field.
|
||||
func CreatedAtIn(vs ...time.Time) predicate.Label {
|
||||
return predicate.Label(sql.FieldIn(FieldCreatedAt, vs...))
|
||||
}
|
||||
|
||||
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
|
||||
func CreatedAtNotIn(vs ...time.Time) predicate.Label {
|
||||
return predicate.Label(sql.FieldNotIn(FieldCreatedAt, vs...))
|
||||
}
|
||||
|
||||
// CreatedAtGT applies the GT predicate on the "created_at" field.
|
||||
func CreatedAtGT(v time.Time) predicate.Label {
|
||||
return predicate.Label(sql.FieldGT(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtGTE applies the GTE predicate on the "created_at" field.
|
||||
func CreatedAtGTE(v time.Time) predicate.Label {
|
||||
return predicate.Label(sql.FieldGTE(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtLT applies the LT predicate on the "created_at" field.
|
||||
func CreatedAtLT(v time.Time) predicate.Label {
|
||||
return predicate.Label(sql.FieldLT(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtLTE applies the LTE predicate on the "created_at" field.
|
||||
func CreatedAtLTE(v time.Time) predicate.Label {
|
||||
return predicate.Label(sql.FieldLTE(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtEQ applies the EQ predicate on the "updated_at" field.
|
||||
func UpdatedAtEQ(v time.Time) predicate.Label {
|
||||
return predicate.Label(sql.FieldEQ(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field.
|
||||
func UpdatedAtNEQ(v time.Time) predicate.Label {
|
||||
return predicate.Label(sql.FieldNEQ(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtIn applies the In predicate on the "updated_at" field.
|
||||
func UpdatedAtIn(vs ...time.Time) predicate.Label {
|
||||
return predicate.Label(sql.FieldIn(FieldUpdatedAt, vs...))
|
||||
}
|
||||
|
||||
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
|
||||
func UpdatedAtNotIn(vs ...time.Time) predicate.Label {
|
||||
return predicate.Label(sql.FieldNotIn(FieldUpdatedAt, vs...))
|
||||
}
|
||||
|
||||
// UpdatedAtGT applies the GT predicate on the "updated_at" field.
|
||||
func UpdatedAtGT(v time.Time) predicate.Label {
|
||||
return predicate.Label(sql.FieldGT(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtGTE applies the GTE predicate on the "updated_at" field.
|
||||
func UpdatedAtGTE(v time.Time) predicate.Label {
|
||||
return predicate.Label(sql.FieldGTE(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtLT applies the LT predicate on the "updated_at" field.
|
||||
func UpdatedAtLT(v time.Time) predicate.Label {
|
||||
return predicate.Label(sql.FieldLT(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtLTE applies the LTE predicate on the "updated_at" field.
|
||||
func UpdatedAtLTE(v time.Time) predicate.Label {
|
||||
return predicate.Label(sql.FieldLTE(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// NameEQ applies the EQ predicate on the "name" field.
|
||||
func NameEQ(v string) predicate.Label {
|
||||
return predicate.Label(sql.FieldEQ(FieldName, v))
|
||||
}
|
||||
|
||||
// NameNEQ applies the NEQ predicate on the "name" field.
|
||||
func NameNEQ(v string) predicate.Label {
|
||||
return predicate.Label(sql.FieldNEQ(FieldName, v))
|
||||
}
|
||||
|
||||
// NameIn applies the In predicate on the "name" field.
|
||||
func NameIn(vs ...string) predicate.Label {
|
||||
return predicate.Label(sql.FieldIn(FieldName, vs...))
|
||||
}
|
||||
|
||||
// NameNotIn applies the NotIn predicate on the "name" field.
|
||||
func NameNotIn(vs ...string) predicate.Label {
|
||||
return predicate.Label(sql.FieldNotIn(FieldName, vs...))
|
||||
}
|
||||
|
||||
// NameGT applies the GT predicate on the "name" field.
|
||||
func NameGT(v string) predicate.Label {
|
||||
return predicate.Label(sql.FieldGT(FieldName, v))
|
||||
}
|
||||
|
||||
// NameGTE applies the GTE predicate on the "name" field.
|
||||
func NameGTE(v string) predicate.Label {
|
||||
return predicate.Label(sql.FieldGTE(FieldName, v))
|
||||
}
|
||||
|
||||
// NameLT applies the LT predicate on the "name" field.
|
||||
func NameLT(v string) predicate.Label {
|
||||
return predicate.Label(sql.FieldLT(FieldName, v))
|
||||
}
|
||||
|
||||
// NameLTE applies the LTE predicate on the "name" field.
|
||||
func NameLTE(v string) predicate.Label {
|
||||
return predicate.Label(sql.FieldLTE(FieldName, v))
|
||||
}
|
||||
|
||||
// NameContains applies the Contains predicate on the "name" field.
|
||||
func NameContains(v string) predicate.Label {
|
||||
return predicate.Label(sql.FieldContains(FieldName, v))
|
||||
}
|
||||
|
||||
// NameHasPrefix applies the HasPrefix predicate on the "name" field.
|
||||
func NameHasPrefix(v string) predicate.Label {
|
||||
return predicate.Label(sql.FieldHasPrefix(FieldName, v))
|
||||
}
|
||||
|
||||
// NameHasSuffix applies the HasSuffix predicate on the "name" field.
|
||||
func NameHasSuffix(v string) predicate.Label {
|
||||
return predicate.Label(sql.FieldHasSuffix(FieldName, v))
|
||||
}
|
||||
|
||||
// NameEqualFold applies the EqualFold predicate on the "name" field.
|
||||
func NameEqualFold(v string) predicate.Label {
|
||||
return predicate.Label(sql.FieldEqualFold(FieldName, v))
|
||||
}
|
||||
|
||||
// NameContainsFold applies the ContainsFold predicate on the "name" field.
|
||||
func NameContainsFold(v string) predicate.Label {
|
||||
return predicate.Label(sql.FieldContainsFold(FieldName, v))
|
||||
}
|
||||
|
||||
// DescriptionEQ applies the EQ predicate on the "description" field.
|
||||
func DescriptionEQ(v string) predicate.Label {
|
||||
return predicate.Label(sql.FieldEQ(FieldDescription, v))
|
||||
}
|
||||
|
||||
// DescriptionNEQ applies the NEQ predicate on the "description" field.
|
||||
func DescriptionNEQ(v string) predicate.Label {
|
||||
return predicate.Label(sql.FieldNEQ(FieldDescription, v))
|
||||
}
|
||||
|
||||
// DescriptionIn applies the In predicate on the "description" field.
|
||||
func DescriptionIn(vs ...string) predicate.Label {
|
||||
return predicate.Label(sql.FieldIn(FieldDescription, vs...))
|
||||
}
|
||||
|
||||
// DescriptionNotIn applies the NotIn predicate on the "description" field.
|
||||
func DescriptionNotIn(vs ...string) predicate.Label {
|
||||
return predicate.Label(sql.FieldNotIn(FieldDescription, vs...))
|
||||
}
|
||||
|
||||
// DescriptionGT applies the GT predicate on the "description" field.
|
||||
func DescriptionGT(v string) predicate.Label {
|
||||
return predicate.Label(sql.FieldGT(FieldDescription, v))
|
||||
}
|
||||
|
||||
// DescriptionGTE applies the GTE predicate on the "description" field.
|
||||
func DescriptionGTE(v string) predicate.Label {
|
||||
return predicate.Label(sql.FieldGTE(FieldDescription, v))
|
||||
}
|
||||
|
||||
// DescriptionLT applies the LT predicate on the "description" field.
|
||||
func DescriptionLT(v string) predicate.Label {
|
||||
return predicate.Label(sql.FieldLT(FieldDescription, v))
|
||||
}
|
||||
|
||||
// DescriptionLTE applies the LTE predicate on the "description" field.
|
||||
func DescriptionLTE(v string) predicate.Label {
|
||||
return predicate.Label(sql.FieldLTE(FieldDescription, v))
|
||||
}
|
||||
|
||||
// DescriptionContains applies the Contains predicate on the "description" field.
|
||||
func DescriptionContains(v string) predicate.Label {
|
||||
return predicate.Label(sql.FieldContains(FieldDescription, v))
|
||||
}
|
||||
|
||||
// DescriptionHasPrefix applies the HasPrefix predicate on the "description" field.
|
||||
func DescriptionHasPrefix(v string) predicate.Label {
|
||||
return predicate.Label(sql.FieldHasPrefix(FieldDescription, v))
|
||||
}
|
||||
|
||||
// DescriptionHasSuffix applies the HasSuffix predicate on the "description" field.
|
||||
func DescriptionHasSuffix(v string) predicate.Label {
|
||||
return predicate.Label(sql.FieldHasSuffix(FieldDescription, v))
|
||||
}
|
||||
|
||||
// DescriptionIsNil applies the IsNil predicate on the "description" field.
|
||||
func DescriptionIsNil() predicate.Label {
|
||||
return predicate.Label(sql.FieldIsNull(FieldDescription))
|
||||
}
|
||||
|
||||
// DescriptionNotNil applies the NotNil predicate on the "description" field.
|
||||
func DescriptionNotNil() predicate.Label {
|
||||
return predicate.Label(sql.FieldNotNull(FieldDescription))
|
||||
}
|
||||
|
||||
// DescriptionEqualFold applies the EqualFold predicate on the "description" field.
|
||||
func DescriptionEqualFold(v string) predicate.Label {
|
||||
return predicate.Label(sql.FieldEqualFold(FieldDescription, v))
|
||||
}
|
||||
|
||||
// DescriptionContainsFold applies the ContainsFold predicate on the "description" field.
|
||||
func DescriptionContainsFold(v string) predicate.Label {
|
||||
return predicate.Label(sql.FieldContainsFold(FieldDescription, v))
|
||||
}
|
||||
|
||||
// ColorEQ applies the EQ predicate on the "color" field.
|
||||
func ColorEQ(v string) predicate.Label {
|
||||
return predicate.Label(sql.FieldEQ(FieldColor, v))
|
||||
}
|
||||
|
||||
// ColorNEQ applies the NEQ predicate on the "color" field.
|
||||
func ColorNEQ(v string) predicate.Label {
|
||||
return predicate.Label(sql.FieldNEQ(FieldColor, v))
|
||||
}
|
||||
|
||||
// ColorIn applies the In predicate on the "color" field.
|
||||
func ColorIn(vs ...string) predicate.Label {
|
||||
return predicate.Label(sql.FieldIn(FieldColor, vs...))
|
||||
}
|
||||
|
||||
// ColorNotIn applies the NotIn predicate on the "color" field.
|
||||
func ColorNotIn(vs ...string) predicate.Label {
|
||||
return predicate.Label(sql.FieldNotIn(FieldColor, vs...))
|
||||
}
|
||||
|
||||
// ColorGT applies the GT predicate on the "color" field.
|
||||
func ColorGT(v string) predicate.Label {
|
||||
return predicate.Label(sql.FieldGT(FieldColor, v))
|
||||
}
|
||||
|
||||
// ColorGTE applies the GTE predicate on the "color" field.
|
||||
func ColorGTE(v string) predicate.Label {
|
||||
return predicate.Label(sql.FieldGTE(FieldColor, v))
|
||||
}
|
||||
|
||||
// ColorLT applies the LT predicate on the "color" field.
|
||||
func ColorLT(v string) predicate.Label {
|
||||
return predicate.Label(sql.FieldLT(FieldColor, v))
|
||||
}
|
||||
|
||||
// ColorLTE applies the LTE predicate on the "color" field.
|
||||
func ColorLTE(v string) predicate.Label {
|
||||
return predicate.Label(sql.FieldLTE(FieldColor, v))
|
||||
}
|
||||
|
||||
// ColorContains applies the Contains predicate on the "color" field.
|
||||
func ColorContains(v string) predicate.Label {
|
||||
return predicate.Label(sql.FieldContains(FieldColor, v))
|
||||
}
|
||||
|
||||
// ColorHasPrefix applies the HasPrefix predicate on the "color" field.
|
||||
func ColorHasPrefix(v string) predicate.Label {
|
||||
return predicate.Label(sql.FieldHasPrefix(FieldColor, v))
|
||||
}
|
||||
|
||||
// ColorHasSuffix applies the HasSuffix predicate on the "color" field.
|
||||
func ColorHasSuffix(v string) predicate.Label {
|
||||
return predicate.Label(sql.FieldHasSuffix(FieldColor, v))
|
||||
}
|
||||
|
||||
// ColorIsNil applies the IsNil predicate on the "color" field.
|
||||
func ColorIsNil() predicate.Label {
|
||||
return predicate.Label(sql.FieldIsNull(FieldColor))
|
||||
}
|
||||
|
||||
// ColorNotNil applies the NotNil predicate on the "color" field.
|
||||
func ColorNotNil() predicate.Label {
|
||||
return predicate.Label(sql.FieldNotNull(FieldColor))
|
||||
}
|
||||
|
||||
// ColorEqualFold applies the EqualFold predicate on the "color" field.
|
||||
func ColorEqualFold(v string) predicate.Label {
|
||||
return predicate.Label(sql.FieldEqualFold(FieldColor, v))
|
||||
}
|
||||
|
||||
// ColorContainsFold applies the ContainsFold predicate on the "color" field.
|
||||
func ColorContainsFold(v string) predicate.Label {
|
||||
return predicate.Label(sql.FieldContainsFold(FieldColor, v))
|
||||
}
|
||||
|
||||
// HasGroup applies the HasEdge predicate on the "group" edge.
|
||||
func HasGroup() predicate.Label {
|
||||
return predicate.Label(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, GroupTable, GroupColumn),
|
||||
)
|
||||
sqlgraph.HasNeighbors(s, step)
|
||||
})
|
||||
}
|
||||
|
||||
// HasGroupWith applies the HasEdge predicate on the "group" edge with a given conditions (other predicates).
|
||||
func HasGroupWith(preds ...predicate.Group) predicate.Label {
|
||||
return predicate.Label(func(s *sql.Selector) {
|
||||
step := newGroupStep()
|
||||
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
for _, p := range preds {
|
||||
p(s)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// HasItems applies the HasEdge predicate on the "items" edge.
|
||||
func HasItems() predicate.Label {
|
||||
return predicate.Label(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2M, false, ItemsTable, ItemsPrimaryKey...),
|
||||
)
|
||||
sqlgraph.HasNeighbors(s, step)
|
||||
})
|
||||
}
|
||||
|
||||
// HasItemsWith applies the HasEdge predicate on the "items" edge with a given conditions (other predicates).
|
||||
func HasItemsWith(preds ...predicate.Item) predicate.Label {
|
||||
return predicate.Label(func(s *sql.Selector) {
|
||||
step := newItemsStep()
|
||||
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
for _, p := range preds {
|
||||
p(s)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// And groups predicates with the AND operator between them.
|
||||
func And(predicates ...predicate.Label) predicate.Label {
|
||||
return predicate.Label(sql.AndPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Or groups predicates with the OR operator between them.
|
||||
func Or(predicates ...predicate.Label) predicate.Label {
|
||||
return predicate.Label(sql.OrPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Not applies the not operator on the given predicate.
|
||||
func Not(p predicate.Label) predicate.Label {
|
||||
return predicate.Label(sql.NotPredicates(p))
|
||||
}
|
||||
@@ -13,24 +13,24 @@ import (
|
||||
"github.com/google/uuid"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/tag"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/label"
|
||||
)
|
||||
|
||||
// TagCreate is the builder for creating a Tag entity.
|
||||
type TagCreate struct {
|
||||
// LabelCreate is the builder for creating a Label entity.
|
||||
type LabelCreate struct {
|
||||
config
|
||||
mutation *TagMutation
|
||||
mutation *LabelMutation
|
||||
hooks []Hook
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (_c *TagCreate) SetCreatedAt(v time.Time) *TagCreate {
|
||||
func (_c *LabelCreate) SetCreatedAt(v time.Time) *LabelCreate {
|
||||
_c.mutation.SetCreatedAt(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
||||
func (_c *TagCreate) SetNillableCreatedAt(v *time.Time) *TagCreate {
|
||||
func (_c *LabelCreate) SetNillableCreatedAt(v *time.Time) *LabelCreate {
|
||||
if v != nil {
|
||||
_c.SetCreatedAt(*v)
|
||||
}
|
||||
@@ -38,13 +38,13 @@ func (_c *TagCreate) SetNillableCreatedAt(v *time.Time) *TagCreate {
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (_c *TagCreate) SetUpdatedAt(v time.Time) *TagCreate {
|
||||
func (_c *LabelCreate) SetUpdatedAt(v time.Time) *LabelCreate {
|
||||
_c.mutation.SetUpdatedAt(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
||||
func (_c *TagCreate) SetNillableUpdatedAt(v *time.Time) *TagCreate {
|
||||
func (_c *LabelCreate) SetNillableUpdatedAt(v *time.Time) *LabelCreate {
|
||||
if v != nil {
|
||||
_c.SetUpdatedAt(*v)
|
||||
}
|
||||
@@ -52,19 +52,19 @@ func (_c *TagCreate) SetNillableUpdatedAt(v *time.Time) *TagCreate {
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (_c *TagCreate) SetName(v string) *TagCreate {
|
||||
func (_c *LabelCreate) SetName(v string) *LabelCreate {
|
||||
_c.mutation.SetName(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetDescription sets the "description" field.
|
||||
func (_c *TagCreate) SetDescription(v string) *TagCreate {
|
||||
func (_c *LabelCreate) SetDescription(v string) *LabelCreate {
|
||||
_c.mutation.SetDescription(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableDescription sets the "description" field if the given value is not nil.
|
||||
func (_c *TagCreate) SetNillableDescription(v *string) *TagCreate {
|
||||
func (_c *LabelCreate) SetNillableDescription(v *string) *LabelCreate {
|
||||
if v != nil {
|
||||
_c.SetDescription(*v)
|
||||
}
|
||||
@@ -72,13 +72,13 @@ func (_c *TagCreate) SetNillableDescription(v *string) *TagCreate {
|
||||
}
|
||||
|
||||
// SetColor sets the "color" field.
|
||||
func (_c *TagCreate) SetColor(v string) *TagCreate {
|
||||
func (_c *LabelCreate) SetColor(v string) *LabelCreate {
|
||||
_c.mutation.SetColor(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableColor sets the "color" field if the given value is not nil.
|
||||
func (_c *TagCreate) SetNillableColor(v *string) *TagCreate {
|
||||
func (_c *LabelCreate) SetNillableColor(v *string) *LabelCreate {
|
||||
if v != nil {
|
||||
_c.SetColor(*v)
|
||||
}
|
||||
@@ -86,13 +86,13 @@ func (_c *TagCreate) SetNillableColor(v *string) *TagCreate {
|
||||
}
|
||||
|
||||
// SetID sets the "id" field.
|
||||
func (_c *TagCreate) SetID(v uuid.UUID) *TagCreate {
|
||||
func (_c *LabelCreate) SetID(v uuid.UUID) *LabelCreate {
|
||||
_c.mutation.SetID(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableID sets the "id" field if the given value is not nil.
|
||||
func (_c *TagCreate) SetNillableID(v *uuid.UUID) *TagCreate {
|
||||
func (_c *LabelCreate) SetNillableID(v *uuid.UUID) *LabelCreate {
|
||||
if v != nil {
|
||||
_c.SetID(*v)
|
||||
}
|
||||
@@ -100,24 +100,24 @@ func (_c *TagCreate) SetNillableID(v *uuid.UUID) *TagCreate {
|
||||
}
|
||||
|
||||
// SetGroupID sets the "group" edge to the Group entity by ID.
|
||||
func (_c *TagCreate) SetGroupID(id uuid.UUID) *TagCreate {
|
||||
func (_c *LabelCreate) SetGroupID(id uuid.UUID) *LabelCreate {
|
||||
_c.mutation.SetGroupID(id)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetGroup sets the "group" edge to the Group entity.
|
||||
func (_c *TagCreate) SetGroup(v *Group) *TagCreate {
|
||||
func (_c *LabelCreate) SetGroup(v *Group) *LabelCreate {
|
||||
return _c.SetGroupID(v.ID)
|
||||
}
|
||||
|
||||
// AddItemIDs adds the "items" edge to the Item entity by IDs.
|
||||
func (_c *TagCreate) AddItemIDs(ids ...uuid.UUID) *TagCreate {
|
||||
func (_c *LabelCreate) AddItemIDs(ids ...uuid.UUID) *LabelCreate {
|
||||
_c.mutation.AddItemIDs(ids...)
|
||||
return _c
|
||||
}
|
||||
|
||||
// AddItems adds the "items" edges to the Item entity.
|
||||
func (_c *TagCreate) AddItems(v ...*Item) *TagCreate {
|
||||
func (_c *LabelCreate) AddItems(v ...*Item) *LabelCreate {
|
||||
ids := make([]uuid.UUID, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
@@ -125,19 +125,19 @@ func (_c *TagCreate) AddItems(v ...*Item) *TagCreate {
|
||||
return _c.AddItemIDs(ids...)
|
||||
}
|
||||
|
||||
// Mutation returns the TagMutation object of the builder.
|
||||
func (_c *TagCreate) Mutation() *TagMutation {
|
||||
// Mutation returns the LabelMutation object of the builder.
|
||||
func (_c *LabelCreate) Mutation() *LabelMutation {
|
||||
return _c.mutation
|
||||
}
|
||||
|
||||
// Save creates the Tag in the database.
|
||||
func (_c *TagCreate) Save(ctx context.Context) (*Tag, error) {
|
||||
// Save creates the Label in the database.
|
||||
func (_c *LabelCreate) Save(ctx context.Context) (*Label, error) {
|
||||
_c.defaults()
|
||||
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
func (_c *TagCreate) SaveX(ctx context.Context) *Tag {
|
||||
func (_c *LabelCreate) SaveX(ctx context.Context) *Label {
|
||||
v, err := _c.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@@ -146,67 +146,67 @@ func (_c *TagCreate) SaveX(ctx context.Context) *Tag {
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (_c *TagCreate) Exec(ctx context.Context) error {
|
||||
func (_c *LabelCreate) Exec(ctx context.Context) error {
|
||||
_, err := _c.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_c *TagCreate) ExecX(ctx context.Context) {
|
||||
func (_c *LabelCreate) ExecX(ctx context.Context) {
|
||||
if err := _c.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (_c *TagCreate) defaults() {
|
||||
func (_c *LabelCreate) defaults() {
|
||||
if _, ok := _c.mutation.CreatedAt(); !ok {
|
||||
v := tag.DefaultCreatedAt()
|
||||
v := label.DefaultCreatedAt()
|
||||
_c.mutation.SetCreatedAt(v)
|
||||
}
|
||||
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
||||
v := tag.DefaultUpdatedAt()
|
||||
v := label.DefaultUpdatedAt()
|
||||
_c.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
if _, ok := _c.mutation.ID(); !ok {
|
||||
v := tag.DefaultID()
|
||||
v := label.DefaultID()
|
||||
_c.mutation.SetID(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (_c *TagCreate) check() error {
|
||||
func (_c *LabelCreate) check() error {
|
||||
if _, ok := _c.mutation.CreatedAt(); !ok {
|
||||
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Tag.created_at"`)}
|
||||
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Label.created_at"`)}
|
||||
}
|
||||
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
||||
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Tag.updated_at"`)}
|
||||
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Label.updated_at"`)}
|
||||
}
|
||||
if _, ok := _c.mutation.Name(); !ok {
|
||||
return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Tag.name"`)}
|
||||
return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Label.name"`)}
|
||||
}
|
||||
if v, ok := _c.mutation.Name(); ok {
|
||||
if err := tag.NameValidator(v); err != nil {
|
||||
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Tag.name": %w`, err)}
|
||||
if err := label.NameValidator(v); err != nil {
|
||||
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Label.name": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _c.mutation.Description(); ok {
|
||||
if err := tag.DescriptionValidator(v); err != nil {
|
||||
return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Tag.description": %w`, err)}
|
||||
if err := label.DescriptionValidator(v); err != nil {
|
||||
return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Label.description": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _c.mutation.Color(); ok {
|
||||
if err := tag.ColorValidator(v); err != nil {
|
||||
return &ValidationError{Name: "color", err: fmt.Errorf(`ent: validator failed for field "Tag.color": %w`, err)}
|
||||
if err := label.ColorValidator(v); err != nil {
|
||||
return &ValidationError{Name: "color", err: fmt.Errorf(`ent: validator failed for field "Label.color": %w`, err)}
|
||||
}
|
||||
}
|
||||
if len(_c.mutation.GroupIDs()) == 0 {
|
||||
return &ValidationError{Name: "group", err: errors.New(`ent: missing required edge "Tag.group"`)}
|
||||
return &ValidationError{Name: "group", err: errors.New(`ent: missing required edge "Label.group"`)}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (_c *TagCreate) sqlSave(ctx context.Context) (*Tag, error) {
|
||||
func (_c *LabelCreate) sqlSave(ctx context.Context) (*Label, error) {
|
||||
if err := _c.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -229,41 +229,41 @@ func (_c *TagCreate) sqlSave(ctx context.Context) (*Tag, error) {
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
func (_c *TagCreate) createSpec() (*Tag, *sqlgraph.CreateSpec) {
|
||||
func (_c *LabelCreate) createSpec() (*Label, *sqlgraph.CreateSpec) {
|
||||
var (
|
||||
_node = &Tag{config: _c.config}
|
||||
_spec = sqlgraph.NewCreateSpec(tag.Table, sqlgraph.NewFieldSpec(tag.FieldID, field.TypeUUID))
|
||||
_node = &Label{config: _c.config}
|
||||
_spec = sqlgraph.NewCreateSpec(label.Table, sqlgraph.NewFieldSpec(label.FieldID, field.TypeUUID))
|
||||
)
|
||||
if id, ok := _c.mutation.ID(); ok {
|
||||
_node.ID = id
|
||||
_spec.ID.Value = &id
|
||||
}
|
||||
if value, ok := _c.mutation.CreatedAt(); ok {
|
||||
_spec.SetField(tag.FieldCreatedAt, field.TypeTime, value)
|
||||
_spec.SetField(label.FieldCreatedAt, field.TypeTime, value)
|
||||
_node.CreatedAt = value
|
||||
}
|
||||
if value, ok := _c.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(tag.FieldUpdatedAt, field.TypeTime, value)
|
||||
_spec.SetField(label.FieldUpdatedAt, field.TypeTime, value)
|
||||
_node.UpdatedAt = value
|
||||
}
|
||||
if value, ok := _c.mutation.Name(); ok {
|
||||
_spec.SetField(tag.FieldName, field.TypeString, value)
|
||||
_spec.SetField(label.FieldName, field.TypeString, value)
|
||||
_node.Name = value
|
||||
}
|
||||
if value, ok := _c.mutation.Description(); ok {
|
||||
_spec.SetField(tag.FieldDescription, field.TypeString, value)
|
||||
_spec.SetField(label.FieldDescription, field.TypeString, value)
|
||||
_node.Description = value
|
||||
}
|
||||
if value, ok := _c.mutation.Color(); ok {
|
||||
_spec.SetField(tag.FieldColor, field.TypeString, value)
|
||||
_spec.SetField(label.FieldColor, field.TypeString, value)
|
||||
_node.Color = value
|
||||
}
|
||||
if nodes := _c.mutation.GroupIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: tag.GroupTable,
|
||||
Columns: []string{tag.GroupColumn},
|
||||
Table: label.GroupTable,
|
||||
Columns: []string{label.GroupColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID),
|
||||
@@ -272,15 +272,15 @@ func (_c *TagCreate) createSpec() (*Tag, *sqlgraph.CreateSpec) {
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_node.group_tags = &nodes[0]
|
||||
_node.group_labels = &nodes[0]
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
if nodes := _c.mutation.ItemsIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2M,
|
||||
Inverse: false,
|
||||
Table: tag.ItemsTable,
|
||||
Columns: tag.ItemsPrimaryKey,
|
||||
Table: label.ItemsTable,
|
||||
Columns: label.ItemsPrimaryKey,
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
|
||||
@@ -294,27 +294,27 @@ func (_c *TagCreate) createSpec() (*Tag, *sqlgraph.CreateSpec) {
|
||||
return _node, _spec
|
||||
}
|
||||
|
||||
// TagCreateBulk is the builder for creating many Tag entities in bulk.
|
||||
type TagCreateBulk struct {
|
||||
// LabelCreateBulk is the builder for creating many Label entities in bulk.
|
||||
type LabelCreateBulk struct {
|
||||
config
|
||||
err error
|
||||
builders []*TagCreate
|
||||
builders []*LabelCreate
|
||||
}
|
||||
|
||||
// Save creates the Tag entities in the database.
|
||||
func (_c *TagCreateBulk) Save(ctx context.Context) ([]*Tag, error) {
|
||||
// Save creates the Label entities in the database.
|
||||
func (_c *LabelCreateBulk) Save(ctx context.Context) ([]*Label, error) {
|
||||
if _c.err != nil {
|
||||
return nil, _c.err
|
||||
}
|
||||
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
|
||||
nodes := make([]*Tag, len(_c.builders))
|
||||
nodes := make([]*Label, len(_c.builders))
|
||||
mutators := make([]Mutator, len(_c.builders))
|
||||
for i := range _c.builders {
|
||||
func(i int, root context.Context) {
|
||||
builder := _c.builders[i]
|
||||
builder.defaults()
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*TagMutation)
|
||||
mutation, ok := m.(*LabelMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
@@ -357,7 +357,7 @@ func (_c *TagCreateBulk) Save(ctx context.Context) ([]*Tag, error) {
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (_c *TagCreateBulk) SaveX(ctx context.Context) []*Tag {
|
||||
func (_c *LabelCreateBulk) SaveX(ctx context.Context) []*Label {
|
||||
v, err := _c.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@@ -366,13 +366,13 @@ func (_c *TagCreateBulk) SaveX(ctx context.Context) []*Tag {
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (_c *TagCreateBulk) Exec(ctx context.Context) error {
|
||||
func (_c *LabelCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := _c.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_c *TagCreateBulk) ExecX(ctx context.Context) {
|
||||
func (_c *LabelCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := _c.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -8,30 +8,30 @@ import (
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/label"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/tag"
|
||||
)
|
||||
|
||||
// TagDelete is the builder for deleting a Tag entity.
|
||||
type TagDelete struct {
|
||||
// LabelDelete is the builder for deleting a Label entity.
|
||||
type LabelDelete struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *TagMutation
|
||||
mutation *LabelMutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the TagDelete builder.
|
||||
func (_d *TagDelete) Where(ps ...predicate.Tag) *TagDelete {
|
||||
// Where appends a list predicates to the LabelDelete builder.
|
||||
func (_d *LabelDelete) Where(ps ...predicate.Label) *LabelDelete {
|
||||
_d.mutation.Where(ps...)
|
||||
return _d
|
||||
}
|
||||
|
||||
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||
func (_d *TagDelete) Exec(ctx context.Context) (int, error) {
|
||||
func (_d *LabelDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_d *TagDelete) ExecX(ctx context.Context) int {
|
||||
func (_d *LabelDelete) ExecX(ctx context.Context) int {
|
||||
n, err := _d.Exec(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@@ -39,8 +39,8 @@ func (_d *TagDelete) ExecX(ctx context.Context) int {
|
||||
return n
|
||||
}
|
||||
|
||||
func (_d *TagDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
_spec := sqlgraph.NewDeleteSpec(tag.Table, sqlgraph.NewFieldSpec(tag.FieldID, field.TypeUUID))
|
||||
func (_d *LabelDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
_spec := sqlgraph.NewDeleteSpec(label.Table, sqlgraph.NewFieldSpec(label.FieldID, field.TypeUUID))
|
||||
if ps := _d.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
@@ -56,32 +56,32 @@ func (_d *TagDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// TagDeleteOne is the builder for deleting a single Tag entity.
|
||||
type TagDeleteOne struct {
|
||||
_d *TagDelete
|
||||
// LabelDeleteOne is the builder for deleting a single Label entity.
|
||||
type LabelDeleteOne struct {
|
||||
_d *LabelDelete
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the TagDelete builder.
|
||||
func (_d *TagDeleteOne) Where(ps ...predicate.Tag) *TagDeleteOne {
|
||||
// Where appends a list predicates to the LabelDelete builder.
|
||||
func (_d *LabelDeleteOne) Where(ps ...predicate.Label) *LabelDeleteOne {
|
||||
_d._d.mutation.Where(ps...)
|
||||
return _d
|
||||
}
|
||||
|
||||
// Exec executes the deletion query.
|
||||
func (_d *TagDeleteOne) Exec(ctx context.Context) error {
|
||||
func (_d *LabelDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := _d._d.Exec(ctx)
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case n == 0:
|
||||
return &NotFoundError{tag.Label}
|
||||
return &NotFoundError{label.Label}
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_d *TagDeleteOne) ExecX(ctx context.Context) {
|
||||
func (_d *LabelDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := _d.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -15,17 +15,17 @@ import (
|
||||
"github.com/google/uuid"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/label"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/tag"
|
||||
)
|
||||
|
||||
// TagQuery is the builder for querying Tag entities.
|
||||
type TagQuery struct {
|
||||
// LabelQuery is the builder for querying Label entities.
|
||||
type LabelQuery struct {
|
||||
config
|
||||
ctx *QueryContext
|
||||
order []tag.OrderOption
|
||||
order []label.OrderOption
|
||||
inters []Interceptor
|
||||
predicates []predicate.Tag
|
||||
predicates []predicate.Label
|
||||
withGroup *GroupQuery
|
||||
withItems *ItemQuery
|
||||
withFKs bool
|
||||
@@ -34,39 +34,39 @@ type TagQuery struct {
|
||||
path func(context.Context) (*sql.Selector, error)
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the TagQuery builder.
|
||||
func (_q *TagQuery) Where(ps ...predicate.Tag) *TagQuery {
|
||||
// Where adds a new predicate for the LabelQuery builder.
|
||||
func (_q *LabelQuery) Where(ps ...predicate.Label) *LabelQuery {
|
||||
_q.predicates = append(_q.predicates, ps...)
|
||||
return _q
|
||||
}
|
||||
|
||||
// Limit the number of records to be returned by this query.
|
||||
func (_q *TagQuery) Limit(limit int) *TagQuery {
|
||||
func (_q *LabelQuery) Limit(limit int) *LabelQuery {
|
||||
_q.ctx.Limit = &limit
|
||||
return _q
|
||||
}
|
||||
|
||||
// Offset to start from.
|
||||
func (_q *TagQuery) Offset(offset int) *TagQuery {
|
||||
func (_q *LabelQuery) Offset(offset int) *LabelQuery {
|
||||
_q.ctx.Offset = &offset
|
||||
return _q
|
||||
}
|
||||
|
||||
// Unique configures the query builder to filter duplicate records on query.
|
||||
// By default, unique is set to true, and can be disabled using this method.
|
||||
func (_q *TagQuery) Unique(unique bool) *TagQuery {
|
||||
func (_q *LabelQuery) Unique(unique bool) *LabelQuery {
|
||||
_q.ctx.Unique = &unique
|
||||
return _q
|
||||
}
|
||||
|
||||
// Order specifies how the records should be ordered.
|
||||
func (_q *TagQuery) Order(o ...tag.OrderOption) *TagQuery {
|
||||
func (_q *LabelQuery) Order(o ...label.OrderOption) *LabelQuery {
|
||||
_q.order = append(_q.order, o...)
|
||||
return _q
|
||||
}
|
||||
|
||||
// QueryGroup chains the current query on the "group" edge.
|
||||
func (_q *TagQuery) QueryGroup() *GroupQuery {
|
||||
func (_q *LabelQuery) QueryGroup() *GroupQuery {
|
||||
query := (&GroupClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
@@ -77,9 +77,9 @@ func (_q *TagQuery) QueryGroup() *GroupQuery {
|
||||
return nil, err
|
||||
}
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(tag.Table, tag.FieldID, selector),
|
||||
sqlgraph.From(label.Table, label.FieldID, selector),
|
||||
sqlgraph.To(group.Table, group.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, tag.GroupTable, tag.GroupColumn),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, label.GroupTable, label.GroupColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
@@ -88,7 +88,7 @@ func (_q *TagQuery) QueryGroup() *GroupQuery {
|
||||
}
|
||||
|
||||
// QueryItems chains the current query on the "items" edge.
|
||||
func (_q *TagQuery) QueryItems() *ItemQuery {
|
||||
func (_q *LabelQuery) QueryItems() *ItemQuery {
|
||||
query := (&ItemClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
@@ -99,9 +99,9 @@ func (_q *TagQuery) QueryItems() *ItemQuery {
|
||||
return nil, err
|
||||
}
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(tag.Table, tag.FieldID, selector),
|
||||
sqlgraph.From(label.Table, label.FieldID, selector),
|
||||
sqlgraph.To(item.Table, item.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2M, false, tag.ItemsTable, tag.ItemsPrimaryKey...),
|
||||
sqlgraph.Edge(sqlgraph.M2M, false, label.ItemsTable, label.ItemsPrimaryKey...),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
@@ -109,21 +109,21 @@ func (_q *TagQuery) QueryItems() *ItemQuery {
|
||||
return query
|
||||
}
|
||||
|
||||
// First returns the first Tag entity from the query.
|
||||
// Returns a *NotFoundError when no Tag was found.
|
||||
func (_q *TagQuery) First(ctx context.Context) (*Tag, error) {
|
||||
// First returns the first Label entity from the query.
|
||||
// Returns a *NotFoundError when no Label was found.
|
||||
func (_q *LabelQuery) First(ctx context.Context) (*Label, error) {
|
||||
nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nil, &NotFoundError{tag.Label}
|
||||
return nil, &NotFoundError{label.Label}
|
||||
}
|
||||
return nodes[0], nil
|
||||
}
|
||||
|
||||
// FirstX is like First, but panics if an error occurs.
|
||||
func (_q *TagQuery) FirstX(ctx context.Context) *Tag {
|
||||
func (_q *LabelQuery) FirstX(ctx context.Context) *Label {
|
||||
node, err := _q.First(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
@@ -131,22 +131,22 @@ func (_q *TagQuery) FirstX(ctx context.Context) *Tag {
|
||||
return node
|
||||
}
|
||||
|
||||
// FirstID returns the first Tag ID from the query.
|
||||
// Returns a *NotFoundError when no Tag ID was found.
|
||||
func (_q *TagQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
// FirstID returns the first Label ID from the query.
|
||||
// Returns a *NotFoundError when no Label ID was found.
|
||||
func (_q *LabelQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
var ids []uuid.UUID
|
||||
if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil {
|
||||
return
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
err = &NotFoundError{tag.Label}
|
||||
err = &NotFoundError{label.Label}
|
||||
return
|
||||
}
|
||||
return ids[0], nil
|
||||
}
|
||||
|
||||
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||
func (_q *TagQuery) FirstIDX(ctx context.Context) uuid.UUID {
|
||||
func (_q *LabelQuery) FirstIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := _q.FirstID(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
@@ -154,10 +154,10 @@ func (_q *TagQuery) FirstIDX(ctx context.Context) uuid.UUID {
|
||||
return id
|
||||
}
|
||||
|
||||
// Only returns a single Tag entity found by the query, ensuring it only returns one.
|
||||
// Returns a *NotSingularError when more than one Tag entity is found.
|
||||
// Returns a *NotFoundError when no Tag entities are found.
|
||||
func (_q *TagQuery) Only(ctx context.Context) (*Tag, error) {
|
||||
// Only returns a single Label entity found by the query, ensuring it only returns one.
|
||||
// Returns a *NotSingularError when more than one Label entity is found.
|
||||
// Returns a *NotFoundError when no Label entities are found.
|
||||
func (_q *LabelQuery) Only(ctx context.Context) (*Label, error) {
|
||||
nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -166,14 +166,14 @@ func (_q *TagQuery) Only(ctx context.Context) (*Tag, error) {
|
||||
case 1:
|
||||
return nodes[0], nil
|
||||
case 0:
|
||||
return nil, &NotFoundError{tag.Label}
|
||||
return nil, &NotFoundError{label.Label}
|
||||
default:
|
||||
return nil, &NotSingularError{tag.Label}
|
||||
return nil, &NotSingularError{label.Label}
|
||||
}
|
||||
}
|
||||
|
||||
// OnlyX is like Only, but panics if an error occurs.
|
||||
func (_q *TagQuery) OnlyX(ctx context.Context) *Tag {
|
||||
func (_q *LabelQuery) OnlyX(ctx context.Context) *Label {
|
||||
node, err := _q.Only(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@@ -181,10 +181,10 @@ func (_q *TagQuery) OnlyX(ctx context.Context) *Tag {
|
||||
return node
|
||||
}
|
||||
|
||||
// OnlyID is like Only, but returns the only Tag ID in the query.
|
||||
// Returns a *NotSingularError when more than one Tag ID is found.
|
||||
// OnlyID is like Only, but returns the only Label ID in the query.
|
||||
// Returns a *NotSingularError when more than one Label ID is found.
|
||||
// Returns a *NotFoundError when no entities are found.
|
||||
func (_q *TagQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
func (_q *LabelQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
var ids []uuid.UUID
|
||||
if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil {
|
||||
return
|
||||
@@ -193,15 +193,15 @@ func (_q *TagQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
|
||||
case 1:
|
||||
id = ids[0]
|
||||
case 0:
|
||||
err = &NotFoundError{tag.Label}
|
||||
err = &NotFoundError{label.Label}
|
||||
default:
|
||||
err = &NotSingularError{tag.Label}
|
||||
err = &NotSingularError{label.Label}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||
func (_q *TagQuery) OnlyIDX(ctx context.Context) uuid.UUID {
|
||||
func (_q *LabelQuery) OnlyIDX(ctx context.Context) uuid.UUID {
|
||||
id, err := _q.OnlyID(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@@ -209,18 +209,18 @@ func (_q *TagQuery) OnlyIDX(ctx context.Context) uuid.UUID {
|
||||
return id
|
||||
}
|
||||
|
||||
// All executes the query and returns a list of Tags.
|
||||
func (_q *TagQuery) All(ctx context.Context) ([]*Tag, error) {
|
||||
// All executes the query and returns a list of Labels.
|
||||
func (_q *LabelQuery) All(ctx context.Context) ([]*Label, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
qr := querierAll[[]*Tag, *TagQuery]()
|
||||
return withInterceptors[[]*Tag](ctx, _q, qr, _q.inters)
|
||||
qr := querierAll[[]*Label, *LabelQuery]()
|
||||
return withInterceptors[[]*Label](ctx, _q, qr, _q.inters)
|
||||
}
|
||||
|
||||
// AllX is like All, but panics if an error occurs.
|
||||
func (_q *TagQuery) AllX(ctx context.Context) []*Tag {
|
||||
func (_q *LabelQuery) AllX(ctx context.Context) []*Label {
|
||||
nodes, err := _q.All(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@@ -228,20 +228,20 @@ func (_q *TagQuery) AllX(ctx context.Context) []*Tag {
|
||||
return nodes
|
||||
}
|
||||
|
||||
// IDs executes the query and returns a list of Tag IDs.
|
||||
func (_q *TagQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
|
||||
// IDs executes the query and returns a list of Label IDs.
|
||||
func (_q *LabelQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
|
||||
if _q.ctx.Unique == nil && _q.path != nil {
|
||||
_q.Unique(true)
|
||||
}
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
|
||||
if err = _q.Select(tag.FieldID).Scan(ctx, &ids); err != nil {
|
||||
if err = _q.Select(label.FieldID).Scan(ctx, &ids); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
// IDsX is like IDs, but panics if an error occurs.
|
||||
func (_q *TagQuery) IDsX(ctx context.Context) []uuid.UUID {
|
||||
func (_q *LabelQuery) IDsX(ctx context.Context) []uuid.UUID {
|
||||
ids, err := _q.IDs(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@@ -250,16 +250,16 @@ func (_q *TagQuery) IDsX(ctx context.Context) []uuid.UUID {
|
||||
}
|
||||
|
||||
// Count returns the count of the given query.
|
||||
func (_q *TagQuery) Count(ctx context.Context) (int, error) {
|
||||
func (_q *LabelQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return withInterceptors[int](ctx, _q, querierCount[*TagQuery](), _q.inters)
|
||||
return withInterceptors[int](ctx, _q, querierCount[*LabelQuery](), _q.inters)
|
||||
}
|
||||
|
||||
// CountX is like Count, but panics if an error occurs.
|
||||
func (_q *TagQuery) CountX(ctx context.Context) int {
|
||||
func (_q *LabelQuery) CountX(ctx context.Context) int {
|
||||
count, err := _q.Count(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@@ -268,7 +268,7 @@ func (_q *TagQuery) CountX(ctx context.Context) int {
|
||||
}
|
||||
|
||||
// Exist returns true if the query has elements in the graph.
|
||||
func (_q *TagQuery) Exist(ctx context.Context) (bool, error) {
|
||||
func (_q *LabelQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
|
||||
switch _, err := _q.FirstID(ctx); {
|
||||
case IsNotFound(err):
|
||||
@@ -281,7 +281,7 @@ func (_q *TagQuery) Exist(ctx context.Context) (bool, error) {
|
||||
}
|
||||
|
||||
// ExistX is like Exist, but panics if an error occurs.
|
||||
func (_q *TagQuery) ExistX(ctx context.Context) bool {
|
||||
func (_q *LabelQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := _q.Exist(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@@ -289,18 +289,18 @@ func (_q *TagQuery) ExistX(ctx context.Context) bool {
|
||||
return exist
|
||||
}
|
||||
|
||||
// Clone returns a duplicate of the TagQuery builder, including all associated steps. It can be
|
||||
// Clone returns a duplicate of the LabelQuery builder, including all associated steps. It can be
|
||||
// used to prepare common query builders and use them differently after the clone is made.
|
||||
func (_q *TagQuery) Clone() *TagQuery {
|
||||
func (_q *LabelQuery) Clone() *LabelQuery {
|
||||
if _q == nil {
|
||||
return nil
|
||||
}
|
||||
return &TagQuery{
|
||||
return &LabelQuery{
|
||||
config: _q.config,
|
||||
ctx: _q.ctx.Clone(),
|
||||
order: append([]tag.OrderOption{}, _q.order...),
|
||||
order: append([]label.OrderOption{}, _q.order...),
|
||||
inters: append([]Interceptor{}, _q.inters...),
|
||||
predicates: append([]predicate.Tag{}, _q.predicates...),
|
||||
predicates: append([]predicate.Label{}, _q.predicates...),
|
||||
withGroup: _q.withGroup.Clone(),
|
||||
withItems: _q.withItems.Clone(),
|
||||
// clone intermediate query.
|
||||
@@ -311,7 +311,7 @@ func (_q *TagQuery) Clone() *TagQuery {
|
||||
|
||||
// WithGroup tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "group" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (_q *TagQuery) WithGroup(opts ...func(*GroupQuery)) *TagQuery {
|
||||
func (_q *LabelQuery) WithGroup(opts ...func(*GroupQuery)) *LabelQuery {
|
||||
query := (&GroupClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
@@ -322,7 +322,7 @@ func (_q *TagQuery) WithGroup(opts ...func(*GroupQuery)) *TagQuery {
|
||||
|
||||
// WithItems tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "items" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (_q *TagQuery) WithItems(opts ...func(*ItemQuery)) *TagQuery {
|
||||
func (_q *LabelQuery) WithItems(opts ...func(*ItemQuery)) *LabelQuery {
|
||||
query := (&ItemClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
@@ -341,15 +341,15 @@ func (_q *TagQuery) WithItems(opts ...func(*ItemQuery)) *TagQuery {
|
||||
// Count int `json:"count,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.Tag.Query().
|
||||
// GroupBy(tag.FieldCreatedAt).
|
||||
// client.Label.Query().
|
||||
// GroupBy(label.FieldCreatedAt).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
func (_q *TagQuery) GroupBy(field string, fields ...string) *TagGroupBy {
|
||||
func (_q *LabelQuery) GroupBy(field string, fields ...string) *LabelGroupBy {
|
||||
_q.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &TagGroupBy{build: _q}
|
||||
grbuild := &LabelGroupBy{build: _q}
|
||||
grbuild.flds = &_q.ctx.Fields
|
||||
grbuild.label = tag.Label
|
||||
grbuild.label = label.Label
|
||||
grbuild.scan = grbuild.Scan
|
||||
return grbuild
|
||||
}
|
||||
@@ -363,23 +363,23 @@ func (_q *TagQuery) GroupBy(field string, fields ...string) *TagGroupBy {
|
||||
// CreatedAt time.Time `json:"created_at,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.Tag.Query().
|
||||
// Select(tag.FieldCreatedAt).
|
||||
// client.Label.Query().
|
||||
// Select(label.FieldCreatedAt).
|
||||
// Scan(ctx, &v)
|
||||
func (_q *TagQuery) Select(fields ...string) *TagSelect {
|
||||
func (_q *LabelQuery) Select(fields ...string) *LabelSelect {
|
||||
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
|
||||
sbuild := &TagSelect{TagQuery: _q}
|
||||
sbuild.label = tag.Label
|
||||
sbuild := &LabelSelect{LabelQuery: _q}
|
||||
sbuild.label = label.Label
|
||||
sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
|
||||
return sbuild
|
||||
}
|
||||
|
||||
// Aggregate returns a TagSelect configured with the given aggregations.
|
||||
func (_q *TagQuery) Aggregate(fns ...AggregateFunc) *TagSelect {
|
||||
// Aggregate returns a LabelSelect configured with the given aggregations.
|
||||
func (_q *LabelQuery) Aggregate(fns ...AggregateFunc) *LabelSelect {
|
||||
return _q.Select().Aggregate(fns...)
|
||||
}
|
||||
|
||||
func (_q *TagQuery) prepareQuery(ctx context.Context) error {
|
||||
func (_q *LabelQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range _q.inters {
|
||||
if inter == nil {
|
||||
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
|
||||
@@ -391,7 +391,7 @@ func (_q *TagQuery) prepareQuery(ctx context.Context) error {
|
||||
}
|
||||
}
|
||||
for _, f := range _q.ctx.Fields {
|
||||
if !tag.ValidColumn(f) {
|
||||
if !label.ValidColumn(f) {
|
||||
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
}
|
||||
@@ -405,9 +405,9 @@ func (_q *TagQuery) prepareQuery(ctx context.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (_q *TagQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Tag, error) {
|
||||
func (_q *LabelQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Label, error) {
|
||||
var (
|
||||
nodes = []*Tag{}
|
||||
nodes = []*Label{}
|
||||
withFKs = _q.withFKs
|
||||
_spec = _q.querySpec()
|
||||
loadedTypes = [2]bool{
|
||||
@@ -419,13 +419,13 @@ func (_q *TagQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Tag, err
|
||||
withFKs = true
|
||||
}
|
||||
if withFKs {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, tag.ForeignKeys...)
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, label.ForeignKeys...)
|
||||
}
|
||||
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||
return (*Tag).scanValues(nil, columns)
|
||||
return (*Label).scanValues(nil, columns)
|
||||
}
|
||||
_spec.Assign = func(columns []string, values []any) error {
|
||||
node := &Tag{config: _q.config}
|
||||
node := &Label{config: _q.config}
|
||||
nodes = append(nodes, node)
|
||||
node.Edges.loadedTypes = loadedTypes
|
||||
return node.assignValues(columns, values)
|
||||
@@ -441,28 +441,28 @@ func (_q *TagQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Tag, err
|
||||
}
|
||||
if query := _q.withGroup; query != nil {
|
||||
if err := _q.loadGroup(ctx, query, nodes, nil,
|
||||
func(n *Tag, e *Group) { n.Edges.Group = e }); err != nil {
|
||||
func(n *Label, e *Group) { n.Edges.Group = e }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if query := _q.withItems; query != nil {
|
||||
if err := _q.loadItems(ctx, query, nodes,
|
||||
func(n *Tag) { n.Edges.Items = []*Item{} },
|
||||
func(n *Tag, e *Item) { n.Edges.Items = append(n.Edges.Items, e) }); err != nil {
|
||||
func(n *Label) { n.Edges.Items = []*Item{} },
|
||||
func(n *Label, e *Item) { n.Edges.Items = append(n.Edges.Items, e) }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func (_q *TagQuery) loadGroup(ctx context.Context, query *GroupQuery, nodes []*Tag, init func(*Tag), assign func(*Tag, *Group)) error {
|
||||
func (_q *LabelQuery) loadGroup(ctx context.Context, query *GroupQuery, nodes []*Label, init func(*Label), assign func(*Label, *Group)) error {
|
||||
ids := make([]uuid.UUID, 0, len(nodes))
|
||||
nodeids := make(map[uuid.UUID][]*Tag)
|
||||
nodeids := make(map[uuid.UUID][]*Label)
|
||||
for i := range nodes {
|
||||
if nodes[i].group_tags == nil {
|
||||
if nodes[i].group_labels == nil {
|
||||
continue
|
||||
}
|
||||
fk := *nodes[i].group_tags
|
||||
fk := *nodes[i].group_labels
|
||||
if _, ok := nodeids[fk]; !ok {
|
||||
ids = append(ids, fk)
|
||||
}
|
||||
@@ -479,7 +479,7 @@ func (_q *TagQuery) loadGroup(ctx context.Context, query *GroupQuery, nodes []*T
|
||||
for _, n := range neighbors {
|
||||
nodes, ok := nodeids[n.ID]
|
||||
if !ok {
|
||||
return fmt.Errorf(`unexpected foreign-key "group_tags" returned %v`, n.ID)
|
||||
return fmt.Errorf(`unexpected foreign-key "group_labels" returned %v`, n.ID)
|
||||
}
|
||||
for i := range nodes {
|
||||
assign(nodes[i], n)
|
||||
@@ -487,10 +487,10 @@ func (_q *TagQuery) loadGroup(ctx context.Context, query *GroupQuery, nodes []*T
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (_q *TagQuery) loadItems(ctx context.Context, query *ItemQuery, nodes []*Tag, init func(*Tag), assign func(*Tag, *Item)) error {
|
||||
func (_q *LabelQuery) loadItems(ctx context.Context, query *ItemQuery, nodes []*Label, init func(*Label), assign func(*Label, *Item)) error {
|
||||
edgeIDs := make([]driver.Value, len(nodes))
|
||||
byID := make(map[uuid.UUID]*Tag)
|
||||
nids := make(map[uuid.UUID]map[*Tag]struct{})
|
||||
byID := make(map[uuid.UUID]*Label)
|
||||
nids := make(map[uuid.UUID]map[*Label]struct{})
|
||||
for i, node := range nodes {
|
||||
edgeIDs[i] = node.ID
|
||||
byID[node.ID] = node
|
||||
@@ -499,11 +499,11 @@ func (_q *TagQuery) loadItems(ctx context.Context, query *ItemQuery, nodes []*Ta
|
||||
}
|
||||
}
|
||||
query.Where(func(s *sql.Selector) {
|
||||
joinT := sql.Table(tag.ItemsTable)
|
||||
s.Join(joinT).On(s.C(item.FieldID), joinT.C(tag.ItemsPrimaryKey[1]))
|
||||
s.Where(sql.InValues(joinT.C(tag.ItemsPrimaryKey[0]), edgeIDs...))
|
||||
joinT := sql.Table(label.ItemsTable)
|
||||
s.Join(joinT).On(s.C(item.FieldID), joinT.C(label.ItemsPrimaryKey[1]))
|
||||
s.Where(sql.InValues(joinT.C(label.ItemsPrimaryKey[0]), edgeIDs...))
|
||||
columns := s.SelectedColumns()
|
||||
s.Select(joinT.C(tag.ItemsPrimaryKey[0]))
|
||||
s.Select(joinT.C(label.ItemsPrimaryKey[0]))
|
||||
s.AppendSelect(columns...)
|
||||
s.SetDistinct(false)
|
||||
})
|
||||
@@ -525,7 +525,7 @@ func (_q *TagQuery) loadItems(ctx context.Context, query *ItemQuery, nodes []*Ta
|
||||
outValue := *values[0].(*uuid.UUID)
|
||||
inValue := *values[1].(*uuid.UUID)
|
||||
if nids[inValue] == nil {
|
||||
nids[inValue] = map[*Tag]struct{}{byID[outValue]: {}}
|
||||
nids[inValue] = map[*Label]struct{}{byID[outValue]: {}}
|
||||
return assign(columns[1:], values[1:])
|
||||
}
|
||||
nids[inValue][byID[outValue]] = struct{}{}
|
||||
@@ -549,7 +549,7 @@ func (_q *TagQuery) loadItems(ctx context.Context, query *ItemQuery, nodes []*Ta
|
||||
return nil
|
||||
}
|
||||
|
||||
func (_q *TagQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
func (_q *LabelQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := _q.querySpec()
|
||||
_spec.Node.Columns = _q.ctx.Fields
|
||||
if len(_q.ctx.Fields) > 0 {
|
||||
@@ -558,8 +558,8 @@ func (_q *TagQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
return sqlgraph.CountNodes(ctx, _q.driver, _spec)
|
||||
}
|
||||
|
||||
func (_q *TagQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
_spec := sqlgraph.NewQuerySpec(tag.Table, tag.Columns, sqlgraph.NewFieldSpec(tag.FieldID, field.TypeUUID))
|
||||
func (_q *LabelQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
_spec := sqlgraph.NewQuerySpec(label.Table, label.Columns, sqlgraph.NewFieldSpec(label.FieldID, field.TypeUUID))
|
||||
_spec.From = _q.sql
|
||||
if unique := _q.ctx.Unique; unique != nil {
|
||||
_spec.Unique = *unique
|
||||
@@ -568,9 +568,9 @@ func (_q *TagQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
}
|
||||
if fields := _q.ctx.Fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, tag.FieldID)
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, label.FieldID)
|
||||
for i := range fields {
|
||||
if fields[i] != tag.FieldID {
|
||||
if fields[i] != label.FieldID {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
|
||||
}
|
||||
}
|
||||
@@ -598,12 +598,12 @@ func (_q *TagQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
return _spec
|
||||
}
|
||||
|
||||
func (_q *TagQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
func (_q *LabelQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(_q.driver.Dialect())
|
||||
t1 := builder.Table(tag.Table)
|
||||
t1 := builder.Table(label.Table)
|
||||
columns := _q.ctx.Fields
|
||||
if len(columns) == 0 {
|
||||
columns = tag.Columns
|
||||
columns = label.Columns
|
||||
}
|
||||
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||
if _q.sql != nil {
|
||||
@@ -630,28 +630,28 @@ func (_q *TagQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
return selector
|
||||
}
|
||||
|
||||
// TagGroupBy is the group-by builder for Tag entities.
|
||||
type TagGroupBy struct {
|
||||
// LabelGroupBy is the group-by builder for Label entities.
|
||||
type LabelGroupBy struct {
|
||||
selector
|
||||
build *TagQuery
|
||||
build *LabelQuery
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the group-by query.
|
||||
func (_g *TagGroupBy) Aggregate(fns ...AggregateFunc) *TagGroupBy {
|
||||
func (_g *LabelGroupBy) Aggregate(fns ...AggregateFunc) *LabelGroupBy {
|
||||
_g.fns = append(_g.fns, fns...)
|
||||
return _g
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (_g *TagGroupBy) Scan(ctx context.Context, v any) error {
|
||||
func (_g *LabelGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
|
||||
if err := _g.build.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*TagQuery, *TagGroupBy](ctx, _g.build, _g, _g.build.inters, v)
|
||||
return scanWithInterceptors[*LabelQuery, *LabelGroupBy](ctx, _g.build, _g, _g.build.inters, v)
|
||||
}
|
||||
|
||||
func (_g *TagGroupBy) sqlScan(ctx context.Context, root *TagQuery, v any) error {
|
||||
func (_g *LabelGroupBy) sqlScan(ctx context.Context, root *LabelQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx).Select()
|
||||
aggregation := make([]string, 0, len(_g.fns))
|
||||
for _, fn := range _g.fns {
|
||||
@@ -678,28 +678,28 @@ func (_g *TagGroupBy) sqlScan(ctx context.Context, root *TagQuery, v any) error
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
|
||||
// TagSelect is the builder for selecting fields of Tag entities.
|
||||
type TagSelect struct {
|
||||
*TagQuery
|
||||
// LabelSelect is the builder for selecting fields of Label entities.
|
||||
type LabelSelect struct {
|
||||
*LabelQuery
|
||||
selector
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the selector query.
|
||||
func (_s *TagSelect) Aggregate(fns ...AggregateFunc) *TagSelect {
|
||||
func (_s *LabelSelect) Aggregate(fns ...AggregateFunc) *LabelSelect {
|
||||
_s.fns = append(_s.fns, fns...)
|
||||
return _s
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (_s *TagSelect) Scan(ctx context.Context, v any) error {
|
||||
func (_s *LabelSelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
|
||||
if err := _s.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*TagQuery, *TagSelect](ctx, _s.TagQuery, _s, _s.inters, v)
|
||||
return scanWithInterceptors[*LabelQuery, *LabelSelect](ctx, _s.LabelQuery, _s, _s.inters, v)
|
||||
}
|
||||
|
||||
func (_s *TagSelect) sqlScan(ctx context.Context, root *TagQuery, v any) error {
|
||||
func (_s *LabelSelect) sqlScan(ctx context.Context, root *LabelQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx)
|
||||
aggregation := make([]string, 0, len(_s.fns))
|
||||
for _, fn := range _s.fns {
|
||||
@@ -14,37 +14,37 @@ import (
|
||||
"github.com/google/uuid"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/label"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/tag"
|
||||
)
|
||||
|
||||
// TagUpdate is the builder for updating Tag entities.
|
||||
type TagUpdate struct {
|
||||
// LabelUpdate is the builder for updating Label entities.
|
||||
type LabelUpdate struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *TagMutation
|
||||
mutation *LabelMutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the TagUpdate builder.
|
||||
func (_u *TagUpdate) Where(ps ...predicate.Tag) *TagUpdate {
|
||||
// Where appends a list predicates to the LabelUpdate builder.
|
||||
func (_u *LabelUpdate) Where(ps ...predicate.Label) *LabelUpdate {
|
||||
_u.mutation.Where(ps...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (_u *TagUpdate) SetUpdatedAt(v time.Time) *TagUpdate {
|
||||
func (_u *LabelUpdate) SetUpdatedAt(v time.Time) *LabelUpdate {
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (_u *TagUpdate) SetName(v string) *TagUpdate {
|
||||
func (_u *LabelUpdate) SetName(v string) *LabelUpdate {
|
||||
_u.mutation.SetName(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableName sets the "name" field if the given value is not nil.
|
||||
func (_u *TagUpdate) SetNillableName(v *string) *TagUpdate {
|
||||
func (_u *LabelUpdate) SetNillableName(v *string) *LabelUpdate {
|
||||
if v != nil {
|
||||
_u.SetName(*v)
|
||||
}
|
||||
@@ -52,13 +52,13 @@ func (_u *TagUpdate) SetNillableName(v *string) *TagUpdate {
|
||||
}
|
||||
|
||||
// SetDescription sets the "description" field.
|
||||
func (_u *TagUpdate) SetDescription(v string) *TagUpdate {
|
||||
func (_u *LabelUpdate) SetDescription(v string) *LabelUpdate {
|
||||
_u.mutation.SetDescription(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableDescription sets the "description" field if the given value is not nil.
|
||||
func (_u *TagUpdate) SetNillableDescription(v *string) *TagUpdate {
|
||||
func (_u *LabelUpdate) SetNillableDescription(v *string) *LabelUpdate {
|
||||
if v != nil {
|
||||
_u.SetDescription(*v)
|
||||
}
|
||||
@@ -66,19 +66,19 @@ func (_u *TagUpdate) SetNillableDescription(v *string) *TagUpdate {
|
||||
}
|
||||
|
||||
// ClearDescription clears the value of the "description" field.
|
||||
func (_u *TagUpdate) ClearDescription() *TagUpdate {
|
||||
func (_u *LabelUpdate) ClearDescription() *LabelUpdate {
|
||||
_u.mutation.ClearDescription()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetColor sets the "color" field.
|
||||
func (_u *TagUpdate) SetColor(v string) *TagUpdate {
|
||||
func (_u *LabelUpdate) SetColor(v string) *LabelUpdate {
|
||||
_u.mutation.SetColor(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableColor sets the "color" field if the given value is not nil.
|
||||
func (_u *TagUpdate) SetNillableColor(v *string) *TagUpdate {
|
||||
func (_u *LabelUpdate) SetNillableColor(v *string) *LabelUpdate {
|
||||
if v != nil {
|
||||
_u.SetColor(*v)
|
||||
}
|
||||
@@ -86,30 +86,30 @@ func (_u *TagUpdate) SetNillableColor(v *string) *TagUpdate {
|
||||
}
|
||||
|
||||
// ClearColor clears the value of the "color" field.
|
||||
func (_u *TagUpdate) ClearColor() *TagUpdate {
|
||||
func (_u *LabelUpdate) ClearColor() *LabelUpdate {
|
||||
_u.mutation.ClearColor()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetGroupID sets the "group" edge to the Group entity by ID.
|
||||
func (_u *TagUpdate) SetGroupID(id uuid.UUID) *TagUpdate {
|
||||
func (_u *LabelUpdate) SetGroupID(id uuid.UUID) *LabelUpdate {
|
||||
_u.mutation.SetGroupID(id)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetGroup sets the "group" edge to the Group entity.
|
||||
func (_u *TagUpdate) SetGroup(v *Group) *TagUpdate {
|
||||
func (_u *LabelUpdate) SetGroup(v *Group) *LabelUpdate {
|
||||
return _u.SetGroupID(v.ID)
|
||||
}
|
||||
|
||||
// AddItemIDs adds the "items" edge to the Item entity by IDs.
|
||||
func (_u *TagUpdate) AddItemIDs(ids ...uuid.UUID) *TagUpdate {
|
||||
func (_u *LabelUpdate) AddItemIDs(ids ...uuid.UUID) *LabelUpdate {
|
||||
_u.mutation.AddItemIDs(ids...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddItems adds the "items" edges to the Item entity.
|
||||
func (_u *TagUpdate) AddItems(v ...*Item) *TagUpdate {
|
||||
func (_u *LabelUpdate) AddItems(v ...*Item) *LabelUpdate {
|
||||
ids := make([]uuid.UUID, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
@@ -117,31 +117,31 @@ func (_u *TagUpdate) AddItems(v ...*Item) *TagUpdate {
|
||||
return _u.AddItemIDs(ids...)
|
||||
}
|
||||
|
||||
// Mutation returns the TagMutation object of the builder.
|
||||
func (_u *TagUpdate) Mutation() *TagMutation {
|
||||
// Mutation returns the LabelMutation object of the builder.
|
||||
func (_u *LabelUpdate) Mutation() *LabelMutation {
|
||||
return _u.mutation
|
||||
}
|
||||
|
||||
// ClearGroup clears the "group" edge to the Group entity.
|
||||
func (_u *TagUpdate) ClearGroup() *TagUpdate {
|
||||
func (_u *LabelUpdate) ClearGroup() *LabelUpdate {
|
||||
_u.mutation.ClearGroup()
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearItems clears all "items" edges to the Item entity.
|
||||
func (_u *TagUpdate) ClearItems() *TagUpdate {
|
||||
func (_u *LabelUpdate) ClearItems() *LabelUpdate {
|
||||
_u.mutation.ClearItems()
|
||||
return _u
|
||||
}
|
||||
|
||||
// RemoveItemIDs removes the "items" edge to Item entities by IDs.
|
||||
func (_u *TagUpdate) RemoveItemIDs(ids ...uuid.UUID) *TagUpdate {
|
||||
func (_u *LabelUpdate) RemoveItemIDs(ids ...uuid.UUID) *LabelUpdate {
|
||||
_u.mutation.RemoveItemIDs(ids...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// RemoveItems removes "items" edges to Item entities.
|
||||
func (_u *TagUpdate) RemoveItems(v ...*Item) *TagUpdate {
|
||||
func (_u *LabelUpdate) RemoveItems(v ...*Item) *LabelUpdate {
|
||||
ids := make([]uuid.UUID, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
@@ -150,13 +150,13 @@ func (_u *TagUpdate) RemoveItems(v ...*Item) *TagUpdate {
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||
func (_u *TagUpdate) Save(ctx context.Context) (int, error) {
|
||||
func (_u *LabelUpdate) Save(ctx context.Context) (int, error) {
|
||||
_u.defaults()
|
||||
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (_u *TagUpdate) SaveX(ctx context.Context) int {
|
||||
func (_u *LabelUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := _u.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@@ -165,54 +165,54 @@ func (_u *TagUpdate) SaveX(ctx context.Context) int {
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (_u *TagUpdate) Exec(ctx context.Context) error {
|
||||
func (_u *LabelUpdate) Exec(ctx context.Context) error {
|
||||
_, err := _u.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_u *TagUpdate) ExecX(ctx context.Context) {
|
||||
func (_u *LabelUpdate) ExecX(ctx context.Context) {
|
||||
if err := _u.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (_u *TagUpdate) defaults() {
|
||||
func (_u *LabelUpdate) defaults() {
|
||||
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
||||
v := tag.UpdateDefaultUpdatedAt()
|
||||
v := label.UpdateDefaultUpdatedAt()
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (_u *TagUpdate) check() error {
|
||||
func (_u *LabelUpdate) check() error {
|
||||
if v, ok := _u.mutation.Name(); ok {
|
||||
if err := tag.NameValidator(v); err != nil {
|
||||
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Tag.name": %w`, err)}
|
||||
if err := label.NameValidator(v); err != nil {
|
||||
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Label.name": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _u.mutation.Description(); ok {
|
||||
if err := tag.DescriptionValidator(v); err != nil {
|
||||
return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Tag.description": %w`, err)}
|
||||
if err := label.DescriptionValidator(v); err != nil {
|
||||
return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Label.description": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _u.mutation.Color(); ok {
|
||||
if err := tag.ColorValidator(v); err != nil {
|
||||
return &ValidationError{Name: "color", err: fmt.Errorf(`ent: validator failed for field "Tag.color": %w`, err)}
|
||||
if err := label.ColorValidator(v); err != nil {
|
||||
return &ValidationError{Name: "color", err: fmt.Errorf(`ent: validator failed for field "Label.color": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _u.mutation.GroupCleared() && len(_u.mutation.GroupIDs()) > 0 {
|
||||
return errors.New(`ent: clearing a required unique edge "Tag.group"`)
|
||||
return errors.New(`ent: clearing a required unique edge "Label.group"`)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (_u *TagUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
func (_u *LabelUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
if err := _u.check(); err != nil {
|
||||
return _node, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(tag.Table, tag.Columns, sqlgraph.NewFieldSpec(tag.FieldID, field.TypeUUID))
|
||||
_spec := sqlgraph.NewUpdateSpec(label.Table, label.Columns, sqlgraph.NewFieldSpec(label.FieldID, field.TypeUUID))
|
||||
if ps := _u.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
@@ -221,29 +221,29 @@ func (_u *TagUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
}
|
||||
}
|
||||
if value, ok := _u.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(tag.FieldUpdatedAt, field.TypeTime, value)
|
||||
_spec.SetField(label.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Name(); ok {
|
||||
_spec.SetField(tag.FieldName, field.TypeString, value)
|
||||
_spec.SetField(label.FieldName, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Description(); ok {
|
||||
_spec.SetField(tag.FieldDescription, field.TypeString, value)
|
||||
_spec.SetField(label.FieldDescription, field.TypeString, value)
|
||||
}
|
||||
if _u.mutation.DescriptionCleared() {
|
||||
_spec.ClearField(tag.FieldDescription, field.TypeString)
|
||||
_spec.ClearField(label.FieldDescription, field.TypeString)
|
||||
}
|
||||
if value, ok := _u.mutation.Color(); ok {
|
||||
_spec.SetField(tag.FieldColor, field.TypeString, value)
|
||||
_spec.SetField(label.FieldColor, field.TypeString, value)
|
||||
}
|
||||
if _u.mutation.ColorCleared() {
|
||||
_spec.ClearField(tag.FieldColor, field.TypeString)
|
||||
_spec.ClearField(label.FieldColor, field.TypeString)
|
||||
}
|
||||
if _u.mutation.GroupCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: tag.GroupTable,
|
||||
Columns: []string{tag.GroupColumn},
|
||||
Table: label.GroupTable,
|
||||
Columns: []string{label.GroupColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID),
|
||||
@@ -255,8 +255,8 @@ func (_u *TagUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: tag.GroupTable,
|
||||
Columns: []string{tag.GroupColumn},
|
||||
Table: label.GroupTable,
|
||||
Columns: []string{label.GroupColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID),
|
||||
@@ -271,8 +271,8 @@ func (_u *TagUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2M,
|
||||
Inverse: false,
|
||||
Table: tag.ItemsTable,
|
||||
Columns: tag.ItemsPrimaryKey,
|
||||
Table: label.ItemsTable,
|
||||
Columns: label.ItemsPrimaryKey,
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
|
||||
@@ -284,8 +284,8 @@ func (_u *TagUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2M,
|
||||
Inverse: false,
|
||||
Table: tag.ItemsTable,
|
||||
Columns: tag.ItemsPrimaryKey,
|
||||
Table: label.ItemsTable,
|
||||
Columns: label.ItemsPrimaryKey,
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
|
||||
@@ -300,8 +300,8 @@ func (_u *TagUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2M,
|
||||
Inverse: false,
|
||||
Table: tag.ItemsTable,
|
||||
Columns: tag.ItemsPrimaryKey,
|
||||
Table: label.ItemsTable,
|
||||
Columns: label.ItemsPrimaryKey,
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
|
||||
@@ -314,7 +314,7 @@ func (_u *TagUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
}
|
||||
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{tag.Label}
|
||||
err = &NotFoundError{label.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
@@ -324,28 +324,28 @@ func (_u *TagUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
// TagUpdateOne is the builder for updating a single Tag entity.
|
||||
type TagUpdateOne struct {
|
||||
// LabelUpdateOne is the builder for updating a single Label entity.
|
||||
type LabelUpdateOne struct {
|
||||
config
|
||||
fields []string
|
||||
hooks []Hook
|
||||
mutation *TagMutation
|
||||
mutation *LabelMutation
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (_u *TagUpdateOne) SetUpdatedAt(v time.Time) *TagUpdateOne {
|
||||
func (_u *LabelUpdateOne) SetUpdatedAt(v time.Time) *LabelUpdateOne {
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (_u *TagUpdateOne) SetName(v string) *TagUpdateOne {
|
||||
func (_u *LabelUpdateOne) SetName(v string) *LabelUpdateOne {
|
||||
_u.mutation.SetName(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableName sets the "name" field if the given value is not nil.
|
||||
func (_u *TagUpdateOne) SetNillableName(v *string) *TagUpdateOne {
|
||||
func (_u *LabelUpdateOne) SetNillableName(v *string) *LabelUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetName(*v)
|
||||
}
|
||||
@@ -353,13 +353,13 @@ func (_u *TagUpdateOne) SetNillableName(v *string) *TagUpdateOne {
|
||||
}
|
||||
|
||||
// SetDescription sets the "description" field.
|
||||
func (_u *TagUpdateOne) SetDescription(v string) *TagUpdateOne {
|
||||
func (_u *LabelUpdateOne) SetDescription(v string) *LabelUpdateOne {
|
||||
_u.mutation.SetDescription(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableDescription sets the "description" field if the given value is not nil.
|
||||
func (_u *TagUpdateOne) SetNillableDescription(v *string) *TagUpdateOne {
|
||||
func (_u *LabelUpdateOne) SetNillableDescription(v *string) *LabelUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetDescription(*v)
|
||||
}
|
||||
@@ -367,19 +367,19 @@ func (_u *TagUpdateOne) SetNillableDescription(v *string) *TagUpdateOne {
|
||||
}
|
||||
|
||||
// ClearDescription clears the value of the "description" field.
|
||||
func (_u *TagUpdateOne) ClearDescription() *TagUpdateOne {
|
||||
func (_u *LabelUpdateOne) ClearDescription() *LabelUpdateOne {
|
||||
_u.mutation.ClearDescription()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetColor sets the "color" field.
|
||||
func (_u *TagUpdateOne) SetColor(v string) *TagUpdateOne {
|
||||
func (_u *LabelUpdateOne) SetColor(v string) *LabelUpdateOne {
|
||||
_u.mutation.SetColor(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableColor sets the "color" field if the given value is not nil.
|
||||
func (_u *TagUpdateOne) SetNillableColor(v *string) *TagUpdateOne {
|
||||
func (_u *LabelUpdateOne) SetNillableColor(v *string) *LabelUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetColor(*v)
|
||||
}
|
||||
@@ -387,30 +387,30 @@ func (_u *TagUpdateOne) SetNillableColor(v *string) *TagUpdateOne {
|
||||
}
|
||||
|
||||
// ClearColor clears the value of the "color" field.
|
||||
func (_u *TagUpdateOne) ClearColor() *TagUpdateOne {
|
||||
func (_u *LabelUpdateOne) ClearColor() *LabelUpdateOne {
|
||||
_u.mutation.ClearColor()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetGroupID sets the "group" edge to the Group entity by ID.
|
||||
func (_u *TagUpdateOne) SetGroupID(id uuid.UUID) *TagUpdateOne {
|
||||
func (_u *LabelUpdateOne) SetGroupID(id uuid.UUID) *LabelUpdateOne {
|
||||
_u.mutation.SetGroupID(id)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetGroup sets the "group" edge to the Group entity.
|
||||
func (_u *TagUpdateOne) SetGroup(v *Group) *TagUpdateOne {
|
||||
func (_u *LabelUpdateOne) SetGroup(v *Group) *LabelUpdateOne {
|
||||
return _u.SetGroupID(v.ID)
|
||||
}
|
||||
|
||||
// AddItemIDs adds the "items" edge to the Item entity by IDs.
|
||||
func (_u *TagUpdateOne) AddItemIDs(ids ...uuid.UUID) *TagUpdateOne {
|
||||
func (_u *LabelUpdateOne) AddItemIDs(ids ...uuid.UUID) *LabelUpdateOne {
|
||||
_u.mutation.AddItemIDs(ids...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddItems adds the "items" edges to the Item entity.
|
||||
func (_u *TagUpdateOne) AddItems(v ...*Item) *TagUpdateOne {
|
||||
func (_u *LabelUpdateOne) AddItems(v ...*Item) *LabelUpdateOne {
|
||||
ids := make([]uuid.UUID, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
@@ -418,31 +418,31 @@ func (_u *TagUpdateOne) AddItems(v ...*Item) *TagUpdateOne {
|
||||
return _u.AddItemIDs(ids...)
|
||||
}
|
||||
|
||||
// Mutation returns the TagMutation object of the builder.
|
||||
func (_u *TagUpdateOne) Mutation() *TagMutation {
|
||||
// Mutation returns the LabelMutation object of the builder.
|
||||
func (_u *LabelUpdateOne) Mutation() *LabelMutation {
|
||||
return _u.mutation
|
||||
}
|
||||
|
||||
// ClearGroup clears the "group" edge to the Group entity.
|
||||
func (_u *TagUpdateOne) ClearGroup() *TagUpdateOne {
|
||||
func (_u *LabelUpdateOne) ClearGroup() *LabelUpdateOne {
|
||||
_u.mutation.ClearGroup()
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearItems clears all "items" edges to the Item entity.
|
||||
func (_u *TagUpdateOne) ClearItems() *TagUpdateOne {
|
||||
func (_u *LabelUpdateOne) ClearItems() *LabelUpdateOne {
|
||||
_u.mutation.ClearItems()
|
||||
return _u
|
||||
}
|
||||
|
||||
// RemoveItemIDs removes the "items" edge to Item entities by IDs.
|
||||
func (_u *TagUpdateOne) RemoveItemIDs(ids ...uuid.UUID) *TagUpdateOne {
|
||||
func (_u *LabelUpdateOne) RemoveItemIDs(ids ...uuid.UUID) *LabelUpdateOne {
|
||||
_u.mutation.RemoveItemIDs(ids...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// RemoveItems removes "items" edges to Item entities.
|
||||
func (_u *TagUpdateOne) RemoveItems(v ...*Item) *TagUpdateOne {
|
||||
func (_u *LabelUpdateOne) RemoveItems(v ...*Item) *LabelUpdateOne {
|
||||
ids := make([]uuid.UUID, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
@@ -450,27 +450,27 @@ func (_u *TagUpdateOne) RemoveItems(v ...*Item) *TagUpdateOne {
|
||||
return _u.RemoveItemIDs(ids...)
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the TagUpdate builder.
|
||||
func (_u *TagUpdateOne) Where(ps ...predicate.Tag) *TagUpdateOne {
|
||||
// Where appends a list predicates to the LabelUpdate builder.
|
||||
func (_u *LabelUpdateOne) Where(ps ...predicate.Label) *LabelUpdateOne {
|
||||
_u.mutation.Where(ps...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// Select allows selecting one or more fields (columns) of the returned entity.
|
||||
// The default is selecting all fields defined in the entity schema.
|
||||
func (_u *TagUpdateOne) Select(field string, fields ...string) *TagUpdateOne {
|
||||
func (_u *LabelUpdateOne) Select(field string, fields ...string) *LabelUpdateOne {
|
||||
_u.fields = append([]string{field}, fields...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// Save executes the query and returns the updated Tag entity.
|
||||
func (_u *TagUpdateOne) Save(ctx context.Context) (*Tag, error) {
|
||||
// Save executes the query and returns the updated Label entity.
|
||||
func (_u *LabelUpdateOne) Save(ctx context.Context) (*Label, error) {
|
||||
_u.defaults()
|
||||
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (_u *TagUpdateOne) SaveX(ctx context.Context) *Tag {
|
||||
func (_u *LabelUpdateOne) SaveX(ctx context.Context) *Label {
|
||||
node, err := _u.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@@ -479,67 +479,67 @@ func (_u *TagUpdateOne) SaveX(ctx context.Context) *Tag {
|
||||
}
|
||||
|
||||
// Exec executes the query on the entity.
|
||||
func (_u *TagUpdateOne) Exec(ctx context.Context) error {
|
||||
func (_u *LabelUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := _u.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (_u *TagUpdateOne) ExecX(ctx context.Context) {
|
||||
func (_u *LabelUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := _u.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (_u *TagUpdateOne) defaults() {
|
||||
func (_u *LabelUpdateOne) defaults() {
|
||||
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
||||
v := tag.UpdateDefaultUpdatedAt()
|
||||
v := label.UpdateDefaultUpdatedAt()
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (_u *TagUpdateOne) check() error {
|
||||
func (_u *LabelUpdateOne) check() error {
|
||||
if v, ok := _u.mutation.Name(); ok {
|
||||
if err := tag.NameValidator(v); err != nil {
|
||||
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Tag.name": %w`, err)}
|
||||
if err := label.NameValidator(v); err != nil {
|
||||
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Label.name": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _u.mutation.Description(); ok {
|
||||
if err := tag.DescriptionValidator(v); err != nil {
|
||||
return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Tag.description": %w`, err)}
|
||||
if err := label.DescriptionValidator(v); err != nil {
|
||||
return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Label.description": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _u.mutation.Color(); ok {
|
||||
if err := tag.ColorValidator(v); err != nil {
|
||||
return &ValidationError{Name: "color", err: fmt.Errorf(`ent: validator failed for field "Tag.color": %w`, err)}
|
||||
if err := label.ColorValidator(v); err != nil {
|
||||
return &ValidationError{Name: "color", err: fmt.Errorf(`ent: validator failed for field "Label.color": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _u.mutation.GroupCleared() && len(_u.mutation.GroupIDs()) > 0 {
|
||||
return errors.New(`ent: clearing a required unique edge "Tag.group"`)
|
||||
return errors.New(`ent: clearing a required unique edge "Label.group"`)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (_u *TagUpdateOne) sqlSave(ctx context.Context) (_node *Tag, err error) {
|
||||
func (_u *LabelUpdateOne) sqlSave(ctx context.Context) (_node *Label, err error) {
|
||||
if err := _u.check(); err != nil {
|
||||
return _node, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(tag.Table, tag.Columns, sqlgraph.NewFieldSpec(tag.FieldID, field.TypeUUID))
|
||||
_spec := sqlgraph.NewUpdateSpec(label.Table, label.Columns, sqlgraph.NewFieldSpec(label.FieldID, field.TypeUUID))
|
||||
id, ok := _u.mutation.ID()
|
||||
if !ok {
|
||||
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Tag.id" for update`)}
|
||||
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Label.id" for update`)}
|
||||
}
|
||||
_spec.Node.ID.Value = id
|
||||
if fields := _u.fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, tag.FieldID)
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, label.FieldID)
|
||||
for _, f := range fields {
|
||||
if !tag.ValidColumn(f) {
|
||||
if !label.ValidColumn(f) {
|
||||
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
if f != tag.FieldID {
|
||||
if f != label.FieldID {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
||||
}
|
||||
}
|
||||
@@ -552,29 +552,29 @@ func (_u *TagUpdateOne) sqlSave(ctx context.Context) (_node *Tag, err error) {
|
||||
}
|
||||
}
|
||||
if value, ok := _u.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(tag.FieldUpdatedAt, field.TypeTime, value)
|
||||
_spec.SetField(label.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Name(); ok {
|
||||
_spec.SetField(tag.FieldName, field.TypeString, value)
|
||||
_spec.SetField(label.FieldName, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Description(); ok {
|
||||
_spec.SetField(tag.FieldDescription, field.TypeString, value)
|
||||
_spec.SetField(label.FieldDescription, field.TypeString, value)
|
||||
}
|
||||
if _u.mutation.DescriptionCleared() {
|
||||
_spec.ClearField(tag.FieldDescription, field.TypeString)
|
||||
_spec.ClearField(label.FieldDescription, field.TypeString)
|
||||
}
|
||||
if value, ok := _u.mutation.Color(); ok {
|
||||
_spec.SetField(tag.FieldColor, field.TypeString, value)
|
||||
_spec.SetField(label.FieldColor, field.TypeString, value)
|
||||
}
|
||||
if _u.mutation.ColorCleared() {
|
||||
_spec.ClearField(tag.FieldColor, field.TypeString)
|
||||
_spec.ClearField(label.FieldColor, field.TypeString)
|
||||
}
|
||||
if _u.mutation.GroupCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: tag.GroupTable,
|
||||
Columns: []string{tag.GroupColumn},
|
||||
Table: label.GroupTable,
|
||||
Columns: []string{label.GroupColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID),
|
||||
@@ -586,8 +586,8 @@ func (_u *TagUpdateOne) sqlSave(ctx context.Context) (_node *Tag, err error) {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: tag.GroupTable,
|
||||
Columns: []string{tag.GroupColumn},
|
||||
Table: label.GroupTable,
|
||||
Columns: []string{label.GroupColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID),
|
||||
@@ -602,8 +602,8 @@ func (_u *TagUpdateOne) sqlSave(ctx context.Context) (_node *Tag, err error) {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2M,
|
||||
Inverse: false,
|
||||
Table: tag.ItemsTable,
|
||||
Columns: tag.ItemsPrimaryKey,
|
||||
Table: label.ItemsTable,
|
||||
Columns: label.ItemsPrimaryKey,
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
|
||||
@@ -615,8 +615,8 @@ func (_u *TagUpdateOne) sqlSave(ctx context.Context) (_node *Tag, err error) {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2M,
|
||||
Inverse: false,
|
||||
Table: tag.ItemsTable,
|
||||
Columns: tag.ItemsPrimaryKey,
|
||||
Table: label.ItemsTable,
|
||||
Columns: label.ItemsPrimaryKey,
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
|
||||
@@ -631,8 +631,8 @@ func (_u *TagUpdateOne) sqlSave(ctx context.Context) (_node *Tag, err error) {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2M,
|
||||
Inverse: false,
|
||||
Table: tag.ItemsTable,
|
||||
Columns: tag.ItemsPrimaryKey,
|
||||
Table: label.ItemsTable,
|
||||
Columns: label.ItemsPrimaryKey,
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(item.FieldID, field.TypeUUID),
|
||||
@@ -643,12 +643,12 @@ func (_u *TagUpdateOne) sqlSave(ctx context.Context) (_node *Tag, err error) {
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
_node = &Tag{config: _u.config}
|
||||
_node = &Label{config: _u.config}
|
||||
_spec.Assign = _node.assignValues
|
||||
_spec.ScanValues = _node.scanValues
|
||||
if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{tag.Label}
|
||||
err = &NotFoundError{label.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
86
backend/internal/data/ent/migrate/schema.go
generated
86
backend/internal/data/ent/migrate/schema.go
generated
@@ -265,7 +265,7 @@ var (
|
||||
{Name: "include_warranty_fields", Type: field.TypeBool, Default: false},
|
||||
{Name: "include_purchase_fields", Type: field.TypeBool, Default: false},
|
||||
{Name: "include_sold_fields", Type: field.TypeBool, Default: false},
|
||||
{Name: "default_tag_ids", Type: field.TypeJSON, Nullable: true},
|
||||
{Name: "default_label_ids", Type: field.TypeJSON, Nullable: true},
|
||||
{Name: "group_item_templates", Type: field.TypeUUID},
|
||||
{Name: "item_template_location", Type: field.TypeUUID, Nullable: true},
|
||||
}
|
||||
@@ -296,6 +296,30 @@ var (
|
||||
},
|
||||
},
|
||||
}
|
||||
// LabelsColumns holds the columns for the "labels" table.
|
||||
LabelsColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeUUID},
|
||||
{Name: "created_at", Type: field.TypeTime},
|
||||
{Name: "updated_at", Type: field.TypeTime},
|
||||
{Name: "name", Type: field.TypeString, Size: 255},
|
||||
{Name: "description", Type: field.TypeString, Nullable: true, Size: 1000},
|
||||
{Name: "color", Type: field.TypeString, Nullable: true, Size: 255},
|
||||
{Name: "group_labels", Type: field.TypeUUID},
|
||||
}
|
||||
// LabelsTable holds the schema information for the "labels" table.
|
||||
LabelsTable = &schema.Table{
|
||||
Name: "labels",
|
||||
Columns: LabelsColumns,
|
||||
PrimaryKey: []*schema.Column{LabelsColumns[0]},
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "labels_groups_labels",
|
||||
Columns: []*schema.Column{LabelsColumns[6]},
|
||||
RefColumns: []*schema.Column{GroupsColumns[0]},
|
||||
OnDelete: schema.Cascade,
|
||||
},
|
||||
},
|
||||
}
|
||||
// LocationsColumns holds the columns for the "locations" table.
|
||||
LocationsColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeUUID},
|
||||
@@ -405,30 +429,6 @@ var (
|
||||
},
|
||||
},
|
||||
}
|
||||
// TagsColumns holds the columns for the "tags" table.
|
||||
TagsColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeUUID},
|
||||
{Name: "created_at", Type: field.TypeTime},
|
||||
{Name: "updated_at", Type: field.TypeTime},
|
||||
{Name: "name", Type: field.TypeString, Size: 255},
|
||||
{Name: "description", Type: field.TypeString, Nullable: true, Size: 1000},
|
||||
{Name: "color", Type: field.TypeString, Nullable: true, Size: 255},
|
||||
{Name: "group_tags", Type: field.TypeUUID},
|
||||
}
|
||||
// TagsTable holds the schema information for the "tags" table.
|
||||
TagsTable = &schema.Table{
|
||||
Name: "tags",
|
||||
Columns: TagsColumns,
|
||||
PrimaryKey: []*schema.Column{TagsColumns[0]},
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "tags_groups_tags",
|
||||
Columns: []*schema.Column{TagsColumns[6]},
|
||||
RefColumns: []*schema.Column{GroupsColumns[0]},
|
||||
OnDelete: schema.Cascade,
|
||||
},
|
||||
},
|
||||
}
|
||||
// TemplateFieldsColumns holds the columns for the "template_fields" table.
|
||||
TemplateFieldsColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeUUID},
|
||||
@@ -491,26 +491,26 @@ var (
|
||||
},
|
||||
},
|
||||
}
|
||||
// TagItemsColumns holds the columns for the "tag_items" table.
|
||||
TagItemsColumns = []*schema.Column{
|
||||
{Name: "tag_id", Type: field.TypeUUID},
|
||||
// LabelItemsColumns holds the columns for the "label_items" table.
|
||||
LabelItemsColumns = []*schema.Column{
|
||||
{Name: "label_id", Type: field.TypeUUID},
|
||||
{Name: "item_id", Type: field.TypeUUID},
|
||||
}
|
||||
// TagItemsTable holds the schema information for the "tag_items" table.
|
||||
TagItemsTable = &schema.Table{
|
||||
Name: "tag_items",
|
||||
Columns: TagItemsColumns,
|
||||
PrimaryKey: []*schema.Column{TagItemsColumns[0], TagItemsColumns[1]},
|
||||
// LabelItemsTable holds the schema information for the "label_items" table.
|
||||
LabelItemsTable = &schema.Table{
|
||||
Name: "label_items",
|
||||
Columns: LabelItemsColumns,
|
||||
PrimaryKey: []*schema.Column{LabelItemsColumns[0], LabelItemsColumns[1]},
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "tag_items_tag_id",
|
||||
Columns: []*schema.Column{TagItemsColumns[0]},
|
||||
RefColumns: []*schema.Column{TagsColumns[0]},
|
||||
Symbol: "label_items_label_id",
|
||||
Columns: []*schema.Column{LabelItemsColumns[0]},
|
||||
RefColumns: []*schema.Column{LabelsColumns[0]},
|
||||
OnDelete: schema.Cascade,
|
||||
},
|
||||
{
|
||||
Symbol: "tag_items_item_id",
|
||||
Columns: []*schema.Column{TagItemsColumns[1]},
|
||||
Symbol: "label_items_item_id",
|
||||
Columns: []*schema.Column{LabelItemsColumns[1]},
|
||||
RefColumns: []*schema.Column{ItemsColumns[0]},
|
||||
OnDelete: schema.Cascade,
|
||||
},
|
||||
@@ -526,13 +526,13 @@ var (
|
||||
ItemsTable,
|
||||
ItemFieldsTable,
|
||||
ItemTemplatesTable,
|
||||
LabelsTable,
|
||||
LocationsTable,
|
||||
MaintenanceEntriesTable,
|
||||
NotifiersTable,
|
||||
TagsTable,
|
||||
TemplateFieldsTable,
|
||||
UsersTable,
|
||||
TagItemsTable,
|
||||
LabelItemsTable,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -548,14 +548,14 @@ func init() {
|
||||
ItemFieldsTable.ForeignKeys[0].RefTable = ItemsTable
|
||||
ItemTemplatesTable.ForeignKeys[0].RefTable = GroupsTable
|
||||
ItemTemplatesTable.ForeignKeys[1].RefTable = LocationsTable
|
||||
LabelsTable.ForeignKeys[0].RefTable = GroupsTable
|
||||
LocationsTable.ForeignKeys[0].RefTable = GroupsTable
|
||||
LocationsTable.ForeignKeys[1].RefTable = LocationsTable
|
||||
MaintenanceEntriesTable.ForeignKeys[0].RefTable = ItemsTable
|
||||
NotifiersTable.ForeignKeys[0].RefTable = GroupsTable
|
||||
NotifiersTable.ForeignKeys[1].RefTable = UsersTable
|
||||
TagsTable.ForeignKeys[0].RefTable = GroupsTable
|
||||
TemplateFieldsTable.ForeignKeys[0].RefTable = ItemTemplatesTable
|
||||
UsersTable.ForeignKeys[0].RefTable = GroupsTable
|
||||
TagItemsTable.ForeignKeys[0].RefTable = TagsTable
|
||||
TagItemsTable.ForeignKeys[1].RefTable = ItemsTable
|
||||
LabelItemsTable.ForeignKeys[0].RefTable = LabelsTable
|
||||
LabelItemsTable.ForeignKeys[1].RefTable = ItemsTable
|
||||
}
|
||||
|
||||
1772
backend/internal/data/ent/mutation.go
generated
1772
backend/internal/data/ent/mutation.go
generated
File diff suppressed because it is too large
Load Diff
6
backend/internal/data/ent/predicate/predicate.go
generated
6
backend/internal/data/ent/predicate/predicate.go
generated
@@ -30,6 +30,9 @@ type ItemField func(*sql.Selector)
|
||||
// ItemTemplate is the predicate function for itemtemplate builders.
|
||||
type ItemTemplate func(*sql.Selector)
|
||||
|
||||
// Label is the predicate function for label builders.
|
||||
type Label func(*sql.Selector)
|
||||
|
||||
// Location is the predicate function for location builders.
|
||||
type Location func(*sql.Selector)
|
||||
|
||||
@@ -39,9 +42,6 @@ type MaintenanceEntry func(*sql.Selector)
|
||||
// Notifier is the predicate function for notifier builders.
|
||||
type Notifier func(*sql.Selector)
|
||||
|
||||
// Tag is the predicate function for tag builders.
|
||||
type Tag func(*sql.Selector)
|
||||
|
||||
// TemplateField is the predicate function for templatefield builders.
|
||||
type TemplateField func(*sql.Selector)
|
||||
|
||||
|
||||
96
backend/internal/data/ent/runtime.go
generated
96
backend/internal/data/ent/runtime.go
generated
@@ -13,11 +13,11 @@ import (
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemfield"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/label"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/location"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/maintenanceentry"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/notifier"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/schema"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/tag"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/templatefield"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/user"
|
||||
)
|
||||
@@ -403,6 +403,53 @@ func init() {
|
||||
itemtemplateDescID := itemtemplateMixinFields0[0].Descriptor()
|
||||
// itemtemplate.DefaultID holds the default value on creation for the id field.
|
||||
itemtemplate.DefaultID = itemtemplateDescID.Default.(func() uuid.UUID)
|
||||
labelMixin := schema.Label{}.Mixin()
|
||||
labelMixinFields0 := labelMixin[0].Fields()
|
||||
_ = labelMixinFields0
|
||||
labelMixinFields1 := labelMixin[1].Fields()
|
||||
_ = labelMixinFields1
|
||||
labelFields := schema.Label{}.Fields()
|
||||
_ = labelFields
|
||||
// labelDescCreatedAt is the schema descriptor for created_at field.
|
||||
labelDescCreatedAt := labelMixinFields0[1].Descriptor()
|
||||
// label.DefaultCreatedAt holds the default value on creation for the created_at field.
|
||||
label.DefaultCreatedAt = labelDescCreatedAt.Default.(func() time.Time)
|
||||
// labelDescUpdatedAt is the schema descriptor for updated_at field.
|
||||
labelDescUpdatedAt := labelMixinFields0[2].Descriptor()
|
||||
// label.DefaultUpdatedAt holds the default value on creation for the updated_at field.
|
||||
label.DefaultUpdatedAt = labelDescUpdatedAt.Default.(func() time.Time)
|
||||
// label.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
|
||||
label.UpdateDefaultUpdatedAt = labelDescUpdatedAt.UpdateDefault.(func() time.Time)
|
||||
// labelDescName is the schema descriptor for name field.
|
||||
labelDescName := labelMixinFields1[0].Descriptor()
|
||||
// label.NameValidator is a validator for the "name" field. It is called by the builders before save.
|
||||
label.NameValidator = func() func(string) error {
|
||||
validators := labelDescName.Validators
|
||||
fns := [...]func(string) error{
|
||||
validators[0].(func(string) error),
|
||||
validators[1].(func(string) error),
|
||||
}
|
||||
return func(name string) error {
|
||||
for _, fn := range fns {
|
||||
if err := fn(name); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}()
|
||||
// labelDescDescription is the schema descriptor for description field.
|
||||
labelDescDescription := labelMixinFields1[1].Descriptor()
|
||||
// label.DescriptionValidator is a validator for the "description" field. It is called by the builders before save.
|
||||
label.DescriptionValidator = labelDescDescription.Validators[0].(func(string) error)
|
||||
// labelDescColor is the schema descriptor for color field.
|
||||
labelDescColor := labelFields[0].Descriptor()
|
||||
// label.ColorValidator is a validator for the "color" field. It is called by the builders before save.
|
||||
label.ColorValidator = labelDescColor.Validators[0].(func(string) error)
|
||||
// labelDescID is the schema descriptor for id field.
|
||||
labelDescID := labelMixinFields0[0].Descriptor()
|
||||
// label.DefaultID holds the default value on creation for the id field.
|
||||
label.DefaultID = labelDescID.Default.(func() uuid.UUID)
|
||||
locationMixin := schema.Location{}.Mixin()
|
||||
locationMixinFields0 := locationMixin[0].Fields()
|
||||
_ = locationMixinFields0
|
||||
@@ -550,53 +597,6 @@ func init() {
|
||||
notifierDescID := notifierMixinFields0[0].Descriptor()
|
||||
// notifier.DefaultID holds the default value on creation for the id field.
|
||||
notifier.DefaultID = notifierDescID.Default.(func() uuid.UUID)
|
||||
tagMixin := schema.Tag{}.Mixin()
|
||||
tagMixinFields0 := tagMixin[0].Fields()
|
||||
_ = tagMixinFields0
|
||||
tagMixinFields1 := tagMixin[1].Fields()
|
||||
_ = tagMixinFields1
|
||||
tagFields := schema.Tag{}.Fields()
|
||||
_ = tagFields
|
||||
// tagDescCreatedAt is the schema descriptor for created_at field.
|
||||
tagDescCreatedAt := tagMixinFields0[1].Descriptor()
|
||||
// tag.DefaultCreatedAt holds the default value on creation for the created_at field.
|
||||
tag.DefaultCreatedAt = tagDescCreatedAt.Default.(func() time.Time)
|
||||
// tagDescUpdatedAt is the schema descriptor for updated_at field.
|
||||
tagDescUpdatedAt := tagMixinFields0[2].Descriptor()
|
||||
// tag.DefaultUpdatedAt holds the default value on creation for the updated_at field.
|
||||
tag.DefaultUpdatedAt = tagDescUpdatedAt.Default.(func() time.Time)
|
||||
// tag.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
|
||||
tag.UpdateDefaultUpdatedAt = tagDescUpdatedAt.UpdateDefault.(func() time.Time)
|
||||
// tagDescName is the schema descriptor for name field.
|
||||
tagDescName := tagMixinFields1[0].Descriptor()
|
||||
// tag.NameValidator is a validator for the "name" field. It is called by the builders before save.
|
||||
tag.NameValidator = func() func(string) error {
|
||||
validators := tagDescName.Validators
|
||||
fns := [...]func(string) error{
|
||||
validators[0].(func(string) error),
|
||||
validators[1].(func(string) error),
|
||||
}
|
||||
return func(name string) error {
|
||||
for _, fn := range fns {
|
||||
if err := fn(name); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}()
|
||||
// tagDescDescription is the schema descriptor for description field.
|
||||
tagDescDescription := tagMixinFields1[1].Descriptor()
|
||||
// tag.DescriptionValidator is a validator for the "description" field. It is called by the builders before save.
|
||||
tag.DescriptionValidator = tagDescDescription.Validators[0].(func(string) error)
|
||||
// tagDescColor is the schema descriptor for color field.
|
||||
tagDescColor := tagFields[0].Descriptor()
|
||||
// tag.ColorValidator is a validator for the "color" field. It is called by the builders before save.
|
||||
tag.ColorValidator = tagDescColor.Validators[0].(func(string) error)
|
||||
// tagDescID is the schema descriptor for id field.
|
||||
tagDescID := tagMixinFields0[0].Descriptor()
|
||||
// tag.DefaultID holds the default value on creation for the id field.
|
||||
tag.DefaultID = tagDescID.Default.(func() uuid.UUID)
|
||||
templatefieldMixin := schema.TemplateField{}.Mixin()
|
||||
templatefieldMixinFields0 := templatefieldMixin[0].Fields()
|
||||
_ = templatefieldMixinFields0
|
||||
|
||||
@@ -45,7 +45,7 @@ func (Group) Edges() []ent.Edge {
|
||||
owned("users", User.Type),
|
||||
owned("locations", Location.Type),
|
||||
owned("items", Item.Type),
|
||||
owned("tags", Tag.Type),
|
||||
owned("labels", Label.Type),
|
||||
owned("invitation_tokens", GroupInvitationToken.Type),
|
||||
owned("notifiers", Notifier.Type),
|
||||
owned("item_templates", ItemTemplate.Type),
|
||||
|
||||
@@ -112,7 +112,7 @@ func (Item) Edges() []ent.Edge {
|
||||
edge.To("children", Item.Type).
|
||||
From("parent").
|
||||
Unique(),
|
||||
edge.From("tag", Tag.Type).
|
||||
edge.From("label", Label.Type).
|
||||
Ref("items"),
|
||||
edge.From("location", Location.Type).
|
||||
Ref("items").
|
||||
|
||||
@@ -86,10 +86,10 @@ func (ItemTemplate) Fields() []ent.Field {
|
||||
Comment("Whether to include sold fields in items created from this template"),
|
||||
|
||||
// ------------------------------------
|
||||
// Default tags (stored as JSON array of UUIDs to allow reuse across templates)
|
||||
field.JSON("default_tag_ids", []uuid.UUID{}).
|
||||
// Default labels (stored as JSON array of UUIDs to allow reuse across templates)
|
||||
field.JSON("default_label_ids", []uuid.UUID{}).
|
||||
Optional().
|
||||
Comment("Default tag IDs for items created from this template"),
|
||||
Comment("Default label IDs for items created from this template"),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,21 +7,21 @@ import (
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/schema/mixins"
|
||||
)
|
||||
|
||||
// Tag holds the schema definition for the Tag entity.
|
||||
type Tag struct {
|
||||
// Label holds the schema definition for the Label entity.
|
||||
type Label struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
func (Tag) Mixin() []ent.Mixin {
|
||||
func (Label) Mixin() []ent.Mixin {
|
||||
return []ent.Mixin{
|
||||
mixins.BaseMixin{},
|
||||
mixins.DetailsMixin{},
|
||||
GroupMixin{ref: "tags"},
|
||||
GroupMixin{ref: "labels"},
|
||||
}
|
||||
}
|
||||
|
||||
// Fields of the Tag.
|
||||
func (Tag) Fields() []ent.Field {
|
||||
// Fields of the Label.
|
||||
func (Label) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.String("color").
|
||||
MaxLen(255).
|
||||
@@ -29,8 +29,8 @@ func (Tag) Fields() []ent.Field {
|
||||
}
|
||||
}
|
||||
|
||||
// Edges of the Tag.
|
||||
func (Tag) Edges() []ent.Edge {
|
||||
// Edges of the Label.
|
||||
func (Label) Edges() []ent.Edge {
|
||||
return []ent.Edge{
|
||||
edge.To("items", Item.Type),
|
||||
}
|
||||
438
backend/internal/data/ent/tag/where.go
generated
438
backend/internal/data/ent/tag/where.go
generated
@@ -1,438 +0,0 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package tag
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"github.com/google/uuid"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
|
||||
)
|
||||
|
||||
// ID filters vertices based on their ID field.
|
||||
func ID(id uuid.UUID) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDEQ applies the EQ predicate on the ID field.
|
||||
func IDEQ(id uuid.UUID) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDNEQ applies the NEQ predicate on the ID field.
|
||||
func IDNEQ(id uuid.UUID) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldNEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDIn applies the In predicate on the ID field.
|
||||
func IDIn(ids ...uuid.UUID) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldIn(FieldID, ids...))
|
||||
}
|
||||
|
||||
// IDNotIn applies the NotIn predicate on the ID field.
|
||||
func IDNotIn(ids ...uuid.UUID) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldNotIn(FieldID, ids...))
|
||||
}
|
||||
|
||||
// IDGT applies the GT predicate on the ID field.
|
||||
func IDGT(id uuid.UUID) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldGT(FieldID, id))
|
||||
}
|
||||
|
||||
// IDGTE applies the GTE predicate on the ID field.
|
||||
func IDGTE(id uuid.UUID) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldGTE(FieldID, id))
|
||||
}
|
||||
|
||||
// IDLT applies the LT predicate on the ID field.
|
||||
func IDLT(id uuid.UUID) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldLT(FieldID, id))
|
||||
}
|
||||
|
||||
// IDLTE applies the LTE predicate on the ID field.
|
||||
func IDLTE(id uuid.UUID) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldLTE(FieldID, id))
|
||||
}
|
||||
|
||||
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
|
||||
func CreatedAt(v time.Time) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldEQ(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ.
|
||||
func UpdatedAt(v time.Time) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldEQ(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// Name applies equality check predicate on the "name" field. It's identical to NameEQ.
|
||||
func Name(v string) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldEQ(FieldName, v))
|
||||
}
|
||||
|
||||
// Description applies equality check predicate on the "description" field. It's identical to DescriptionEQ.
|
||||
func Description(v string) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldEQ(FieldDescription, v))
|
||||
}
|
||||
|
||||
// Color applies equality check predicate on the "color" field. It's identical to ColorEQ.
|
||||
func Color(v string) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldEQ(FieldColor, v))
|
||||
}
|
||||
|
||||
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
|
||||
func CreatedAtEQ(v time.Time) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldEQ(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
|
||||
func CreatedAtNEQ(v time.Time) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldNEQ(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtIn applies the In predicate on the "created_at" field.
|
||||
func CreatedAtIn(vs ...time.Time) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldIn(FieldCreatedAt, vs...))
|
||||
}
|
||||
|
||||
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
|
||||
func CreatedAtNotIn(vs ...time.Time) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldNotIn(FieldCreatedAt, vs...))
|
||||
}
|
||||
|
||||
// CreatedAtGT applies the GT predicate on the "created_at" field.
|
||||
func CreatedAtGT(v time.Time) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldGT(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtGTE applies the GTE predicate on the "created_at" field.
|
||||
func CreatedAtGTE(v time.Time) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldGTE(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtLT applies the LT predicate on the "created_at" field.
|
||||
func CreatedAtLT(v time.Time) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldLT(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtLTE applies the LTE predicate on the "created_at" field.
|
||||
func CreatedAtLTE(v time.Time) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldLTE(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtEQ applies the EQ predicate on the "updated_at" field.
|
||||
func UpdatedAtEQ(v time.Time) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldEQ(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field.
|
||||
func UpdatedAtNEQ(v time.Time) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldNEQ(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtIn applies the In predicate on the "updated_at" field.
|
||||
func UpdatedAtIn(vs ...time.Time) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldIn(FieldUpdatedAt, vs...))
|
||||
}
|
||||
|
||||
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
|
||||
func UpdatedAtNotIn(vs ...time.Time) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldNotIn(FieldUpdatedAt, vs...))
|
||||
}
|
||||
|
||||
// UpdatedAtGT applies the GT predicate on the "updated_at" field.
|
||||
func UpdatedAtGT(v time.Time) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldGT(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtGTE applies the GTE predicate on the "updated_at" field.
|
||||
func UpdatedAtGTE(v time.Time) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldGTE(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtLT applies the LT predicate on the "updated_at" field.
|
||||
func UpdatedAtLT(v time.Time) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldLT(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtLTE applies the LTE predicate on the "updated_at" field.
|
||||
func UpdatedAtLTE(v time.Time) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldLTE(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// NameEQ applies the EQ predicate on the "name" field.
|
||||
func NameEQ(v string) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldEQ(FieldName, v))
|
||||
}
|
||||
|
||||
// NameNEQ applies the NEQ predicate on the "name" field.
|
||||
func NameNEQ(v string) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldNEQ(FieldName, v))
|
||||
}
|
||||
|
||||
// NameIn applies the In predicate on the "name" field.
|
||||
func NameIn(vs ...string) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldIn(FieldName, vs...))
|
||||
}
|
||||
|
||||
// NameNotIn applies the NotIn predicate on the "name" field.
|
||||
func NameNotIn(vs ...string) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldNotIn(FieldName, vs...))
|
||||
}
|
||||
|
||||
// NameGT applies the GT predicate on the "name" field.
|
||||
func NameGT(v string) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldGT(FieldName, v))
|
||||
}
|
||||
|
||||
// NameGTE applies the GTE predicate on the "name" field.
|
||||
func NameGTE(v string) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldGTE(FieldName, v))
|
||||
}
|
||||
|
||||
// NameLT applies the LT predicate on the "name" field.
|
||||
func NameLT(v string) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldLT(FieldName, v))
|
||||
}
|
||||
|
||||
// NameLTE applies the LTE predicate on the "name" field.
|
||||
func NameLTE(v string) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldLTE(FieldName, v))
|
||||
}
|
||||
|
||||
// NameContains applies the Contains predicate on the "name" field.
|
||||
func NameContains(v string) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldContains(FieldName, v))
|
||||
}
|
||||
|
||||
// NameHasPrefix applies the HasPrefix predicate on the "name" field.
|
||||
func NameHasPrefix(v string) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldHasPrefix(FieldName, v))
|
||||
}
|
||||
|
||||
// NameHasSuffix applies the HasSuffix predicate on the "name" field.
|
||||
func NameHasSuffix(v string) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldHasSuffix(FieldName, v))
|
||||
}
|
||||
|
||||
// NameEqualFold applies the EqualFold predicate on the "name" field.
|
||||
func NameEqualFold(v string) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldEqualFold(FieldName, v))
|
||||
}
|
||||
|
||||
// NameContainsFold applies the ContainsFold predicate on the "name" field.
|
||||
func NameContainsFold(v string) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldContainsFold(FieldName, v))
|
||||
}
|
||||
|
||||
// DescriptionEQ applies the EQ predicate on the "description" field.
|
||||
func DescriptionEQ(v string) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldEQ(FieldDescription, v))
|
||||
}
|
||||
|
||||
// DescriptionNEQ applies the NEQ predicate on the "description" field.
|
||||
func DescriptionNEQ(v string) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldNEQ(FieldDescription, v))
|
||||
}
|
||||
|
||||
// DescriptionIn applies the In predicate on the "description" field.
|
||||
func DescriptionIn(vs ...string) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldIn(FieldDescription, vs...))
|
||||
}
|
||||
|
||||
// DescriptionNotIn applies the NotIn predicate on the "description" field.
|
||||
func DescriptionNotIn(vs ...string) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldNotIn(FieldDescription, vs...))
|
||||
}
|
||||
|
||||
// DescriptionGT applies the GT predicate on the "description" field.
|
||||
func DescriptionGT(v string) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldGT(FieldDescription, v))
|
||||
}
|
||||
|
||||
// DescriptionGTE applies the GTE predicate on the "description" field.
|
||||
func DescriptionGTE(v string) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldGTE(FieldDescription, v))
|
||||
}
|
||||
|
||||
// DescriptionLT applies the LT predicate on the "description" field.
|
||||
func DescriptionLT(v string) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldLT(FieldDescription, v))
|
||||
}
|
||||
|
||||
// DescriptionLTE applies the LTE predicate on the "description" field.
|
||||
func DescriptionLTE(v string) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldLTE(FieldDescription, v))
|
||||
}
|
||||
|
||||
// DescriptionContains applies the Contains predicate on the "description" field.
|
||||
func DescriptionContains(v string) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldContains(FieldDescription, v))
|
||||
}
|
||||
|
||||
// DescriptionHasPrefix applies the HasPrefix predicate on the "description" field.
|
||||
func DescriptionHasPrefix(v string) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldHasPrefix(FieldDescription, v))
|
||||
}
|
||||
|
||||
// DescriptionHasSuffix applies the HasSuffix predicate on the "description" field.
|
||||
func DescriptionHasSuffix(v string) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldHasSuffix(FieldDescription, v))
|
||||
}
|
||||
|
||||
// DescriptionIsNil applies the IsNil predicate on the "description" field.
|
||||
func DescriptionIsNil() predicate.Tag {
|
||||
return predicate.Tag(sql.FieldIsNull(FieldDescription))
|
||||
}
|
||||
|
||||
// DescriptionNotNil applies the NotNil predicate on the "description" field.
|
||||
func DescriptionNotNil() predicate.Tag {
|
||||
return predicate.Tag(sql.FieldNotNull(FieldDescription))
|
||||
}
|
||||
|
||||
// DescriptionEqualFold applies the EqualFold predicate on the "description" field.
|
||||
func DescriptionEqualFold(v string) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldEqualFold(FieldDescription, v))
|
||||
}
|
||||
|
||||
// DescriptionContainsFold applies the ContainsFold predicate on the "description" field.
|
||||
func DescriptionContainsFold(v string) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldContainsFold(FieldDescription, v))
|
||||
}
|
||||
|
||||
// ColorEQ applies the EQ predicate on the "color" field.
|
||||
func ColorEQ(v string) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldEQ(FieldColor, v))
|
||||
}
|
||||
|
||||
// ColorNEQ applies the NEQ predicate on the "color" field.
|
||||
func ColorNEQ(v string) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldNEQ(FieldColor, v))
|
||||
}
|
||||
|
||||
// ColorIn applies the In predicate on the "color" field.
|
||||
func ColorIn(vs ...string) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldIn(FieldColor, vs...))
|
||||
}
|
||||
|
||||
// ColorNotIn applies the NotIn predicate on the "color" field.
|
||||
func ColorNotIn(vs ...string) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldNotIn(FieldColor, vs...))
|
||||
}
|
||||
|
||||
// ColorGT applies the GT predicate on the "color" field.
|
||||
func ColorGT(v string) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldGT(FieldColor, v))
|
||||
}
|
||||
|
||||
// ColorGTE applies the GTE predicate on the "color" field.
|
||||
func ColorGTE(v string) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldGTE(FieldColor, v))
|
||||
}
|
||||
|
||||
// ColorLT applies the LT predicate on the "color" field.
|
||||
func ColorLT(v string) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldLT(FieldColor, v))
|
||||
}
|
||||
|
||||
// ColorLTE applies the LTE predicate on the "color" field.
|
||||
func ColorLTE(v string) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldLTE(FieldColor, v))
|
||||
}
|
||||
|
||||
// ColorContains applies the Contains predicate on the "color" field.
|
||||
func ColorContains(v string) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldContains(FieldColor, v))
|
||||
}
|
||||
|
||||
// ColorHasPrefix applies the HasPrefix predicate on the "color" field.
|
||||
func ColorHasPrefix(v string) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldHasPrefix(FieldColor, v))
|
||||
}
|
||||
|
||||
// ColorHasSuffix applies the HasSuffix predicate on the "color" field.
|
||||
func ColorHasSuffix(v string) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldHasSuffix(FieldColor, v))
|
||||
}
|
||||
|
||||
// ColorIsNil applies the IsNil predicate on the "color" field.
|
||||
func ColorIsNil() predicate.Tag {
|
||||
return predicate.Tag(sql.FieldIsNull(FieldColor))
|
||||
}
|
||||
|
||||
// ColorNotNil applies the NotNil predicate on the "color" field.
|
||||
func ColorNotNil() predicate.Tag {
|
||||
return predicate.Tag(sql.FieldNotNull(FieldColor))
|
||||
}
|
||||
|
||||
// ColorEqualFold applies the EqualFold predicate on the "color" field.
|
||||
func ColorEqualFold(v string) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldEqualFold(FieldColor, v))
|
||||
}
|
||||
|
||||
// ColorContainsFold applies the ContainsFold predicate on the "color" field.
|
||||
func ColorContainsFold(v string) predicate.Tag {
|
||||
return predicate.Tag(sql.FieldContainsFold(FieldColor, v))
|
||||
}
|
||||
|
||||
// HasGroup applies the HasEdge predicate on the "group" edge.
|
||||
func HasGroup() predicate.Tag {
|
||||
return predicate.Tag(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, GroupTable, GroupColumn),
|
||||
)
|
||||
sqlgraph.HasNeighbors(s, step)
|
||||
})
|
||||
}
|
||||
|
||||
// HasGroupWith applies the HasEdge predicate on the "group" edge with a given conditions (other predicates).
|
||||
func HasGroupWith(preds ...predicate.Group) predicate.Tag {
|
||||
return predicate.Tag(func(s *sql.Selector) {
|
||||
step := newGroupStep()
|
||||
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
for _, p := range preds {
|
||||
p(s)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// HasItems applies the HasEdge predicate on the "items" edge.
|
||||
func HasItems() predicate.Tag {
|
||||
return predicate.Tag(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2M, false, ItemsTable, ItemsPrimaryKey...),
|
||||
)
|
||||
sqlgraph.HasNeighbors(s, step)
|
||||
})
|
||||
}
|
||||
|
||||
// HasItemsWith applies the HasEdge predicate on the "items" edge with a given conditions (other predicates).
|
||||
func HasItemsWith(preds ...predicate.Item) predicate.Tag {
|
||||
return predicate.Tag(func(s *sql.Selector) {
|
||||
step := newItemsStep()
|
||||
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
for _, p := range preds {
|
||||
p(s)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// And groups predicates with the AND operator between them.
|
||||
func And(predicates ...predicate.Tag) predicate.Tag {
|
||||
return predicate.Tag(sql.AndPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Or groups predicates with the OR operator between them.
|
||||
func Or(predicates ...predicate.Tag) predicate.Tag {
|
||||
return predicate.Tag(sql.OrPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Not applies the not operator on the given predicate.
|
||||
func Not(p predicate.Tag) predicate.Tag {
|
||||
return predicate.Tag(sql.NotPredicates(p))
|
||||
}
|
||||
6
backend/internal/data/ent/tx.go
generated
6
backend/internal/data/ent/tx.go
generated
@@ -28,14 +28,14 @@ type Tx struct {
|
||||
ItemField *ItemFieldClient
|
||||
// ItemTemplate is the client for interacting with the ItemTemplate builders.
|
||||
ItemTemplate *ItemTemplateClient
|
||||
// Label is the client for interacting with the Label builders.
|
||||
Label *LabelClient
|
||||
// Location is the client for interacting with the Location builders.
|
||||
Location *LocationClient
|
||||
// MaintenanceEntry is the client for interacting with the MaintenanceEntry builders.
|
||||
MaintenanceEntry *MaintenanceEntryClient
|
||||
// Notifier is the client for interacting with the Notifier builders.
|
||||
Notifier *NotifierClient
|
||||
// Tag is the client for interacting with the Tag builders.
|
||||
Tag *TagClient
|
||||
// TemplateField is the client for interacting with the TemplateField builders.
|
||||
TemplateField *TemplateFieldClient
|
||||
// User is the client for interacting with the User builders.
|
||||
@@ -179,10 +179,10 @@ func (tx *Tx) init() {
|
||||
tx.Item = NewItemClient(tx.config)
|
||||
tx.ItemField = NewItemFieldClient(tx.config)
|
||||
tx.ItemTemplate = NewItemTemplateClient(tx.config)
|
||||
tx.Label = NewLabelClient(tx.config)
|
||||
tx.Location = NewLocationClient(tx.config)
|
||||
tx.MaintenanceEntry = NewMaintenanceEntryClient(tx.config)
|
||||
tx.Notifier = NewNotifierClient(tx.config)
|
||||
tx.Tag = NewTagClient(tx.config)
|
||||
tx.TemplateField = NewTemplateFieldClient(tx.config)
|
||||
tx.User = NewUserClient(tx.config)
|
||||
}
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
-- goose Up
|
||||
ALTER TABLE labels RENAME TO tags;
|
||||
ALTER TABLE label_items RENAME TO tag_items;
|
||||
@@ -1,3 +0,0 @@
|
||||
-- goose Up
|
||||
ALTER TABLE labels RENAME TO tags;
|
||||
ALTER TABLE label_items RENAME TO tag_items;
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/groupinvitationtoken"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/tag"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/label"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/location"
|
||||
)
|
||||
|
||||
@@ -79,7 +79,7 @@ type (
|
||||
TotalUsers int `json:"totalUsers"`
|
||||
TotalItems int `json:"totalItems"`
|
||||
TotalLocations int `json:"totalLocations"`
|
||||
TotalTags int `json:"totalTags"`
|
||||
TotalLabels int `json:"totalLabels"`
|
||||
TotalItemPrice float64 `json:"totalItemPrice"`
|
||||
TotalWithWarranty int `json:"totalWithWarranty"`
|
||||
}
|
||||
@@ -131,21 +131,21 @@ func (r *GroupRepository) StatsLocationsByPurchasePrice(ctx context.Context, gid
|
||||
return v, err
|
||||
}
|
||||
|
||||
func (r *GroupRepository) StatsTagsByPurchasePrice(ctx context.Context, gid uuid.UUID) ([]TotalsByOrganizer, error) {
|
||||
func (r *GroupRepository) StatsLabelsByPurchasePrice(ctx context.Context, gid uuid.UUID) ([]TotalsByOrganizer, error) {
|
||||
var v []TotalsByOrganizer
|
||||
|
||||
err := r.db.Tag.Query().
|
||||
err := r.db.Label.Query().
|
||||
Where(
|
||||
tag.HasGroupWith(group.ID(gid)),
|
||||
label.HasGroupWith(group.ID(gid)),
|
||||
).
|
||||
GroupBy(tag.FieldID, tag.FieldName).
|
||||
GroupBy(label.FieldID, label.FieldName).
|
||||
Aggregate(func(sq *sql.Selector) string {
|
||||
itemTable := sql.Table(item.Table)
|
||||
|
||||
jt := sql.Table(tag.ItemsTable)
|
||||
jt := sql.Table(label.ItemsTable)
|
||||
|
||||
sq.Join(jt).On(sq.C(tag.FieldID), jt.C(tag.ItemsPrimaryKey[0]))
|
||||
sq.Join(itemTable).On(jt.C(tag.ItemsPrimaryKey[1]), itemTable.C(item.FieldID))
|
||||
sq.Join(jt).On(sq.C(label.FieldID), jt.C(label.ItemsPrimaryKey[0]))
|
||||
sq.Join(itemTable).On(jt.C(label.ItemsPrimaryKey[1]), itemTable.C(item.FieldID))
|
||||
|
||||
return sql.As(sql.Sum(itemTable.C(item.FieldPurchasePrice)), "total")
|
||||
}).
|
||||
@@ -226,7 +226,7 @@ func (r *GroupRepository) StatsGroup(ctx context.Context, gid uuid.UUID) (GroupS
|
||||
(SELECT COUNT(*) FROM users WHERE group_users = $2) AS total_users,
|
||||
(SELECT COUNT(*) FROM items WHERE group_items = $2 AND items.archived = false) AS total_items,
|
||||
(SELECT COUNT(*) FROM locations WHERE group_locations = $2) AS total_locations,
|
||||
(SELECT COUNT(*) FROM tags WHERE group_tags = $2) AS total_tags,
|
||||
(SELECT COUNT(*) FROM labels WHERE group_labels = $2) AS total_labels,
|
||||
(SELECT SUM(purchase_price*quantity) FROM items WHERE group_items = $2 AND items.archived = false) AS total_item_price,
|
||||
(SELECT COUNT(*)
|
||||
FROM items
|
||||
@@ -241,7 +241,7 @@ func (r *GroupRepository) StatsGroup(ctx context.Context, gid uuid.UUID) (GroupS
|
||||
var maybeTotalItemPrice *float64
|
||||
var maybeTotalWithWarranty *int
|
||||
|
||||
err := row.Scan(&stats.TotalUsers, &stats.TotalItems, &stats.TotalLocations, &stats.TotalTags, &maybeTotalItemPrice, &maybeTotalWithWarranty)
|
||||
err := row.Scan(&stats.TotalUsers, &stats.TotalItems, &stats.TotalLocations, &stats.TotalLabels, &maybeTotalItemPrice, &maybeTotalWithWarranty)
|
||||
if err != nil {
|
||||
return GroupStatistics{}, err
|
||||
}
|
||||
|
||||
@@ -36,13 +36,13 @@ func Test_Group_Update(t *testing.T) {
|
||||
// TODO: Fix this test at some point, the data itself in production/development is working fine, it only fails on the test
|
||||
/*func Test_Group_GroupStatistics(t *testing.T) {
|
||||
useItems(t, 20)
|
||||
useTags(t, 20)
|
||||
useLabels(t, 20)
|
||||
|
||||
stats, err := tRepos.Groups.StatsGroup(context.Background(), tGroup.ID)
|
||||
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, 20, stats.TotalItems)
|
||||
assert.Equal(t, 20, stats.TotalTags)
|
||||
assert.Equal(t, 20, stats.TotalLabels)
|
||||
assert.Equal(t, 1, stats.TotalUsers)
|
||||
assert.Equal(t, 1, stats.TotalLocations)
|
||||
}*/
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemtemplate"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/tag"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/label"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/templatefield"
|
||||
)
|
||||
|
||||
@@ -27,7 +27,7 @@ type (
|
||||
TextValue string `json:"textValue"`
|
||||
}
|
||||
|
||||
TemplateTagSummary struct {
|
||||
TemplateLabelSummary struct {
|
||||
ID uuid.UUID `json:"id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
@@ -52,9 +52,9 @@ type (
|
||||
DefaultLifetimeWarranty bool `json:"defaultLifetimeWarranty"`
|
||||
DefaultWarrantyDetails *string `json:"defaultWarrantyDetails,omitempty" extensions:"x-nullable" validate:"omitempty,max=1000"`
|
||||
|
||||
// Default location and tags
|
||||
// Default location and labels
|
||||
DefaultLocationID uuid.UUID `json:"defaultLocationId,omitempty" extensions:"x-nullable"`
|
||||
DefaultTagIDs *[]uuid.UUID `json:"defaultTagIds,omitempty" extensions:"x-nullable"`
|
||||
DefaultLabelIDs *[]uuid.UUID `json:"defaultLabelIds,omitempty" extensions:"x-nullable"`
|
||||
|
||||
// Metadata flags
|
||||
IncludeWarrantyFields bool `json:"includeWarrantyFields"`
|
||||
@@ -81,9 +81,9 @@ type (
|
||||
DefaultLifetimeWarranty bool `json:"defaultLifetimeWarranty"`
|
||||
DefaultWarrantyDetails *string `json:"defaultWarrantyDetails,omitempty" extensions:"x-nullable" validate:"omitempty,max=1000"`
|
||||
|
||||
// Default location and tags
|
||||
// Default location and labels
|
||||
DefaultLocationID uuid.UUID `json:"defaultLocationId,omitempty" extensions:"x-nullable"`
|
||||
DefaultTagIDs *[]uuid.UUID `json:"defaultTagIds,omitempty" extensions:"x-nullable"`
|
||||
DefaultLabelIDs *[]uuid.UUID `json:"defaultLabelIds,omitempty" extensions:"x-nullable"`
|
||||
|
||||
// Metadata flags
|
||||
IncludeWarrantyFields bool `json:"includeWarrantyFields"`
|
||||
@@ -120,9 +120,9 @@ type (
|
||||
DefaultLifetimeWarranty bool `json:"defaultLifetimeWarranty"`
|
||||
DefaultWarrantyDetails string `json:"defaultWarrantyDetails"`
|
||||
|
||||
// Default location and tags
|
||||
// Default location and labels
|
||||
DefaultLocation *TemplateLocationSummary `json:"defaultLocation"`
|
||||
DefaultTags []TemplateTagSummary `json:"defaultTags"`
|
||||
DefaultLabels []TemplateLabelSummary `json:"defaultLabels"`
|
||||
|
||||
// Metadata flags
|
||||
IncludeWarrantyFields bool `json:"includeWarrantyFields"`
|
||||
@@ -177,15 +177,15 @@ func (r *ItemTemplatesRepository) mapTemplateOut(ctx context.Context, template *
|
||||
}
|
||||
}
|
||||
|
||||
// Fetch tags from database using stored IDs
|
||||
tags := make([]TemplateTagSummary, 0)
|
||||
if len(template.DefaultTagIds) > 0 {
|
||||
tagEntities, err := r.db.Tag.Query().
|
||||
Where(tag.IDIn(template.DefaultTagIds...)).
|
||||
// Fetch labels from database using stored IDs
|
||||
labels := make([]TemplateLabelSummary, 0)
|
||||
if len(template.DefaultLabelIds) > 0 {
|
||||
labelEntities, err := r.db.Label.Query().
|
||||
Where(label.IDIn(template.DefaultLabelIds...)).
|
||||
All(ctx)
|
||||
if err == nil {
|
||||
for _, l := range tagEntities {
|
||||
tags = append(tags, TemplateTagSummary{
|
||||
for _, l := range labelEntities {
|
||||
labels = append(labels, TemplateLabelSummary{
|
||||
ID: l.ID,
|
||||
Name: l.Name,
|
||||
})
|
||||
@@ -209,7 +209,7 @@ func (r *ItemTemplatesRepository) mapTemplateOut(ctx context.Context, template *
|
||||
DefaultLifetimeWarranty: template.DefaultLifetimeWarranty,
|
||||
DefaultWarrantyDetails: template.DefaultWarrantyDetails,
|
||||
DefaultLocation: location,
|
||||
DefaultTags: tags,
|
||||
DefaultLabels: labels,
|
||||
IncludeWarrantyFields: template.IncludeWarrantyFields,
|
||||
IncludePurchaseFields: template.IncludePurchaseFields,
|
||||
IncludeSoldFields: template.IncludeSoldFields,
|
||||
@@ -284,9 +284,9 @@ func (r *ItemTemplatesRepository) Create(ctx context.Context, gid uuid.UUID, dat
|
||||
if data.DefaultLocationID != uuid.Nil {
|
||||
q.SetLocationID(data.DefaultLocationID)
|
||||
}
|
||||
// Set default tag IDs (stored as JSON)
|
||||
if data.DefaultTagIDs != nil && len(*data.DefaultTagIDs) > 0 {
|
||||
q.SetDefaultTagIds(*data.DefaultTagIDs)
|
||||
// Set default label IDs (stored as JSON)
|
||||
if data.DefaultLabelIDs != nil && len(*data.DefaultLabelIDs) > 0 {
|
||||
q.SetDefaultLabelIds(*data.DefaultLabelIDs)
|
||||
}
|
||||
|
||||
template, err := q.Save(ctx)
|
||||
@@ -351,11 +351,11 @@ func (r *ItemTemplatesRepository) Update(ctx context.Context, gid uuid.UUID, dat
|
||||
updateQ.ClearLocation()
|
||||
}
|
||||
|
||||
// Update default tag IDs (stored as JSON)
|
||||
if data.DefaultTagIDs != nil && len(*data.DefaultTagIDs) > 0 {
|
||||
updateQ.SetDefaultTagIds(*data.DefaultTagIDs)
|
||||
// Update default label IDs (stored as JSON)
|
||||
if data.DefaultLabelIDs != nil && len(*data.DefaultLabelIDs) > 0 {
|
||||
updateQ.SetDefaultLabelIds(*data.DefaultLabelIDs)
|
||||
} else {
|
||||
updateQ.ClearDefaultTagIds()
|
||||
updateQ.ClearDefaultLabelIds()
|
||||
}
|
||||
|
||||
_, err = updateQ.Save(ctx)
|
||||
|
||||
@@ -263,34 +263,34 @@ func TestItemTemplatesRepository_CreateWithLocation(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestItemTemplatesRepository_CreateWithTags(t *testing.T) {
|
||||
// Create some tags
|
||||
tag1, err := tRepos.Tags.Create(context.Background(), tGroup.ID, TagCreate{
|
||||
func TestItemTemplatesRepository_CreateWithLabels(t *testing.T) {
|
||||
// Create some labels
|
||||
label1, err := tRepos.Labels.Create(context.Background(), tGroup.ID, LabelCreate{
|
||||
Name: fk.Str(10),
|
||||
Description: fk.Str(50),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
tag2, err := tRepos.Tags.Create(context.Background(), tGroup.ID, TagCreate{
|
||||
label2, err := tRepos.Labels.Create(context.Background(), tGroup.ID, LabelCreate{
|
||||
Name: fk.Str(10),
|
||||
Description: fk.Str(50),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
t.Cleanup(func() {
|
||||
_ = tRepos.Tags.delete(context.Background(), tag1.ID)
|
||||
_ = tRepos.Tags.delete(context.Background(), tag2.ID)
|
||||
_ = tRepos.Labels.delete(context.Background(), label1.ID)
|
||||
_ = tRepos.Labels.delete(context.Background(), label2.ID)
|
||||
})
|
||||
|
||||
// Create template with tags
|
||||
// Create template with labels
|
||||
data := templateFactory()
|
||||
tagIDs := []uuid.UUID{tag1.ID, tag2.ID}
|
||||
data.DefaultTagIDs = &tagIDs
|
||||
labelIDs := []uuid.UUID{label1.ID, label2.ID}
|
||||
data.DefaultLabelIDs = &labelIDs
|
||||
|
||||
template, err := tRepos.ItemTemplates.Create(context.Background(), tGroup.ID, data)
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.Len(t, template.DefaultTags, 2)
|
||||
assert.Len(t, template.DefaultLabels, 2)
|
||||
|
||||
// Cleanup
|
||||
err = tRepos.ItemTemplates.Delete(context.Background(), tGroup.ID, template.ID)
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/item"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/itemfield"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/tag"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/label"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/location"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/maintenanceentry"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
|
||||
@@ -38,8 +38,8 @@ type (
|
||||
Search string `json:"search"`
|
||||
AssetID AssetID `json:"assetId"`
|
||||
LocationIDs []uuid.UUID `json:"locationIds"`
|
||||
TagIDs []uuid.UUID `json:"tagIds"`
|
||||
NegateTags bool `json:"negateTags"`
|
||||
LabelIDs []uuid.UUID `json:"labelIds"`
|
||||
NegateLabels bool `json:"negateLabels"`
|
||||
OnlyWithoutPhoto bool `json:"onlyWithoutPhoto"`
|
||||
OnlyWithPhoto bool `json:"onlyWithPhoto"`
|
||||
ParentItemIDs []uuid.UUID `json:"parentIds"`
|
||||
@@ -76,7 +76,7 @@ type (
|
||||
|
||||
// Edges
|
||||
LocationID uuid.UUID `json:"locationId"`
|
||||
TagIDs []uuid.UUID `json:"tagIds"`
|
||||
LabelIDs []uuid.UUID `json:"labelIds"`
|
||||
}
|
||||
|
||||
ItemUpdate struct {
|
||||
@@ -92,7 +92,7 @@ type (
|
||||
|
||||
// Edges
|
||||
LocationID uuid.UUID `json:"locationId"`
|
||||
TagIDs []uuid.UUID `json:"tagIds"`
|
||||
LabelIDs []uuid.UUID `json:"labelIds"`
|
||||
|
||||
// Identifications
|
||||
SerialNumber string `json:"serialNumber"`
|
||||
@@ -125,7 +125,7 @@ type (
|
||||
Quantity *int `json:"quantity,omitempty" extensions:"x-nullable,x-omitempty"`
|
||||
ImportRef *string `json:"-,omitempty" extensions:"x-nullable,x-omitempty"`
|
||||
LocationID uuid.UUID `json:"locationId" extensions:"x-nullable,x-omitempty"`
|
||||
TagIDs []uuid.UUID `json:"tagIds" extensions:"x-nullable,x-omitempty"`
|
||||
LabelIDs []uuid.UUID `json:"labelIds" extensions:"x-nullable,x-omitempty"`
|
||||
}
|
||||
|
||||
ItemSummary struct {
|
||||
@@ -144,7 +144,7 @@ type (
|
||||
|
||||
// Edges
|
||||
Location *LocationSummary `json:"location,omitempty" extensions:"x-nullable,x-omitempty"`
|
||||
Tags []TagSummary `json:"tags"`
|
||||
Labels []LabelSummary `json:"labels"`
|
||||
|
||||
ImageID *uuid.UUID `json:"imageId,omitempty" extensions:"x-nullable,x-omitempty"`
|
||||
ThumbnailId *uuid.UUID `json:"thumbnailId,omitempty" extensions:"x-nullable,x-omitempty"`
|
||||
@@ -196,9 +196,9 @@ func mapItemSummary(item *ent.Item) ItemSummary {
|
||||
location = &loc
|
||||
}
|
||||
|
||||
tags := make([]TagSummary, len(item.Edges.Tag))
|
||||
if item.Edges.Tag != nil {
|
||||
tags = mapEach(item.Edges.Tag, mapTagSummary)
|
||||
labels := make([]LabelSummary, len(item.Edges.Label))
|
||||
if item.Edges.Label != nil {
|
||||
labels = mapEach(item.Edges.Label, mapLabelSummary)
|
||||
}
|
||||
|
||||
var imageID *uuid.UUID
|
||||
@@ -235,7 +235,7 @@ func mapItemSummary(item *ent.Item) ItemSummary {
|
||||
|
||||
// Edges
|
||||
Location: location,
|
||||
Tags: tags,
|
||||
Labels: labels,
|
||||
|
||||
// Warranty
|
||||
Insured: item.Insured,
|
||||
@@ -329,7 +329,7 @@ func (e *ItemsRepository) getOneTx(ctx context.Context, tx *ent.Tx, where ...pre
|
||||
|
||||
return mapItemOutErr(q.
|
||||
WithFields().
|
||||
WithTag().
|
||||
WithLabel().
|
||||
WithLocation().
|
||||
WithGroup().
|
||||
WithParent().
|
||||
@@ -412,24 +412,24 @@ func (e *ItemsRepository) QueryByGroup(ctx context.Context, gid uuid.UUID, q Ite
|
||||
// of filters is OR'd together.
|
||||
//
|
||||
// The goal is to allow matches like where the item has
|
||||
// - one of the selected tags AND
|
||||
// - one of the selected labels AND
|
||||
// - one of the selected locations AND
|
||||
// - one of the selected fields key/value matches
|
||||
var andPredicates []predicate.Item
|
||||
{
|
||||
if len(q.TagIDs) > 0 {
|
||||
tagPredicates := make([]predicate.Item, 0, len(q.TagIDs))
|
||||
for _, l := range q.TagIDs {
|
||||
if !q.NegateTags {
|
||||
tagPredicates = append(tagPredicates, item.HasTagWith(tag.ID(l)))
|
||||
if len(q.LabelIDs) > 0 {
|
||||
labelPredicates := make([]predicate.Item, 0, len(q.LabelIDs))
|
||||
for _, l := range q.LabelIDs {
|
||||
if !q.NegateLabels {
|
||||
labelPredicates = append(labelPredicates, item.HasLabelWith(label.ID(l)))
|
||||
} else {
|
||||
tagPredicates = append(tagPredicates, item.Not(item.HasTagWith(tag.ID(l))))
|
||||
labelPredicates = append(labelPredicates, item.Not(item.HasLabelWith(label.ID(l))))
|
||||
}
|
||||
}
|
||||
if !q.NegateTags {
|
||||
andPredicates = append(andPredicates, item.Or(tagPredicates...))
|
||||
if !q.NegateLabels {
|
||||
andPredicates = append(andPredicates, item.Or(labelPredicates...))
|
||||
} else {
|
||||
andPredicates = append(andPredicates, item.And(tagPredicates...))
|
||||
andPredicates = append(andPredicates, item.And(labelPredicates...))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -504,7 +504,7 @@ func (e *ItemsRepository) QueryByGroup(ctx context.Context, gid uuid.UUID, q Ite
|
||||
}
|
||||
|
||||
qb = qb.
|
||||
WithTag().
|
||||
WithLabel().
|
||||
WithLocation().
|
||||
WithAttachments(func(aq *ent.AttachmentQuery) {
|
||||
aq.Where(
|
||||
@@ -549,7 +549,7 @@ func (e *ItemsRepository) QueryByAssetID(ctx context.Context, gid uuid.UUID, ass
|
||||
|
||||
items, err := mapItemsSummaryErr(
|
||||
qb.Order(ent.Asc(item.FieldName)).
|
||||
WithTag().
|
||||
WithLabel().
|
||||
WithLocation().
|
||||
All(ctx),
|
||||
)
|
||||
@@ -565,11 +565,11 @@ func (e *ItemsRepository) QueryByAssetID(ctx context.Context, gid uuid.UUID, ass
|
||||
}, nil
|
||||
}
|
||||
|
||||
// GetAll returns all the items in the database with the Tags and Locations eager loaded.
|
||||
// GetAll returns all the items in the database with the Labels and Locations eager loaded.
|
||||
func (e *ItemsRepository) GetAll(ctx context.Context, gid uuid.UUID) ([]ItemOut, error) {
|
||||
return mapItemsOutErr(e.db.Item.Query().
|
||||
Where(item.HasGroupWith(group.ID(gid))).
|
||||
WithTag().
|
||||
WithLabel().
|
||||
WithLocation().
|
||||
WithFields().
|
||||
All(ctx))
|
||||
@@ -641,8 +641,8 @@ func (e *ItemsRepository) Create(ctx context.Context, gid uuid.UUID, data ItemCr
|
||||
q.SetParentID(data.ParentID)
|
||||
}
|
||||
|
||||
if len(data.TagIDs) > 0 {
|
||||
q.AddTagIDs(data.TagIDs...)
|
||||
if len(data.LabelIDs) > 0 {
|
||||
q.AddLabelIDs(data.LabelIDs...)
|
||||
}
|
||||
|
||||
result, err := q.Save(ctx)
|
||||
@@ -660,7 +660,7 @@ type ItemCreateFromTemplate struct {
|
||||
Description string
|
||||
Quantity int
|
||||
LocationID uuid.UUID
|
||||
TagIDs []uuid.UUID
|
||||
LabelIDs []uuid.UUID
|
||||
Insured bool
|
||||
Manufacturer string
|
||||
ModelNumber string
|
||||
@@ -707,8 +707,8 @@ func (e *ItemsRepository) CreateFromTemplate(ctx context.Context, gid uuid.UUID,
|
||||
SetLifetimeWarranty(data.LifetimeWarranty).
|
||||
SetWarrantyDetails(data.WarrantyDetails)
|
||||
|
||||
if len(data.TagIDs) > 0 {
|
||||
itemBuilder.AddTagIDs(data.TagIDs...)
|
||||
if len(data.LabelIDs) > 0 {
|
||||
itemBuilder.AddLabelIDs(data.LabelIDs...)
|
||||
}
|
||||
|
||||
_, err = itemBuilder.Save(ctx)
|
||||
@@ -809,7 +809,7 @@ func (e *ItemsRepository) DeleteByGroup(ctx context.Context, gid, id uuid.UUID)
|
||||
return err
|
||||
}
|
||||
|
||||
func (e *ItemsRepository) WipeInventory(ctx context.Context, gid uuid.UUID, wipeTags bool, wipeLocations bool, wipeMaintenance bool) (int, error) {
|
||||
func (e *ItemsRepository) WipeInventory(ctx context.Context, gid uuid.UUID, wipeLabels bool, wipeLocations bool, wipeMaintenance bool) (int, error) {
|
||||
deleted := 0
|
||||
|
||||
// Wipe maintenance records if requested
|
||||
@@ -865,14 +865,14 @@ func (e *ItemsRepository) WipeInventory(ctx context.Context, gid uuid.UUID, wipe
|
||||
deleted++
|
||||
}
|
||||
|
||||
// Wipe tags if requested
|
||||
if wipeTags {
|
||||
tagCount, err := e.db.Tag.Delete().Where(tag.HasGroupWith(group.ID(gid))).Exec(ctx)
|
||||
// Wipe labels if requested
|
||||
if wipeLabels {
|
||||
labelCount, err := e.db.Label.Delete().Where(label.HasGroupWith(group.ID(gid))).Exec(ctx)
|
||||
if err != nil {
|
||||
log.Err(err).Msg("failed to delete tags during wipe inventory")
|
||||
log.Err(err).Msg("failed to delete labels during wipe inventory")
|
||||
} else {
|
||||
log.Info().Int("count", tagCount).Msg("deleted tags during wipe inventory")
|
||||
deleted += tagCount
|
||||
log.Info().Int("count", labelCount).Msg("deleted labels during wipe inventory")
|
||||
deleted += labelCount
|
||||
}
|
||||
}
|
||||
|
||||
@@ -916,23 +916,23 @@ func (e *ItemsRepository) UpdateByGroup(ctx context.Context, gid uuid.UUID, data
|
||||
SetAssetID(int(data.AssetID)).
|
||||
SetSyncChildItemsLocations(data.SyncChildItemsLocations)
|
||||
|
||||
currentTags, err := e.db.Item.Query().Where(item.ID(data.ID)).QueryTag().All(ctx)
|
||||
currentLabels, err := e.db.Item.Query().Where(item.ID(data.ID)).QueryLabel().All(ctx)
|
||||
if err != nil {
|
||||
return ItemOut{}, err
|
||||
}
|
||||
|
||||
set := newIDSet(currentTags)
|
||||
set := newIDSet(currentLabels)
|
||||
|
||||
for _, l := range data.TagIDs {
|
||||
for _, l := range data.LabelIDs {
|
||||
if set.Contains(l) {
|
||||
set.Remove(l)
|
||||
continue
|
||||
}
|
||||
q.AddTagIDs(l)
|
||||
q.AddLabelIDs(l)
|
||||
}
|
||||
|
||||
if set.Len() > 0 {
|
||||
q.RemoveTagIDs(set.Slice()...)
|
||||
q.RemoveLabelIDs(set.Slice()...)
|
||||
}
|
||||
|
||||
if data.ParentID != uuid.Nil {
|
||||
@@ -1087,26 +1087,26 @@ func (e *ItemsRepository) Patch(ctx context.Context, gid, id uuid.UUID, data Ite
|
||||
return err
|
||||
}
|
||||
|
||||
if data.TagIDs != nil {
|
||||
currentTags, err := tx.Item.Query().Where(item.ID(id), item.HasGroupWith(group.ID(gid))).QueryTag().All(ctx)
|
||||
if data.LabelIDs != nil {
|
||||
currentLabels, err := tx.Item.Query().Where(item.ID(id), item.HasGroupWith(group.ID(gid))).QueryLabel().All(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
set := newIDSet(currentTags)
|
||||
set := newIDSet(currentLabels)
|
||||
|
||||
addTags := []uuid.UUID{}
|
||||
for _, l := range data.TagIDs {
|
||||
addLabels := []uuid.UUID{}
|
||||
for _, l := range data.LabelIDs {
|
||||
if set.Contains(l) {
|
||||
set.Remove(l)
|
||||
} else {
|
||||
addTags = append(addTags, l)
|
||||
addLabels = append(addLabels, l)
|
||||
}
|
||||
}
|
||||
|
||||
if len(addTags) > 0 {
|
||||
if len(addLabels) > 0 {
|
||||
if err := tx.Item.Update().
|
||||
Where(item.ID(id), item.HasGroupWith(group.ID(gid))).
|
||||
AddTagIDs(addTags...).
|
||||
AddLabelIDs(addLabels...).
|
||||
Exec(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1114,7 +1114,7 @@ func (e *ItemsRepository) Patch(ctx context.Context, gid, id uuid.UUID, data Ite
|
||||
if set.Len() > 0 {
|
||||
if err := tx.Item.Update().
|
||||
Where(item.ID(id), item.HasGroupWith(group.ID(gid))).
|
||||
RemoveTagIDs(set.Slice()...).
|
||||
RemoveLabelIDs(set.Slice()...).
|
||||
Exec(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1402,13 +1402,13 @@ func (e *ItemsRepository) Duplicate(ctx context.Context, gid, id uuid.UUID, opti
|
||||
itemBuilder.SetParentID(originalItem.Parent.ID)
|
||||
}
|
||||
|
||||
// Add tags
|
||||
if len(originalItem.Tags) > 0 {
|
||||
tagIDs := make([]uuid.UUID, len(originalItem.Tags))
|
||||
for i, tag := range originalItem.Tags {
|
||||
tagIDs[i] = tag.ID
|
||||
// Add labels
|
||||
if len(originalItem.Labels) > 0 {
|
||||
labelIDs := make([]uuid.UUID, len(originalItem.Labels))
|
||||
for i, label := range originalItem.Labels {
|
||||
labelIDs[i] = label.ID
|
||||
}
|
||||
itemBuilder.AddTagIDs(tagIDs...)
|
||||
itemBuilder.AddLabelIDs(labelIDs...)
|
||||
}
|
||||
|
||||
_, err = itemBuilder.Save(ctx)
|
||||
|
||||
@@ -165,14 +165,14 @@ func TestItemsRepository_Delete(t *testing.T) {
|
||||
assert.Empty(t, results)
|
||||
}
|
||||
|
||||
func TestItemsRepository_Update_Tags(t *testing.T) {
|
||||
func TestItemsRepository_Update_Labels(t *testing.T) {
|
||||
entity := useItems(t, 1)[0]
|
||||
tags := useTags(t, 3)
|
||||
labels := useLabels(t, 3)
|
||||
|
||||
tagsIDs := []uuid.UUID{tags[0].ID, tags[1].ID, tags[2].ID}
|
||||
labelsIDs := []uuid.UUID{labels[0].ID, labels[1].ID, labels[2].ID}
|
||||
|
||||
type args struct {
|
||||
tagIds []uuid.UUID
|
||||
labelIds []uuid.UUID
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
@@ -181,44 +181,44 @@ func TestItemsRepository_Update_Tags(t *testing.T) {
|
||||
want []uuid.UUID
|
||||
}{
|
||||
{
|
||||
name: "add all tags",
|
||||
name: "add all labels",
|
||||
args: args{
|
||||
tagIds: tagsIDs,
|
||||
labelIds: labelsIDs,
|
||||
},
|
||||
want: tagsIDs,
|
||||
want: labelsIDs,
|
||||
},
|
||||
{
|
||||
name: "update with one tag",
|
||||
name: "update with one label",
|
||||
args: args{
|
||||
tagIds: tagsIDs[:1],
|
||||
labelIds: labelsIDs[:1],
|
||||
},
|
||||
want: tagsIDs[:1],
|
||||
want: labelsIDs[:1],
|
||||
},
|
||||
{
|
||||
name: "add one new tag to existing single tag",
|
||||
name: "add one new label to existing single label",
|
||||
args: args{
|
||||
tagIds: tagsIDs[1:],
|
||||
labelIds: labelsIDs[1:],
|
||||
},
|
||||
want: tagsIDs[1:],
|
||||
want: labelsIDs[1:],
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
// Apply all tags to entity
|
||||
// Apply all labels to entity
|
||||
updateData := ItemUpdate{
|
||||
ID: entity.ID,
|
||||
Name: entity.Name,
|
||||
LocationID: entity.Location.ID,
|
||||
TagIDs: tt.args.tagIds,
|
||||
LabelIDs: tt.args.labelIds,
|
||||
}
|
||||
|
||||
updated, err := tRepos.Items.UpdateByGroup(context.Background(), tGroup.ID, updateData)
|
||||
require.NoError(t, err)
|
||||
assert.Len(t, tt.want, len(updated.Tags))
|
||||
assert.Len(t, tt.want, len(updated.Labels))
|
||||
|
||||
for _, tag := range updated.Tags {
|
||||
assert.Contains(t, tt.want, tag.ID)
|
||||
for _, label := range updated.Labels {
|
||||
assert.Contains(t, tt.want, label.ID)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -234,7 +234,7 @@ func TestItemsRepository_Update(t *testing.T) {
|
||||
Name: entity.Name,
|
||||
LocationID: entity.Location.ID,
|
||||
SerialNumber: fk.Str(10),
|
||||
TagIDs: nil,
|
||||
LabelIDs: nil,
|
||||
ModelNumber: fk.Str(10),
|
||||
Manufacturer: fk.Str(10),
|
||||
PurchaseTime: types.DateFromTime(time.Now()),
|
||||
@@ -399,51 +399,51 @@ func TestItemsRepository_DeleteByGroupWithAttachments(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestItemsRepository_WipeInventory(t *testing.T) {
|
||||
// Create test data: items, tags, locations, and maintenance entries
|
||||
|
||||
// Create test data: items, labels, locations, and maintenance entries
|
||||
|
||||
// Create locations
|
||||
loc1, err := tRepos.Locations.Create(context.Background(), tGroup.ID, LocationCreate{
|
||||
Name: "Test Location 1",
|
||||
Description: "Test location for wipe test",
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
|
||||
loc2, err := tRepos.Locations.Create(context.Background(), tGroup.ID, LocationCreate{
|
||||
Name: "Test Location 2",
|
||||
Description: "Another test location",
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
// Create tags
|
||||
tag1, err := tRepos.Tags.Create(context.Background(), tGroup.ID, TagCreate{
|
||||
Name: "Test Tag 1",
|
||||
Description: "Test tag for wipe test",
|
||||
|
||||
// Create labels
|
||||
label1, err := tRepos.Labels.Create(context.Background(), tGroup.ID, LabelCreate{
|
||||
Name: "Test Label 1",
|
||||
Description: "Test label for wipe test",
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
tag2, err := tRepos.Tags.Create(context.Background(), tGroup.ID, TagCreate{
|
||||
Name: "Test Tag 2",
|
||||
Description: "Another test tag",
|
||||
|
||||
label2, err := tRepos.Labels.Create(context.Background(), tGroup.ID, LabelCreate{
|
||||
Name: "Test Label 2",
|
||||
Description: "Another test label",
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
|
||||
// Create items
|
||||
item1, err := tRepos.Items.Create(context.Background(), tGroup.ID, ItemCreate{
|
||||
Name: "Test Item 1",
|
||||
Description: "Test item for wipe test",
|
||||
LocationID: loc1.ID,
|
||||
TagIDs: []uuid.UUID{tag1.ID},
|
||||
LabelIDs: []uuid.UUID{label1.ID},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
|
||||
item2, err := tRepos.Items.Create(context.Background(), tGroup.ID, ItemCreate{
|
||||
Name: "Test Item 2",
|
||||
Description: "Another test item",
|
||||
LocationID: loc2.ID,
|
||||
TagIDs: []uuid.UUID{tag2.ID},
|
||||
LabelIDs: []uuid.UUID{label2.ID},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
|
||||
// Create maintenance entries for items
|
||||
_, err = tRepos.MaintEntry.Create(context.Background(), item1.ID, MaintenanceEntryCreate{
|
||||
CompletedDate: types.DateFromTime(time.Now()),
|
||||
@@ -452,7 +452,7 @@ func TestItemsRepository_WipeInventory(t *testing.T) {
|
||||
Cost: 100.0,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
|
||||
_, err = tRepos.MaintEntry.Create(context.Background(), item2.ID, MaintenanceEntryCreate{
|
||||
CompletedDate: types.DateFromTime(time.Now()),
|
||||
Name: "Test Maintenance 2",
|
||||
@@ -460,40 +460,40 @@ func TestItemsRepository_WipeInventory(t *testing.T) {
|
||||
Cost: 200.0,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
|
||||
// Test 1: Wipe inventory with all options enabled
|
||||
t.Run("wipe all including tags, locations, and maintenance", func(t *testing.T) {
|
||||
t.Run("wipe all including labels, locations, and maintenance", func(t *testing.T) {
|
||||
deleted, err := tRepos.Items.WipeInventory(context.Background(), tGroup.ID, true, true, true)
|
||||
require.NoError(t, err)
|
||||
assert.Greater(t, deleted, 0, "Should have deleted at least some entities")
|
||||
|
||||
|
||||
// Verify items are deleted
|
||||
_, err = tRepos.Items.GetOneByGroup(context.Background(), tGroup.ID, item1.ID)
|
||||
require.Error(t, err, "Item 1 should be deleted")
|
||||
|
||||
|
||||
_, err = tRepos.Items.GetOneByGroup(context.Background(), tGroup.ID, item2.ID)
|
||||
require.Error(t, err, "Item 2 should be deleted")
|
||||
|
||||
|
||||
// Verify maintenance entries are deleted (query by item ID, should return empty)
|
||||
maint1List, err := tRepos.MaintEntry.GetMaintenanceByItemID(context.Background(), tGroup.ID, item1.ID, MaintenanceFilters{})
|
||||
require.NoError(t, err)
|
||||
assert.Empty(t, maint1List, "Maintenance entry 1 should be deleted")
|
||||
|
||||
|
||||
maint2List, err := tRepos.MaintEntry.GetMaintenanceByItemID(context.Background(), tGroup.ID, item2.ID, MaintenanceFilters{})
|
||||
require.NoError(t, err)
|
||||
assert.Empty(t, maint2List, "Maintenance entry 2 should be deleted")
|
||||
|
||||
// Verify tags are deleted
|
||||
_, err = tRepos.Tags.GetOneByGroup(context.Background(), tGroup.ID, tag1.ID)
|
||||
require.Error(t, err, "Tag 1 should be deleted")
|
||||
|
||||
_, err = tRepos.Tags.GetOneByGroup(context.Background(), tGroup.ID, tag2.ID)
|
||||
require.Error(t, err, "Tag 2 should be deleted")
|
||||
|
||||
|
||||
// Verify labels are deleted
|
||||
_, err = tRepos.Labels.GetOneByGroup(context.Background(), tGroup.ID, label1.ID)
|
||||
require.Error(t, err, "Label 1 should be deleted")
|
||||
|
||||
_, err = tRepos.Labels.GetOneByGroup(context.Background(), tGroup.ID, label2.ID)
|
||||
require.Error(t, err, "Label 2 should be deleted")
|
||||
|
||||
// Verify locations are deleted
|
||||
_, err = tRepos.Locations.Get(context.Background(), loc1.ID)
|
||||
require.Error(t, err, "Location 1 should be deleted")
|
||||
|
||||
|
||||
_, err = tRepos.Locations.Get(context.Background(), loc2.ID)
|
||||
require.Error(t, err, "Location 2 should be deleted")
|
||||
})
|
||||
@@ -506,21 +506,21 @@ func TestItemsRepository_WipeInventory_OnlyItems(t *testing.T) {
|
||||
Description: "Test location for wipe test",
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
tag, err := tRepos.Tags.Create(context.Background(), tGroup.ID, TagCreate{
|
||||
Name: "Test Tag",
|
||||
Description: "Test tag for wipe test",
|
||||
|
||||
label, err := tRepos.Labels.Create(context.Background(), tGroup.ID, LabelCreate{
|
||||
Name: "Test Label",
|
||||
Description: "Test label for wipe test",
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
|
||||
item, err := tRepos.Items.Create(context.Background(), tGroup.ID, ItemCreate{
|
||||
Name: "Test Item",
|
||||
Description: "Test item for wipe test",
|
||||
LocationID: loc.ID,
|
||||
TagIDs: []uuid.UUID{tag.ID},
|
||||
LabelIDs: []uuid.UUID{label.ID},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
|
||||
_, err = tRepos.MaintEntry.Create(context.Background(), item.ID, MaintenanceEntryCreate{
|
||||
CompletedDate: types.DateFromTime(time.Now()),
|
||||
Name: "Test Maintenance",
|
||||
@@ -528,30 +528,31 @@ func TestItemsRepository_WipeInventory_OnlyItems(t *testing.T) {
|
||||
Cost: 100.0,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
// Test: Wipe inventory with only items (no tags, locations, or maintenance)
|
||||
|
||||
// Test: Wipe inventory with only items (no labels, locations, or maintenance)
|
||||
deleted, err := tRepos.Items.WipeInventory(context.Background(), tGroup.ID, false, false, false)
|
||||
require.NoError(t, err)
|
||||
assert.Greater(t, deleted, 0, "Should have deleted at least the item")
|
||||
|
||||
|
||||
// Verify item is deleted
|
||||
_, err = tRepos.Items.GetOneByGroup(context.Background(), tGroup.ID, item.ID)
|
||||
require.Error(t, err, "Item should be deleted")
|
||||
|
||||
|
||||
// Verify maintenance entry is deleted due to cascade
|
||||
maintList, err := tRepos.MaintEntry.GetMaintenanceByItemID(context.Background(), tGroup.ID, item.ID, MaintenanceFilters{})
|
||||
require.NoError(t, err)
|
||||
assert.Empty(t, maintList, "Maintenance entry should be cascade deleted with item")
|
||||
|
||||
// Verify tag still exists
|
||||
_, err = tRepos.Tags.GetOneByGroup(context.Background(), tGroup.ID, tag.ID)
|
||||
require.NoError(t, err, "Tag should still exist")
|
||||
|
||||
|
||||
// Verify label still exists
|
||||
_, err = tRepos.Labels.GetOneByGroup(context.Background(), tGroup.ID, label.ID)
|
||||
require.NoError(t, err, "Label should still exist")
|
||||
|
||||
// Verify location still exists
|
||||
_, err = tRepos.Locations.Get(context.Background(), loc.ID)
|
||||
require.NoError(t, err, "Location should still exist")
|
||||
|
||||
|
||||
// Cleanup
|
||||
_ = tRepos.Tags.DeleteByGroup(context.Background(), tGroup.ID, tag.ID)
|
||||
_ = tRepos.Labels.DeleteByGroup(context.Background(), tGroup.ID, label.ID)
|
||||
_ = tRepos.Locations.delete(context.Background(), loc.ID)
|
||||
}
|
||||
|
||||
|
||||
@@ -8,30 +8,30 @@ import (
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/core/services/reporting/eventbus"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/tag"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/label"
|
||||
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
|
||||
)
|
||||
|
||||
type TagRepository struct {
|
||||
type LabelRepository struct {
|
||||
db *ent.Client
|
||||
bus *eventbus.EventBus
|
||||
}
|
||||
|
||||
type (
|
||||
TagCreate struct {
|
||||
LabelCreate struct {
|
||||
Name string `json:"name" validate:"required,min=1,max=255"`
|
||||
Description string `json:"description" validate:"max=1000"`
|
||||
Color string `json:"color"`
|
||||
}
|
||||
|
||||
TagUpdate struct {
|
||||
LabelUpdate struct {
|
||||
ID uuid.UUID `json:"id"`
|
||||
Name string `json:"name" validate:"required,min=1,max=255"`
|
||||
Description string `json:"description" validate:"max=1000"`
|
||||
Color string `json:"color"`
|
||||
}
|
||||
|
||||
TagSummary struct {
|
||||
LabelSummary struct {
|
||||
ID uuid.UUID `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
@@ -40,86 +40,86 @@ type (
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
}
|
||||
|
||||
TagOut struct {
|
||||
TagSummary
|
||||
LabelOut struct {
|
||||
LabelSummary
|
||||
}
|
||||
)
|
||||
|
||||
func mapTagSummary(tag *ent.Tag) TagSummary {
|
||||
return TagSummary{
|
||||
ID: tag.ID,
|
||||
Name: tag.Name,
|
||||
Description: tag.Description,
|
||||
Color: tag.Color,
|
||||
CreatedAt: tag.CreatedAt,
|
||||
UpdatedAt: tag.UpdatedAt,
|
||||
func mapLabelSummary(label *ent.Label) LabelSummary {
|
||||
return LabelSummary{
|
||||
ID: label.ID,
|
||||
Name: label.Name,
|
||||
Description: label.Description,
|
||||
Color: label.Color,
|
||||
CreatedAt: label.CreatedAt,
|
||||
UpdatedAt: label.UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
var (
|
||||
mapTagOutErr = mapTErrFunc(mapTagOut)
|
||||
mapTagsOut = mapTEachErrFunc(mapTagSummary)
|
||||
mapLabelOutErr = mapTErrFunc(mapLabelOut)
|
||||
mapLabelsOut = mapTEachErrFunc(mapLabelSummary)
|
||||
)
|
||||
|
||||
func mapTagOut(tag *ent.Tag) TagOut {
|
||||
return TagOut{
|
||||
TagSummary: mapTagSummary(tag),
|
||||
func mapLabelOut(label *ent.Label) LabelOut {
|
||||
return LabelOut{
|
||||
LabelSummary: mapLabelSummary(label),
|
||||
}
|
||||
}
|
||||
|
||||
func (r *TagRepository) publishMutationEvent(gid uuid.UUID) {
|
||||
func (r *LabelRepository) publishMutationEvent(gid uuid.UUID) {
|
||||
if r.bus != nil {
|
||||
r.bus.Publish(eventbus.EventTagMutation, eventbus.GroupMutationEvent{GID: gid})
|
||||
r.bus.Publish(eventbus.EventLabelMutation, eventbus.GroupMutationEvent{GID: gid})
|
||||
}
|
||||
}
|
||||
|
||||
func (r *TagRepository) getOne(ctx context.Context, where ...predicate.Tag) (TagOut, error) {
|
||||
return mapTagOutErr(r.db.Tag.Query().
|
||||
func (r *LabelRepository) getOne(ctx context.Context, where ...predicate.Label) (LabelOut, error) {
|
||||
return mapLabelOutErr(r.db.Label.Query().
|
||||
Where(where...).
|
||||
WithGroup().
|
||||
Only(ctx),
|
||||
)
|
||||
}
|
||||
|
||||
func (r *TagRepository) GetOne(ctx context.Context, id uuid.UUID) (TagOut, error) {
|
||||
return r.getOne(ctx, tag.ID(id))
|
||||
func (r *LabelRepository) GetOne(ctx context.Context, id uuid.UUID) (LabelOut, error) {
|
||||
return r.getOne(ctx, label.ID(id))
|
||||
}
|
||||
|
||||
func (r *TagRepository) GetOneByGroup(ctx context.Context, gid, ld uuid.UUID) (TagOut, error) {
|
||||
return r.getOne(ctx, tag.ID(ld), tag.HasGroupWith(group.ID(gid)))
|
||||
func (r *LabelRepository) GetOneByGroup(ctx context.Context, gid, ld uuid.UUID) (LabelOut, error) {
|
||||
return r.getOne(ctx, label.ID(ld), label.HasGroupWith(group.ID(gid)))
|
||||
}
|
||||
|
||||
func (r *TagRepository) GetAll(ctx context.Context, groupID uuid.UUID) ([]TagSummary, error) {
|
||||
return mapTagsOut(r.db.Tag.Query().
|
||||
Where(tag.HasGroupWith(group.ID(groupID))).
|
||||
Order(ent.Asc(tag.FieldName)).
|
||||
func (r *LabelRepository) GetAll(ctx context.Context, groupID uuid.UUID) ([]LabelSummary, error) {
|
||||
return mapLabelsOut(r.db.Label.Query().
|
||||
Where(label.HasGroupWith(group.ID(groupID))).
|
||||
Order(ent.Asc(label.FieldName)).
|
||||
WithGroup().
|
||||
All(ctx),
|
||||
)
|
||||
}
|
||||
|
||||
func (r *TagRepository) Create(ctx context.Context, groupID uuid.UUID, data TagCreate) (TagOut, error) {
|
||||
tag, err := r.db.Tag.Create().
|
||||
func (r *LabelRepository) Create(ctx context.Context, groupID uuid.UUID, data LabelCreate) (LabelOut, error) {
|
||||
label, err := r.db.Label.Create().
|
||||
SetName(data.Name).
|
||||
SetDescription(data.Description).
|
||||
SetColor(data.Color).
|
||||
SetGroupID(groupID).
|
||||
Save(ctx)
|
||||
if err != nil {
|
||||
return TagOut{}, err
|
||||
return LabelOut{}, err
|
||||
}
|
||||
|
||||
tag.Edges.Group = &ent.Group{ID: groupID} // bootstrap group ID
|
||||
label.Edges.Group = &ent.Group{ID: groupID} // bootstrap group ID
|
||||
r.publishMutationEvent(groupID)
|
||||
return mapTagOut(tag), err
|
||||
return mapLabelOut(label), err
|
||||
}
|
||||
|
||||
func (r *TagRepository) update(ctx context.Context, data TagUpdate, where ...predicate.Tag) (int, error) {
|
||||
func (r *LabelRepository) update(ctx context.Context, data LabelUpdate, where ...predicate.Label) (int, error) {
|
||||
if len(where) == 0 {
|
||||
panic("empty where not supported empty")
|
||||
}
|
||||
|
||||
return r.db.Tag.Update().
|
||||
return r.db.Label.Update().
|
||||
Where(where...).
|
||||
SetName(data.Name).
|
||||
SetDescription(data.Description).
|
||||
@@ -127,27 +127,27 @@ func (r *TagRepository) update(ctx context.Context, data TagUpdate, where ...pre
|
||||
Save(ctx)
|
||||
}
|
||||
|
||||
func (r *TagRepository) UpdateByGroup(ctx context.Context, gid uuid.UUID, data TagUpdate) (TagOut, error) {
|
||||
_, err := r.update(ctx, data, tag.ID(data.ID), tag.HasGroupWith(group.ID(gid)))
|
||||
func (r *LabelRepository) UpdateByGroup(ctx context.Context, gid uuid.UUID, data LabelUpdate) (LabelOut, error) {
|
||||
_, err := r.update(ctx, data, label.ID(data.ID), label.HasGroupWith(group.ID(gid)))
|
||||
if err != nil {
|
||||
return TagOut{}, err
|
||||
return LabelOut{}, err
|
||||
}
|
||||
|
||||
r.publishMutationEvent(gid)
|
||||
return r.GetOne(ctx, data.ID)
|
||||
}
|
||||
|
||||
// delete removes the tag from the database. This should only be used when
|
||||
// the tag's ownership is already confirmed/validated.
|
||||
func (r *TagRepository) delete(ctx context.Context, id uuid.UUID) error {
|
||||
return r.db.Tag.DeleteOneID(id).Exec(ctx)
|
||||
// delete removes the label from the database. This should only be used when
|
||||
// the label's ownership is already confirmed/validated.
|
||||
func (r *LabelRepository) delete(ctx context.Context, id uuid.UUID) error {
|
||||
return r.db.Label.DeleteOneID(id).Exec(ctx)
|
||||
}
|
||||
|
||||
func (r *TagRepository) DeleteByGroup(ctx context.Context, gid, id uuid.UUID) error {
|
||||
_, err := r.db.Tag.Delete().
|
||||
func (r *LabelRepository) DeleteByGroup(ctx context.Context, gid, id uuid.UUID) error {
|
||||
_, err := r.db.Label.Delete().
|
||||
Where(
|
||||
tag.ID(id),
|
||||
tag.HasGroupWith(group.ID(gid)),
|
||||
label.ID(id),
|
||||
label.HasGroupWith(group.ID(gid)),
|
||||
).Exec(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -8,96 +8,96 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func tagFactory() TagCreate {
|
||||
return TagCreate{
|
||||
func labelFactory() LabelCreate {
|
||||
return LabelCreate{
|
||||
Name: fk.Str(10),
|
||||
Description: fk.Str(100),
|
||||
}
|
||||
}
|
||||
|
||||
func useTags(t *testing.T, len int) []TagOut {
|
||||
func useLabels(t *testing.T, len int) []LabelOut {
|
||||
t.Helper()
|
||||
|
||||
tags := make([]TagOut, len)
|
||||
labels := make([]LabelOut, len)
|
||||
for i := 0; i < len; i++ {
|
||||
itm := tagFactory()
|
||||
itm := labelFactory()
|
||||
|
||||
item, err := tRepos.Tags.Create(context.Background(), tGroup.ID, itm)
|
||||
item, err := tRepos.Labels.Create(context.Background(), tGroup.ID, itm)
|
||||
require.NoError(t, err)
|
||||
tags[i] = item
|
||||
labels[i] = item
|
||||
}
|
||||
|
||||
t.Cleanup(func() {
|
||||
for _, item := range tags {
|
||||
_ = tRepos.Tags.delete(context.Background(), item.ID)
|
||||
for _, item := range labels {
|
||||
_ = tRepos.Labels.delete(context.Background(), item.ID)
|
||||
}
|
||||
})
|
||||
|
||||
return tags
|
||||
return labels
|
||||
}
|
||||
|
||||
func TestTagRepository_Get(t *testing.T) {
|
||||
tags := useTags(t, 1)
|
||||
tag := tags[0]
|
||||
func TestLabelRepository_Get(t *testing.T) {
|
||||
labels := useLabels(t, 1)
|
||||
label := labels[0]
|
||||
|
||||
// Get by ID
|
||||
foundLoc, err := tRepos.Tags.GetOne(context.Background(), tag.ID)
|
||||
foundLoc, err := tRepos.Labels.GetOne(context.Background(), label.ID)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, tag.ID, foundLoc.ID)
|
||||
assert.Equal(t, label.ID, foundLoc.ID)
|
||||
}
|
||||
|
||||
func TestTagRepositoryGetAll(t *testing.T) {
|
||||
useTags(t, 10)
|
||||
func TestLabelRepositoryGetAll(t *testing.T) {
|
||||
useLabels(t, 10)
|
||||
|
||||
all, err := tRepos.Tags.GetAll(context.Background(), tGroup.ID)
|
||||
all, err := tRepos.Labels.GetAll(context.Background(), tGroup.ID)
|
||||
require.NoError(t, err)
|
||||
assert.Len(t, all, 10)
|
||||
}
|
||||
|
||||
func TestTagRepository_Create(t *testing.T) {
|
||||
loc, err := tRepos.Tags.Create(context.Background(), tGroup.ID, tagFactory())
|
||||
func TestLabelRepository_Create(t *testing.T) {
|
||||
loc, err := tRepos.Labels.Create(context.Background(), tGroup.ID, labelFactory())
|
||||
require.NoError(t, err)
|
||||
|
||||
// Get by ID
|
||||
foundLoc, err := tRepos.Tags.GetOne(context.Background(), loc.ID)
|
||||
foundLoc, err := tRepos.Labels.GetOne(context.Background(), loc.ID)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, loc.ID, foundLoc.ID)
|
||||
|
||||
err = tRepos.Tags.delete(context.Background(), loc.ID)
|
||||
err = tRepos.Labels.delete(context.Background(), loc.ID)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestTagsRepository_Update(t *testing.T) {
|
||||
loc, err := tRepos.Tags.Create(context.Background(), tGroup.ID, tagFactory())
|
||||
func TestLabelRepository_Update(t *testing.T) {
|
||||
loc, err := tRepos.Labels.Create(context.Background(), tGroup.ID, labelFactory())
|
||||
require.NoError(t, err)
|
||||
|
||||
updateData := TagUpdate{
|
||||
updateData := LabelUpdate{
|
||||
ID: loc.ID,
|
||||
Name: fk.Str(10),
|
||||
Description: fk.Str(100),
|
||||
}
|
||||
|
||||
update, err := tRepos.Tags.UpdateByGroup(context.Background(), tGroup.ID, updateData)
|
||||
update, err := tRepos.Labels.UpdateByGroup(context.Background(), tGroup.ID, updateData)
|
||||
require.NoError(t, err)
|
||||
|
||||
foundLoc, err := tRepos.Tags.GetOne(context.Background(), loc.ID)
|
||||
foundLoc, err := tRepos.Labels.GetOne(context.Background(), loc.ID)
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.Equal(t, update.ID, foundLoc.ID)
|
||||
assert.Equal(t, update.Name, foundLoc.Name)
|
||||
assert.Equal(t, update.Description, foundLoc.Description)
|
||||
|
||||
err = tRepos.Tags.delete(context.Background(), loc.ID)
|
||||
err = tRepos.Labels.delete(context.Background(), loc.ID)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestTagRepository_Delete(t *testing.T) {
|
||||
loc, err := tRepos.Tags.Create(context.Background(), tGroup.ID, tagFactory())
|
||||
func TestLabelRepository_Delete(t *testing.T) {
|
||||
loc, err := tRepos.Labels.Create(context.Background(), tGroup.ID, labelFactory())
|
||||
require.NoError(t, err)
|
||||
|
||||
err = tRepos.Tags.delete(context.Background(), loc.ID)
|
||||
err = tRepos.Labels.delete(context.Background(), loc.ID)
|
||||
require.NoError(t, err)
|
||||
|
||||
_, err = tRepos.Tags.GetOne(context.Background(), loc.ID)
|
||||
_, err = tRepos.Labels.GetOne(context.Background(), loc.ID)
|
||||
require.Error(t, err)
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
|
||||
// TestWipeInventory_Integration tests the complete wipe inventory flow
|
||||
func TestWipeInventory_Integration(t *testing.T) {
|
||||
// Create test data: locations, tags, items with maintenance
|
||||
// Create test data: locations, labels, items with maintenance
|
||||
|
||||
// 1. Create locations
|
||||
loc1, err := tRepos.Locations.Create(context.Background(), tGroup.ID, LocationCreate{
|
||||
@@ -28,16 +28,16 @@ func TestWipeInventory_Integration(t *testing.T) {
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
// 2. Create tags
|
||||
tag1, err := tRepos.Tags.Create(context.Background(), tGroup.ID, TagCreate{
|
||||
// 2. Create labels
|
||||
label1, err := tRepos.Labels.Create(context.Background(), tGroup.ID, LabelCreate{
|
||||
Name: "Test Electronics",
|
||||
Description: "Electronics tag",
|
||||
Description: "Electronics label",
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
tag2, err := tRepos.Tags.Create(context.Background(), tGroup.ID, TagCreate{
|
||||
label2, err := tRepos.Labels.Create(context.Background(), tGroup.ID, LabelCreate{
|
||||
Name: "Test Tools",
|
||||
Description: "Tools tag",
|
||||
Description: "Tools label",
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -46,7 +46,7 @@ func TestWipeInventory_Integration(t *testing.T) {
|
||||
Name: "Test Laptop",
|
||||
Description: "Work laptop",
|
||||
LocationID: loc1.ID,
|
||||
TagIDs: []uuid.UUID{tag1.ID},
|
||||
LabelIDs: []uuid.UUID{label1.ID},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -54,7 +54,7 @@ func TestWipeInventory_Integration(t *testing.T) {
|
||||
Name: "Test Drill",
|
||||
Description: "Power drill",
|
||||
LocationID: loc2.ID,
|
||||
TagIDs: []uuid.UUID{tag2.ID},
|
||||
LabelIDs: []uuid.UUID{label2.ID},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -62,7 +62,7 @@ func TestWipeInventory_Integration(t *testing.T) {
|
||||
Name: "Test Monitor",
|
||||
Description: "Computer monitor",
|
||||
LocationID: loc1.ID,
|
||||
TagIDs: []uuid.UUID{tag1.ID},
|
||||
LabelIDs: []uuid.UUID{label1.ID},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -119,13 +119,13 @@ func TestWipeInventory_Integration(t *testing.T) {
|
||||
maint1After, err := tRepos.MaintEntry.GetMaintenanceByItemID(context.Background(), tGroup.ID, item1.ID, MaintenanceFilters{})
|
||||
require.NoError(t, err)
|
||||
assert.Empty(t, maint1After, "Item 1 maintenance records should be deleted")
|
||||
|
||||
// 10. Verify tags are deleted
|
||||
_, err = tRepos.Tags.GetOneByGroup(context.Background(), tGroup.ID, tag1.ID)
|
||||
require.Error(t, err, "Tag 1 should be deleted")
|
||||
|
||||
_, err = tRepos.Tags.GetOneByGroup(context.Background(), tGroup.ID, tag2.ID)
|
||||
require.Error(t, err, "Tag 2 should be deleted")
|
||||
|
||||
// 10. Verify labels are deleted
|
||||
_, err = tRepos.Labels.GetOneByGroup(context.Background(), tGroup.ID, label1.ID)
|
||||
require.Error(t, err, "Label 1 should be deleted")
|
||||
|
||||
_, err = tRepos.Labels.GetOneByGroup(context.Background(), tGroup.ID, label2.ID)
|
||||
require.Error(t, err, "Label 2 should be deleted")
|
||||
|
||||
// 11. Verify locations are deleted
|
||||
_, err = tRepos.Locations.Get(context.Background(), loc1.ID)
|
||||
@@ -144,9 +144,9 @@ func TestWipeInventory_SelectiveWipe(t *testing.T) {
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
tag, err := tRepos.Tags.Create(context.Background(), tGroup.ID, TagCreate{
|
||||
label, err := tRepos.Labels.Create(context.Background(), tGroup.ID, LabelCreate{
|
||||
Name: "Test Important",
|
||||
Description: "Important tag",
|
||||
Description: "Important label",
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -154,7 +154,7 @@ func TestWipeInventory_SelectiveWipe(t *testing.T) {
|
||||
Name: "Test Computer",
|
||||
Description: "Desktop computer",
|
||||
LocationID: loc.ID,
|
||||
TagIDs: []uuid.UUID{tag.ID},
|
||||
LabelIDs: []uuid.UUID{label.ID},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -165,8 +165,8 @@ func TestWipeInventory_SelectiveWipe(t *testing.T) {
|
||||
Cost: 0,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
// Test: Wipe only items (keep tags and locations)
|
||||
|
||||
// Test: Wipe only items (keep labels and locations)
|
||||
deleted, err := tRepos.Items.WipeInventory(context.Background(), tGroup.ID, false, false, false)
|
||||
require.NoError(t, err)
|
||||
assert.Greater(t, deleted, 0, "Should have deleted at least items")
|
||||
@@ -180,15 +180,15 @@ func TestWipeInventory_SelectiveWipe(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
assert.Empty(t, maintList, "Maintenance should be cascade deleted")
|
||||
|
||||
// Verify tag still exists
|
||||
_, err = tRepos.Tags.GetOneByGroup(context.Background(), tGroup.ID, tag.ID)
|
||||
require.NoError(t, err, "Tag should still exist")
|
||||
|
||||
// Verify label still exists
|
||||
_, err = tRepos.Labels.GetOneByGroup(context.Background(), tGroup.ID, label.ID)
|
||||
require.NoError(t, err, "Label should still exist")
|
||||
|
||||
// Verify location still exists
|
||||
_, err = tRepos.Locations.Get(context.Background(), loc.ID)
|
||||
require.NoError(t, err, "Location should still exist")
|
||||
|
||||
// Cleanup
|
||||
_ = tRepos.Tags.DeleteByGroup(context.Background(), tGroup.ID, tag.ID)
|
||||
_ = tRepos.Labels.DeleteByGroup(context.Background(), tGroup.ID, label.ID)
|
||||
_ = tRepos.Locations.delete(context.Background(), loc.ID)
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ type AllRepos struct {
|
||||
AuthTokens *TokenRepository
|
||||
Groups *GroupRepository
|
||||
Locations *LocationRepository
|
||||
Tags *TagRepository
|
||||
Labels *LabelRepository
|
||||
Items *ItemsRepository
|
||||
ItemTemplates *ItemTemplatesRepository
|
||||
Attachments *AttachmentRepo
|
||||
@@ -28,7 +28,7 @@ func New(db *ent.Client, bus *eventbus.EventBus, storage config.Storage, pubSubC
|
||||
AuthTokens: &TokenRepository{db},
|
||||
Groups: NewGroupRepository(db),
|
||||
Locations: &LocationRepository{db, bus},
|
||||
Tags: &TagRepository{db, bus},
|
||||
Labels: &LabelRepository{db, bus},
|
||||
Items: &ItemsRepository{db, bus, attachments},
|
||||
ItemTemplates: &ItemTemplatesRepository{db, bus},
|
||||
Attachments: attachments,
|
||||
|
||||
@@ -6,7 +6,7 @@ Using the CSV import is the recommended way for adding items to the database. It
|
||||
|
||||
**Current Limitations**
|
||||
|
||||
- Imports only support importing items, locations, and tags
|
||||
- Imports only support importing items, locations, and labels
|
||||
- Imports and Exports do not support attachments. Attachments must be uploaded after import
|
||||
- CSV Exports do not support nested path exports (e.g. `Home / Office / Desk`) and will only export the Items direct parent, (though imports _do_ support nested paths)
|
||||
- Cannot specify item-to-item relationships (e.g. `Item A` is a child of `Item B`)
|
||||
@@ -40,9 +40,9 @@ Specifying import refs also allows you to update existing items via the CSV impo
|
||||
|
||||
* Supports Path Separators for nested locations (e.g. `Home / Office / Desk`)
|
||||
|
||||
`HB.tags`
|
||||
`HB.labels`
|
||||
|
||||
: List of tags to apply to the item separated by a `;` can be existing or new tags.
|
||||
: List of labels to apply to the item separated by a `;` can be existing or new labels.
|
||||
|
||||
`HB.field.{field_name}` (e.g. `HB.field.Serial Number`)
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -205,6 +205,22 @@ paths:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/repo.GroupStatistics"
|
||||
/v1/groups/statistics/labels:
|
||||
get:
|
||||
security:
|
||||
- Bearer: []
|
||||
tags:
|
||||
- Statistics
|
||||
summary: Get Label Statistics
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/repo.TotalsByOrganizer"
|
||||
/v1/groups/statistics/locations:
|
||||
get:
|
||||
security:
|
||||
@@ -246,22 +262,6 @@ paths:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/repo.ValueOverTime"
|
||||
/v1/groups/statistics/tags:
|
||||
get:
|
||||
security:
|
||||
- Bearer: []
|
||||
tags:
|
||||
- Statistics
|
||||
summary: Get Tags Statistics
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/repo.TotalsByOrganizer"
|
||||
/v1/items:
|
||||
get:
|
||||
security:
|
||||
@@ -285,8 +285,8 @@ paths:
|
||||
in: query
|
||||
schema:
|
||||
type: integer
|
||||
- description: tags Ids
|
||||
name: tags
|
||||
- description: label Ids
|
||||
name: labels
|
||||
in: query
|
||||
explode: true
|
||||
schema:
|
||||
@@ -819,6 +819,99 @@ paths:
|
||||
application/json:
|
||||
schema:
|
||||
type: string
|
||||
/v1/labels:
|
||||
get:
|
||||
security:
|
||||
- Bearer: []
|
||||
tags:
|
||||
- Labels
|
||||
summary: Get All Labels
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/repo.LabelOut"
|
||||
post:
|
||||
security:
|
||||
- Bearer: []
|
||||
tags:
|
||||
- Labels
|
||||
summary: Create Label
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/repo.LabelCreate"
|
||||
description: Label Data
|
||||
required: true
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/repo.LabelSummary"
|
||||
"/v1/labels/{id}":
|
||||
get:
|
||||
security:
|
||||
- Bearer: []
|
||||
tags:
|
||||
- Labels
|
||||
summary: Get Label
|
||||
parameters:
|
||||
- description: Label ID
|
||||
name: id
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/repo.LabelOut"
|
||||
put:
|
||||
security:
|
||||
- Bearer: []
|
||||
tags:
|
||||
- Labels
|
||||
summary: Update Label
|
||||
parameters:
|
||||
- description: Label ID
|
||||
name: id
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/repo.LabelOut"
|
||||
delete:
|
||||
security:
|
||||
- Bearer: []
|
||||
tags:
|
||||
- Labels
|
||||
summary: Delete Label
|
||||
parameters:
|
||||
- description: Label ID
|
||||
name: id
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
"204":
|
||||
description: No Content
|
||||
/v1/locations:
|
||||
get:
|
||||
security:
|
||||
@@ -1185,99 +1278,6 @@ paths:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/v1.APISummary"
|
||||
/v1/tags:
|
||||
get:
|
||||
security:
|
||||
- Bearer: []
|
||||
tags:
|
||||
- Tags
|
||||
summary: Get All Tags
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/repo.TagOut"
|
||||
post:
|
||||
security:
|
||||
- Bearer: []
|
||||
tags:
|
||||
- Tags
|
||||
summary: Create Tag
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/repo.TagCreate"
|
||||
description: Tag Data
|
||||
required: true
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/repo.TagSummary"
|
||||
"/v1/tags/{id}":
|
||||
get:
|
||||
security:
|
||||
- Bearer: []
|
||||
tags:
|
||||
- Tags
|
||||
summary: Get Tag
|
||||
parameters:
|
||||
- description: Tag ID
|
||||
name: id
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/repo.TagOut"
|
||||
put:
|
||||
security:
|
||||
- Bearer: []
|
||||
tags:
|
||||
- Tags
|
||||
summary: Update Tag
|
||||
parameters:
|
||||
- description: Tag ID
|
||||
name: id
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/repo.TagOut"
|
||||
delete:
|
||||
security:
|
||||
- Bearer: []
|
||||
tags:
|
||||
- Tags
|
||||
summary: Delete Tag
|
||||
parameters:
|
||||
- description: Tag ID
|
||||
name: id
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
"204":
|
||||
description: No Content
|
||||
/v1/templates:
|
||||
get:
|
||||
security:
|
||||
@@ -1784,6 +1784,11 @@ components:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/ent.Item"
|
||||
labels:
|
||||
description: Labels holds the value of the labels edge.
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/ent.Label"
|
||||
locations:
|
||||
description: Locations holds the value of the locations edge.
|
||||
type: array
|
||||
@@ -1794,11 +1799,6 @@ components:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/ent.Notifier"
|
||||
tags:
|
||||
description: Tags holds the value of the tags edge.
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/ent.Tag"
|
||||
users:
|
||||
description: Users holds the value of the users edge.
|
||||
type: array
|
||||
@@ -1949,6 +1949,11 @@ components:
|
||||
description: Group holds the value of the group edge.
|
||||
allOf:
|
||||
- $ref: "#/components/schemas/ent.Group"
|
||||
label:
|
||||
description: Label holds the value of the label edge.
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/ent.Label"
|
||||
location:
|
||||
description: Location holds the value of the location edge.
|
||||
allOf:
|
||||
@@ -1962,11 +1967,6 @@ components:
|
||||
description: Parent holds the value of the parent edge.
|
||||
allOf:
|
||||
- $ref: "#/components/schemas/ent.Item"
|
||||
tag:
|
||||
description: Tag holds the value of the tag edge.
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/ent.Tag"
|
||||
ent.ItemField:
|
||||
type: object
|
||||
properties:
|
||||
@@ -2027,6 +2027,11 @@ components:
|
||||
default_insured:
|
||||
description: DefaultInsured holds the value of the "default_insured" field.
|
||||
type: boolean
|
||||
default_label_ids:
|
||||
description: Default label IDs for items created from this template
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
default_lifetime_warranty:
|
||||
description: DefaultLifetimeWarranty holds the value of the
|
||||
"default_lifetime_warranty" field.
|
||||
@@ -2044,11 +2049,6 @@ components:
|
||||
default_quantity:
|
||||
description: DefaultQuantity holds the value of the "default_quantity" field.
|
||||
type: integer
|
||||
default_tag_ids:
|
||||
description: Default tag IDs for items created from this template
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
default_warranty_details:
|
||||
description: DefaultWarrantyDetails holds the value of the
|
||||
"default_warranty_details" field.
|
||||
@@ -2102,6 +2102,46 @@ components:
|
||||
description: Location holds the value of the location edge.
|
||||
allOf:
|
||||
- $ref: "#/components/schemas/ent.Location"
|
||||
ent.Label:
|
||||
type: object
|
||||
properties:
|
||||
color:
|
||||
description: Color holds the value of the "color" field.
|
||||
type: string
|
||||
created_at:
|
||||
description: CreatedAt holds the value of the "created_at" field.
|
||||
type: string
|
||||
description:
|
||||
description: Description holds the value of the "description" field.
|
||||
type: string
|
||||
edges:
|
||||
description: >-
|
||||
Edges holds the relations/edges for other nodes in the graph.
|
||||
|
||||
The values are being populated by the LabelQuery when eager-loading is set.
|
||||
allOf:
|
||||
- $ref: "#/components/schemas/ent.LabelEdges"
|
||||
id:
|
||||
description: ID of the ent.
|
||||
type: string
|
||||
name:
|
||||
description: Name holds the value of the "name" field.
|
||||
type: string
|
||||
updated_at:
|
||||
description: UpdatedAt holds the value of the "updated_at" field.
|
||||
type: string
|
||||
ent.LabelEdges:
|
||||
type: object
|
||||
properties:
|
||||
group:
|
||||
description: Group holds the value of the group edge.
|
||||
allOf:
|
||||
- $ref: "#/components/schemas/ent.Group"
|
||||
items:
|
||||
description: Items holds the value of the items edge.
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/ent.Item"
|
||||
ent.Location:
|
||||
type: object
|
||||
properties:
|
||||
@@ -2234,46 +2274,6 @@ components:
|
||||
description: User holds the value of the user edge.
|
||||
allOf:
|
||||
- $ref: "#/components/schemas/ent.User"
|
||||
ent.Tag:
|
||||
type: object
|
||||
properties:
|
||||
color:
|
||||
description: Color holds the value of the "color" field.
|
||||
type: string
|
||||
created_at:
|
||||
description: CreatedAt holds the value of the "created_at" field.
|
||||
type: string
|
||||
description:
|
||||
description: Description holds the value of the "description" field.
|
||||
type: string
|
||||
edges:
|
||||
description: >-
|
||||
Edges holds the relations/edges for other nodes in the graph.
|
||||
|
||||
The values are being populated by the TagQuery when eager-loading is set.
|
||||
allOf:
|
||||
- $ref: "#/components/schemas/ent.TagEdges"
|
||||
id:
|
||||
description: ID of the ent.
|
||||
type: string
|
||||
name:
|
||||
description: Name holds the value of the "name" field.
|
||||
type: string
|
||||
updated_at:
|
||||
description: UpdatedAt holds the value of the "updated_at" field.
|
||||
type: string
|
||||
ent.TagEdges:
|
||||
type: object
|
||||
properties:
|
||||
group:
|
||||
description: Group holds the value of the group edge.
|
||||
allOf:
|
||||
- $ref: "#/components/schemas/ent.Group"
|
||||
items:
|
||||
description: Items holds the value of the items edge.
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/ent.Item"
|
||||
ent.TemplateField:
|
||||
type: object
|
||||
properties:
|
||||
@@ -2438,9 +2438,9 @@ components:
|
||||
type: number
|
||||
totalItems:
|
||||
type: integer
|
||||
totalLocations:
|
||||
totalLabels:
|
||||
type: integer
|
||||
totalTags:
|
||||
totalLocations:
|
||||
type: integer
|
||||
totalUsers:
|
||||
type: integer
|
||||
@@ -2491,6 +2491,10 @@ components:
|
||||
description:
|
||||
type: string
|
||||
maxLength: 1000
|
||||
labelIds:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
locationId:
|
||||
description: Edges
|
||||
type: string
|
||||
@@ -2503,10 +2507,6 @@ components:
|
||||
nullable: true
|
||||
quantity:
|
||||
type: integer
|
||||
tagIds:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
repo.ItemField:
|
||||
type: object
|
||||
properties:
|
||||
@@ -2550,6 +2550,10 @@ components:
|
||||
nullable: true
|
||||
insured:
|
||||
type: boolean
|
||||
labels:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/repo.LabelSummary"
|
||||
lifetimeWarranty:
|
||||
description: Warranty
|
||||
type: boolean
|
||||
@@ -2595,10 +2599,6 @@ components:
|
||||
type: string
|
||||
syncChildItemsLocations:
|
||||
type: boolean
|
||||
tags:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/repo.TagSummary"
|
||||
thumbnailId:
|
||||
type: string
|
||||
x-omitempty: true
|
||||
@@ -2614,6 +2614,12 @@ components:
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
labelIds:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
x-omitempty: true
|
||||
nullable: true
|
||||
locationId:
|
||||
type: string
|
||||
x-omitempty: true
|
||||
@@ -2622,12 +2628,6 @@ components:
|
||||
type: integer
|
||||
x-omitempty: true
|
||||
nullable: true
|
||||
tagIds:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
x-omitempty: true
|
||||
nullable: true
|
||||
repo.ItemPath:
|
||||
type: object
|
||||
properties:
|
||||
@@ -2657,6 +2657,10 @@ components:
|
||||
nullable: true
|
||||
insured:
|
||||
type: boolean
|
||||
labels:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/repo.LabelSummary"
|
||||
location:
|
||||
description: Edges
|
||||
allOf:
|
||||
@@ -2672,10 +2676,6 @@ components:
|
||||
soldTime:
|
||||
description: Sale details
|
||||
type: string
|
||||
tags:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/repo.TagSummary"
|
||||
thumbnailId:
|
||||
type: string
|
||||
x-omitempty: true
|
||||
@@ -2693,10 +2693,15 @@ components:
|
||||
nullable: true
|
||||
defaultInsured:
|
||||
type: boolean
|
||||
defaultLabelIds:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
nullable: true
|
||||
defaultLifetimeWarranty:
|
||||
type: boolean
|
||||
defaultLocationId:
|
||||
description: Default location and tags
|
||||
description: Default location and labels
|
||||
type: string
|
||||
nullable: true
|
||||
defaultManufacturer:
|
||||
@@ -2715,11 +2720,6 @@ components:
|
||||
description: Default values for items
|
||||
type: integer
|
||||
nullable: true
|
||||
defaultTagIds:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
nullable: true
|
||||
defaultWarrantyDetails:
|
||||
type: string
|
||||
maxLength: 1000
|
||||
@@ -2755,10 +2755,14 @@ components:
|
||||
type: string
|
||||
defaultInsured:
|
||||
type: boolean
|
||||
defaultLabels:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/repo.TemplateLabelSummary"
|
||||
defaultLifetimeWarranty:
|
||||
type: boolean
|
||||
defaultLocation:
|
||||
description: Default location and tags
|
||||
description: Default location and labels
|
||||
allOf:
|
||||
- $ref: "#/components/schemas/repo.TemplateLocationSummary"
|
||||
defaultManufacturer:
|
||||
@@ -2770,10 +2774,6 @@ components:
|
||||
defaultQuantity:
|
||||
description: Default values for items
|
||||
type: integer
|
||||
defaultTags:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/repo.TemplateTagSummary"
|
||||
defaultWarrantyDetails:
|
||||
type: string
|
||||
description:
|
||||
@@ -2822,10 +2822,15 @@ components:
|
||||
nullable: true
|
||||
defaultInsured:
|
||||
type: boolean
|
||||
defaultLabelIds:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
nullable: true
|
||||
defaultLifetimeWarranty:
|
||||
type: boolean
|
||||
defaultLocationId:
|
||||
description: Default location and tags
|
||||
description: Default location and labels
|
||||
type: string
|
||||
nullable: true
|
||||
defaultManufacturer:
|
||||
@@ -2844,11 +2849,6 @@ components:
|
||||
description: Default values for items
|
||||
type: integer
|
||||
nullable: true
|
||||
defaultTagIds:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
nullable: true
|
||||
defaultWarrantyDetails:
|
||||
type: string
|
||||
maxLength: 1000
|
||||
@@ -2905,6 +2905,10 @@ components:
|
||||
type: string
|
||||
insured:
|
||||
type: boolean
|
||||
labelIds:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
lifetimeWarranty:
|
||||
description: Warranty
|
||||
type: boolean
|
||||
@@ -2955,14 +2959,54 @@ components:
|
||||
maxLength: 255
|
||||
syncChildItemsLocations:
|
||||
type: boolean
|
||||
tagIds:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
warrantyDetails:
|
||||
type: string
|
||||
warrantyExpires:
|
||||
type: string
|
||||
repo.LabelCreate:
|
||||
type: object
|
||||
required:
|
||||
- name
|
||||
properties:
|
||||
color:
|
||||
type: string
|
||||
description:
|
||||
type: string
|
||||
maxLength: 1000
|
||||
name:
|
||||
type: string
|
||||
maxLength: 255
|
||||
minLength: 1
|
||||
repo.LabelOut:
|
||||
type: object
|
||||
properties:
|
||||
color:
|
||||
type: string
|
||||
createdAt:
|
||||
type: string
|
||||
description:
|
||||
type: string
|
||||
id:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
updatedAt:
|
||||
type: string
|
||||
repo.LabelSummary:
|
||||
type: object
|
||||
properties:
|
||||
color:
|
||||
type: string
|
||||
createdAt:
|
||||
type: string
|
||||
description:
|
||||
type: string
|
||||
id:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
updatedAt:
|
||||
type: string
|
||||
repo.LocationCreate:
|
||||
type: object
|
||||
properties:
|
||||
@@ -3170,50 +3214,6 @@ components:
|
||||
type: integer
|
||||
total:
|
||||
type: integer
|
||||
repo.TagCreate:
|
||||
type: object
|
||||
required:
|
||||
- name
|
||||
properties:
|
||||
color:
|
||||
type: string
|
||||
description:
|
||||
type: string
|
||||
maxLength: 1000
|
||||
name:
|
||||
type: string
|
||||
maxLength: 255
|
||||
minLength: 1
|
||||
repo.TagOut:
|
||||
type: object
|
||||
properties:
|
||||
color:
|
||||
type: string
|
||||
createdAt:
|
||||
type: string
|
||||
description:
|
||||
type: string
|
||||
id:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
updatedAt:
|
||||
type: string
|
||||
repo.TagSummary:
|
||||
type: object
|
||||
properties:
|
||||
color:
|
||||
type: string
|
||||
createdAt:
|
||||
type: string
|
||||
description:
|
||||
type: string
|
||||
id:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
updatedAt:
|
||||
type: string
|
||||
repo.TemplateField:
|
||||
type: object
|
||||
properties:
|
||||
@@ -3225,14 +3225,14 @@ components:
|
||||
type: string
|
||||
type:
|
||||
type: string
|
||||
repo.TemplateLocationSummary:
|
||||
repo.TemplateLabelSummary:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
repo.TemplateTagSummary:
|
||||
repo.TemplateLocationSummary:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
@@ -3427,6 +3427,10 @@ components:
|
||||
description:
|
||||
type: string
|
||||
maxLength: 1000
|
||||
labelIds:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
locationId:
|
||||
type: string
|
||||
name:
|
||||
@@ -3435,10 +3439,6 @@ components:
|
||||
minLength: 1
|
||||
quantity:
|
||||
type: integer
|
||||
tagIds:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
v1.LoginForm:
|
||||
type: object
|
||||
properties:
|
||||
@@ -3473,12 +3473,12 @@ components:
|
||||
v1.WipeInventoryOptions:
|
||||
type: object
|
||||
properties:
|
||||
wipeLabels:
|
||||
type: boolean
|
||||
wipeLocations:
|
||||
type: boolean
|
||||
wipeMaintenance:
|
||||
type: boolean
|
||||
wipeTags:
|
||||
type: boolean
|
||||
v1.Wrapped:
|
||||
type: object
|
||||
properties:
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -189,6 +189,11 @@ definitions:
|
||||
items:
|
||||
$ref: '#/definitions/ent.Item'
|
||||
type: array
|
||||
labels:
|
||||
description: Labels holds the value of the labels edge.
|
||||
items:
|
||||
$ref: '#/definitions/ent.Label'
|
||||
type: array
|
||||
locations:
|
||||
description: Locations holds the value of the locations edge.
|
||||
items:
|
||||
@@ -199,11 +204,6 @@ definitions:
|
||||
items:
|
||||
$ref: '#/definitions/ent.Notifier'
|
||||
type: array
|
||||
tags:
|
||||
description: Tags holds the value of the tags edge.
|
||||
items:
|
||||
$ref: '#/definitions/ent.Tag'
|
||||
type: array
|
||||
users:
|
||||
description: Users holds the value of the users edge.
|
||||
items:
|
||||
@@ -352,6 +352,11 @@ definitions:
|
||||
allOf:
|
||||
- $ref: '#/definitions/ent.Group'
|
||||
description: Group holds the value of the group edge.
|
||||
label:
|
||||
description: Label holds the value of the label edge.
|
||||
items:
|
||||
$ref: '#/definitions/ent.Label'
|
||||
type: array
|
||||
location:
|
||||
allOf:
|
||||
- $ref: '#/definitions/ent.Location'
|
||||
@@ -366,11 +371,6 @@ definitions:
|
||||
allOf:
|
||||
- $ref: '#/definitions/ent.Item'
|
||||
description: Parent holds the value of the parent edge.
|
||||
tag:
|
||||
description: Tag holds the value of the tag edge.
|
||||
items:
|
||||
$ref: '#/definitions/ent.Tag'
|
||||
type: array
|
||||
type: object
|
||||
ent.ItemField:
|
||||
properties:
|
||||
@@ -430,6 +430,11 @@ definitions:
|
||||
default_insured:
|
||||
description: DefaultInsured holds the value of the "default_insured" field.
|
||||
type: boolean
|
||||
default_label_ids:
|
||||
description: Default label IDs for items created from this template
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
default_lifetime_warranty:
|
||||
description: DefaultLifetimeWarranty holds the value of the "default_lifetime_warranty"
|
||||
field.
|
||||
@@ -447,11 +452,6 @@ definitions:
|
||||
default_quantity:
|
||||
description: DefaultQuantity holds the value of the "default_quantity" field.
|
||||
type: integer
|
||||
default_tag_ids:
|
||||
description: Default tag IDs for items created from this template
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
default_warranty_details:
|
||||
description: DefaultWarrantyDetails holds the value of the "default_warranty_details"
|
||||
field.
|
||||
@@ -505,6 +505,45 @@ definitions:
|
||||
- $ref: '#/definitions/ent.Location'
|
||||
description: Location holds the value of the location edge.
|
||||
type: object
|
||||
ent.Label:
|
||||
properties:
|
||||
color:
|
||||
description: Color holds the value of the "color" field.
|
||||
type: string
|
||||
created_at:
|
||||
description: CreatedAt holds the value of the "created_at" field.
|
||||
type: string
|
||||
description:
|
||||
description: Description holds the value of the "description" field.
|
||||
type: string
|
||||
edges:
|
||||
allOf:
|
||||
- $ref: '#/definitions/ent.LabelEdges'
|
||||
description: |-
|
||||
Edges holds the relations/edges for other nodes in the graph.
|
||||
The values are being populated by the LabelQuery when eager-loading is set.
|
||||
id:
|
||||
description: ID of the ent.
|
||||
type: string
|
||||
name:
|
||||
description: Name holds the value of the "name" field.
|
||||
type: string
|
||||
updated_at:
|
||||
description: UpdatedAt holds the value of the "updated_at" field.
|
||||
type: string
|
||||
type: object
|
||||
ent.LabelEdges:
|
||||
properties:
|
||||
group:
|
||||
allOf:
|
||||
- $ref: '#/definitions/ent.Group'
|
||||
description: Group holds the value of the group edge.
|
||||
items:
|
||||
description: Items holds the value of the items edge.
|
||||
items:
|
||||
$ref: '#/definitions/ent.Item'
|
||||
type: array
|
||||
type: object
|
||||
ent.Location:
|
||||
properties:
|
||||
created_at:
|
||||
@@ -634,45 +673,6 @@ definitions:
|
||||
- $ref: '#/definitions/ent.User'
|
||||
description: User holds the value of the user edge.
|
||||
type: object
|
||||
ent.Tag:
|
||||
properties:
|
||||
color:
|
||||
description: Color holds the value of the "color" field.
|
||||
type: string
|
||||
created_at:
|
||||
description: CreatedAt holds the value of the "created_at" field.
|
||||
type: string
|
||||
description:
|
||||
description: Description holds the value of the "description" field.
|
||||
type: string
|
||||
edges:
|
||||
allOf:
|
||||
- $ref: '#/definitions/ent.TagEdges'
|
||||
description: |-
|
||||
Edges holds the relations/edges for other nodes in the graph.
|
||||
The values are being populated by the TagQuery when eager-loading is set.
|
||||
id:
|
||||
description: ID of the ent.
|
||||
type: string
|
||||
name:
|
||||
description: Name holds the value of the "name" field.
|
||||
type: string
|
||||
updated_at:
|
||||
description: UpdatedAt holds the value of the "updated_at" field.
|
||||
type: string
|
||||
type: object
|
||||
ent.TagEdges:
|
||||
properties:
|
||||
group:
|
||||
allOf:
|
||||
- $ref: '#/definitions/ent.Group'
|
||||
description: Group holds the value of the group edge.
|
||||
items:
|
||||
description: Items holds the value of the items edge.
|
||||
items:
|
||||
$ref: '#/definitions/ent.Item'
|
||||
type: array
|
||||
type: object
|
||||
ent.TemplateField:
|
||||
properties:
|
||||
created_at:
|
||||
@@ -834,9 +834,9 @@ definitions:
|
||||
type: number
|
||||
totalItems:
|
||||
type: integer
|
||||
totalLocations:
|
||||
totalLabels:
|
||||
type: integer
|
||||
totalTags:
|
||||
totalLocations:
|
||||
type: integer
|
||||
totalUsers:
|
||||
type: integer
|
||||
@@ -885,6 +885,10 @@ definitions:
|
||||
description:
|
||||
maxLength: 1000
|
||||
type: string
|
||||
labelIds:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
locationId:
|
||||
description: Edges
|
||||
type: string
|
||||
@@ -897,10 +901,6 @@ definitions:
|
||||
x-nullable: true
|
||||
quantity:
|
||||
type: integer
|
||||
tagIds:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
required:
|
||||
- name
|
||||
type: object
|
||||
@@ -946,6 +946,10 @@ definitions:
|
||||
x-omitempty: true
|
||||
insured:
|
||||
type: boolean
|
||||
labels:
|
||||
items:
|
||||
$ref: '#/definitions/repo.LabelSummary'
|
||||
type: array
|
||||
lifetimeWarranty:
|
||||
description: Warranty
|
||||
type: boolean
|
||||
@@ -991,10 +995,6 @@ definitions:
|
||||
type: string
|
||||
syncChildItemsLocations:
|
||||
type: boolean
|
||||
tags:
|
||||
items:
|
||||
$ref: '#/definitions/repo.TagSummary'
|
||||
type: array
|
||||
thumbnailId:
|
||||
type: string
|
||||
x-nullable: true
|
||||
@@ -1010,6 +1010,12 @@ definitions:
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
labelIds:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
x-nullable: true
|
||||
x-omitempty: true
|
||||
locationId:
|
||||
type: string
|
||||
x-nullable: true
|
||||
@@ -1018,12 +1024,6 @@ definitions:
|
||||
type: integer
|
||||
x-nullable: true
|
||||
x-omitempty: true
|
||||
tagIds:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
x-nullable: true
|
||||
x-omitempty: true
|
||||
type: object
|
||||
repo.ItemPath:
|
||||
properties:
|
||||
@@ -1053,6 +1053,10 @@ definitions:
|
||||
x-omitempty: true
|
||||
insured:
|
||||
type: boolean
|
||||
labels:
|
||||
items:
|
||||
$ref: '#/definitions/repo.LabelSummary'
|
||||
type: array
|
||||
location:
|
||||
allOf:
|
||||
- $ref: '#/definitions/repo.LocationSummary'
|
||||
@@ -1068,10 +1072,6 @@ definitions:
|
||||
soldTime:
|
||||
description: Sale details
|
||||
type: string
|
||||
tags:
|
||||
items:
|
||||
$ref: '#/definitions/repo.TagSummary'
|
||||
type: array
|
||||
thumbnailId:
|
||||
type: string
|
||||
x-nullable: true
|
||||
@@ -1087,10 +1087,15 @@ definitions:
|
||||
x-nullable: true
|
||||
defaultInsured:
|
||||
type: boolean
|
||||
defaultLabelIds:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
x-nullable: true
|
||||
defaultLifetimeWarranty:
|
||||
type: boolean
|
||||
defaultLocationId:
|
||||
description: Default location and tags
|
||||
description: Default location and labels
|
||||
type: string
|
||||
x-nullable: true
|
||||
defaultManufacturer:
|
||||
@@ -1109,11 +1114,6 @@ definitions:
|
||||
description: Default values for items
|
||||
type: integer
|
||||
x-nullable: true
|
||||
defaultTagIds:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
x-nullable: true
|
||||
defaultWarrantyDetails:
|
||||
maxLength: 1000
|
||||
type: string
|
||||
@@ -1151,12 +1151,16 @@ definitions:
|
||||
type: string
|
||||
defaultInsured:
|
||||
type: boolean
|
||||
defaultLabels:
|
||||
items:
|
||||
$ref: '#/definitions/repo.TemplateLabelSummary'
|
||||
type: array
|
||||
defaultLifetimeWarranty:
|
||||
type: boolean
|
||||
defaultLocation:
|
||||
allOf:
|
||||
- $ref: '#/definitions/repo.TemplateLocationSummary'
|
||||
description: Default location and tags
|
||||
description: Default location and labels
|
||||
defaultManufacturer:
|
||||
type: string
|
||||
defaultModelNumber:
|
||||
@@ -1166,10 +1170,6 @@ definitions:
|
||||
defaultQuantity:
|
||||
description: Default values for items
|
||||
type: integer
|
||||
defaultTags:
|
||||
items:
|
||||
$ref: '#/definitions/repo.TemplateTagSummary'
|
||||
type: array
|
||||
defaultWarrantyDetails:
|
||||
type: string
|
||||
description:
|
||||
@@ -1216,10 +1216,15 @@ definitions:
|
||||
x-nullable: true
|
||||
defaultInsured:
|
||||
type: boolean
|
||||
defaultLabelIds:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
x-nullable: true
|
||||
defaultLifetimeWarranty:
|
||||
type: boolean
|
||||
defaultLocationId:
|
||||
description: Default location and tags
|
||||
description: Default location and labels
|
||||
type: string
|
||||
x-nullable: true
|
||||
defaultManufacturer:
|
||||
@@ -1238,11 +1243,6 @@ definitions:
|
||||
description: Default values for items
|
||||
type: integer
|
||||
x-nullable: true
|
||||
defaultTagIds:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
x-nullable: true
|
||||
defaultWarrantyDetails:
|
||||
maxLength: 1000
|
||||
type: string
|
||||
@@ -1299,6 +1299,10 @@ definitions:
|
||||
type: string
|
||||
insured:
|
||||
type: boolean
|
||||
labelIds:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
lifetimeWarranty:
|
||||
description: Warranty
|
||||
type: boolean
|
||||
@@ -1349,10 +1353,6 @@ definitions:
|
||||
type: string
|
||||
syncChildItemsLocations:
|
||||
type: boolean
|
||||
tagIds:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
warrantyDetails:
|
||||
type: string
|
||||
warrantyExpires:
|
||||
@@ -1360,6 +1360,50 @@ definitions:
|
||||
required:
|
||||
- name
|
||||
type: object
|
||||
repo.LabelCreate:
|
||||
properties:
|
||||
color:
|
||||
type: string
|
||||
description:
|
||||
maxLength: 1000
|
||||
type: string
|
||||
name:
|
||||
maxLength: 255
|
||||
minLength: 1
|
||||
type: string
|
||||
required:
|
||||
- name
|
||||
type: object
|
||||
repo.LabelOut:
|
||||
properties:
|
||||
color:
|
||||
type: string
|
||||
createdAt:
|
||||
type: string
|
||||
description:
|
||||
type: string
|
||||
id:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
updatedAt:
|
||||
type: string
|
||||
type: object
|
||||
repo.LabelSummary:
|
||||
properties:
|
||||
color:
|
||||
type: string
|
||||
createdAt:
|
||||
type: string
|
||||
description:
|
||||
type: string
|
||||
id:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
updatedAt:
|
||||
type: string
|
||||
type: object
|
||||
repo.LocationCreate:
|
||||
properties:
|
||||
description:
|
||||
@@ -1567,50 +1611,6 @@ definitions:
|
||||
total:
|
||||
type: integer
|
||||
type: object
|
||||
repo.TagCreate:
|
||||
properties:
|
||||
color:
|
||||
type: string
|
||||
description:
|
||||
maxLength: 1000
|
||||
type: string
|
||||
name:
|
||||
maxLength: 255
|
||||
minLength: 1
|
||||
type: string
|
||||
required:
|
||||
- name
|
||||
type: object
|
||||
repo.TagOut:
|
||||
properties:
|
||||
color:
|
||||
type: string
|
||||
createdAt:
|
||||
type: string
|
||||
description:
|
||||
type: string
|
||||
id:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
updatedAt:
|
||||
type: string
|
||||
type: object
|
||||
repo.TagSummary:
|
||||
properties:
|
||||
color:
|
||||
type: string
|
||||
createdAt:
|
||||
type: string
|
||||
description:
|
||||
type: string
|
||||
id:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
updatedAt:
|
||||
type: string
|
||||
type: object
|
||||
repo.TemplateField:
|
||||
properties:
|
||||
id:
|
||||
@@ -1622,14 +1622,14 @@ definitions:
|
||||
type:
|
||||
type: string
|
||||
type: object
|
||||
repo.TemplateLocationSummary:
|
||||
repo.TemplateLabelSummary:
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
type: object
|
||||
repo.TemplateTagSummary:
|
||||
repo.TemplateLocationSummary:
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
@@ -1820,6 +1820,10 @@ definitions:
|
||||
description:
|
||||
maxLength: 1000
|
||||
type: string
|
||||
labelIds:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
locationId:
|
||||
type: string
|
||||
name:
|
||||
@@ -1828,10 +1832,6 @@ definitions:
|
||||
type: string
|
||||
quantity:
|
||||
type: integer
|
||||
tagIds:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
required:
|
||||
- locationId
|
||||
- name
|
||||
@@ -1869,12 +1869,12 @@ definitions:
|
||||
type: object
|
||||
v1.WipeInventoryOptions:
|
||||
properties:
|
||||
wipeLabels:
|
||||
type: boolean
|
||||
wipeLocations:
|
||||
type: boolean
|
||||
wipeMaintenance:
|
||||
type: boolean
|
||||
wipeTags:
|
||||
type: boolean
|
||||
type: object
|
||||
v1.Wrapped:
|
||||
properties:
|
||||
@@ -2093,6 +2093,22 @@ paths:
|
||||
summary: Get Group Statistics
|
||||
tags:
|
||||
- Statistics
|
||||
/v1/groups/statistics/labels:
|
||||
get:
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
items:
|
||||
$ref: '#/definitions/repo.TotalsByOrganizer'
|
||||
type: array
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: Get Label Statistics
|
||||
tags:
|
||||
- Statistics
|
||||
/v1/groups/statistics/locations:
|
||||
get:
|
||||
produces:
|
||||
@@ -2132,22 +2148,6 @@ paths:
|
||||
summary: Get Purchase Price Statistics
|
||||
tags:
|
||||
- Statistics
|
||||
/v1/groups/statistics/tags:
|
||||
get:
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
items:
|
||||
$ref: '#/definitions/repo.TotalsByOrganizer'
|
||||
type: array
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: Get Tags Statistics
|
||||
tags:
|
||||
- Statistics
|
||||
/v1/items:
|
||||
get:
|
||||
parameters:
|
||||
@@ -2164,11 +2164,11 @@ paths:
|
||||
name: pageSize
|
||||
type: integer
|
||||
- collectionFormat: multi
|
||||
description: tags Ids
|
||||
description: label Ids
|
||||
in: query
|
||||
items:
|
||||
type: string
|
||||
name: tags
|
||||
name: labels
|
||||
type: array
|
||||
- collectionFormat: multi
|
||||
description: location Ids
|
||||
@@ -2662,6 +2662,98 @@ paths:
|
||||
summary: Get Location label
|
||||
tags:
|
||||
- Locations
|
||||
/v1/labels:
|
||||
get:
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
items:
|
||||
$ref: '#/definitions/repo.LabelOut'
|
||||
type: array
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: Get All Labels
|
||||
tags:
|
||||
- Labels
|
||||
post:
|
||||
parameters:
|
||||
- description: Label Data
|
||||
in: body
|
||||
name: payload
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/repo.LabelCreate'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/repo.LabelSummary'
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: Create Label
|
||||
tags:
|
||||
- Labels
|
||||
/v1/labels/{id}:
|
||||
delete:
|
||||
parameters:
|
||||
- description: Label ID
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: string
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"204":
|
||||
description: No Content
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: Delete Label
|
||||
tags:
|
||||
- Labels
|
||||
get:
|
||||
parameters:
|
||||
- description: Label ID
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: string
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/repo.LabelOut'
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: Get Label
|
||||
tags:
|
||||
- Labels
|
||||
put:
|
||||
parameters:
|
||||
- description: Label ID
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: string
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/repo.LabelOut'
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: Update Label
|
||||
tags:
|
||||
- Labels
|
||||
/v1/locations:
|
||||
get:
|
||||
parameters:
|
||||
@@ -3016,98 +3108,6 @@ paths:
|
||||
summary: Application Info
|
||||
tags:
|
||||
- Base
|
||||
/v1/tags:
|
||||
get:
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
items:
|
||||
$ref: '#/definitions/repo.TagOut'
|
||||
type: array
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: Get All Tags
|
||||
tags:
|
||||
- Tags
|
||||
post:
|
||||
parameters:
|
||||
- description: Tag Data
|
||||
in: body
|
||||
name: payload
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/repo.TagCreate'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/repo.TagSummary'
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: Create Tag
|
||||
tags:
|
||||
- Tags
|
||||
/v1/tags/{id}:
|
||||
delete:
|
||||
parameters:
|
||||
- description: Tag ID
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: string
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"204":
|
||||
description: No Content
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: Delete Tag
|
||||
tags:
|
||||
- Tags
|
||||
get:
|
||||
parameters:
|
||||
- description: Tag ID
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: string
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/repo.TagOut'
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: Get Tag
|
||||
tags:
|
||||
- Tags
|
||||
put:
|
||||
parameters:
|
||||
- description: Tag ID
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: string
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/repo.TagOut'
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: Update Tag
|
||||
tags:
|
||||
- Tags
|
||||
/v1/templates:
|
||||
get:
|
||||
produces:
|
||||
|
||||
@@ -28,8 +28,8 @@ features:
|
||||
details: Import a CSV file to quickly get started with existing information, or export to save information
|
||||
- title: Custom Report
|
||||
details: Export bill of materials, or generate QR codes for items
|
||||
- title: Custom tags and locations
|
||||
details: Use custom tags and locations to organize items
|
||||
- title: Custom labeling and locations
|
||||
details: Use custom labels and locations to organize items
|
||||
- title: Multi-Tenant Support
|
||||
details: All users are in a group, and can only see what's in the group. Invite family members or share an instance with friends.
|
||||
---
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Organizing Your Items
|
||||
|
||||
Homebox allows you to organize your items using locations and tags.
|
||||
Homebox allows you to organize your items using locations and labels.
|
||||
|
||||
## Items
|
||||
|
||||
@@ -10,7 +10,7 @@ To create an item, click on the Create button in the main menu, the select Item
|
||||
- Parent Location (Required) - The location in which the item is stored
|
||||
- Item Name (Required) - Name of the item
|
||||
- Item Description (Optional) - Description of the item
|
||||
- Tags (Optional) - Here, you can add as many Tags to the item as you like for further organization
|
||||
- Labels (Optional) - Here, you can add as many Labels to the item as you like for further organization
|
||||
- Photo (Optional) - Allows you to add a photo of the item. Additional photos can be added after the item has been created.
|
||||
|
||||
::: details Additional Fields
|
||||
@@ -63,18 +63,18 @@ Locations have 3 parameters:
|
||||
|
||||
To view all locations and the items stored in them, select Locations in the main menu.
|
||||
|
||||
## Tags
|
||||
## Labels
|
||||
|
||||
Tags allow you to organize items independently of location. For example, you might have electronic devices all over your house. What if you wanted to see a list of every Electronic Device you own without having to go through every single location?
|
||||
Labels allow you to organize items independently of location. For example, you might have electronic devices all over your house. What if you wanted to see a list of every Electronic Device you own without having to go through every single location?
|
||||
|
||||
Tags enable this. In the example above, if you tag all electronic devices with the "Electronics" tag when you create them, you can easily see the list of all your Electronics by going to the related page.
|
||||
Labels enable this. In the example above, if you tag all electronic devices with the "Electronics" label when you create them, you can easily see the list of all your Electronics by going to the related page.
|
||||
|
||||
To create a Tag, click the Create button in the menu, then select Tag. Tags have the following parameters:
|
||||
To create a Label, click the Create button in the menu, then select Label. Labels have the following parameters:
|
||||
- Name
|
||||
- Description (Optional)
|
||||
|
||||
To see all items related to a specific tag (or specific combination of tags):
|
||||
- From the Home page, scroll to the bottom and select the Tag you want to see.
|
||||
- Alternatively, navigate to the Search page and use the Tags dropdown to filter by one or more tags.
|
||||
To see all items related to a specific label (or specific combination of labels):
|
||||
- From the Home page, scroll to the bottom and select the Label you want to see.
|
||||
- Alternatively, navigate to the Search page and use the Labels dropdown to filter by one or more labels.
|
||||
|
||||
Items can have as many tags as you wish. The example above is only one example of how tags can be used for organization. Experiment with what tags work best for you!
|
||||
Items can have as many labels as you wish. The example above is only one example of how labels can be used for organization. Experiment with what labels work best for you!
|
||||
|
||||
@@ -69,7 +69,7 @@
|
||||
</TooltipProvider>
|
||||
<Markdown class="mb-2 line-clamp-3 text-ellipsis" :source="item.description" />
|
||||
<div class="-mr-1 mt-auto flex flex-wrap justify-end gap-2">
|
||||
<TagChip v-for="tag in itemTags" :key="tag.id" :tag="tag" size="sm" />
|
||||
<LabelChip v-for="label in itemLabels" :key="label.id" :label="label" size="sm" />
|
||||
</div>
|
||||
</div>
|
||||
</NuxtLink>
|
||||
@@ -85,7 +85,7 @@
|
||||
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";
|
||||
import { Separator } from "@/components/ui/separator";
|
||||
import Markdown from "@/components/global/Markdown.vue";
|
||||
import TagChip from "@/components/Tag/Chip.vue";
|
||||
import LabelChip from "@/components/Label/Chip.vue";
|
||||
import type { Row } from "@tanstack/vue-table";
|
||||
import { Checkbox } from "@/components/ui/checkbox";
|
||||
|
||||
@@ -103,8 +103,8 @@
|
||||
}
|
||||
});
|
||||
|
||||
const itemTags = computed(() => {
|
||||
return props.item.tags || [];
|
||||
const itemLabels = computed(() => {
|
||||
return props.item.labels || [];
|
||||
});
|
||||
|
||||
const props = defineProps({
|
||||
|
||||
@@ -106,9 +106,9 @@
|
||||
{{ templateData.defaultLocation.name }}
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="templateData.defaultTags && templateData.defaultTags.length > 0" class="mt-1">
|
||||
<span class="font-medium">{{ $t("global.tags") }}:</span>
|
||||
{{ templateData.defaultTags.map((t: any) => t.name).join(", ") }}
|
||||
<div v-if="templateData.defaultLabels && templateData.defaultLabels.length > 0" class="mt-1">
|
||||
<span class="font-medium">{{ $t("global.labels") }}:</span>
|
||||
{{ templateData.defaultLabels.map((l: any) => l.name).join(", ") }}
|
||||
</div>
|
||||
<div v-if="templateData.defaultDescription" class="mt-1">
|
||||
<p class="font-medium">{{ $t("components.template.form.item_description") }}:</p>
|
||||
@@ -153,7 +153,7 @@
|
||||
:label="$t('components.item.create_modal.item_description')"
|
||||
:max-length="1000"
|
||||
/>
|
||||
<TagSelector v-model="form.tags" :tags="tags ?? []" />
|
||||
<LabelSelector v-model="form.labels" :labels="labels ?? []" />
|
||||
<div class="flex w-full flex-col gap-1.5">
|
||||
<Label for="image-create-photo" class="flex w-full px-1">
|
||||
{{ $t("components.item.create_modal.item_photo") }}
|
||||
@@ -274,7 +274,7 @@
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import type { ItemCreate, ItemTemplateOut, ItemTemplateSummary, LocationOut } from "~~/lib/api/types/data-contracts";
|
||||
import { useTagStore } from "~/stores/tags";
|
||||
import { useLabelStore } from "~~/stores/labels";
|
||||
import { useLocationStore } from "~~/stores/locations";
|
||||
import MdiBarcode from "~icons/mdi/barcode";
|
||||
import MdiBarcodeScan from "~icons/mdi/barcode-scan";
|
||||
@@ -289,7 +289,7 @@
|
||||
import MdiClose from "~icons/mdi/close";
|
||||
import { AttachmentTypes } from "~~/lib/api/types/non-generated";
|
||||
import { useDialog, useDialogHotkey } from "~/components/ui/dialog-provider";
|
||||
import TagSelector from "~/components/Tag/Selector.vue";
|
||||
import LabelSelector from "~/components/Label/Selector.vue";
|
||||
import ItemSelector from "~/components/Item/Selector.vue";
|
||||
import TemplateSelector from "~/components/Template/Selector.vue";
|
||||
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "~/components/ui/tooltip";
|
||||
@@ -314,8 +314,8 @@
|
||||
const locationsStore = useLocationStore();
|
||||
const locations = computed(() => locationsStore.allLocations);
|
||||
|
||||
const tagStore = useTagStore();
|
||||
const tags = computed(() => tagStore.tags);
|
||||
const labelStore = useLabelStore();
|
||||
const labels = computed(() => labelStore.labels);
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
@@ -325,8 +325,8 @@
|
||||
const subItemCreateParam = useRouteQuery("subItemCreate", "n");
|
||||
const subItemCreate = ref();
|
||||
|
||||
const tagId = computed(() => {
|
||||
if (route.fullPath.includes("/tag/")) {
|
||||
const labelId = computed(() => {
|
||||
if (route.fullPath.includes("/label/")) {
|
||||
return route.params.id;
|
||||
}
|
||||
return null;
|
||||
@@ -362,7 +362,7 @@
|
||||
quantity: 1,
|
||||
description: "",
|
||||
color: "",
|
||||
tags: [] as string[],
|
||||
labels: [] as string[],
|
||||
photos: [] as PhotoPreview[],
|
||||
});
|
||||
|
||||
@@ -400,9 +400,9 @@
|
||||
form.location = found;
|
||||
}
|
||||
}
|
||||
// Pre-fill tags from template
|
||||
if (data.defaultTags && data.defaultTags.length > 0) {
|
||||
form.tags = data.defaultTags.map(l => l.id);
|
||||
// Pre-fill labels from template
|
||||
if (data.defaultLabels && data.defaultLabels.length > 0) {
|
||||
form.labels = data.defaultLabels.map(l => l.id);
|
||||
}
|
||||
|
||||
// Save template ID to localStorage for persistence
|
||||
@@ -440,9 +440,9 @@
|
||||
form.location = found;
|
||||
}
|
||||
}
|
||||
// Pre-fill tags from template
|
||||
if (data.defaultTags && data.defaultTags.length > 0) {
|
||||
form.tags = data.defaultTags.map(l => l.id);
|
||||
// Pre-fill labels from template
|
||||
if (data.defaultLabels && data.defaultLabels.length > 0) {
|
||||
form.labels = data.defaultLabels.map(l => l.id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -554,8 +554,8 @@
|
||||
}
|
||||
}
|
||||
|
||||
if (tagId.value) {
|
||||
form.tags = tags.value.filter(l => l.id === tagId.value).map(l => l.id);
|
||||
if (labelId.value) {
|
||||
form.labels = labels.value.filter(l => l.id === labelId.value).map(l => l.id);
|
||||
}
|
||||
|
||||
// Restore last used template if available
|
||||
@@ -588,7 +588,7 @@
|
||||
name: form.name,
|
||||
description: form.description,
|
||||
locationId: form.location.id as string,
|
||||
tagIds: form.tags,
|
||||
labelIds: form.labels,
|
||||
quantity: form.quantity,
|
||||
};
|
||||
|
||||
@@ -603,7 +603,7 @@
|
||||
quantity: form.quantity,
|
||||
description: form.description,
|
||||
locationId: form.location.id as string,
|
||||
tagIds: form.tags,
|
||||
labelIds: form.labels,
|
||||
};
|
||||
|
||||
const result = await api.items.create(out);
|
||||
@@ -649,7 +649,7 @@
|
||||
form.description = "";
|
||||
form.color = "";
|
||||
form.photos = [];
|
||||
form.tags = [];
|
||||
form.labels = [];
|
||||
selectedTemplate.value = null;
|
||||
templateData.value = null;
|
||||
showTemplateDetails.value = false;
|
||||
|
||||
@@ -3,51 +3,51 @@
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { useDialog } from "@/components/ui/dialog-provider";
|
||||
import { DialogID } from "~/components/ui/dialog-provider/utils";
|
||||
import type { ItemPatch, ItemSummary, TagOut, LocationSummary } from "~/lib/api/types/data-contracts";
|
||||
import type { ItemPatch, ItemSummary, LabelOut, LocationSummary } from "~/lib/api/types/data-contracts";
|
||||
import LocationSelector from "~/components/Location/Selector.vue";
|
||||
import MdiLoading from "~icons/mdi/loading";
|
||||
import { toast } from "~/components/ui/sonner";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import TagSelector from "~/components/Tag/Selector.vue";
|
||||
import LabelSelector from "~/components/Label/Selector.vue";
|
||||
|
||||
const { closeDialog, registerOpenDialogCallback } = useDialog();
|
||||
|
||||
const api = useUserApi();
|
||||
const { t } = useI18n();
|
||||
const tagStore = useTagStore();
|
||||
const labelStore = useLabelStore();
|
||||
|
||||
const allTags = computed(() => tagStore.tags);
|
||||
const allLabels = computed(() => labelStore.labels);
|
||||
|
||||
const items = ref<ItemSummary[]>([]);
|
||||
const saving = ref(false);
|
||||
|
||||
const enabled = reactive({
|
||||
changeLocation: false,
|
||||
addTags: false,
|
||||
removeTags: false,
|
||||
addLabels: false,
|
||||
removeLabels: false,
|
||||
});
|
||||
|
||||
const newLocation = ref<LocationSummary | null>(null);
|
||||
const addTags = ref<string[]>([]);
|
||||
const removeTags = ref<string[]>([]);
|
||||
const addLabels = ref<string[]>([]);
|
||||
const removeLabels = ref<string[]>([]);
|
||||
|
||||
const availableToAddTags = ref<TagOut[]>([]);
|
||||
const availableToRemoveTags = ref<TagOut[]>([]);
|
||||
const availableToAddLabels = ref<LabelOut[]>([]);
|
||||
const availableToRemoveLabels = ref<LabelOut[]>([]);
|
||||
|
||||
const intersectTagIds = (items: ItemSummary[]): string[] => {
|
||||
const intersectLabelIds = (items: ItemSummary[]): string[] => {
|
||||
if (items.length === 0) return [];
|
||||
const counts = new Map<string, number>();
|
||||
for (const it of items) {
|
||||
const seen = new Set<string>();
|
||||
for (const l of it.tags || []) seen.add(l.id);
|
||||
for (const l of it.labels || []) seen.add(l.id);
|
||||
for (const id of seen) counts.set(id, (counts.get(id) || 0) + 1);
|
||||
}
|
||||
return [...counts.entries()].filter(([_, c]) => c === items.length).map(([id]) => id);
|
||||
};
|
||||
|
||||
const unionTagIds = (items: ItemSummary[]): string[] => {
|
||||
const unionLabelIds = (items: ItemSummary[]): string[] => {
|
||||
const s = new Set<string>();
|
||||
for (const it of items) for (const l of it.tags || []) s.add(l.id);
|
||||
for (const it of items) for (const l of it.labels || []) s.add(l.id);
|
||||
return Array.from(s);
|
||||
};
|
||||
|
||||
@@ -55,8 +55,8 @@
|
||||
const cleanup = registerOpenDialogCallback(DialogID.ItemChangeDetails, params => {
|
||||
items.value = params.items;
|
||||
enabled.changeLocation = params.changeLocation ?? false;
|
||||
enabled.addTags = params.addTags ?? false;
|
||||
enabled.removeTags = params.removeTags ?? false;
|
||||
enabled.addLabels = params.addLabels ?? false;
|
||||
enabled.removeLabels = params.removeLabels ?? false;
|
||||
|
||||
if (params.changeLocation && params.items.length > 0) {
|
||||
// if all locations are the same then set the current location to said location
|
||||
@@ -68,14 +68,14 @@
|
||||
}
|
||||
}
|
||||
|
||||
if (params.addTags && params.items.length > 0) {
|
||||
const intersection = intersectTagIds(params.items);
|
||||
availableToAddTags.value = allTags.value.filter(l => !intersection.includes(l.id));
|
||||
if (params.addLabels && params.items.length > 0) {
|
||||
const intersection = intersectLabelIds(params.items);
|
||||
availableToAddLabels.value = allLabels.value.filter(l => !intersection.includes(l.id));
|
||||
}
|
||||
|
||||
if (params.removeTags && params.items.length > 0) {
|
||||
const union = unionTagIds(params.items);
|
||||
availableToRemoveTags.value = allTags.value.filter(l => union.includes(l.id));
|
||||
if (params.removeLabels && params.items.length > 0) {
|
||||
const union = unionLabelIds(params.items);
|
||||
availableToRemoveLabels.value = allLabels.value.filter(l => union.includes(l.id));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -84,8 +84,8 @@
|
||||
|
||||
const save = async () => {
|
||||
const location = newLocation.value;
|
||||
const tagsToAdd = addTags.value;
|
||||
const tagsToRemove = removeTags.value;
|
||||
const labelsToAdd = addLabels.value;
|
||||
const labelsToRemove = removeLabels.value;
|
||||
if (!items.value.length || (enabled.changeLocation && !location)) {
|
||||
return;
|
||||
}
|
||||
@@ -102,18 +102,18 @@
|
||||
patch.locationId = location!.id;
|
||||
}
|
||||
|
||||
let currentTags = item.tags.map(l => l.id);
|
||||
let currentLabels = item.labels.map(l => l.id);
|
||||
|
||||
if (enabled.addTags) {
|
||||
currentTags = currentTags.concat(tagsToAdd);
|
||||
if (enabled.addLabels) {
|
||||
currentLabels = currentLabels.concat(labelsToAdd);
|
||||
}
|
||||
|
||||
if (enabled.removeTags) {
|
||||
currentTags = currentTags.filter(l => !tagsToRemove.includes(l));
|
||||
if (enabled.removeLabels) {
|
||||
currentLabels = currentLabels.filter(l => !labelsToRemove.includes(l));
|
||||
}
|
||||
|
||||
if (enabled.addTags || enabled.removeTags) {
|
||||
patch.tagIds = Array.from(new Set(currentTags));
|
||||
if (enabled.addLabels || enabled.removeLabels) {
|
||||
patch.labelIds = Array.from(new Set(currentLabels));
|
||||
}
|
||||
|
||||
const { error, data } = await api.items.patch(item.id, patch);
|
||||
@@ -128,13 +128,13 @@
|
||||
|
||||
closeDialog(DialogID.ItemChangeDetails, true);
|
||||
enabled.changeLocation = false;
|
||||
enabled.addTags = false;
|
||||
enabled.removeTags = false;
|
||||
enabled.addLabels = false;
|
||||
enabled.removeLabels = false;
|
||||
items.value = [];
|
||||
addTags.value = [];
|
||||
removeTags.value = [];
|
||||
availableToAddTags.value = [];
|
||||
availableToRemoveTags.value = [];
|
||||
addLabels.value = [];
|
||||
removeLabels.value = [];
|
||||
availableToAddLabels.value = [];
|
||||
availableToRemoveLabels.value = [];
|
||||
saving.value = false;
|
||||
};
|
||||
</script>
|
||||
@@ -146,17 +146,17 @@
|
||||
<DialogTitle>{{ $t("components.item.view.change_details.title") }}</DialogTitle>
|
||||
</DialogHeader>
|
||||
<LocationSelector v-if="enabled.changeLocation" v-model="newLocation" />
|
||||
<TagSelector
|
||||
v-if="enabled.addTags"
|
||||
v-model="addTags"
|
||||
:tags="availableToAddTags"
|
||||
:name="$t('components.item.view.change_details.add_tags')"
|
||||
<LabelSelector
|
||||
v-if="enabled.addLabels"
|
||||
v-model="addLabels"
|
||||
:labels="availableToAddLabels"
|
||||
:name="$t('components.item.view.change_details.add_labels')"
|
||||
/>
|
||||
<TagSelector
|
||||
v-if="enabled.removeTags"
|
||||
v-model="removeTags"
|
||||
:tags="availableToRemoveTags"
|
||||
:name="$t('components.item.view.change_details.remove_tags')"
|
||||
<LabelSelector
|
||||
v-if="enabled.removeLabels"
|
||||
v-model="removeLabels"
|
||||
:labels="availableToRemoveLabels"
|
||||
:name="$t('components.item.view.change_details.remove_labels')"
|
||||
/>
|
||||
<DialogFooter>
|
||||
<Button type="submit" :disabled="saving || (enabled.changeLocation && !newLocation)" @click="save">
|
||||
|
||||
@@ -205,25 +205,25 @@
|
||||
>
|
||||
{{ t("components.item.view.table.dropdown.change_location") }}
|
||||
</DropdownMenuItem>
|
||||
<!-- change tags -->
|
||||
<!-- change labels -->
|
||||
<DropdownMenuItem
|
||||
@click="
|
||||
openDialog(DialogID.ItemChangeDetails, {
|
||||
params: {
|
||||
items: multi ? multi.items.map(row => row.original) : [item!],
|
||||
addTags: true,
|
||||
removeTags: true,
|
||||
addLabels: true,
|
||||
removeLabels: true,
|
||||
},
|
||||
onClose: result => {
|
||||
if (result) {
|
||||
toast.success(t('components.item.view.table.dropdown.change_tags_success'));
|
||||
toast.success(t('components.item.view.table.dropdown.change_labels_success'));
|
||||
resetSelection();
|
||||
}
|
||||
},
|
||||
})
|
||||
"
|
||||
>
|
||||
{{ t("components.item.view.table.dropdown.change_tags") }}
|
||||
{{ t("components.item.view.table.dropdown.change_labels") }}
|
||||
</DropdownMenuItem>
|
||||
<!-- maintenance -->
|
||||
<DropdownMenuItem
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from "vue";
|
||||
import type { ItemSummary } from "~/lib/api/types/data-contracts";
|
||||
import TagChip from "@/components/Tag/Chip.vue";
|
||||
import LabelChip from "@/components/Label/Chip.vue";
|
||||
import Badge from "~/components/ui/badge/Badge.vue";
|
||||
|
||||
const props = defineProps<{
|
||||
@@ -35,7 +35,7 @@
|
||||
</NuxtLink>
|
||||
</Badge>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<TagChip v-for="tag in item.tags" :key="tag.id" :tag="tag" size="sm" />
|
||||
<LabelChip v-for="label in item.labels" :key="label.id" :label="label" size="sm" />
|
||||
</div>
|
||||
<p class="whitespace-pre-line break-words text-sm text-muted-foreground">
|
||||
{{ item.description || $t("components.item.no_description") }}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
<script setup lang="ts">
|
||||
import type { TagOut, TagSummary } from "~~/lib/api/types/data-contracts";
|
||||
import type { LabelOut, LabelSummary } from "~~/lib/api/types/data-contracts";
|
||||
import MdiArrowUp from "~icons/mdi/arrow-up";
|
||||
import MdiTagOutline from "~icons/mdi/tag-outline";
|
||||
import { getContrastTextColor } from "~/lib/utils";
|
||||
|
||||
export type sizes = "sm" | "md" | "lg" | "xl";
|
||||
defineProps({
|
||||
tag: {
|
||||
type: Object as () => TagOut | TagSummary,
|
||||
label: {
|
||||
type: Object as () => LabelOut | LabelSummary,
|
||||
required: true,
|
||||
},
|
||||
size: {
|
||||
@@ -19,29 +19,29 @@
|
||||
|
||||
<template>
|
||||
<NuxtLink
|
||||
class="group/tag-chip flex gap-2 rounded-full shadow transition duration-300 hover:bg-accent/50"
|
||||
class="group/label-chip flex gap-2 rounded-full shadow transition duration-300 hover:bg-accent/50"
|
||||
:class="{
|
||||
'p-4 py-1 text-base': size === 'lg',
|
||||
'p-3 py-1 text-sm': size !== 'sm' && size !== 'lg',
|
||||
'p-2 py-0.5 text-xs': size === 'sm',
|
||||
}"
|
||||
:style="
|
||||
tag.color
|
||||
? { backgroundColor: tag.color, color: getContrastTextColor(tag.color) }
|
||||
label.color
|
||||
? { backgroundColor: label.color, color: getContrastTextColor(label.color) }
|
||||
: { backgroundColor: 'hsl(var(--accent))' }
|
||||
"
|
||||
:to="`/tag/${tag.id}`"
|
||||
:to="`/label/${label.id}`"
|
||||
>
|
||||
<div class="relative">
|
||||
<MdiTagOutline class="invisible" /><!-- hack to ensure the size is correct -->
|
||||
|
||||
<div
|
||||
class="absolute inset-0 flex items-center justify-center transition-transform duration-300 group-hover/tag-chip:rotate-90"
|
||||
class="absolute inset-0 flex items-center justify-center transition-transform duration-300 group-hover/label-chip:rotate-90"
|
||||
>
|
||||
<MdiTagOutline class="group-hover/tag-chip:hidden" />
|
||||
<MdiArrowUp class="hidden group-hover/tag-chip:block" />
|
||||
<MdiTagOutline class="group-hover/label-chip:hidden" />
|
||||
<MdiArrowUp class="hidden group-hover/label-chip:block" />
|
||||
</div>
|
||||
</div>
|
||||
{{ tag.name }}
|
||||
{{ label.name }}
|
||||
</NuxtLink>
|
||||
</template>
|
||||
@@ -1,20 +1,20 @@
|
||||
<template>
|
||||
<BaseModal :dialog-id="DialogID.CreateTag" :title="$t('components.tag.create_modal.title')">
|
||||
<BaseModal :dialog-id="DialogID.CreateLabel" :title="$t('components.label.create_modal.title')">
|
||||
<form class="flex min-w-0 flex-col gap-2" @submit.prevent="create()">
|
||||
<FormTextField
|
||||
v-model="form.name"
|
||||
:trigger-focus="focused"
|
||||
:autofocus="true"
|
||||
:label="$t('components.tag.create_modal.tag_name')"
|
||||
:label="$t('components.label.create_modal.label_name')"
|
||||
:max-length="50"
|
||||
:min-length="1"
|
||||
/>
|
||||
<FormTextArea
|
||||
v-model="form.description"
|
||||
:label="$t('components.tag.create_modal.tag_description')"
|
||||
:label="$t('components.label.create_modal.label_description')"
|
||||
:max-length="1000"
|
||||
/>
|
||||
<ColorSelector v-model="form.color" :label="$t('components.tag.create_modal.tag_color')" :show-hex="true" />
|
||||
<ColorSelector v-model="form.color" :label="$t('components.label.create_modal.label_color')" :show-hex="true" />
|
||||
<div class="mt-4 flex flex-row-reverse">
|
||||
<ButtonGroup>
|
||||
<Button :disabled="loading" type="submit">{{ $t("global.create") }}</Button>
|
||||
@@ -42,7 +42,7 @@
|
||||
|
||||
const { closeDialog } = useDialog();
|
||||
|
||||
useDialogHotkey(DialogID.CreateTag, { code: "Digit2", shift: true });
|
||||
useDialogHotkey(DialogID.CreateLabel, { code: "Digit2", shift: true });
|
||||
|
||||
const loading = ref(false);
|
||||
const focused = ref(false);
|
||||
@@ -65,11 +65,11 @@
|
||||
|
||||
async function create(close = true) {
|
||||
if (loading.value) {
|
||||
toast.error(t("components.tag.create_modal.toast.already_creating"));
|
||||
toast.error(t("components.label.create_modal.toast.already_creating"));
|
||||
return;
|
||||
}
|
||||
if (form.name.length > 50) {
|
||||
toast.error(t("components.tag.create_modal.toast.tag_name_too_long"));
|
||||
toast.error(t("components.label.create_modal.toast.label_name_too_long"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -77,20 +77,20 @@
|
||||
|
||||
if (shift?.value) close = false;
|
||||
|
||||
const { error, data } = await api.tags.create(form);
|
||||
const { error, data } = await api.labels.create(form);
|
||||
|
||||
if (error) {
|
||||
toast.error(t("components.tag.create_modal.toast.create_failed"));
|
||||
toast.error(t("components.label.create_modal.toast.create_failed"));
|
||||
loading.value = false;
|
||||
return;
|
||||
}
|
||||
|
||||
toast.success(t("components.tag.create_modal.toast.create_success"));
|
||||
toast.success(t("components.label.create_modal.toast.create_success"));
|
||||
reset();
|
||||
|
||||
if (close) {
|
||||
closeDialog(DialogID.CreateTag);
|
||||
navigateTo(`/tag/${data.id}`);
|
||||
closeDialog(DialogID.CreateLabel);
|
||||
navigateTo(`/label/${data.id}`);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -1,20 +1,20 @@
|
||||
<template>
|
||||
<div class="flex flex-col gap-1">
|
||||
<Label :for="id" class="px-1">
|
||||
{{ props.name ?? $t("global.tags") }}
|
||||
{{ props.name ?? $t("global.labels") }}
|
||||
</Label>
|
||||
|
||||
<TagsInput
|
||||
v-model="modelValue"
|
||||
class="w-full gap-0 px-0"
|
||||
:display-value="v => props.tags.find(t => t.id === v)?.name ?? 'Loading...'"
|
||||
:display-value="v => props.labels.find(l => l.id === v)?.name ?? 'Loading...'"
|
||||
>
|
||||
<div class="flex flex-wrap items-center gap-2 overflow-hidden px-3">
|
||||
<TagsInputItem v-for="item in modelValue" :key="item" :value="item" class="h-auto overflow-hidden text-wrap">
|
||||
<span
|
||||
v-if="props.tags.find(t => t.id === item)?.color"
|
||||
v-if="props.labels.find(l => l.id === item)?.color"
|
||||
class="ml-2 size-4 shrink-0 rounded-full"
|
||||
:style="{ backgroundColor: props.tags.find(t => t.id === item)?.color }"
|
||||
:style="{ backgroundColor: props.labels.find(l => l.id === item)?.color }"
|
||||
/>
|
||||
<TagsInputItemText class="py-0.5" />
|
||||
<TagsInputItemDelete />
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
<ComboboxRoot v-model="modelValue" v-model:open="open" class="w-full" :ignore-filter="true">
|
||||
<ComboboxAnchor as-child>
|
||||
<ComboboxInput v-model="searchTerm" :placeholder="$t('components.tag.selector.select_tags')" as-child>
|
||||
<ComboboxInput v-model="searchTerm" :placeholder="$t('components.label.selector.select_labels')" as-child>
|
||||
<TagsInputInput
|
||||
:id="id"
|
||||
class="w-full px-3"
|
||||
@@ -42,9 +42,9 @@
|
||||
<CommandEmpty />
|
||||
<CommandGroup>
|
||||
<CommandItem
|
||||
v-for="tag in filteredTags"
|
||||
:key="tag.value"
|
||||
:value="tag.value"
|
||||
v-for="label in filteredLabels"
|
||||
:key="label.value"
|
||||
:value="label.value"
|
||||
@select.prevent="
|
||||
ev => {
|
||||
if (typeof ev.detail.value === 'string') {
|
||||
@@ -62,10 +62,10 @@
|
||||
>
|
||||
<span
|
||||
class="mr-2 size-4 shrink-0 rounded-full align-middle"
|
||||
:class="{ border: props.tags.find(t => t.id === tag.value)?.color }"
|
||||
:style="{ backgroundColor: props.tags.find(t => t.id === tag.value)?.color }"
|
||||
:class="{ border: props.labels.find(l => l.id === label.value)?.color }"
|
||||
:style="{ backgroundColor: props.labels.find(l => l.id === label.value)?.color }"
|
||||
/>
|
||||
{{ tag.label }}
|
||||
{{ label.label }}
|
||||
</CommandItem>
|
||||
</CommandGroup>
|
||||
</CommandList>
|
||||
@@ -89,7 +89,7 @@
|
||||
TagsInputItemDelete,
|
||||
TagsInputItemText,
|
||||
} from "@/components/ui/tags-input";
|
||||
import type { TagOut } from "~/lib/api/types/data-contracts";
|
||||
import type { LabelOut } from "~/lib/api/types/data-contracts";
|
||||
import { Label } from "@/components/ui/label";
|
||||
|
||||
const { t } = useI18n();
|
||||
@@ -104,8 +104,8 @@
|
||||
type: Array as () => string[],
|
||||
default: null,
|
||||
},
|
||||
tags: {
|
||||
type: Array as () => TagOut[],
|
||||
labels: {
|
||||
type: Array as () => LabelOut[],
|
||||
required: true,
|
||||
},
|
||||
name: {
|
||||
@@ -120,9 +120,9 @@
|
||||
const open = ref(false);
|
||||
const searchTerm = ref("");
|
||||
|
||||
const filteredTags = computed(() => {
|
||||
const filteredLabels = computed(() => {
|
||||
const filtered = fuzzysort
|
||||
.go(searchTerm.value, props.tags, { key: "name", all: true })
|
||||
.go(searchTerm.value, props.labels, { key: "name", all: true })
|
||||
.map(l => ({
|
||||
value: l.obj.id,
|
||||
label: l.obj.name,
|
||||
@@ -132,7 +132,7 @@
|
||||
// Only show "Create" option if search term is not empty and no exact match exists
|
||||
if (searchTerm.value.trim() !== "") {
|
||||
const trimmedSearchTerm = searchTerm.value.trim();
|
||||
const hasExactMatch = props.tags.some(tag => tag.name.toLowerCase() === trimmedSearchTerm.toLowerCase());
|
||||
const hasExactMatch = props.labels.some(label => label.name.toLowerCase() === trimmedSearchTerm.toLowerCase());
|
||||
|
||||
if (!hasExactMatch) {
|
||||
filtered.push({ value: "create-item", label: `${t("global.create")} ${searchTerm.value}` });
|
||||
@@ -144,24 +144,24 @@
|
||||
|
||||
const createAndAdd = async (name: string, color = "") => {
|
||||
if (name.length > 50) {
|
||||
toast.error(t("components.tag.create_modal.toast.tag_name_too_long"));
|
||||
toast.error(t("components.label.create_modal.toast.label_name_too_long"));
|
||||
return;
|
||||
}
|
||||
const { error, data } = await api.tags.create({
|
||||
const { error, data } = await api.labels.create({
|
||||
name,
|
||||
color,
|
||||
description: "",
|
||||
});
|
||||
|
||||
if (error) {
|
||||
toast.error(t("components.tag.create_modal.toast.create_failed"));
|
||||
toast.error(t("components.label.create_modal.toast.create_failed"));
|
||||
return;
|
||||
}
|
||||
|
||||
toast.success(t("components.tag.create_modal.toast.create_success"));
|
||||
toast.success(t("components.label.create_modal.toast.create_success"));
|
||||
|
||||
modelValue.value = [...modelValue.value, data.id];
|
||||
};
|
||||
|
||||
// TODO: when reka-ui 2 is release use hook to set cursor to end when tag is added with click
|
||||
// TODO: when reka-ui 2 is release use hook to set cursor to end when label is added with click
|
||||
</script>
|
||||
@@ -59,7 +59,7 @@
|
||||
defaultLifetimeWarranty: fullTemplate.defaultLifetimeWarranty,
|
||||
defaultWarrantyDetails: fullTemplate.defaultWarrantyDetails,
|
||||
defaultLocationId: fullTemplate.defaultLocation?.id ?? null,
|
||||
defaultTagIds: fullTemplate.defaultTags?.map(l => l.id) ?? [],
|
||||
defaultLabelIds: fullTemplate.defaultLabels?.map(l => l.id) || [],
|
||||
includeWarrantyFields: fullTemplate.includeWarrantyFields,
|
||||
includePurchaseFields: fullTemplate.includePurchaseFields,
|
||||
includeSoldFields: fullTemplate.includeSoldFields,
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
v-model="form.defaultLocationObject"
|
||||
:label="$t('components.template.form.default_location')"
|
||||
/>
|
||||
<TagSelector v-model="form.defaultTagIds" :tags="tags ?? []" />
|
||||
<LabelSelector v-model="form.defaultLabelIds" :labels="labels ?? []" />
|
||||
<div class="flex items-center gap-4">
|
||||
<div class="flex items-center gap-2">
|
||||
<Switch id="defaultInsured" v-model:checked="form.defaultInsured" />
|
||||
@@ -105,15 +105,15 @@
|
||||
import { Switch } from "@/components/ui/switch";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import LocationSelector from "~/components/Location/Selector.vue";
|
||||
import TagSelector from "~/components/Tag/Selector.vue";
|
||||
import { useTagStore } from "~/stores/tags";
|
||||
import LabelSelector from "~/components/Label/Selector.vue";
|
||||
import { useLabelStore } from "~~/stores/labels";
|
||||
import type { LocationSummary } from "~~/lib/api/types/data-contracts";
|
||||
|
||||
const emit = defineEmits<{ created: [] }>();
|
||||
const { closeDialog } = useDialog();
|
||||
|
||||
const tagStore = useTagStore();
|
||||
const tags = computed(() => tagStore.tags);
|
||||
const labelStore = useLabelStore();
|
||||
const labels = computed(() => labelStore.labels);
|
||||
|
||||
const loading = ref(false);
|
||||
const form = reactive({
|
||||
@@ -130,7 +130,7 @@
|
||||
defaultWarrantyDetails: "",
|
||||
defaultLocationId: null as string | null,
|
||||
defaultLocationObject: null as LocationSummary | null,
|
||||
defaultTagIds: [] as string[],
|
||||
defaultLabelIds: [] as string[],
|
||||
includeWarrantyFields: false,
|
||||
includePurchaseFields: false,
|
||||
includeSoldFields: false,
|
||||
@@ -158,7 +158,7 @@
|
||||
defaultWarrantyDetails: "",
|
||||
defaultLocationId: null,
|
||||
defaultLocationObject: null,
|
||||
defaultTagIds: [],
|
||||
defaultLabelIds: [],
|
||||
includeWarrantyFields: false,
|
||||
includePurchaseFields: false,
|
||||
includeSoldFields: false,
|
||||
@@ -189,7 +189,7 @@
|
||||
defaultLifetimeWarranty: form.defaultLifetimeWarranty,
|
||||
defaultWarrantyDetails: form.defaultWarrantyDetails || null,
|
||||
defaultLocationId: form.defaultLocationObject?.id ?? null,
|
||||
defaultTagIds: form.defaultTagIds,
|
||||
defaultLabelIds: form.defaultLabelIds,
|
||||
includeWarrantyFields: form.includeWarrantyFields,
|
||||
includePurchaseFields: form.includePurchaseFields,
|
||||
includeSoldFields: form.includeSoldFields,
|
||||
|
||||
@@ -10,9 +10,14 @@
|
||||
|
||||
<div class="space-y-2">
|
||||
<div class="flex items-center space-x-2">
|
||||
<input id="wipe-tags-checkbox" v-model="wipeTags" type="checkbox" class="size-4 rounded border-gray-300" />
|
||||
<label for="wipe-tags-checkbox" class="cursor-pointer text-sm font-medium">
|
||||
{{ $t("tools.actions_set.wipe_inventory_tags") }}
|
||||
<input
|
||||
id="wipe-labels-checkbox"
|
||||
v-model="wipeLabels"
|
||||
type="checkbox"
|
||||
class="size-4 rounded border-gray-300"
|
||||
/>
|
||||
<label for="wipe-labels-checkbox" class="cursor-pointer text-sm font-medium">
|
||||
{{ $t("tools.actions_set.wipe_inventory_labels") }}
|
||||
</label>
|
||||
</div>
|
||||
|
||||
@@ -74,14 +79,14 @@
|
||||
const { registerOpenDialogCallback, closeDialog, addAlert, removeAlert } = useDialog();
|
||||
|
||||
const dialog = ref(false);
|
||||
const wipeTags = ref(false);
|
||||
const wipeLabels = ref(false);
|
||||
const wipeLocations = ref(false);
|
||||
const wipeMaintenance = ref(false);
|
||||
const isConfirming = ref(false);
|
||||
|
||||
registerOpenDialogCallback(DialogID.WipeInventory, () => {
|
||||
dialog.value = true;
|
||||
wipeTags.value = false;
|
||||
wipeLabels.value = false;
|
||||
wipeLocations.value = false;
|
||||
wipeMaintenance.value = false;
|
||||
isConfirming.value = false;
|
||||
@@ -113,7 +118,7 @@
|
||||
function confirm() {
|
||||
isConfirming.value = true;
|
||||
const result = {
|
||||
wipeTags: wipeTags.value,
|
||||
wipeLabels: wipeLabels.value,
|
||||
wipeLocations: wipeLocations.value,
|
||||
wipeMaintenance: wipeMaintenance.value,
|
||||
};
|
||||
|
||||
@@ -8,7 +8,7 @@ export enum DialogID {
|
||||
ChangePassword = "changePassword",
|
||||
CreateItem = "create-item",
|
||||
CreateLocation = "create-location",
|
||||
CreateTag = "create-tag",
|
||||
CreateLabel = "create-label",
|
||||
CreateNotifier = "create-notifier",
|
||||
CreateTemplate = "create-template",
|
||||
DuplicateSettings = "duplicate-settings",
|
||||
@@ -22,7 +22,7 @@ export enum DialogID {
|
||||
QuickMenu = "quick-menu",
|
||||
Scanner = "scanner",
|
||||
PageQRCode = "page-qr-code",
|
||||
UpdateTag = "update-tag",
|
||||
UpdateLabel = "update-label",
|
||||
UpdateLocation = "update-location",
|
||||
UpdateTemplate = "update-template",
|
||||
ItemChangeDetails = "item-table-updater",
|
||||
@@ -60,8 +60,8 @@ export type DialogParamsMap = {
|
||||
[DialogID.ItemChangeDetails]: {
|
||||
items: ItemSummary[];
|
||||
changeLocation?: boolean;
|
||||
addTags?: boolean;
|
||||
removeTags?: boolean;
|
||||
addLabels?: boolean;
|
||||
removeLabels?: boolean;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -72,7 +72,7 @@ export type DialogResultMap = {
|
||||
[DialogID.ItemImage]?: { action: "delete"; id: string };
|
||||
[DialogID.EditMaintenance]?: boolean;
|
||||
[DialogID.ItemChangeDetails]?: boolean;
|
||||
[DialogID.WipeInventory]?: { wipeTags: boolean; wipeLocations: boolean; wipeMaintenance: boolean };
|
||||
[DialogID.WipeInventory]?: { wipeLabels: boolean; wipeLocations: boolean; wipeMaintenance: boolean };
|
||||
};
|
||||
|
||||
/** Helpers to split IDs by requirement */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { ItemSummary, TagSummary, LocationSummary } from "~~/lib/api/types/data-contracts";
|
||||
import type { ItemSummary, LabelSummary, LocationSummary } from "~~/lib/api/types/data-contracts";
|
||||
import type { UserClient } from "~~/lib/api/user";
|
||||
|
||||
type SearchOptions = {
|
||||
@@ -8,7 +8,7 @@ type SearchOptions = {
|
||||
export function useItemSearch(client: UserClient, opts?: SearchOptions) {
|
||||
const query = ref("");
|
||||
const locations = ref<LocationSummary[]>([]);
|
||||
const tags = ref<TagSummary[]>([]);
|
||||
const labels = ref<LabelSummary[]>([]);
|
||||
const results = ref<ItemSummary[]>([]);
|
||||
const includeArchived = ref(false);
|
||||
const isLoading = ref(false);
|
||||
@@ -26,12 +26,12 @@ export function useItemSearch(client: UserClient, opts?: SearchOptions) {
|
||||
isLoading.value = true;
|
||||
try {
|
||||
const locIds = locations.value.map(l => l.id);
|
||||
const tagIds = tags.value.map(t => t.id);
|
||||
const labelIds = labels.value.map(l => l.id);
|
||||
|
||||
const { data, error } = await client.items.getAll({
|
||||
q: searchQuery,
|
||||
locations: locIds,
|
||||
tags: tagIds,
|
||||
labels: labelIds,
|
||||
includeArchived: includeArchived.value,
|
||||
});
|
||||
|
||||
@@ -85,7 +85,7 @@ export function useItemSearch(client: UserClient, opts?: SearchOptions) {
|
||||
query,
|
||||
results,
|
||||
locations,
|
||||
tags,
|
||||
labels,
|
||||
isLoading,
|
||||
triggerSearch,
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
export enum ServerEvent {
|
||||
LocationMutation = "location.mutation",
|
||||
ItemMutation = "item.mutation",
|
||||
TagMutation = "tag.mutation",
|
||||
LabelMutation = "label.mutation",
|
||||
}
|
||||
|
||||
export type EventMessage = {
|
||||
@@ -43,7 +43,7 @@ function connect(onmessage: (m: EventMessage) => void) {
|
||||
|
||||
thorttled.set(ServerEvent.LocationMutation, useThrottleFn(onmessage, 1000));
|
||||
thorttled.set(ServerEvent.ItemMutation, useThrottleFn(onmessage, 1000));
|
||||
thorttled.set(ServerEvent.TagMutation, useThrottleFn(onmessage, 1000));
|
||||
thorttled.set(ServerEvent.LabelMutation, useThrottleFn(onmessage, 1000));
|
||||
|
||||
ws.onmessage = msg => {
|
||||
const pm = JSON.parse(msg.data);
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<OutdatedModal v-if="status" :status="status" />
|
||||
<ItemCreateModal />
|
||||
<WipeInventoryDialog />
|
||||
<TagCreateModal />
|
||||
<LabelCreateModal />
|
||||
<LocationCreateModal />
|
||||
<ItemBarcodeModal />
|
||||
<AppQuickMenuModal :actions="quickMenuActions" />
|
||||
@@ -172,7 +172,7 @@
|
||||
<script lang="ts" setup>
|
||||
import { useI18n } from "vue-i18n";
|
||||
import DOMPurify from "dompurify";
|
||||
import { useTagStore } from "~/stores/tags";
|
||||
import { useLabelStore } from "~~/stores/labels";
|
||||
import { useLocationStore } from "~~/stores/locations";
|
||||
|
||||
import MdiHome from "~icons/mdi/home";
|
||||
@@ -219,7 +219,7 @@
|
||||
import ItemCreateModal from "~/components/Item/CreateModal.vue";
|
||||
import WipeInventoryDialog from "~/components/WipeInventoryDialog.vue";
|
||||
|
||||
import TagCreateModal from "~/components/Tag/CreateModal.vue";
|
||||
import LabelCreateModal from "~/components/Label/CreateModal.vue";
|
||||
import LocationCreateModal from "~/components/Location/CreateModal.vue";
|
||||
import ItemBarcodeModal from "~/components/Item/BarcodeModal.vue";
|
||||
import AppQuickMenuModal from "~/components/App/QuickMenuModal.vue";
|
||||
@@ -303,9 +303,9 @@
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: computed(() => t("menu.create_tag")),
|
||||
name: computed(() => t("menu.create_label")),
|
||||
shortcut: "Shift+2",
|
||||
dialogId: DialogID.CreateTag,
|
||||
dialogId: DialogID.CreateLabel,
|
||||
},
|
||||
];
|
||||
|
||||
@@ -377,8 +377,8 @@
|
||||
})),
|
||||
]);
|
||||
|
||||
const tagStore = useTagStore();
|
||||
tagStore.ensureAllTagsFetched();
|
||||
const labelStore = useLabelStore();
|
||||
labelStore.ensureAllLabelsFetched();
|
||||
|
||||
const locationStore = useLocationStore();
|
||||
locationStore.ensureLocationsFetched();
|
||||
@@ -388,8 +388,8 @@
|
||||
locationStore.refreshTree();
|
||||
});
|
||||
|
||||
onServerEvent(ServerEvent.TagMutation, () => {
|
||||
tagStore.refresh();
|
||||
onServerEvent(ServerEvent.LabelMutation, () => {
|
||||
labelStore.refresh();
|
||||
});
|
||||
|
||||
onServerEvent(ServerEvent.LocationMutation, () => {
|
||||
|
||||
@@ -5,7 +5,7 @@ import { PublicApi } from "../../public";
|
||||
import type {
|
||||
ItemField,
|
||||
ItemTemplateCreate,
|
||||
TagCreate,
|
||||
LabelCreate,
|
||||
LocationCreate,
|
||||
UserRegistration,
|
||||
} from "../../types/data-contracts";
|
||||
@@ -47,7 +47,7 @@ function location(parentId: string | null = null): LocationCreate {
|
||||
};
|
||||
}
|
||||
|
||||
function tag(): TagCreate {
|
||||
function label(): LabelCreate {
|
||||
return {
|
||||
name: faker.lorem.word(),
|
||||
description: faker.lorem.sentence(),
|
||||
@@ -69,7 +69,7 @@ function template(): ItemTemplateCreate {
|
||||
defaultLifetimeWarranty: false,
|
||||
defaultWarrantyDetails: "",
|
||||
defaultLocationId: null,
|
||||
defaultTagIds: null,
|
||||
defaultLabelIds: null,
|
||||
includeWarrantyFields: false,
|
||||
includePurchaseFields: false,
|
||||
includeSoldFields: false,
|
||||
@@ -113,7 +113,7 @@ async function userSingleUse(): Promise<TestUser> {
|
||||
export const factories = {
|
||||
user,
|
||||
location,
|
||||
tag,
|
||||
label,
|
||||
template,
|
||||
itemField,
|
||||
client: {
|
||||
|
||||
@@ -36,7 +36,7 @@ describe("user should be able to create an item and add an attachment", () => {
|
||||
const { response, data: item } = await api.items.create({
|
||||
parentId: null,
|
||||
name: "test-item",
|
||||
tagIds: [],
|
||||
labelIds: [],
|
||||
description: "test-description",
|
||||
quantity: 2,
|
||||
locationId: location.id,
|
||||
@@ -71,7 +71,7 @@ describe("user should be able to create an item and add an attachment", () => {
|
||||
const { response, data: item } = await api.items.create({
|
||||
parentId: null,
|
||||
name: faker.vehicle.model(),
|
||||
tagIds: [],
|
||||
labelIds: [],
|
||||
description: faker.lorem.paragraph(1),
|
||||
quantity: 2,
|
||||
locationId: location.id,
|
||||
@@ -90,7 +90,7 @@ describe("user should be able to create an item and add an attachment", () => {
|
||||
parentId: null,
|
||||
...item,
|
||||
locationId: item.location?.id || null,
|
||||
tagIds: item.tags.map(l => l.id),
|
||||
labelIds: item.labels.map(l => l.id),
|
||||
fields,
|
||||
};
|
||||
|
||||
@@ -126,7 +126,7 @@ describe("user should be able to create an item and add an attachment", () => {
|
||||
const { response, data: item } = await api.items.create({
|
||||
parentId: null,
|
||||
name: faker.vehicle.model(),
|
||||
tagIds: [],
|
||||
labelIds: [],
|
||||
description: faker.lorem.paragraph(1),
|
||||
quantity: 2,
|
||||
locationId: location.id,
|
||||
@@ -178,7 +178,7 @@ describe("user should be able to create an item and add an attachment", () => {
|
||||
|
||||
const { response, data: item } = await api.items.create({
|
||||
name: faker.vehicle.model(),
|
||||
tagIds: [],
|
||||
labelIds: [],
|
||||
description: faker.lorem.paragraph(1),
|
||||
quantity: 2,
|
||||
locationId: lastLocationId,
|
||||
@@ -203,7 +203,7 @@ describe("user should be able to create an item and add an attachment", () => {
|
||||
|
||||
const { response: parentResponse, data: parent } = await api.items.create({
|
||||
name: "parent-item",
|
||||
tagIds: [],
|
||||
labelIds: [],
|
||||
description: "test-description",
|
||||
quantity: 2,
|
||||
locationId: parentLocation.id,
|
||||
@@ -213,7 +213,7 @@ describe("user should be able to create an item and add an attachment", () => {
|
||||
|
||||
const { response: child1Response, data: child1Item } = await api.items.create({
|
||||
name: "child1-item",
|
||||
tagIds: [],
|
||||
labelIds: [],
|
||||
description: "test-description",
|
||||
quantity: 2,
|
||||
locationId: childsLocation.id,
|
||||
@@ -223,14 +223,14 @@ describe("user should be able to create an item and add an attachment", () => {
|
||||
parentId: parent.id,
|
||||
...child1Item,
|
||||
locationId: child1Item.location?.id,
|
||||
tagIds: [],
|
||||
labelIds: [],
|
||||
};
|
||||
const { response: child1UpdatedResponse } = await api.items.update(child1Item.id, child1ItemUpdate as ItemUpdate);
|
||||
expect(child1UpdatedResponse.status).toBe(200);
|
||||
|
||||
const { response: child2Response, data: child2Item } = await api.items.create({
|
||||
name: "child2-item",
|
||||
tagIds: [],
|
||||
labelIds: [],
|
||||
description: "test-description",
|
||||
quantity: 2,
|
||||
locationId: childsLocation.id,
|
||||
@@ -240,7 +240,7 @@ describe("user should be able to create an item and add an attachment", () => {
|
||||
parentId: parent.id,
|
||||
...child2Item,
|
||||
locationId: child2Item.location?.id,
|
||||
tagIds: [],
|
||||
labelIds: [],
|
||||
};
|
||||
const { response: child2UpdatedResponse } = await api.items.update(child2Item.id, child2ItemUpdate as ItemUpdate);
|
||||
expect(child2UpdatedResponse.status).toBe(200);
|
||||
@@ -249,7 +249,7 @@ describe("user should be able to create an item and add an attachment", () => {
|
||||
parentId: null,
|
||||
...parent,
|
||||
locationId: parentLocation.id,
|
||||
tagIds: [],
|
||||
labelIds: [],
|
||||
syncChildItemsLocations: true,
|
||||
};
|
||||
const { response: updateResponse } = await api.items.update(parent.id, itemUpdate);
|
||||
|
||||
82
frontend/lib/api/__test__/user/labels.test.ts
Normal file
82
frontend/lib/api/__test__/user/labels.test.ts
Normal file
@@ -0,0 +1,82 @@
|
||||
import { describe, expect, test } from "vitest";
|
||||
import type { LabelOut } from "../../types/data-contracts";
|
||||
import type { UserClient } from "../../user";
|
||||
import { factories } from "../factories";
|
||||
import { sharedUserClient } from "../test-utils";
|
||||
|
||||
describe("locations lifecycle (create, update, delete)", () => {
|
||||
/**
|
||||
* useLabel sets up a label resource for testing, and returns a function
|
||||
* that can be used to delete the label from the backend server.
|
||||
*/
|
||||
async function useLabel(api: UserClient): Promise<[LabelOut, () => Promise<void>]> {
|
||||
const { response, data } = await api.labels.create(factories.label());
|
||||
expect(response.status).toBe(201);
|
||||
|
||||
const cleanup = async () => {
|
||||
const { response } = await api.labels.delete(data.id);
|
||||
expect(response.status).toBe(204);
|
||||
};
|
||||
return [data, cleanup];
|
||||
}
|
||||
|
||||
test("user should be able to create a label", async () => {
|
||||
const api = await sharedUserClient();
|
||||
|
||||
const labelData = factories.label();
|
||||
|
||||
const { response, data } = await api.labels.create(labelData);
|
||||
|
||||
expect(response.status).toBe(201);
|
||||
expect(data.id).toBeTruthy();
|
||||
|
||||
// Ensure we can get the label
|
||||
const { response: getResponse, data: getData } = await api.labels.get(data.id);
|
||||
|
||||
expect(getResponse.status).toBe(200);
|
||||
expect(getData.id).toBe(data.id);
|
||||
expect(getData.name).toBe(labelData.name);
|
||||
expect(getData.description).toBe(labelData.description);
|
||||
|
||||
// Cleanup
|
||||
const { response: deleteResponse } = await api.labels.delete(data.id);
|
||||
expect(deleteResponse.status).toBe(204);
|
||||
});
|
||||
|
||||
test("user should be able to update a label", async () => {
|
||||
const api = await sharedUserClient();
|
||||
const [label, cleanup] = await useLabel(api);
|
||||
|
||||
const labelData = {
|
||||
name: "test-label",
|
||||
description: "test-description",
|
||||
color: "",
|
||||
};
|
||||
|
||||
const { response, data } = await api.labels.update(label.id, labelData);
|
||||
expect(response.status).toBe(200);
|
||||
expect(data.id).toBe(label.id);
|
||||
|
||||
// Ensure we can get the label
|
||||
const { response: getResponse, data: getData } = await api.labels.get(data.id);
|
||||
expect(getResponse.status).toBe(200);
|
||||
expect(getData.id).toBe(data.id);
|
||||
expect(getData.name).toBe(labelData.name);
|
||||
expect(getData.description).toBe(labelData.description);
|
||||
|
||||
// Cleanup
|
||||
await cleanup();
|
||||
});
|
||||
|
||||
test("user should be able to delete a label", async () => {
|
||||
const api = await sharedUserClient();
|
||||
const [label, _] = await useLabel(api);
|
||||
|
||||
const { response } = await api.labels.delete(label.id);
|
||||
expect(response.status).toBe(204);
|
||||
|
||||
// Ensure we can't get the label
|
||||
const { response: getResponse } = await api.labels.get(label.id);
|
||||
expect(getResponse.status).toBe(404);
|
||||
});
|
||||
});
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user