mirror of
https://github.com/hay-kot/homebox.git
synced 2025-07-18 16:40:29 +00:00
feat: items-editor (#5)
* format readme * update logo * format html * add logo to docs * repository for document and document tokens * add attachments type and repository * autogenerate types via scripts * use autogenerated types * attachment type updates * add insured and quantity fields for items * implement HasID interface for entities * implement label updates for items * implement service update method * WIP item update client side actions * check err on attachment * finish types for basic items editor * remove unused var * house keeping
This commit is contained in:
parent
fbc364dcd2
commit
95ab14b866
125 changed files with 15626 additions and 1791 deletions
|
@ -11,6 +11,7 @@ import (
|
|||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
"github.com/google/uuid"
|
||||
"github.com/hay-kot/content/backend/ent/document"
|
||||
"github.com/hay-kot/content/backend/ent/group"
|
||||
"github.com/hay-kot/content/backend/ent/item"
|
||||
"github.com/hay-kot/content/backend/ent/label"
|
||||
|
@ -147,6 +148,21 @@ func (gc *GroupCreate) AddLabels(l ...*Label) *GroupCreate {
|
|||
return gc.AddLabelIDs(ids...)
|
||||
}
|
||||
|
||||
// AddDocumentIDs adds the "documents" edge to the Document entity by IDs.
|
||||
func (gc *GroupCreate) AddDocumentIDs(ids ...uuid.UUID) *GroupCreate {
|
||||
gc.mutation.AddDocumentIDs(ids...)
|
||||
return gc
|
||||
}
|
||||
|
||||
// AddDocuments adds the "documents" edges to the Document entity.
|
||||
func (gc *GroupCreate) AddDocuments(d ...*Document) *GroupCreate {
|
||||
ids := make([]uuid.UUID, len(d))
|
||||
for i := range d {
|
||||
ids[i] = d[i].ID
|
||||
}
|
||||
return gc.AddDocumentIDs(ids...)
|
||||
}
|
||||
|
||||
// Mutation returns the GroupMutation object of the builder.
|
||||
func (gc *GroupCreate) Mutation() *GroupMutation {
|
||||
return gc.mutation
|
||||
|
@ -410,6 +426,25 @@ func (gc *GroupCreate) createSpec() (*Group, *sqlgraph.CreateSpec) {
|
|||
}
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
if nodes := gc.mutation.DocumentsIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: group.DocumentsTable,
|
||||
Columns: []string{group.DocumentsColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: &sqlgraph.FieldSpec{
|
||||
Type: field.TypeUUID,
|
||||
Column: document.FieldID,
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
return _node, _spec
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue