8000 activity: exclusive editing && confirmation of leaving during editing by molon · Pull Request #514 · qor5/admin · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

activity: exclusive editing && confirmation of leaving during editing #514

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 3 commits into from
Aug 23, 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
28 changes: 17 additions & 11 deletions activity/timeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (c *TimelineCompo) humanContent(ctx context.Context, log *ActivityLog, forc
Attr(web.VField("note", note.Note)...),
h.Div().Class("d-flex flex-row ga-2").Style("position: absolute; bottom: 32px; right: 12px").Children(
v.VBtn("").Variant(v.VariantText).Color("grey-darken-3").Size(16).
Attr("@click", "xlocals.showEditBox = false").Children(
Attr("@click", "xlocals.showEditBox = false; toplocals.editing = false ").Children(
v.VIcon("mdi-close").Size(16),
),
v.VBtn("").Variant(v.VariantText).Color(v.ColorPrimary).Size(16).
Expand Down Expand Up @@ -126,17 +126,17 @@ func (c *TimelineCompo) MarshalHTML(ctx context.Context) ([]byte, error) {

children := []h.HTMLComponent{
h.Div().Class("text-h6 mb-8").Text(msgr.Activities),
web.Scope().VSlot("{locals: xlocals,form}").Init("{showEditBox:false}").Children(
v.VBtn(msgr.AddNote).Attr("v-if", "!xlocals.showEditBox").
web.Scope().VSlot("{locals: xlocals, form}").Init("{showEditBox:false}").Children(
v.VBtn(msgr.AddNote).Attr("v-if", "!xlocals.showEditBox").Attr(":disabled", "toplocals.editing").
Class("text-none mb-4").Variant(v.VariantTonal).Color("grey-darken-3").Size(v.SizeDefault).PrependIcon("mdi-plus").
Attr("@click", "xlocals.showEditBox = true"),
Attr("@click", "xlocals.showEditBox = true; toplocals.editing = true"),
h.Div().Attr("v-if", "!!xlocals.showEditBox").Class("d-flex flex-column").Style("position: relative").Children(
v.VTextarea().Rows(2).Attr(":row-height", "12").Clearable(false).AutoGrow(true).Label("").Placeholder(msgr.AddNote).Variant(v.VariantOutlined).
Color(v.ColorPrimary).Class("text-grey-darken-3 textarea-with-bottom-btns").
Attr(web.VField("note", "")...),
h.Div().Class("d-flex flex-row ga-2").Style("position: absolute; bottom: 32px; right: 12px").Children(
v.VBtn("").Variant(v.VariantText).Color("grey-darken-3").Size(16).
Attr("@click", "xlocals.showEditBox = false").Children(
Attr("@click", "xlocals.showEditBox = false; toplocals.editing = false").Children(
v.VIcon("mdi-close").Size(16),
),
v.VBtn("").Variant(v.VariantText).Color("grey-darken-3").Size(16).
Expand Down Expand Up @@ -203,10 +203,10 @@ func (c *TimelineCompo) MarshalHTML(ctx context.Context) ([]byte, error) {
v.VHover().Disabled(log.UserID != user.ID).Children(
web.Slot().Name("default").Scope("{ isHovering, props }").Children(
h.Div().Class("d-flex flex-column").Style("position: relative").Attr("v-bind", "props").Children(
h.Div().Attr("v-if", "isHovering && !xlocals.showEditBox").Class("d-flex flex-row ga-1").
h.Div().Attr("v-if", "isHovering && !xlocals.showEditBox && !toplocals.editing").Class("d-flex flex-row ga-1").
Style("position: absolute; top: 21px; right: 16px").Children(
v.VBtn("").Variant(v.VariantText).Color("grey-darken-3").Size(v.SizeXSmall).Icon("mdi-square-edit-outline").
Attr("@click", "xlocals.showEditBox = true"),
Attr("@click", "xlocals.showEditBox = true; toplocals.editing = true"),
v.VBtn("").Variant(v.VariantText).Color("grey-darken-3").Size(v.SizeXSmall).Icon("mdi-delete").
Attr("@click", fmt.Sprintf(`toplocals.deletingLogID = %d`, log.ID)),
),
Expand Down Expand Up @@ -239,7 +239,16 @@ func (c *TimelineCompo) MarshalHTML(ctx context.Context) ([]byte, error) {
`, stateful.ReloadAction(ctx, c, nil).Go()),
presets.NotifModelsDeleted(&ActivityLog{}), stateful.ReloadAction(ctx, c, nil).Go(),
),
web.Scope().VSlot("{locals: toplocals, form}").Init(`{ deletingLogID: -1 }`).Children(
web.Scope().VSlot("{locals: toplocals}").Init(`{ deletingLogID: -1, editing: false }`).Children(
h.Div().Class("d-flex flex-column mb-8").Style("text-body-2").Attr("v-on-mounted", fmt.Sprintf(`({watch}) => {
watch(() => toplocals.editing, (val) => {
if (vars.%s) {
vars.%s.__activity_editing__ = val
}
})
}`, presets.VarsPresetsDataChanged, presets.VarsPresetsDataChanged)).Children(
children...,
),
v.VDialog().MaxWidth("520px").
Attr(":model-value", `toplocals.deletingLogID !== -1`).
Attr("@update:model-value", `(value) => { toplocals.deletingLogID = value ? toplocals.deletingLogID : -1; }`).Children(
Expand All @@ -258,9 +267,6 @@ func (c *TimelineCompo) MarshalHTML(ctx context.Context) ([]byte, error) {
),
),
),
h.Div().Class("d-flex flex-column mb-8").Style("text-body-2").Children(
children...,
),
),
).MarshalHTML(ctx)
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ require (
github.com/pkg/errors v0.9.1
github.com/pquerna/otp v1.4.0
github.com/qor/oss v0.0.0-20240729105053-88484a799a79
github.com/qor5/web/v3 v3.0.7-0.20240823021609-53fc3c71f073
github.com/qor5/x/v3 v3.0.8-0.20240822084601-035b0043ea88
github.com/qor5/web/v3 v3.0.7-0.20240822071414-115873e68278
github.com/samber/lo v1.47.0
github.com/shurcooL/sanitized_anchor_name v1.0.0
github.com/spf13/cast v1.6.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,10 @@ github.com/qor/oss v0.0.0-20240729105053-88484a799a79 h1:MXQCoxxGj15XjuOSdhkLrPs
github.com/qor/oss v0.0.0-20240729105053-88484a799a79/go.mod h1:FDxJAVwmZ1j8ITcKJExFlzkTYuUor1dBKZgNVWqEqlM=
github.com/qor5/web v1.3.2 h1:zw796YJeDLe8vRwGR1cM+uS1ZuSkPutchBEXv2GgOhI=
github.com/qor5/web v1.3.2/go.mod h1:LszskQJbFQDJwOeZC6j6afOiHxxyjrzz8B3zuBwfgKQ=
github.com/qor5/web/v3 v3.0.7-0.20240823021609-53fc3c71f073 h1:RUarY7aCCG6s5lLdYwEyc4zKohbKSt0L8rzTj4C7V0k=
github.com/qor5/web/v3 v3.0.7-0.20240823021609-53fc3c71f073/go.mod h1:32vdHHcZb2JimlcaclW9hLUyimdXjrllZDHTh3rl6d0=
github.com/qor5/x/v3 v3.0.8-0.20240822084601-035b0043ea88 h1:BF/DFxKPKZbnjZsmbhr6LfR1tmerNBvhADu0gIy13HI=
github.com/qor5/x/v3 v3.0.8-0.20240822084601-035b0043ea88/go.mod h1:aLBRfhcgVnpGmMOTyXLCoOyPOYUpYNZ9T8YyNPqCuVM=
github.com/qor5/web/v3 v3.0.7-0.20240822071414-115873e68278 h1:WLshTknWi+hiIx4BSDiaR0zIqiRJGsnLwabVRQznftU=
github.com/qor5/web/v3 v3.0.7-0.20240822071414-115873e68278/go.mod h1:32vdHHcZb2JimlcaclW9hLUyimdXjrllZDHTh3rl6d0=
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
Expand Down
2 changes: 1 addition & 1 deletion presets/presets.go
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ const (
)

func ConfirmLeaveScript(confirmEvent, leaveEvent string) string {
return fmt.Sprintf("if(Object.values(vars.presetsDataChanged).some(value => value === true)){%s}else{%s};", confirmEvent, leaveEvent)
return fmt.Sprintf("if(Object.values(vars.%s).some(value => value === true)){%s}else{%s};", VarsPresetsDataChanged, confirmEvent, leaveEvent)
}

func (b *Builder) overlay(ctx *web.EventContext, r *web.EventResponse, comp h.HTMLComponent, width string) {
Expand Down
Loading
0