Browse Source

add shared containers mgmt page rename

zealllot 1 year ago
parent
commit
1cc397bab2
3 changed files with 29 additions and 4 deletions
  1. 20 3
      pagebuilder/builder.go
  2. 5 1
      pagebuilder/editor.go
  3. 4 0
      pagebuilder/messages.go

+ 20 - 3
pagebuilder/builder.go

@@ -1464,7 +1464,24 @@ func (b *Builder) ConfigSharedContainer(pb *presets.Builder, db *gorm.DB) (pm *p
 	pm.RegisterEventFunc(republishRelatedOnlinePagesEvent, republishRelatedOnlinePages(b.mb.Info().ListingHref()))
 
 	listing := pm.Listing("DisplayName").SearchColumns("display_name")
-	listing.RowMenu("").Empty()
+	listing.RowMenu("Rename").RowMenuItem("Rename").ComponentFunc(func(obj interface{}, id string, ctx *web.EventContext) h.HTMLComponent {
+		c := obj.(*Container)
+		msgr := i18n.MustGetModuleMessages(ctx.R, I18nPageBuilderKey, Messages_en_US).(*Messages)
+		return VListItem(
+			VListItemIcon(VIcon("edit_note")),
+
+			VListItemTitle(h.Text(msgr.Rename)),
+		).Attr("@click",
+			web.Plaid().
+				URL(b.ContainerByName(c.ModelName).mb.Info().ListingHref()).
+				EventFunc(RenameContainerDialogEvent).
+				Query(paramContainerID, c.PrimarySlug()).
+				Query(paramContainerName, c.DisplayName).
+				Query("portal", "presets").
+				Go(),
+		)
+	})
+
 	// ed := pm.Editing("SelectContainer")
 	// ed.Field("SelectContainer").ComponentFunc(func(obj interface{}, field *presets.FieldContext, ctx *web.EventContext) h.HTMLComponent {
 	//	var containers []h.HTMLComponent
@@ -1728,7 +1745,7 @@ func sharedContainerSearcher(db *gorm.DB, mb *presets.ModelBuilder) presets.Sear
 
 		locale, _ := l10n.IsLocalizableFromCtx(ctx.R.Context())
 		var c int64
-		if err = wh.Select("count(display_name)").Where("shared = true AND locale_code = ?", locale).Group("display_name,model_name,model_id").Count(&c).Error; err != nil {
+		if err = wh.Select("count(display_name)").Where("shared = true AND locale_code = ?", locale).Group("display_name, model_name, model_id, locale_code").Count(&c).Error; err != nil {
 			return
 		}
 		totalCount = int(c)
@@ -1743,7 +1760,7 @@ func sharedContainerSearcher(db *gorm.DB, mb *presets.ModelBuilder) presets.Sear
 			wh = wh.Offset(int(offset))
 		}
 
-		if err = wh.Select("display_name,model_name,model_id").Find(obj).Error; err != nil {
+		if err = wh.Select("MIN(id) AS id, display_name, model_name, model_id, locale_code").Find(obj).Error; err != nil {
 			return
 		}
 		r = reflect.ValueOf(obj).Elem().Interface()

+ 5 - 1
pagebuilder/editor.go

@@ -870,8 +870,12 @@ func (b *Builder) RenameContainerDialog(ctx *web.EventContext) (r web.EventRespo
 	okAction := web.Plaid().
 		URL(fmt.Sprintf("%s/editors", b.prefix)).
 		EventFunc(RenameContainerEvent).Query(paramContainerID, paramID).Go()
+	portalName := dialogPortalName
+	if ctx.R.FormValue("portal") == "presets" {
+		portalName = presets.DialogPortalName
+	}
 	r.UpdatePortals = append(r.UpdatePortals, &web.PortalUpdate{
-		Name: dialogPortalName,
+		Name: portalName,
 		Body: web.Scope(
 			VDialog(
 				VCard(

+ 4 - 0
pagebuilder/messages.go

@@ -25,6 +25,7 @@ type Messages struct {
 	FilterTabAllVersions           string
 	FilterTabOnlineVersion         string
 	FilterTabNamedVersions         string
+	Rename                         string
 }
 
 var Messages_en_US = &Messages{
@@ -48,6 +49,7 @@ var Messages_en_US = &Messages{
 	FilterTabAllVersions:           "All Versions",
 	FilterTabOnlineVersion:         "Online Version",
 	FilterTabNamedVersions:         "Named Versions",
+	Rename:                         "Rename",
 }
 
 var Messages_zh_CN = &Messages{
@@ -71,6 +73,7 @@ var Messages_zh_CN = &Messages{
 	FilterTabAllVersions:           "所有版本",
 	FilterTabOnlineVersion:         "在线版本",
 	FilterTabNamedVersions:         "已命名版本",
+	Rename:                         "重命名",
 }
 
 var Messages_ja_JP = &Messages{
@@ -93,4 +96,5 @@ var Messages_ja_JP = &Messages{
 	FilterTabAllVersions:           "全てのバージョン",
 	FilterTabOnlineVersion:         "オンラインバージョン",
 	FilterTabNamedVersions:         "名付け済みバージョン",
+	Rename:                         "名前の変更",
 }