8000 fix rename by zhangshanwen · Pull Request #382 · qor5/admin · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix rename #382

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions example/integration/media_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,8 @@ func TestMedia(t *testing.T) {
BuildEventFuncRequest()
return req
},
ExpectPortalUpdate0ContainsInOrder: []string{"Rename", "Name", "Snipaste_2024-06-14_10-06-12.png"},
ExpectPortalUpdate0ContainsInOrder: []string{"Rename", "Name", "Snipaste_2024-06-14_10-06-12"},
ExpectPortalUpdate0NotContains: []string{".png"},
},
{
Name: "MediaLibrary Rename",
Expand All @@ -274,7 +275,7 @@ func TestMedia(t *testing.T) {
PageURL("/media-library").
Query(web.EventFuncIDName, media.RenameEvent).
Query(media.ParamMediaIDS, "1").
AddField(media.ParamName, "1.png").
AddField(media.ParamName, "1").
BuildEventFuncRequest()
return req
},
Expand Down
4 changes: 3 additions & 1 deletion media/filechooser.go
Original file line number Diff line number Diff line change
Expand Up @@ -735,9 +735,11 @@ func mediaLibraryContent(mb *Builder, field string, ctx *web.EventContext,
VPagination().
Length(pagesCount).
ModelValue(int(currentPageInt)).
Attr("@input", web.Plaid().
Attr("@update:model-value", web.Plaid().
FieldValue(currentPageName(field), web.Var("$event")).
EventFunc(imageJumpPageEvent).
Query(paramTab, tab).
Query(paramParentID, parentID).
Query(ParamField, field).
Query(ParamCfg, h.JSONString(cfg)).
Go()),
Expand Down
5 changes: 3 additions & 2 deletions media/media_box.go
A33E
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ func rename(mb *Builder) web.EventFunc {
return
}

obj.File.FileName = ctx.Param(ParamName)
obj.File.FileName = ctx.Param(ParamName) + path.Ext(obj.File.FileName)
if err = db.Save(&obj).Error; err != nil {
return
}
Expand Down Expand Up @@ -644,6 +644,7 @@ func renameDialog(mb *Builder) web.EventFunc {

return func(ctx *web.EventContext) (r web.EventResponse, err error) {
obj := wrapFirst(mb, ctx, &r)
fileName := strings.TrimSuffix(obj.File.FileName, path.Ext(obj.File.FileName))
r.UpdatePortals = append(r.UpdatePortals, &web.PortalUpdate{
Name: renameDialogPortalName,
Body: web.Scope(
Expand All @@ -657,7 +658,7 @@ func renameDialog(mb *Builder) web.EventFunc {
).Name(VSlotAppend),
VTextField().Variant(FieldVariantUnderlined).
Class("px-6").
Label("Name").Attr(web.VField(ParamName, obj.File.FileName)...),
Label("Name").Attr(web.VField(ParamName, fileName)...),
VCardActions(
VSpacer(),
VBtn("Cancel").Color(ColorSecondary).Attr("@click", "dialogLocals.show=false"),
Expand Down
Loading
0