@multiplatform.one/backoffice 7.83.2 → 7.84.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/chrome/UserMenu.cjs +1 -1
- package/dist/cjs/chrome/UserMenu.native.js +1 -1
- package/dist/cjs/chrome/UserMenu.native.js.map +1 -1
- package/dist/cjs/form/FormToolbar.cjs +28 -24
- package/dist/cjs/form/FormToolbar.native.js +32 -28
- package/dist/cjs/form/FormToolbar.native.js.map +1 -1
- package/dist/cjs/list/ListSidebar.cjs +2 -0
- package/dist/cjs/list/ListSidebar.native.js +4 -0
- package/dist/cjs/list/ListSidebar.native.js.map +1 -1
- package/dist/cjs/views/ViewHeader.cjs +41 -12
- package/dist/cjs/views/ViewHeader.native.js +47 -16
- package/dist/cjs/views/ViewHeader.native.js.map +1 -1
- package/dist/cjs/views/viewMeta.cjs +4 -0
- package/dist/cjs/views/viewMeta.native.js +7 -0
- package/dist/cjs/views/viewMeta.native.js.map +1 -1
- package/dist/esm/chrome/UserMenu.mjs +1 -1
- package/dist/esm/chrome/UserMenu.mjs.map +1 -1
- package/dist/esm/chrome/UserMenu.native.js +1 -1
- package/dist/esm/chrome/UserMenu.native.js.map +1 -1
- package/dist/esm/form/FormToolbar.mjs +29 -25
- package/dist/esm/form/FormToolbar.mjs.map +1 -1
- package/dist/esm/form/FormToolbar.native.js +33 -29
- package/dist/esm/form/FormToolbar.native.js.map +1 -1
- package/dist/esm/list/ListSidebar.mjs +2 -0
- package/dist/esm/list/ListSidebar.mjs.map +1 -1
- package/dist/esm/list/ListSidebar.native.js +4 -0
- package/dist/esm/list/ListSidebar.native.js.map +1 -1
- package/dist/esm/views/ViewHeader.mjs +45 -16
- package/dist/esm/views/ViewHeader.mjs.map +1 -1
- package/dist/esm/views/ViewHeader.native.js +51 -20
- package/dist/esm/views/ViewHeader.native.js.map +1 -1
- package/dist/esm/views/viewMeta.mjs +4 -0
- package/dist/esm/views/viewMeta.mjs.map +1 -1
- package/dist/esm/views/viewMeta.native.js +7 -0
- package/dist/esm/views/viewMeta.native.js.map +1 -1
- package/dist/jsx/chrome/UserMenu.mjs +1 -1
- package/dist/jsx/chrome/UserMenu.mjs.map +1 -1
- package/dist/jsx/chrome/UserMenu.native.js +1 -1
- package/dist/jsx/chrome/UserMenu.native.js.map +1 -1
- package/dist/jsx/form/FormToolbar.mjs +29 -25
- package/dist/jsx/form/FormToolbar.mjs.map +1 -1
- package/dist/jsx/form/FormToolbar.native.js +32 -28
- package/dist/jsx/form/FormToolbar.native.js.map +1 -1
- package/dist/jsx/list/ListSidebar.mjs +2 -0
- package/dist/jsx/list/ListSidebar.mjs.map +1 -1
- package/dist/jsx/list/ListSidebar.native.js +4 -0
- package/dist/jsx/list/ListSidebar.native.js.map +1 -1
- package/dist/jsx/views/ViewHeader.mjs +45 -16
- package/dist/jsx/views/ViewHeader.mjs.map +1 -1
- package/dist/jsx/views/ViewHeader.native.js +47 -16
- package/dist/jsx/views/ViewHeader.native.js.map +1 -1
- package/dist/jsx/views/viewMeta.mjs +4 -0
- package/dist/jsx/views/viewMeta.mjs.map +1 -1
- package/dist/jsx/views/viewMeta.native.js +7 -0
- package/dist/jsx/views/viewMeta.native.js.map +1 -1
- package/package.json +14 -14
- package/src/chrome/UserMenu.screen.spec.tsx +17 -0
- package/src/chrome/UserMenu.tsx +1 -1
- package/src/design/DeskPhoneBoard.stories.tsx +64 -114
- package/src/form/FormToolbar.screen.spec.tsx +34 -3
- package/src/form/FormToolbar.tsx +38 -27
- package/src/list/DoctypeListScreen.guest.screen.spec.tsx +10 -0
- package/src/list/ListSidebar.screen.spec.tsx +28 -0
- package/src/list/ListSidebar.tsx +9 -0
- package/src/views/ViewHeader.screen.spec.tsx +22 -1
- package/src/views/ViewHeader.tsx +67 -29
- package/src/views/viewMeta.ts +5 -0
- package/types/form/FormToolbar.d.ts.map +1 -1
- package/types/list/ListSidebar.d.ts.map +1 -1
- package/types/views/ViewHeader.d.ts.map +1 -1
- package/types/views/viewMeta.d.ts.map +1 -1
|
@@ -4,19 +4,18 @@
|
|
|
4
4
|
import {
|
|
5
5
|
Chip,
|
|
6
6
|
DetailPageLayout,
|
|
7
|
-
H2,
|
|
8
7
|
Image,
|
|
9
8
|
List,
|
|
10
9
|
ListPageLayout,
|
|
10
|
+
DropdownMenu,
|
|
11
11
|
ListRow,
|
|
12
|
-
ListRowMeta,
|
|
13
12
|
PageHeader,
|
|
13
|
+
PageMenuButton,
|
|
14
14
|
PageSection,
|
|
15
|
-
Text,
|
|
16
|
-
ViewSwitcher,
|
|
17
15
|
XStack,
|
|
18
16
|
YStack,
|
|
19
17
|
ActionButton,
|
|
18
|
+
type DropdownMenuEntry,
|
|
20
19
|
} from "@multiplatform.one/components";
|
|
21
20
|
import {
|
|
22
21
|
Button,
|
|
@@ -25,7 +24,6 @@ import {
|
|
|
25
24
|
ImageField,
|
|
26
25
|
Input,
|
|
27
26
|
SearchInput,
|
|
28
|
-
ToggleGroup,
|
|
29
27
|
} from "@multiplatform.one/forms";
|
|
30
28
|
import { DataTable, type DataTableColumn } from "@multiplatform.one/table";
|
|
31
29
|
import {
|
|
@@ -34,9 +32,9 @@ import {
|
|
|
34
32
|
ChartBarIcon,
|
|
35
33
|
FunnelIcon,
|
|
36
34
|
ListBulletsIcon,
|
|
37
|
-
PlusIcon,
|
|
38
35
|
} from "@phosphor-icons/react";
|
|
39
36
|
import { useState } from "react";
|
|
37
|
+
import { LIST_PAGE_SIZE, ListPaging } from "../list/list-paging";
|
|
40
38
|
|
|
41
39
|
const meta = {
|
|
42
40
|
title: "Boards/Freeform/Backoffice",
|
|
@@ -94,14 +92,20 @@ const views = [
|
|
|
94
92
|
|
|
95
93
|
function HeaderActions({ view }: { view: string }) {
|
|
96
94
|
const [current, setCurrent] = useState(view);
|
|
95
|
+
const entries: DropdownMenuEntry[] = views.map(({ type, label, icon: Icon }) => ({
|
|
96
|
+
key: type,
|
|
97
|
+
label,
|
|
98
|
+
icon: <Icon />,
|
|
99
|
+
checked: type === current,
|
|
100
|
+
onSelect: () => setCurrent(type),
|
|
101
|
+
}));
|
|
97
102
|
return (
|
|
98
|
-
|
|
99
|
-
<
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
</XStack>
|
|
103
|
+
<>
|
|
104
|
+
<DropdownMenu items={entries} closeOnSelect placement="bottom-end">
|
|
105
|
+
<PageMenuButton />
|
|
106
|
+
</DropdownMenu>
|
|
107
|
+
<ActionButton kind="add" />
|
|
108
|
+
</>
|
|
105
109
|
);
|
|
106
110
|
}
|
|
107
111
|
|
|
@@ -110,34 +114,21 @@ function FilterBar({ filters }: { filters?: number }) {
|
|
|
110
114
|
return (
|
|
111
115
|
<XStack gap="$2" alignItems="center" justifyContent="space-between">
|
|
112
116
|
<IconButton icon={FunnelIcon} aria-label={filters ? `Filter (${filters})` : "Filter"} />
|
|
113
|
-
<Button iconAfter={ArrowDownIcon}>Last
|
|
117
|
+
<Button iconAfter={ArrowDownIcon}>Last updated on</Button>
|
|
114
118
|
</XStack>
|
|
115
119
|
);
|
|
116
120
|
}
|
|
117
121
|
|
|
118
|
-
/**
|
|
122
|
+
/** The list's paging, as the desk list screen draws it. */
|
|
119
123
|
function PageFoot({ shown, total }: { shown: number; total: number }) {
|
|
120
|
-
const [
|
|
124
|
+
const [pageIndex, setPageIndex] = useState(0);
|
|
121
125
|
return (
|
|
122
|
-
<
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
aria-label="Page size"
|
|
129
|
-
type="single"
|
|
130
|
-
value={size}
|
|
131
|
-
onChange={(value) => setSize(Array.isArray(value) ? (value[0] ?? "20") : value)}
|
|
132
|
-
options={[
|
|
133
|
-
{ label: "20", value: "20" },
|
|
134
|
-
{ label: "100", value: "100" },
|
|
135
|
-
{ label: "500", value: "500" },
|
|
136
|
-
]}
|
|
137
|
-
/>
|
|
138
|
-
<Button>Load More</Button>
|
|
139
|
-
</XStack>
|
|
140
|
-
</YStack>
|
|
126
|
+
<ListPaging
|
|
127
|
+
pagination={{ pageIndex, pageSize: LIST_PAGE_SIZE, totalCount: total }}
|
|
128
|
+
onPaginationChange={(next) => setPageIndex(next.pageIndex)}
|
|
129
|
+
shown={shown}
|
|
130
|
+
total={total}
|
|
131
|
+
/>
|
|
141
132
|
);
|
|
142
133
|
}
|
|
143
134
|
|
|
@@ -145,10 +136,10 @@ export const ListView = {
|
|
|
145
136
|
name: "List",
|
|
146
137
|
render: () => (
|
|
147
138
|
<ListPageLayout
|
|
148
|
-
header={<PageHeader
|
|
139
|
+
header={<PageHeader title="Pokemon" actions={<HeaderActions view="list" />} />}
|
|
149
140
|
toolbar={
|
|
150
141
|
<YStack gap="$3">
|
|
151
|
-
<SearchInput placeholder="Pokemon
|
|
142
|
+
<SearchInput placeholder="Pokemon name" aria-label="Pokemon name" defaultValue="" />
|
|
152
143
|
<FilterBar />
|
|
153
144
|
</YStack>
|
|
154
145
|
}
|
|
@@ -159,14 +150,10 @@ export const ListView = {
|
|
|
159
150
|
aria-label="Pokemon"
|
|
160
151
|
renderItem={(doc) => (
|
|
161
152
|
<ListRow
|
|
162
|
-
|
|
153
|
+
media={<Image src={sprite(doc.poke_id)} alt="" size="extraSmall" />}
|
|
163
154
|
title={doc.pokemon_name}
|
|
164
|
-
subtitle={
|
|
165
|
-
|
|
166
|
-
{doc.species} · Poke ID {doc.poke_id}
|
|
167
|
-
</Text>
|
|
168
|
-
}
|
|
169
|
-
meta={<ListRowMeta color="$color10">{doc.modified}</ListRowMeta>}
|
|
155
|
+
subtitle={doc.species}
|
|
156
|
+
meta={doc.modified}
|
|
170
157
|
/>
|
|
171
158
|
)}
|
|
172
159
|
/>
|
|
@@ -176,40 +163,30 @@ export const ListView = {
|
|
|
176
163
|
),
|
|
177
164
|
};
|
|
178
165
|
|
|
179
|
-
const numberHeader = (label: string) => () => (
|
|
180
|
-
<Text flex={1} textAlign="right" numberOfLines={1}>
|
|
181
|
-
{label}
|
|
182
|
-
</Text>
|
|
183
|
-
);
|
|
184
|
-
|
|
185
166
|
const reportColumns = [
|
|
186
167
|
{
|
|
187
168
|
accessorKey: "pokemon_name",
|
|
188
|
-
header: "Pokemon
|
|
169
|
+
header: "Pokemon name",
|
|
189
170
|
width: 164,
|
|
190
171
|
cell: ({ row }) => (
|
|
191
|
-
<
|
|
192
|
-
<Image src={sprite(row.original.poke_id)} alt="" size="extraSmall" />
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
{row.original.species}
|
|
197
|
-
</Text>
|
|
198
|
-
</YStack>
|
|
199
|
-
</XStack>
|
|
172
|
+
<ListRow
|
|
173
|
+
media={<Image src={sprite(row.original.poke_id)} alt="" size="extraSmall" />}
|
|
174
|
+
title={row.original.pokemon_name}
|
|
175
|
+
subtitle={row.original.species}
|
|
176
|
+
/>
|
|
200
177
|
),
|
|
201
178
|
},
|
|
202
179
|
{
|
|
203
180
|
accessorKey: "poke_id",
|
|
204
181
|
width: 90,
|
|
205
|
-
header:
|
|
182
|
+
header: "Poke ID",
|
|
206
183
|
align: "right",
|
|
207
184
|
meta: { label: "Poke ID", align: "right" },
|
|
208
185
|
},
|
|
209
186
|
{
|
|
210
187
|
accessorKey: "weight",
|
|
211
188
|
width: 96,
|
|
212
|
-
header:
|
|
189
|
+
header: "Weight",
|
|
213
190
|
align: "right",
|
|
214
191
|
meta: { label: "Weight (hg)", align: "right" },
|
|
215
192
|
},
|
|
@@ -219,7 +196,7 @@ export const ReportView = {
|
|
|
219
196
|
name: "Report",
|
|
220
197
|
render: () => (
|
|
221
198
|
<ListPageLayout
|
|
222
|
-
header={<PageHeader
|
|
199
|
+
header={<PageHeader title="Pokemon" actions={<HeaderActions view="report" />} />}
|
|
223
200
|
toolbar={
|
|
224
201
|
<YStack gap="$3">
|
|
225
202
|
<FilterBar filters={1} />
|
|
@@ -244,8 +221,8 @@ export const ReportView = {
|
|
|
244
221
|
enableSorting={false}
|
|
245
222
|
/>
|
|
246
223
|
<XStack gap="$2" flexWrap="wrap">
|
|
247
|
-
<Button>Pick
|
|
248
|
-
<Button>Group
|
|
224
|
+
<Button>Pick columns</Button>
|
|
225
|
+
<Button>Group by</Button>
|
|
249
226
|
</XStack>
|
|
250
227
|
<PageFoot shown={pokemon.length} total={151} />
|
|
251
228
|
</YStack>
|
|
@@ -264,64 +241,37 @@ export const FormView = {
|
|
|
264
241
|
name: "Form",
|
|
265
242
|
render: () => (
|
|
266
243
|
<DetailPageLayout
|
|
267
|
-
header={
|
|
268
|
-
<PageHeader
|
|
269
|
-
heading={
|
|
270
|
-
<YStack gap="$1">
|
|
271
|
-
<H2>Caterpie</H2>
|
|
272
|
-
<Text color="$color11">Not Saved</Text>
|
|
273
|
-
</YStack>
|
|
274
|
-
}
|
|
275
|
-
/>
|
|
276
|
-
}
|
|
244
|
+
header={<PageHeader title="Caterpie" subtitle="Not saved" />}
|
|
277
245
|
toolbarLeading={
|
|
278
|
-
<
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
</Button>
|
|
282
|
-
</YStack>
|
|
246
|
+
<Button chromeless edge="start" icon={CaretLeftIcon}>
|
|
247
|
+
Pokemon
|
|
248
|
+
</Button>
|
|
283
249
|
}
|
|
284
250
|
toolbarTrailing={
|
|
285
|
-
|
|
251
|
+
<>
|
|
286
252
|
<ActionButton kind="more" label="More actions" />
|
|
287
253
|
<ActionButton kind="save" />
|
|
288
|
-
|
|
254
|
+
</>
|
|
289
255
|
}
|
|
290
256
|
>
|
|
291
257
|
<PageSection>
|
|
292
|
-
<FormGrid>
|
|
293
|
-
<Input label="Pokemon
|
|
258
|
+
<FormGrid columns={2}>
|
|
259
|
+
<Input label="Pokemon name" defaultValue="Caterpie" />
|
|
294
260
|
<Input label="Species" defaultValue="Worm Pokémon" />
|
|
261
|
+
<Input label="Poke ID" defaultValue="10" keyboardType="numeric" />
|
|
262
|
+
<Input label="Base experience" defaultValue="39" keyboardType="numeric" />
|
|
263
|
+
<Input label="Height (dm)" defaultValue="3" keyboardType="numeric" />
|
|
264
|
+
<Input label="Weight (hg)" defaultValue="29" keyboardType="numeric" />
|
|
295
265
|
</FormGrid>
|
|
296
|
-
<XStack gap="$4">
|
|
297
|
-
<YStack flex={1}>
|
|
298
|
-
<Input label="Poke ID" defaultValue="10" keyboardType="numeric" />
|
|
299
|
-
</YStack>
|
|
300
|
-
<YStack flex={1}>
|
|
301
|
-
<Input label="Base Experience" defaultValue="39" keyboardType="numeric" />
|
|
302
|
-
</YStack>
|
|
303
|
-
</XStack>
|
|
304
|
-
<XStack gap="$4">
|
|
305
|
-
<YStack flex={1}>
|
|
306
|
-
<Input label="Height (dm)" defaultValue="3" keyboardType="numeric" />
|
|
307
|
-
</YStack>
|
|
308
|
-
<YStack flex={1}>
|
|
309
|
-
<Input label="Weight (hg)" defaultValue="29" keyboardType="numeric" />
|
|
310
|
-
</YStack>
|
|
311
|
-
</XStack>
|
|
312
266
|
</PageSection>
|
|
313
267
|
<PageSection title="Sprites">
|
|
314
|
-
<
|
|
315
|
-
<
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
defaultValue="https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/back/10.png"
|
|
322
|
-
/>
|
|
323
|
-
</YStack>
|
|
324
|
-
</XStack>
|
|
268
|
+
<FormGrid columns={2}>
|
|
269
|
+
<ImageField label="Sprite (front)" defaultValue={sprite(10)} />
|
|
270
|
+
<ImageField
|
|
271
|
+
label="Sprite (back)"
|
|
272
|
+
defaultValue="https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/back/10.png"
|
|
273
|
+
/>
|
|
274
|
+
</FormGrid>
|
|
325
275
|
</PageSection>
|
|
326
276
|
<PageSection title="Stats">
|
|
327
277
|
<DataTable
|
|
@@ -329,8 +279,8 @@ export const FormView = {
|
|
|
329
279
|
columns={
|
|
330
280
|
[
|
|
331
281
|
{ accessorKey: "stat", header: "Stat" },
|
|
332
|
-
{ accessorKey: "base_stat", header:
|
|
333
|
-
{ accessorKey: "effort", header:
|
|
282
|
+
{ accessorKey: "base_stat", header: "Base stat", align: "right" },
|
|
283
|
+
{ accessorKey: "effort", header: "Effort", align: "right" },
|
|
334
284
|
] as DataTableColumn<(typeof stats)[number]>[]
|
|
335
285
|
}
|
|
336
286
|
layout="table"
|
|
@@ -341,7 +291,7 @@ export const FormView = {
|
|
|
341
291
|
enableColumnVisibility={false}
|
|
342
292
|
/>
|
|
343
293
|
<XStack>
|
|
344
|
-
<
|
|
294
|
+
<ActionButton kind="add" label="Add row" />
|
|
345
295
|
</XStack>
|
|
346
296
|
</PageSection>
|
|
347
297
|
</DetailPageLayout>
|
|
@@ -197,7 +197,7 @@ describe("FormToolbar", () => {
|
|
|
197
197
|
expect(onNextDoc).toHaveBeenCalledTimes(1);
|
|
198
198
|
});
|
|
199
199
|
|
|
200
|
-
it("puts back in the phone top bar
|
|
200
|
+
it("puts back, Save and the chromeless menu in the phone top bar, the title centred in it (LC-145, LC-270)", () => {
|
|
201
201
|
layout.size = "compact";
|
|
202
202
|
const onNavigate = vi.fn();
|
|
203
203
|
renderWithProviders(
|
|
@@ -216,8 +216,9 @@ describe("FormToolbar", () => {
|
|
|
216
216
|
expect(bar.contains(screen.getByTestId("form-toolbar-save"))).toBe(true);
|
|
217
217
|
expect(bar.contains(screen.getByTestId("form-toolbar-menu"))).toBe(true);
|
|
218
218
|
const title = screen.getByRole("heading", { name: "SO-0001" });
|
|
219
|
-
expect(bar.contains(title)).toBe(
|
|
220
|
-
expect(
|
|
219
|
+
expect(bar.contains(title)).toBe(true);
|
|
220
|
+
expect(title.getAttribute("aria-level")).toBe("1");
|
|
221
|
+
expect(document.querySelector("h1")).toBeNull();
|
|
221
222
|
expect(screen.getByTestId("form-toolbar-menu").getAttribute("data-top-bar-control")).toBe(
|
|
222
223
|
"menu",
|
|
223
224
|
);
|
|
@@ -226,6 +227,36 @@ describe("FormToolbar", () => {
|
|
|
226
227
|
expect(onNavigate).toHaveBeenCalledWith("/backoffice/sales-order");
|
|
227
228
|
});
|
|
228
229
|
|
|
230
|
+
it("keeps the large title under the breadcrumbs on a wide screen (LC-270 is phone only)", () => {
|
|
231
|
+
renderWithProviders(<FormToolbar {...props()} />);
|
|
232
|
+
const title = screen.getByRole("heading", { name: "SO-0001" });
|
|
233
|
+
expect(title.tagName).toBe("H1");
|
|
234
|
+
expect(document.querySelector("[data-bar-title]")).toBeNull();
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
it("opens the record's … over its button with no X, rows from the top, Escape closes (LC-112)", async () => {
|
|
238
|
+
layout.size = "compact";
|
|
239
|
+
renderWithProviders(
|
|
240
|
+
<FormToolbar
|
|
241
|
+
{...props({
|
|
242
|
+
indicator: "saved",
|
|
243
|
+
canSubmit: false,
|
|
244
|
+
onPrevDoc: vi.fn(),
|
|
245
|
+
onNextDoc: vi.fn(),
|
|
246
|
+
menuItems: [{ key: "reload", label: "Reload", onSelect: vi.fn() }],
|
|
247
|
+
})}
|
|
248
|
+
/>,
|
|
249
|
+
);
|
|
250
|
+
fireEvent.click(screen.getByTestId("form-toolbar-menu"));
|
|
251
|
+
const menu = await screen.findByRole("menu");
|
|
252
|
+
expect(menu.querySelector('[aria-label="Close"]')).toBeNull();
|
|
253
|
+
expect(screen.queryByRole("button", { name: "Close" })).toBeNull();
|
|
254
|
+
const rows = screen.getAllByRole("menuitem");
|
|
255
|
+
expect(rows[0].textContent).toContain("Previous document");
|
|
256
|
+
fireEvent.keyDown(menu, { key: "Escape" });
|
|
257
|
+
await waitFor(() => expect(screen.queryByRole("menu")).toBeNull());
|
|
258
|
+
});
|
|
259
|
+
|
|
229
260
|
it("pages prev/next and disables the boundary arrow instead of hiding it", () => {
|
|
230
261
|
const onPrevDoc = vi.fn();
|
|
231
262
|
const onNextDoc = vi.fn();
|
package/src/form/FormToolbar.tsx
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
PageBackButton,
|
|
8
8
|
PageHeader,
|
|
9
9
|
PageMenuButton,
|
|
10
|
+
PushedPage,
|
|
10
11
|
ScreenToolbar,
|
|
11
12
|
StatusDot,
|
|
12
13
|
XStack,
|
|
@@ -439,35 +440,45 @@ export function FormToolbar({
|
|
|
439
440
|
) : undefined;
|
|
440
441
|
|
|
441
442
|
if (isNarrow) {
|
|
442
|
-
// LC-145: back leads the top bar on the row Save and "…" trail
|
|
443
|
-
//
|
|
443
|
+
// LC-145: back leads the top bar on the row Save and "…" trail. LC-270:
|
|
444
|
+
// the record is a pushed page, so its title sits centred in that bar.
|
|
445
|
+
// Back goes to the list crumb.
|
|
444
446
|
const back = [...breadcrumbs].reverse().find((crumb) => crumb.href);
|
|
445
447
|
return (
|
|
446
|
-
<
|
|
447
|
-
<
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
448
|
+
<PushedPage>
|
|
449
|
+
<YStack
|
|
450
|
+
{...knobProps.panelPadding}
|
|
451
|
+
paddingBottom={0}
|
|
452
|
+
gap="$2"
|
|
453
|
+
flexShrink={0}
|
|
454
|
+
testID="form-toolbar"
|
|
455
|
+
>
|
|
456
|
+
<ScreenToolbar
|
|
457
|
+
title={title}
|
|
458
|
+
leading={
|
|
459
|
+
back?.href ? (
|
|
460
|
+
<PageBackButton
|
|
461
|
+
label={back.label}
|
|
462
|
+
onPress={() => onNavigate(back.href as string)}
|
|
463
|
+
aria-label={t("backToList", "Back to {{doctype}} list", { doctype: back.label })}
|
|
464
|
+
testID="form-toolbar-back"
|
|
465
|
+
/>
|
|
466
|
+
) : null
|
|
467
|
+
}
|
|
468
|
+
trailing={
|
|
469
|
+
<>
|
|
470
|
+
{saveButton}
|
|
471
|
+
{menuButton}
|
|
472
|
+
</>
|
|
473
|
+
}
|
|
474
|
+
// The block pads the bar and the title alike, so the bar takes no
|
|
475
|
+
// inset or bleed of its own and back stays on the title's line.
|
|
476
|
+
padding={0}
|
|
477
|
+
marginHorizontal={0}
|
|
478
|
+
/>
|
|
479
|
+
<PageHeader title={title} heading={heading} status={status} divider={false} />
|
|
480
|
+
</YStack>
|
|
481
|
+
</PushedPage>
|
|
471
482
|
);
|
|
472
483
|
}
|
|
473
484
|
|
|
@@ -186,6 +186,16 @@ describe("DoctypeListScreen with DocType meta refused (LC-96)", () => {
|
|
|
186
186
|
expect(screen.getByText("Seed monster")).toBeTruthy();
|
|
187
187
|
});
|
|
188
188
|
|
|
189
|
+
it("leads a guest's phone rows with the record's image (FZ-7684)", async () => {
|
|
190
|
+
layout.size = "compact";
|
|
191
|
+
renderList();
|
|
192
|
+
await waitFor(() => expect(screen.getByText("bulbasaur")).toBeTruthy(), settle);
|
|
193
|
+
await waitFor(
|
|
194
|
+
() => expect(document.querySelector('img[src$="/files/bulbasaur.png"]')).toBeTruthy(),
|
|
195
|
+
settle,
|
|
196
|
+
);
|
|
197
|
+
});
|
|
198
|
+
|
|
189
199
|
it("keeps compact rows in a bounded document list", async () => {
|
|
190
200
|
layout.size = "compact";
|
|
191
201
|
renderList();
|
|
@@ -27,6 +27,7 @@ interface FacetCall {
|
|
|
27
27
|
let run = 0;
|
|
28
28
|
let calls: FacetCall[] = [];
|
|
29
29
|
let failFacets = false;
|
|
30
|
+
let emptyFacets = false;
|
|
30
31
|
|
|
31
32
|
function json(body: unknown, status = 200) {
|
|
32
33
|
return new Response(JSON.stringify(body), {
|
|
@@ -64,6 +65,7 @@ beforeEach(() => {
|
|
|
64
65
|
run += 1;
|
|
65
66
|
calls = [];
|
|
66
67
|
failFacets = false;
|
|
68
|
+
emptyFacets = false;
|
|
67
69
|
vi.stubGlobal("fetch", async (input: string | URL | Request, init?: RequestInit) => {
|
|
68
70
|
const url = new URL(String(input instanceof Request ? input.url : input));
|
|
69
71
|
const method = url.pathname.replace(/^\/api\/method\//, "");
|
|
@@ -73,6 +75,11 @@ beforeEach(() => {
|
|
|
73
75
|
if (method.startsWith("frappe.desk.")) {
|
|
74
76
|
calls.push({ method, body });
|
|
75
77
|
if (failFacets) return json({ exc_type: "PermissionError" }, 403);
|
|
78
|
+
if (emptyFacets) {
|
|
79
|
+
return method === "frappe.desk.reportview.get_sidebar_stats"
|
|
80
|
+
? json({ message: { stats: {} } })
|
|
81
|
+
: json({ message: [] });
|
|
82
|
+
}
|
|
76
83
|
}
|
|
77
84
|
if (method === "frappe.desk.listview.get_group_by_count") {
|
|
78
85
|
return json({ message: groupBy[body.field] ?? [] });
|
|
@@ -95,6 +102,7 @@ interface SidebarOptions {
|
|
|
95
102
|
filters?: FrappeFilters;
|
|
96
103
|
hiddenSections?: ListSidebarSection[];
|
|
97
104
|
capabilities?: BackofficeCapabilities;
|
|
105
|
+
fill?: boolean;
|
|
98
106
|
}
|
|
99
107
|
|
|
100
108
|
function renderSidebar({
|
|
@@ -102,6 +110,7 @@ function renderSidebar({
|
|
|
102
110
|
filters = [],
|
|
103
111
|
hiddenSections,
|
|
104
112
|
capabilities,
|
|
113
|
+
fill,
|
|
105
114
|
}: SidebarOptions = {}) {
|
|
106
115
|
const onFiltersChange = vi.fn();
|
|
107
116
|
renderWithProviders(
|
|
@@ -116,6 +125,7 @@ function renderSidebar({
|
|
|
116
125
|
filters={filters}
|
|
117
126
|
onFiltersChange={onFiltersChange}
|
|
118
127
|
hiddenSections={hiddenSections}
|
|
128
|
+
fill={fill}
|
|
119
129
|
/>
|
|
120
130
|
</BackofficeProvider>,
|
|
121
131
|
);
|
|
@@ -199,4 +209,22 @@ describe("ListSidebar", () => {
|
|
|
199
209
|
renderSidebar();
|
|
200
210
|
expect(await screen.findByText("Filters sidebar unavailable")).toBeTruthy();
|
|
201
211
|
});
|
|
212
|
+
|
|
213
|
+
// FZ-8939 (LC-39): the desk Pokemon list has no assignments, owners, tags or
|
|
214
|
+
// status to count. Its sidebar drew a 200pt column of nothing and pushed the
|
|
215
|
+
// table off the page's leading edge.
|
|
216
|
+
it("draws no column once every facet resolves empty", async () => {
|
|
217
|
+
emptyFacets = true;
|
|
218
|
+
renderSidebar();
|
|
219
|
+
await waitFor(() => expect(calls).toHaveLength(4));
|
|
220
|
+
await waitFor(() => expect(screen.queryByLabelText("List filters sidebar")).toBeNull());
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
it("keeps its group in the shell rail when every facet resolves empty (LC-101)", async () => {
|
|
224
|
+
emptyFacets = true;
|
|
225
|
+
renderSidebar({ fill: true });
|
|
226
|
+
await waitFor(() => expect(calls).toHaveLength(4));
|
|
227
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
228
|
+
expect(screen.getByLabelText("List filters sidebar")).toBeTruthy();
|
|
229
|
+
});
|
|
202
230
|
});
|
package/src/list/ListSidebar.tsx
CHANGED
|
@@ -162,6 +162,15 @@ export function ListSidebar({
|
|
|
162
162
|
// Whole surface unavailable — every facet errored (e.g. no read perm).
|
|
163
163
|
const unavailable = sections.every((section) => !section.state.loading && section.state.error);
|
|
164
164
|
|
|
165
|
+
// LC-39 (FZ-8939): standing as the page's own column, a sidebar whose facets
|
|
166
|
+
// all resolved empty is a fixed column of nothing that pushed the list off
|
|
167
|
+
// the page's leading edge (Tier 2 `screens-backoffice-desk-pokemon--list`).
|
|
168
|
+
// In the shell rail (`fill`) it is a group under the nav and costs no column.
|
|
169
|
+
const resolvedEmpty = sections.every(
|
|
170
|
+
(section) => !section.state.loading && !section.state.error && section.rows.length === 0,
|
|
171
|
+
);
|
|
172
|
+
if (resolvedEmpty && !fill) return null;
|
|
173
|
+
|
|
165
174
|
return (
|
|
166
175
|
<YStack
|
|
167
176
|
width={
|
|
@@ -5,7 +5,7 @@ import React from "react";
|
|
|
5
5
|
import { InMemoryFixtureProvider } from "@multiplatform.one/frappe";
|
|
6
6
|
import { renderWithProviders } from "@multiplatform.one/test-utils";
|
|
7
7
|
import { act, fireEvent, screen, waitFor } from "@testing-library/react";
|
|
8
|
-
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
8
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
9
9
|
import { BackofficeProvider } from "../config/BackofficeProvider";
|
|
10
10
|
import type { BackofficeCapabilities } from "../config/capabilities";
|
|
11
11
|
import { createMemoryNavigator, type MemoryNavigator } from "../navigation/navigator";
|
|
@@ -183,3 +183,24 @@ describe("<ViewHeader />", () => {
|
|
|
183
183
|
expect(bench.rolesAnswered()).toBe(true);
|
|
184
184
|
});
|
|
185
185
|
});
|
|
186
|
+
|
|
187
|
+
describe("<ViewHeader /> on a phone (FZ-7684)", () => {
|
|
188
|
+
const width = window.innerWidth;
|
|
189
|
+
beforeEach(() => {
|
|
190
|
+
window.innerWidth = 390;
|
|
191
|
+
});
|
|
192
|
+
afterEach(() => {
|
|
193
|
+
window.innerWidth = width;
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
it("leaves the title to the top bar and puts views and Open in Desk in one menu", async () => {
|
|
197
|
+
const bench = renderBenchHeader(["Guest"]);
|
|
198
|
+
fireEvent.click(await screen.findByTestId("view-header-more", {}, { timeout: 5000 }));
|
|
199
|
+
await screen.findByRole("menu", {}, { timeout: 5000 });
|
|
200
|
+
await waitFor(() => expect(offeredViews()).toContain("List"));
|
|
201
|
+
expect(screen.getByText("Open in Desk")).toBeTruthy();
|
|
202
|
+
await bench.settle();
|
|
203
|
+
expect(screen.queryByRole("heading", { name: "Poke Move" })).toBeNull();
|
|
204
|
+
expect(screen.queryByTestId("list-view-switcher")).toBeNull();
|
|
205
|
+
});
|
|
206
|
+
});
|