Skip to content

Commit

Permalink
Add option to disable on record save notifications per record page
Browse files Browse the repository at this point in the history
  • Loading branch information
Fajfa committed Sep 30, 2024
1 parent c83f77f commit b744202
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 4 deletions.
4 changes: 3 additions & 1 deletion client/web/compose/src/mixins/record.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,9 @@ export default {
}
}

this.toastSuccess(this.$t(`notification:record.${isNew ? 'create' : 'update'}Success`))
if (this.page.meta.notifications.enabled) {
this.toastSuccess(this.$t(`notification:record.${isNew ? 'create' : 'update'}Success`))
}
})
.catch(e => {
// Since processing is set to false by the view record component, we need to set it to false here if we error out
Expand Down
8 changes: 8 additions & 0 deletions client/web/compose/src/views/Admin/Pages/Edit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,14 @@
>
{{ $t('showSubPages') }}
</b-form-checkbox>

<b-form-checkbox
v-if="isRecordPage"
v-model="page.meta.notifications.enabled"
data-test-id="checkbox-page-notifications-enabled"
>
{{ $t('edit.notifications.enabled') }}
</b-form-checkbox>
</b-form-group>
</b-col>

Expand Down
14 changes: 12 additions & 2 deletions lib/js/src/compose/types/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,19 @@ interface PartialPage extends Partial<Omit<Page, 'children' | 'meta' | 'blocks'

blocks?: PageBlock[];

meta?: object;
meta?: PageMeta;

createdAt?: string|number|Date;
updatedAt?: string|number|Date;
deletedAt?: string|number|Date;
}

interface PageMeta {
notifications: {
enabled: boolean;
};
}

interface PageConfig {
navItem: {
icon: {
Expand Down Expand Up @@ -54,7 +60,11 @@ export class Page {
},
}

public meta: object = {};
public meta: PageMeta = {
notifications: {
enabled: true,
},
};

public createdAt?: Date = undefined;
public updatedAt?: Date = undefined;
Expand Down
4 changes: 3 additions & 1 deletion locale/en/corteza-webapp-compose/page.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,11 @@ createLabel: Create page
edit:
create: Create page
edit: Edit page
otherOptions: Other options
pageDescription: Page description
visible: Is page visible
otherOptions: Other options
notifications:
enabled: Show record save notifications
icon:
configure: Configure page icon
noIcon: No icon
Expand Down
5 changes: 5 additions & 0 deletions server/compose/service/page.go
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,11 @@ func (svc page) handleUpdate(ctx context.Context, upd *types.Page) pageUpdateHan
changes |= pageChanged
}

if !reflect.DeepEqual(res.Meta.Notifications, upd.Meta.Notifications) {
res.Meta.Notifications = upd.Meta.Notifications
changes |= pageChanged
}

if res.Title != upd.Title {
res.Title = upd.Title
changes |= pageChanged
Expand Down
1 change: 1 addition & 0 deletions server/compose/types/page.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ type (

PageMeta struct {
AllowPersonalLayouts bool `json:"allowPersonalLayouts"`
Notifications map[string]any `json:"notifications,omitempty"`
}

PageBlockStyle struct {
Expand Down

0 comments on commit b744202

Please sign in to comment.