mirror of
https://github.com/hay-kot/homebox.git
synced 2025-06-03 11:02:29 +00:00
feat: QR Codes (#226)
* code gen updates * qrcode support * remove opacity on toast * update item view to use tab-like pages * adjust view for cards * fix old API calls for ioutils * move embed * extract QR code * add docs for QR codes * add QR code
This commit is contained in:
parent
f532b39c46
commit
c19fe94c08
88 changed files with 3151 additions and 6454 deletions
|
@ -486,50 +486,8 @@ func (ic *ItemCreate) Mutation() *ItemMutation {
|
|||
|
||||
// Save creates the Item in the database.
|
||||
func (ic *ItemCreate) Save(ctx context.Context) (*Item, error) {
|
||||
var (
|
||||
err error
|
||||
node *Item
|
||||
)
|
||||
ic.defaults()
|
||||
if len(ic.hooks) == 0 {
|
||||
if err = ic.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
node, err = ic.sqlSave(ctx)
|
||||
} else {
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*ItemMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
if err = ic.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ic.mutation = mutation
|
||||
if node, err = ic.sqlSave(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mutation.id = &node.ID
|
||||
mutation.done = true
|
||||
return node, err
|
||||
})
|
||||
for i := len(ic.hooks) - 1; i >= 0; i-- {
|
||||
if ic.hooks[i] == nil {
|
||||
return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
|
||||
}
|
||||
mut = ic.hooks[i](mut)
|
||||
}
|
||||
v, err := mut.Mutate(ctx, ic.mutation)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
nv, ok := v.(*Item)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected node type %T returned from ItemMutation", v)
|
||||
}
|
||||
node = nv
|
||||
}
|
||||
return node, err
|
||||
return withHooks[*Item, ItemMutation](ctx, ic.sqlSave, ic.mutation, ic.hooks)
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
|
@ -682,6 +640,9 @@ func (ic *ItemCreate) check() error {
|
|||
}
|
||||
|
||||
func (ic *ItemCreate) sqlSave(ctx context.Context) (*Item, error) {
|
||||
if err := ic.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_node, _spec := ic.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, ic.driver, _spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
|
@ -696,6 +657,8 @@ func (ic *ItemCreate) sqlSave(ctx context.Context) (*Item, error) {
|
|||
return nil, err
|
||||
}
|
||||
}
|
||||
ic.mutation.id = &_node.ID
|
||||
ic.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue