8000 editing: toast msgr.SuccessfullyCreated when created && some i18n by molon · Pull Request #472 · qor5/admin · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
8000

editing: toast msgr.SuccessfullyCreated when created && some i18n #472

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 14, 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
2 changes: 1 addition & 1 deletion activity/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ var Messages_ja_JP = &Messages{
ModelAction: "アクション",
ModelUser: "作成者",
ModelKeys: "キー",
ModelName: "テーブル名",
ModelName: "モデル名",
ModelLabel: "メニュー名",
ModelLink: "リンク",
ModelDiffs: "差分",
Expand Down
4 changes: 2 additions & 2 deletions example/admin/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ var Messages_ja_JP_ModelsI18nModuleKey = &Messages_ModelsI18nModuleKey{
SharedContainers: "共有コンテナ",
DemoContainers: "デモ用コン店た",
Templates: "テンプレート",
PageCategories: "カテゴリー",
PageCategories: "カテゴリ",
ECManagement: "ECマネジメント",
ECDashboard: "ECダッシュボード",
Orders: "注文",
Expand Down Expand Up @@ -478,7 +478,7 @@ var Messages_ja_JP_ModelsI18nModuleKey = &Messages_ModelsI18nModuleKey{
Page: "ページ",
PagesStatus: "状態",
PagesSchedule: "スケジュール",
PagesCategoryID: "カテゴリーID",
PagesCategoryID: "カテゴリID",
PagesTemplateSelection: "テンプレート選択",
PagesEditContainer: "コンテナ編集",

Expand Down
8 changes: 4 additions & 4 deletions pagebuilder/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ var Messages_ja_JP = &Messages{
Preview: "プレビュー",
Containers: "コンテナ",
AddContainers: "コンテナの追加",
New: "新規作成",
New: "作成する",
Shared: "共有",
Select: "選択",
SelectedTemplateLabel: "テンプレート",
Expand Down Expand Up @@ -278,7 +278,7 @@ var Messages_ja_JP = &Messages{
ConflictSlugMsg: "競合するスラッグ",
ConflictPathMsg: "競合するパス",
ExistingPathMsg: "既存のパス",
UnableDeleteCategoryMsg: "このカテゴリーを削除するには、まず商品との関連付けをすべて削除する必要があります。",
UnableDeleteCategoryMsg: "このカテゴリを削除するには、まず商品との関連付けをすべて削除する必要があります。",
Versions: "バージョン",
NewComponent: "新しいコンポーネント",
Settings: "設定",
Expand All @@ -304,8 +304,8 @@ var Messages_ja_JP = &Messages{
ModelLabelDemoContainer: "デモコンテナ",
ModelLabelTemplates: "テンプレート",
ModelLabelTemplate: "テンプレート",
ModelLabelPageCategories: "ページカテゴリー",
ModelLabelPageCategory: "ページカテゴリー",
ModelLabelPageCategories: "ページカテゴリ",
ModelLabelPageCategory: "ページカテゴリ",
AreWantDeleteContainer: func(v string) string {
return fmt.Sprintf("%v を削除してもよろしいですか?", v)
},
Expand Down
25 changes: 16 additions & 9 deletions presets/editing.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,10 @@
r *web.EventResponse,
// will not close drawer/dialog
silent bool,
) (err error) {
) (created bool, err error) {
id := ctx.R.FormValue(ParamID)
created = id == ""

usingB := b
if b.mb.creating != nil && id == "" {
usingB = b.mb.creating
Expand All @@ -438,32 +440,32 @@
obj, vErr := usingB.FetchAndUnmarshal(id, true, ctx)
if vErr.HaveErrors() {
usingB.UpdateOverlayContent(ctx, r, obj, "", &vErr)
return &vErr
return created, &vErr

Check warning on line 443 in presets/editing.go

View check run for this annotation

Codecov / codecov/patch

presets/editing.go#L443

Added line #L443 was not covered by tests
}

if len(id) > 0 {
if b.mb.Info().Verifier().Do(PermUpdate).ObjectOn(obj).WithReq(ctx.R).IsAllowed() != nil {
b.UpdateOverlayContent(ctx, r, obj, "", perm.PermissionDenied)
return perm.PermissionDenied
return created, perm.PermissionDenied

Check warning on line 449 in presets/editing.go

View check run for this annotation

Codecov / codecov/patch

presets/editing.go#L449

Added line #L449 was not covered by tests
}
} else {
if b.mb.Info().Verifier().Do(PermCreate).ObjectOn(obj).WithReq(ctx.R).IsAllowed() != nil {
b.UpdateOverlayContent(ctx, r, obj, "", perm.PermissionDenied)
return perm.PermissionDenied
return created, perm.PermissionDenied

Check warning on line 454 in presets/editing.go

View check run for this annotation

Codecov / codecov/patch

presets/editing.go#L454

Added line #L454 was not covered by tests
}
}

if usingB.Validator != nil {
if vErr = usingB.Validator(obj, ctx); vErr.HaveErrors() {
usingB.UpdateOverlayContent(ctx, r, obj, "", &vErr)
return &vErr
return created, &vErr
}
}

err1 := usingB.Saver(obj, id, ctx)
if err1 != nil {
usingB.UpdateOverlayContent(ctx, r, obj, "", err1)
return err1
return created, err1

Check warning on line 468 in presets/editing.go

View check run for this annotation

Codecov / codecov/patch

presets/editing.go#L468

Added line #L468 was not covered by tests
}

if id == "" {
Expand Down Expand Up @@ -505,10 +507,14 @@
}

func (b *EditingBuilder) defaultUpdate(ctx *web.EventContext) (r web.EventResponse, err error) {
uErr := b.doUpdate(ctx, &r, false)
created, uErr := b.doUpdate(ctx, &r, false)
if uErr == nil {
msgr := MustGetMessages(ctx.R)
ShowMessage(&r, msgr.SuccessfullyUpdated, "")
if created {
ShowMessage(&r, msgr.SuccessfullyCreated, "")
} else {
ShowMessage(&r, msgr.SuccessfullyUpdated, "")
}
}
return r, nil
}
Expand All @@ -517,7 +523,8 @@
ctx *web.EventContext,
r *web.EventResponse,
) (err error) {
return b.doUpdate(ctx, r, true)
_, err = b.doUpdate(ctx, r, true)
return err

Check warning on line 527 in presets/editing.go

View check run for this annotation

Codecov / codecov/patch

presets/editing.go#L526-L527

Added lines #L526 - L527 were not covered by tests
}

func (b *EditingBuilder) RunSetterFunc(ctx *web.EventContext, removeDeletedAndSort bool, toObj interface{}) (vErr web.ValidationErrors) {
Expand Down
8 changes: 6 additions & 2 deletions presets/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

type Messages struct {
SuccessfullyUpdated string
SuccessfullyCreated string
Search string
New string
Update string
Expand Down Expand Up @@ -146,6 +147,7 @@ func (msgr *Messages) HumanizeTime(then time.Time) string {

var Messages_en_US = &Messages{
SuccessfullyUpdated: "Successfully Updated",
SuccessfullyCreated: "Successfully Created",
Search: "Search",
New: "New",
Update: "Update",
Expand Down Expand Up @@ -223,6 +225,7 @@ var Messages_en_US = &Messages{

var Messages_zh_CN = &Messages{
SuccessfullyUpdated: "成功更新了",
SuccessfullyCreated: "成功创建了",
Search: "搜索",
New: "新建",
Update: "更新",
Expand Down Expand Up @@ -300,15 +303,16 @@ var Messages_zh_CN = &Messages{

var Messages_ja_JP = &Messages{
SuccessfullyUpdated: "更新に成功しました",
SuccessfullyCreated: "作成に成功しました",
Search: "検索",
New: "新規作成",
New: "作成する",
Update: "更新",
Delete: "削除",
Edit: "編集",
FormTitle: "フォーム",
OK: "OK",
Cancel: "キャンセル",
Create: "新規作成",
Create: "作成する",
DeleteConfirmationTextTemplate: "ID: {id} を削除してもよろしいですか?",
CreatingObjectTitleTemplate: "新規{modelName}作成",
EditingObjectTitleTemplate: "{modelName} {id}を編集する",
Expand Down
Loading
0