Skip to content
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

Only update dirty properties of views #3885

Merged
merged 2 commits into from
Jan 2, 2025
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
6 changes: 3 additions & 3 deletions cmp/viewmanager/ViewManagerModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ export interface ViewCreateSpec {
}

export interface ViewUpdateSpec {
name: string;
group: string;
description: string;
name?: string;
group?: string;
description?: string;
isShared?: boolean;
isDefaultPinned?: boolean;
}
Expand Down
16 changes: 5 additions & 11 deletions desktop/cmp/viewmanager/dialog/ViewPanelModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import {FormModel} from '@xh/hoist/cmp/form';
import {fragment, p, strong} from '@xh/hoist/cmp/layout';
import {HoistModel, managed, TaskObserver, XH} from '@xh/hoist/core';
import {capitalize} from 'lodash';
import {capitalize, isUndefined} from 'lodash';
import {ManageDialogModel} from './ManageDialogModel';
import {makeObservable} from '@xh/hoist/mobx';
import {ViewInfo} from '@xh/hoist/cmp/viewmanager';
Expand Down Expand Up @@ -55,14 +55,14 @@ export class ViewPanelModel extends HoistModel {

async saveAsync() {
const {parent, view, formModel} = this,
{name, group, description, isDefaultPinned, isShared} = formModel.getData(),
updates = formModel.getData(true),
isValid = await formModel.validateAsync(),
isDirty = formModel.isDirty;

if (!isValid || !isDirty) return;

if (view.isOwned && view.isShared != isShared) {
const msg: ReactNode = !isShared
if (view.isOwned && !isUndefined(updates.isShared)) {
const msg: ReactNode = !updates.isShared
? `Your ${view.typedName} will no longer be visible to all other ${XH.appName} users.`
: `Your ${view.typedName} will become visible to all other ${XH.appName} users.`;
const msgs = [msg, strong('Are you sure you want to proceed?')];
Expand All @@ -79,13 +79,7 @@ export class ViewPanelModel extends HoistModel {
if (!confirmed) return;
}

await parent.updateAsync(view, {
name,
group,
description,
isShared,
isDefaultPinned
});
await parent.updateAsync(view, updates);
}

//------------------------
Expand Down
Loading