Skip to content

Commit

Permalink
Merge pull request #404 from qor5/fix-upload
Browse files Browse the repository at this point in the history
fix upload ;and move to dialog next folder
  • Loading branch information
zhangshanwen authored Aug 1, 2024
2 parents 7edd6bf + 2071970 commit 9fc2c09
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion media/filechooser.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ func uploadFile(mb *Builder) web.EventFunc {
return func(ctx *web.EventContext) (r web.EventResponse, err error) {
field := ctx.Param(ParamField)
cfg := stringToCfg(ctx.Param(ParamCfg))
parentID := ctx.ParamAsInt(ParamParentID)

if err = mb.uploadIsAllowed(ctx.R); err != nil {
return
Expand All @@ -134,7 +135,7 @@ func uploadFile(mb *Builder) web.EventFunc {
var uf uploadFiles
ctx.MustUnmarshalForm(&uf)
for _, fh := range uf.NewFiles {
m := media_library.MediaLibrary{}
m := media_library.MediaLibrary{ParentId: uint(parentID)}

if base.IsImageFormat(fh.Filename) {
m.SelectedType = media_library.ALLOW_TYPE_IMAGE
Expand Down Expand Up @@ -719,6 +720,8 @@ func mediaLibraryContent(mb *Builder, field string, ctx *web.EventContext,
web.Plaid().
BeforeScript("locals.fileChooserUploadingFiles = $event.target.files").
EventFunc(uploadFileEvent).
Query(paramTab, tab).
Query(ParamParentID, parentID).
Query(ParamField, field).
Query(ParamCfg, h.JSONString(cfg)).
Go()),
Expand Down
2 changes: 1 addition & 1 deletion media/media_box.go
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@ func folderGroupsComponents(db *gorm.DB, ctx *web.EventContext, parentID int) (i
PrependIcon("mdi-folder").
Attr(":active", fmt.Sprintf(`form.%s==%v`, ParamSelectFolderID, record.ID)).
Attr("@click", fmt.Sprintf("form.%s=%v;", ParamSelectFolderID, record.ID)+
fmt.Sprintf(`if (!locals.folder%v){locals.folder%v=1;%s}`, record.ID, record.ID,
fmt.Sprintf(`if (!dialogLocals.folder%v){dialogLocals.folder%v=1;%s}`, record.ID, record.ID,
web.Plaid().
EventFunc(NextFolderEvent).
Query(ParamSelectIDS, ctx.Param(ParamSelectIDS)).
Expand Down

0 comments on commit 9fc2c09

Please sign in to comment.