forked from mirrors/homebox
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
|
@ -6,7 +6,10 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/hay-kot/content/backend/ent/attachment"
|
||||
"github.com/hay-kot/content/backend/ent/authtokens"
|
||||
"github.com/hay-kot/content/backend/ent/document"
|
||||
"github.com/hay-kot/content/backend/ent/documenttoken"
|
||||
"github.com/hay-kot/content/backend/ent/group"
|
||||
"github.com/hay-kot/content/backend/ent/item"
|
||||
"github.com/hay-kot/content/backend/ent/itemfield"
|
||||
|
@ -20,6 +23,25 @@ import (
|
|||
// (default values, validators, hooks and policies) and stitches it
|
||||
// to their package variables.
|
||||
func init() {
|
||||
attachmentMixin := schema.Attachment{}.Mixin()
|
||||
attachmentMixinFields0 := attachmentMixin[0].Fields()
|
||||
_ = attachmentMixinFields0
|
||||
attachmentFields := schema.Attachment{}.Fields()
|
||||
_ = attachmentFields
|
||||
// attachmentDescCreatedAt is the schema descriptor for created_at field.
|
||||
attachmentDescCreatedAt := attachmentMixinFields0[1].Descriptor()
|
||||
// attachment.DefaultCreatedAt holds the default value on creation for the created_at field.
|
||||
attachment.DefaultCreatedAt = attachmentDescCreatedAt.Default.(func() time.Time)
|
||||
// attachmentDescUpdatedAt is the schema descriptor for updated_at field.
|
||||
attachmentDescUpdatedAt := attachmentMixinFields0[2].Descriptor()
|
||||
// attachment.DefaultUpdatedAt holds the default value on creation for the updated_at field.
|
||||
attachment.DefaultUpdatedAt = attachmentDescUpdatedAt.Default.(func() time.Time)
|
||||
// attachment.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
|
||||
attachment.UpdateDefaultUpdatedAt = attachmentDescUpdatedAt.UpdateDefault.(func() time.Time)
|
||||
// attachmentDescID is the schema descriptor for id field.
|
||||
attachmentDescID := attachmentMixinFields0[0].Descriptor()
|
||||
// attachment.DefaultID holds the default value on creation for the id field.
|
||||
attachment.DefaultID = attachmentDescID.Default.(func() uuid.UUID)
|
||||
authtokensMixin := schema.AuthTokens{}.Mixin()
|
||||
authtokensMixinFields0 := authtokensMixin[0].Fields()
|
||||
_ = authtokensMixinFields0
|
||||
|
@ -43,6 +65,92 @@ func init() {
|
|||
authtokensDescID := authtokensMixinFields0[0].Descriptor()
|
||||
// authtokens.DefaultID holds the default value on creation for the id field.
|
||||
authtokens.DefaultID = authtokensDescID.Default.(func() uuid.UUID)
|
||||
documentMixin := schema.Document{}.Mixin()
|
||||
documentMixinFields0 := documentMixin[0].Fields()
|
||||
_ = documentMixinFields0
|
||||
documentFields := schema.Document{}.Fields()
|
||||
_ = documentFields
|
||||
// documentDescCreatedAt is the schema descriptor for created_at field.
|
||||
documentDescCreatedAt := documentMixinFields0[1].Descriptor()
|
||||
// document.DefaultCreatedAt holds the default value on creation for the created_at field.
|
||||
document.DefaultCreatedAt = documentDescCreatedAt.Default.(func() time.Time)
|
||||
// documentDescUpdatedAt is the schema descriptor for updated_at field.
|
||||
documentDescUpdatedAt := documentMixinFields0[2].Descriptor()
|
||||
// document.DefaultUpdatedAt holds the default value on creation for the updated_at field.
|
||||
document.DefaultUpdatedAt = documentDescUpdatedAt.Default.(func() time.Time)
|
||||
// document.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
|
||||
document.UpdateDefaultUpdatedAt = documentDescUpdatedAt.UpdateDefault.(func() time.Time)
|
||||
// documentDescTitle is the schema descriptor for title field.
|
||||
documentDescTitle := documentFields[0].Descriptor()
|
||||
// document.TitleValidator is a validator for the "title" field. It is called by the builders before save.
|
||||
document.TitleValidator = func() func(string) error {
|
||||
validators := documentDescTitle.Validators
|
||||
fns := [...]func(string) error{
|
||||
validators[0].(func(string) error),
|
||||
validators[1].(func(string) error),
|
||||
}
|
||||
return func(title string) error {
|
||||
for _, fn := range fns {
|
||||
if err := fn(title); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}()
|
||||
// documentDescPath is the schema descriptor for path field.
|
||||
documentDescPath := documentFields[1].Descriptor()
|
||||
// document.PathValidator is a validator for the "path" field. It is called by the builders before save.
|
||||
document.PathValidator = func() func(string) error {
|
||||
validators := documentDescPath.Validators
|
||||
fns := [...]func(string) error{
|
||||
validators[0].(func(string) error),
|
||||
validators[1].(func(string) error),
|
||||
}
|
||||
return func(_path string) error {
|
||||
for _, fn := range fns {
|
||||
if err := fn(_path); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}()
|
||||
// documentDescID is the schema descriptor for id field.
|
||||
documentDescID := documentMixinFields0[0].Descriptor()
|
||||
// document.DefaultID holds the default value on creation for the id field.
|
||||
document.DefaultID = documentDescID.Default.(func() uuid.UUID)
|
||||
documenttokenMixin := schema.DocumentToken{}.Mixin()
|
||||
documenttokenMixinFields0 := documenttokenMixin[0].Fields()
|
||||
_ = documenttokenMixinFields0
|
||||
documenttokenFields := schema.DocumentToken{}.Fields()
|
||||
_ = documenttokenFields
|
||||
// documenttokenDescCreatedAt is the schema descriptor for created_at field.
|
||||
documenttokenDescCreatedAt := documenttokenMixinFields0[1].Descriptor()
|
||||
// documenttoken.DefaultCreatedAt holds the default value on creation for the created_at field.
|
||||
documenttoken.DefaultCreatedAt = documenttokenDescCreatedAt.Default.(func() time.Time)
|
||||
// documenttokenDescUpdatedAt is the schema descriptor for updated_at field.
|
||||
documenttokenDescUpdatedAt := documenttokenMixinFields0[2].Descriptor()
|
||||
// documenttoken.DefaultUpdatedAt holds the default value on creation for the updated_at field.
|
||||
documenttoken.DefaultUpdatedAt = documenttokenDescUpdatedAt.Default.(func() time.Time)
|
||||
// documenttoken.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
|
||||
documenttoken.UpdateDefaultUpdatedAt = documenttokenDescUpdatedAt.UpdateDefault.(func() time.Time)
|
||||
// documenttokenDescToken is the schema descriptor for token field.
|
||||
documenttokenDescToken := documenttokenFields[0].Descriptor()
|
||||
// documenttoken.TokenValidator is a validator for the "token" field. It is called by the builders before save.
|
||||
documenttoken.TokenValidator = documenttokenDescToken.Validators[0].(func([]byte) error)
|
||||
// documenttokenDescUses is the schema descriptor for uses field.
|
||||
documenttokenDescUses := documenttokenFields[1].Descriptor()
|
||||
// documenttoken.DefaultUses holds the default value on creation for the uses field.
|
||||
documenttoken.DefaultUses = documenttokenDescUses.Default.(int)
|
||||
// documenttokenDescExpiresAt is the schema descriptor for expires_at field.
|
||||
documenttokenDescExpiresAt := documenttokenFields[2].Descriptor()
|
||||
// documenttoken.DefaultExpiresAt holds the default value on creation for the expires_at field.
|
||||
documenttoken.DefaultExpiresAt = documenttokenDescExpiresAt.Default.(func() time.Time)
|
||||
// documenttokenDescID is the schema descriptor for id field.
|
||||
documenttokenDescID := documenttokenMixinFields0[0].Descriptor()
|
||||
// documenttoken.DefaultID holds the default value on creation for the id field.
|
||||
documenttoken.DefaultID = documenttokenDescID.Default.(func() uuid.UUID)
|
||||
groupMixin := schema.Group{}.Mixin()
|
||||
groupMixinFields0 := groupMixin[0].Fields()
|
||||
_ = groupMixinFields0
|
||||
|
@ -123,36 +231,44 @@ func init() {
|
|||
itemDescNotes := itemFields[0].Descriptor()
|
||||
// item.NotesValidator is a validator for the "notes" field. It is called by the builders before save.
|
||||
item.NotesValidator = itemDescNotes.Validators[0].(func(string) error)
|
||||
// itemDescQuantity is the schema descriptor for quantity field.
|
||||
itemDescQuantity := itemFields[1].Descriptor()
|
||||
// item.DefaultQuantity holds the default value on creation for the quantity field.
|
||||
item.DefaultQuantity = itemDescQuantity.Default.(int)
|
||||
// itemDescInsured is the schema descriptor for insured field.
|
||||
itemDescInsured := itemFields[2].Descriptor()
|
||||
// item.DefaultInsured holds the default value on creation for the insured field.
|
||||
item.DefaultInsured = itemDescInsured.Default.(bool)
|
||||
// itemDescSerialNumber is the schema descriptor for serial_number field.
|
||||
itemDescSerialNumber := itemFields[1].Descriptor()
|
||||
itemDescSerialNumber := itemFields[3].Descriptor()
|
||||
// item.SerialNumberValidator is a validator for the "serial_number" field. It is called by the builders before save.
|
||||
item.SerialNumberValidator = itemDescSerialNumber.Validators[0].(func(string) error)
|
||||
// itemDescModelNumber is the schema descriptor for model_number field.
|
||||
itemDescModelNumber := itemFields[2].Descriptor()
|
||||
itemDescModelNumber := itemFields[4].Descriptor()
|
||||
// item.ModelNumberValidator is a validator for the "model_number" field. It is called by the builders before save.
|
||||
item.ModelNumberValidator = itemDescModelNumber.Validators[0].(func(string) error)
|
||||
// itemDescManufacturer is the schema descriptor for manufacturer field.
|
||||
itemDescManufacturer := itemFields[3].Descriptor()
|
||||
itemDescManufacturer := itemFields[5].Descriptor()
|
||||
// item.ManufacturerValidator is a validator for the "manufacturer" field. It is called by the builders before save.
|
||||
item.ManufacturerValidator = itemDescManufacturer.Validators[0].(func(string) error)
|
||||
// itemDescLifetimeWarranty is the schema descriptor for lifetime_warranty field.
|
||||
itemDescLifetimeWarranty := itemFields[4].Descriptor()
|
||||
itemDescLifetimeWarranty := itemFields[6].Descriptor()
|
||||
// item.DefaultLifetimeWarranty holds the default value on creation for the lifetime_warranty field.
|
||||
item.DefaultLifetimeWarranty = itemDescLifetimeWarranty.Default.(bool)
|
||||
// itemDescWarrantyDetails is the schema descriptor for warranty_details field.
|
||||
itemDescWarrantyDetails := itemFields[6].Descriptor()
|
||||
itemDescWarrantyDetails := itemFields[8].Descriptor()
|
||||
// item.WarrantyDetailsValidator is a validator for the "warranty_details" field. It is called by the builders before save.
|
||||
item.WarrantyDetailsValidator = itemDescWarrantyDetails.Validators[0].(func(string) error)
|
||||
// itemDescPurchasePrice is the schema descriptor for purchase_price field.
|
||||
itemDescPurchasePrice := itemFields[9].Descriptor()
|
||||
itemDescPurchasePrice := itemFields[11].Descriptor()
|
||||
// item.DefaultPurchasePrice holds the default value on creation for the purchase_price field.
|
||||
item.DefaultPurchasePrice = itemDescPurchasePrice.Default.(float64)
|
||||
// itemDescSoldPrice is the schema descriptor for sold_price field.
|
||||
itemDescSoldPrice := itemFields[12].Descriptor()
|
||||
itemDescSoldPrice := itemFields[14].Descriptor()
|
||||
// item.DefaultSoldPrice holds the default value on creation for the sold_price field.
|
||||
item.DefaultSoldPrice = itemDescSoldPrice.Default.(float64)
|
||||
// itemDescSoldNotes is the schema descriptor for sold_notes field.
|
||||
itemDescSoldNotes := itemFields[13].Descriptor()
|
||||
itemDescSoldNotes := itemFields[15].Descriptor()
|
||||
// item.SoldNotesValidator is a validator for the "sold_notes" field. It is called by the builders before save.
|
||||
item.SoldNotesValidator = itemDescSoldNotes.Validators[0].(func(string) error)
|
||||
// itemDescID is the schema descriptor for id field.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue