diff --git a/activity/builder.go b/activity/builder.go index 8f8a44f89..e374fab2e 100644 --- a/activity/builder.go +++ b/activity/builder.go @@ -21,7 +21,7 @@ type User struct { Avatar string } -const DefaultMaxCountShowInTimeline = 5 +const DefaultMaxCountShowInTimeline = 10 // @snippet_begin(ActivityBuilder) type Builder struct { diff --git a/docs/docsrc/examples/examples_admin/activity_test.go b/docs/docsrc/examples/examples_admin/activity_test.go index 97f9171fa..8ab036117 100644 --- a/docs/docsrc/examples/examples_admin/activity_test.go +++ b/docs/docsrc/examples/examples_admin/activity_test.go @@ -123,10 +123,10 @@ func TestActivity(t *testing.T) { activityExample(pb, TestDB, func(mb *presets.ModelBuilder, ab *activity.Builder) { defer pb.Use(ab) ab.FindLogsForTimelineFunc(func(ctx context.Context, db *gorm.DB, modelName, modelKeys string) ([]*activity.ActivityLog, bool, error) { - maxCount := 11 + maxCount := 10 var logs []*activity.ActivityLog err := db.Where("hidden = FALSE AND model_name = ? AND model_keys = ? AND action = ?", modelName, modelKeys, activity.ActionNote). - Order("created_at DESC").Limit(maxCount).Find(&logs).Error + Order("created_at DESC").Limit(maxCount + 1).Find(&logs).Error if err != nil { return nil, false, err } diff --git a/pagebuilder/editor.go b/pagebuilder/editor.go index aa967feaa..9e101e002 100644 --- a/pagebuilder/editor.go +++ b/pagebuilder/editor.go @@ -138,7 +138,7 @@ func (b *Builder) Editor(m *ModelBuilder) web.PageFunc { Attr("ref", "overlay"). Attr("@after-leave", afterLeaveEvent). Attr("v-model", "vars.overlay") - versionComponent = publish.DefaultVersionComponentFunc(m.editor, publish.VersionComponentConfig{Top: true, DisableListeners: true})(obj, &presets.FieldContext{ModelInfo: m.editor.Info()}, ctx) + versionComponent = publish.DefaultVersionComponentFunc(m.editor, publish.VersionComponentConfig{Top: true, DisableListeners: true, DisableDataChangeTracking: true})(obj, &presets.FieldContext{ModelInfo: m.editor.Info()}, ctx) pageAppbarContent = h.Components( h.Div( h.Div().Style("transform:rotateY(180deg)").Class("mr-4").Children( diff --git a/publish/version_compo.go b/publish/version_compo.go index 3b185be0d..963a8680d 100644 --- a/publish/version_compo.go +++ b/publish/version_compo.go @@ -37,11 +37,12 @@ const VersionListDialogURISuffix = "-version-list-dialog" type VersionComponentConfig struct { // If you want to use custom publish dialog, you can update the portal named PublishCustomDialogPortalName - PublishEvent func(obj interface{}, field *presets.FieldContext, ctx *web.EventContext) string - UnPublishEvent func(obj interface{}, field *presets.FieldContext, ctx *web.EventContext) string - RePublishEvent func(obj interface{}, field *presets.FieldContext, ctx *web.EventContext) string - Top bool - DisableListeners bool + PublishEvent func(obj interface{}, field *presets.FieldContext, ctx *web.EventContext) string + UnPublishEvent func(obj interface{}, field *presets.FieldContext, ctx *web.EventContext) string + RePublishEvent func(obj interface{}, field *presets.FieldContext, ctx *web.EventContext) string + Top bool + DisableListeners bool + DisableDataChangeTracking bool } func DefaultVersionComponentFunc(mb *presets.ModelBuilder, cfg ...VersionComponentConfig) presets.FieldComponentFunc { @@ -49,6 +50,10 @@ func DefaultVersionComponentFunc(mb *presets.ModelBuilder, cfg ...VersionCompone if len(cfg) > 0 { config = cfg[0] } + phraseHasPresetsDataChanged := presets.PhraseHasPresetsDataChanged + if config.DisableDataChangeTracking { + phraseHasPresetsDataChanged = "false" + } return func(obj interface{}, field *presets.FieldContext, ctx *web.EventContext) h.HTMLComponent { var ( version VersionInterface @@ -85,7 +90,7 @@ func DefaultVersionComponentFunc(mb *presets.ModelBuilder, cfg ...VersionCompone h.Text(`{{ xlocals.versionName }}`), ).Label(true).Variant(v.VariantOutlined). Attr("style", "height:36px;"). - Attr(":disabled", presets.PhraseHasPresetsDataChanged). + Attr(":disabled", phraseHasPresetsDataChanged). On("click", web.Plaid().EventFunc(actions.OpenListingDialog). URL(mb.Info().PresetsPrefix()+"/"+urlSuffix). Query(filterKeySelected, slug). @@ -105,7 +110,7 @@ func DefaultVersionComponentFunc(mb *presets.ModelBuilder, cfg ...VersionCompone if !DeniedDo(verifier, obj, ctx.R, presets.PermUpdate, PermDuplicate) { div.AppendChildren(v.VBtn(msgr.Duplicate). Height(36).Class("ml-2").Variant(v.VariantOutlined). - Attr(":disabled", presets.PhraseHasPresetsDataChanged). + Attr(":disabled", phraseHasPresetsDataChanged). Attr("@click", fmt.Sprintf(`locals.action="%s";locals.commonConfirmDialog = true`, EventDuplicateVersion))) } } @@ -122,7 +127,7 @@ func DefaultVersionComponentFunc(mb *presets.ModelBuilder, cfg ...VersionCompone } publishBtn = h.Div( v.VBtn(msgr.Publish). - Attr(":disabled", presets.PhraseHasPresetsDataChanged). + Attr(":disabled", phraseHasPresetsDataChanged). Attr("@click", publishEvent).Class("ml-2"). ClassIf("rounded", config.Top).ClassIf("rounded-0 rounded-s", !config.Top). Variant(v.VariantElevated).Color(v.ColorPrimary).Height(36), @@ -146,13 +151,13 @@ func DefaultVersionComponentFunc(mb *presets.ModelBuilder, cfg ...VersionCompone publishBtn = h.Div( h.Iff(unPublishEvent != "", func() h.HTMLComponent { return v.VBtn(msgr.Unpublish). - Attr(":disabled", presets.PhraseHasPresetsDataChanged). + Attr(":disabled", phraseHasPresetsDataChanged). Attr("@click", unPublishEvent). Class("ml-2").Variant(v.VariantElevated).Color(v.ColorError).Height(36) }), h.Iff(rePublishEvent != "", func() h.HTMLComponent { return v.VBtn(msgr.Republish). - Attr(":disabled", presets.PhraseHasPresetsDataChanged). + Attr(":disabled", phraseHasPresetsDataChanged). Attr("@click", rePublishEvent).Class("ml-2"). ClassIf("rounded", config.Top).ClassIf("rounded-0 rounded-s", !config.Top). Variant(v.VariantElevated).Color(v.ColorPrimary).Height(36) @@ -182,11 +187,13 @@ func DefaultVersionComponentFunc(mb *presets.ModelBuilder, cfg ...VersionCompone scheduleBtn = v.VAutocomplete().PrependInnerIcon("mdi-alarm").Density(v.DensityCompact). Variant(v.FieldVariantSoloFilled).ModelValue(msgr.SchedulePublishTime). BgColor(v.ColorPrimaryLighten2).Readonly(true). - Width(500).HideDetails(true).Attr("@click", clickEvent).Class("ml-2 text-caption page-builder-autoCmp") + Width(500).HideDetails(true). + Attr(":disabled", phraseHasPresetsDataChanged). + Attr("@click", clickEvent).Class("ml-2 text-caption page-builder-autoCmp") } else { scheduleBtn = v.VBtn("").Size(v.SizeSmall).Children(v.VIcon("mdi-alarm").Size(v.SizeXLarge)).Rounded("0").Class("rounded-e ml-abs-1"). Variant(v.VariantElevated).Color(v.ColorPrimary).Width(36).Height(36). - Attr(":disabled", presets.PhraseHasPresetsDataChanged). + Attr(":disabled", phraseHasPresetsDataChanged). Attr("@click", clickEvent) } div.AppendChildren(scheduleBtn)