From b33c855e6642a7701f1205a73ff45207e62608d2 Mon Sep 17 00:00:00 2001 From: Leo Gretzinger Date: Mon, 12 Jun 2023 13:31:40 -0700 Subject: [PATCH 1/3] Update menuActions type to include '-' by using exported RecordActionLike from RecordAction --- desktop/cmp/rest/RestGridModel.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/desktop/cmp/rest/RestGridModel.ts b/desktop/cmp/rest/RestGridModel.ts index be9690d054..8cb83d9c55 100644 --- a/desktop/cmp/rest/RestGridModel.ts +++ b/desktop/cmp/rest/RestGridModel.ts @@ -9,7 +9,7 @@ import {BaseFieldConfig} from '@xh/hoist/cmp/form'; import {GridConfig, GridModel} from '@xh/hoist/cmp/grid'; import {HoistModel, managed, PlainObject, ElementSpec, XH} from '@xh/hoist/core'; import '@xh/hoist/desktop/register'; -import {RecordAction, RecordActionSpec, StoreRecord} from '@xh/hoist/data'; +import {RecordAction, RecordActionLike, RecordActionSpec, StoreRecord} from '@xh/hoist/data'; import {Icon} from '@xh/hoist/icon/Icon'; import {pluralize, throwIf, withDefault} from '@xh/hoist/utils/js'; import {isFunction} from 'lodash'; @@ -29,7 +29,7 @@ export interface RestGridConfig extends GridConfig { toolbarActions?: Array; /** actions to display in the grid context menu. Defaults to add, edit, delete. */ - menuActions?: Array; + menuActions?: Array; /** Actions to display in the form toolbar. Defaults to delete. */ formActions?: Array; @@ -89,7 +89,7 @@ export class RestGridModel extends HoistModel { readonly: boolean; editors: RestGridEditor[]; toolbarActions: Array; - menuActions: Array; + menuActions: Array; formActions: Array; prepareCloneFn: (input: {record: StoreRecord; clone: PlainObject}) => void; unit: string; From 4cf86b883db9c49f77c5f1cfe8ab56162e41773c Mon Sep 17 00:00:00 2001 From: Leo Gretzinger Date: Mon, 12 Jun 2023 17:32:52 -0700 Subject: [PATCH 2/3] Add check for '-' and '|' as separators and create disabled toolbarSep button (to account for buttonGroup) in that case instead of action button --- data/RecordAction.ts | 2 +- desktop/cmp/record/RecordActionBar.ts | 26 +++++++++++++++----------- desktop/cmp/rest/RestGridModel.ts | 10 +++++----- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/data/RecordAction.ts b/data/RecordAction.ts index ae32933cb2..649477d004 100644 --- a/data/RecordAction.ts +++ b/data/RecordAction.ts @@ -56,7 +56,7 @@ export interface RecordActionSpec { recordsRequired?: boolean | number; } -export type RecordActionLike = RecordAction | RecordActionSpec | '-'; +export type RecordActionLike = RecordAction | RecordActionSpec | '-' | '|'; /** * Data passed to the Action Function of a RecordAction diff --git a/desktop/cmp/record/RecordActionBar.ts b/desktop/cmp/record/RecordActionBar.ts index 29158a1ea1..b2010bd218 100644 --- a/desktop/cmp/record/RecordActionBar.ts +++ b/desktop/cmp/record/RecordActionBar.ts @@ -7,8 +7,9 @@ import {Column, GridModel} from '@xh/hoist/cmp/grid'; import {hoistCmp} from '@xh/hoist/core'; -import {RecordActionSpec, RecordAction, StoreRecord, StoreSelectionModel} from '@xh/hoist/data'; -import {buttonGroup, ButtonGroupProps} from '@xh/hoist/desktop/cmp/button'; +import {RecordAction, RecordActionLike, StoreRecord, StoreSelectionModel} from '@xh/hoist/data'; +import {toolbarSep} from '@xh/hoist/desktop/cmp/toolbar'; +import {button, buttonGroup, ButtonGroupProps} from '@xh/hoist/desktop/cmp/button'; import '@xh/hoist/desktop/register'; import {throwIf} from '@xh/hoist/utils/js'; import {isEmpty} from 'lodash'; @@ -16,7 +17,7 @@ import {recordActionButton, RecordActionButtonProps} from './impl/RecordActionBu export interface RecordActionBarProps extends ButtonGroupProps { /** Actions to include. */ - actions: Array; + actions: Array; /** The StoreRecord to associate with the actions. Required if selModel is omitted. */ record?: StoreRecord; @@ -65,14 +66,17 @@ export const [RecordActionBar, recordActionBar] = hoistCmp.withFactory - recordActionButton({ - action: action instanceof RecordAction ? action : new RecordAction(action), - record, - selModel, - gridModel, - column, - ...buttonProps - }) + action !== '-' && action !== '|' + ? recordActionButton({ + action: + action instanceof RecordAction ? action : new RecordAction(action), + record, + selModel, + gridModel, + column, + ...buttonProps + }) + : button({text: toolbarSep(), disabled: true}) ), ...rest }); diff --git a/desktop/cmp/rest/RestGridModel.ts b/desktop/cmp/rest/RestGridModel.ts index 8cb83d9c55..61e068a26f 100644 --- a/desktop/cmp/rest/RestGridModel.ts +++ b/desktop/cmp/rest/RestGridModel.ts @@ -9,7 +9,7 @@ import {BaseFieldConfig} from '@xh/hoist/cmp/form'; import {GridConfig, GridModel} from '@xh/hoist/cmp/grid'; import {HoistModel, managed, PlainObject, ElementSpec, XH} from '@xh/hoist/core'; import '@xh/hoist/desktop/register'; -import {RecordAction, RecordActionLike, RecordActionSpec, StoreRecord} from '@xh/hoist/data'; +import {RecordActionLike, StoreRecord} from '@xh/hoist/data'; import {Icon} from '@xh/hoist/icon/Icon'; import {pluralize, throwIf, withDefault} from '@xh/hoist/utils/js'; import {isFunction} from 'lodash'; @@ -26,13 +26,13 @@ export interface RestGridConfig extends GridConfig { readonly?: boolean; /** Actions to display in the toolbar. Defaults to add, edit, delete. */ - toolbarActions?: Array; + toolbarActions?: Array; /** actions to display in the grid context menu. Defaults to add, edit, delete. */ menuActions?: Array; /** Actions to display in the form toolbar. Defaults to delete. */ - formActions?: Array; + formActions?: Array; /** Warning to display before actions on a selection of records. */ actionWarning?: { @@ -88,9 +88,9 @@ export class RestGridModel extends HoistModel { //---------------- readonly: boolean; editors: RestGridEditor[]; - toolbarActions: Array; + toolbarActions: Array; menuActions: Array; - formActions: Array; + formActions: Array; prepareCloneFn: (input: {record: StoreRecord; clone: PlainObject}) => void; unit: string; filterFields: string[] = null; From b5c57e2d74e2f490c60d6f5f6bff79227512f990 Mon Sep 17 00:00:00 2001 From: Leo Gretzinger Date: Tue, 15 Aug 2023 23:32:37 -0700 Subject: [PATCH 3/3] Remove '|' in RecordActionLike for further consideration and yarn install --- data/RecordAction.ts | 2 +- desktop/cmp/record/RecordActionBar.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/data/RecordAction.ts b/data/RecordAction.ts index 649477d004..ae32933cb2 100644 --- a/data/RecordAction.ts +++ b/data/RecordAction.ts @@ -56,7 +56,7 @@ export interface RecordActionSpec { recordsRequired?: boolean | number; } -export type RecordActionLike = RecordAction | RecordActionSpec | '-' | '|'; +export type RecordActionLike = RecordAction | RecordActionSpec | '-'; /** * Data passed to the Action Function of a RecordAction diff --git a/desktop/cmp/record/RecordActionBar.ts b/desktop/cmp/record/RecordActionBar.ts index b2010bd218..2f1d0aec03 100644 --- a/desktop/cmp/record/RecordActionBar.ts +++ b/desktop/cmp/record/RecordActionBar.ts @@ -66,7 +66,7 @@ export const [RecordActionBar, recordActionBar] = hoistCmp.withFactory - action !== '-' && action !== '|' + action !== '-' ? recordActionButton({ action: action instanceof RecordAction ? action : new RecordAction(action),