@nocobase/app-skills 0.1.0-beta.58 → 0.1.0-beta.60
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/package.json +1 -1
- package/skills/nocobase-app-development/SKILL.md +8 -4
- package/skills/nocobase-app-development/assets/business-examples/onboarding/tests/client/onboarding.test.tsx +26 -3
- package/skills/nocobase-app-development/assets/business-examples/onboarding/tests/server/onboarding.test.ts +13 -1
- package/skills/nocobase-app-development/assets/business-examples/procurement/tests/server/procurement.test.ts +15 -1
- package/skills/nocobase-app-development/assets/customer-contacts-example/client/pages/customer-contacts/detail.tsx +66 -55
- package/skills/nocobase-app-development/assets/customer-contacts-example/client/pages/customer-contacts/index.tsx +11 -29
- package/skills/nocobase-app-development/assets/customer-contacts-example/client/pages/customer-contacts/locales.ts +0 -2
- package/skills/nocobase-app-development/assets/customer-contacts-example/client/pages/customer-contacts/relation-picker.tsx +68 -18
- package/skills/nocobase-app-development/assets/customer-contacts-example/client/pages/customer-contacts/shared.tsx +32 -12
- package/skills/nocobase-app-development/assets/customer-contacts-example/tests/client/customer-contacts.test.tsx +155 -2
- package/skills/nocobase-app-development/assets/list-edit-example/client/pages/skill-projects/detail.tsx +103 -0
- package/skills/nocobase-app-development/assets/list-edit-example/client/pages/skill-projects/index.tsx +7 -2
- package/skills/nocobase-app-development/assets/list-edit-example/client/pages/skill-projects/locales.ts +5 -0
- package/skills/nocobase-app-development/assets/list-edit-example/tests/client/skill-projects.test.tsx +88 -0
- package/skills/nocobase-app-development/references/frontend/frontend-dev.md +2 -0
- package/skills/nocobase-app-development/references/frontend/references/child-routes.md +14 -15
- package/skills/nocobase-app-development/references/frontend/references/example/copy.md +0 -4
- package/skills/nocobase-app-development/references/frontend/references/example/create-page.md +12 -8
- package/skills/nocobase-app-development/references/frontend/references/example/detail-page-tabs.md +13 -11
- package/skills/nocobase-app-development/references/frontend/references/example/list-page.md +1 -1
- package/skills/nocobase-app-development/references/frontend/references/example/project-dashboard.md +21 -21
- package/skills/nocobase-app-development/references/frontend/references/example/project-summary.md +8 -27
- package/skills/nocobase-app-development/references/frontend/references/example/server-table.md +1 -1
- package/skills/nocobase-app-development/references/frontend/references/executable-list-edit.md +35 -3
- package/skills/nocobase-app-development/references/frontend/references/list-feedback.md +27 -22
- package/skills/nocobase-app-development/references/frontend/references/navigation.md +99 -0
- package/skills/nocobase-app-development/references/frontend/references/overlay.md +31 -0
- package/skills/nocobase-app-development/references/frontend/references/page-freshness.md +23 -0
- package/skills/nocobase-app-development/references/frontend/references/page.md +52 -53
- package/skills/nocobase-app-development/references/frontend/references/shell.md +2 -1
- package/skills/nocobase-app-development/references/frontend/references/styling.md +8 -8
- package/skills/nocobase-app-development/references/frontend/references/table.md +1 -1
- package/skills/nocobase-app-development/references/frontend/references/ui-library.md +45 -9
- package/skills/nocobase-app-development/references/frontend/ui-guidelines.md +13 -9
- package/skills/nocobase-app-development/references/lifecycle-ui.md +3 -3
- package/skills/nocobase-app-development/references/lifecycle.md +1 -1
- package/skills/nocobase-app-development/references/organization/settings-page.md +8 -4
- package/skills/nocobase-app-development/references/pending-feedback.md +132 -0
- package/skills/nocobase-app-development/references/settings-navigation.md +72 -0
- package/skills/nocobase-app-development/references/system-administration.md +4 -4
- package/skills/nocobase-app-development/references/system-settings.md +8 -4
- package/skills/nocobase-app-plugin-development/references/client-child-routes.md +2 -0
- package/skills/nocobase-app-upgrade/SKILL.md +4 -0
- package/skills/nocobase-app-upgrade/references/list-feedback-upgrade.md +2 -0
- package/skills/nocobase-app-upgrade/references/notification-template-upgrade.md +12 -0
- package/skills/nocobase-app-upgrade/references/settings-navigation-upgrade.md +35 -0
package/package.json
CHANGED
|
@@ -87,6 +87,10 @@ Install, update and customize plugins, and remove a direct NocoBase package, as
|
|
|
87
87
|
|
|
88
88
|
Business role assignments must be visible and editable through administration. Default to explicit users; do not assign application roles to every authenticated identity or broaden the inherited member role merely to enable a feature. Follow [permission assignment safety](references/authorization.md#visible-and-manageable-assignments) and run the template's initialized-assignment guard before delivery.
|
|
89
89
|
|
|
90
|
+
## Waiting feedback
|
|
91
|
+
|
|
92
|
+
For page/panel waits and native submit buttons, follow [pending feedback](references/pending-feedback.md). Use installed Loading/PendingButton and the shared timing hook; retain submission and list-state owners.
|
|
93
|
+
|
|
90
94
|
## Choose sample data or a demo system
|
|
91
95
|
|
|
92
96
|
A request to add example customers, orders or tasks normally means sample data in the existing application. Use `sample: true` seeds or `sampleDataToken`; see [sample data and demo systems](references/migrations.md#sample-data-and-demo-systems). Keep required initialization data in ordinary seeds. Do not infer an isolated demo deployment from the words "demo data" alone.
|
|
@@ -97,9 +101,9 @@ When the application already depends on `@nocobase/app-plugin-demo-mode`, a chan
|
|
|
97
101
|
|
|
98
102
|
## Deliver system administration by default
|
|
99
103
|
|
|
100
|
-
When a user asks you to build a complete application, deliver
|
|
104
|
+
When a user asks you to build a complete application, deliver the System settings structure ([System settings navigation](references/settings-navigation.md)) and administration pages alongside the business features, unless the user explicitly excludes them or requests a narrower deliverable such as an API-only service or a prototype explicitly limited to business screens. Users do not need to request administration pages individually. Include user management and role and permission management by default. Register workflow management, background tasks and other applicable administration as module cards of the System settings home; show execution status, failures and supported recovery actions within each capability's pages, without an additional Operational monitoring group. Reuse existing pages and installed plugins, and implement missing application-owned pages. Read [system administration](references/system-administration.md) for the baseline, capability-specific pages and acceptance criteria. For a focused feature change, extend existing administration where that feature requires it.
|
|
101
105
|
|
|
102
|
-
Whenever application requirements include a process to develop, deliver its workflow management pages by default, even when the user mentions only the business process. Reuse the installed `workflow-management` UI Library block, or install it with `yes n | pnpm exec shadcn add @nocobase/workflow-management`. Follow [Lifecycle UI](references/lifecycle-ui.md) for installation, application adapters and the default layout: one Workflow management
|
|
106
|
+
Whenever application requirements include a process to develop, deliver its workflow management pages by default, even when the user mentions only the business process. Reuse the installed `workflow-management` UI Library block, or install it with `yes n | pnpm exec shadcn add @nocobase/workflow-management`. Follow [Lifecycle UI](references/lifecycle-ui.md) for installation, application adapters and the default layout: one Workflow management settings card with in-page Definitions and Executions tabs, definition diagrams with visible parameter forms, and execution details with history and effects. The two tab views use URL-backed child routes without sidebar `navigation`. Extend an existing management area rather than adding a duplicate. Follow the scope exceptions in [system administration](references/system-administration.md#default-delivery).
|
|
103
107
|
|
|
104
108
|
For process management, distinguish administrator-adjustable reviewers, departments, thresholds and other [lifecycle parameters](references/lifecycle-parameters.md) from workflow structure, which remains defined in source unless a supported visual designer is explicitly required.
|
|
105
109
|
|
|
@@ -115,7 +119,7 @@ Replace `/main` with the application's `APP_BASE_PATH`. Swagger UI for people is
|
|
|
115
119
|
|
|
116
120
|
## Include administration by default
|
|
117
121
|
|
|
118
|
-
For every application feature, apply [system settings delivery](references/system-settings.md): keep unused business settings disabled in a newly created application while retaining its restricted App Foundation entry; as the application develops beyond that basic shell, reconcile the template's prepared Users and Roles and permissions routes and the management surfaces for each capability actually used. Inspect this on every build or iteration, enable missing routes once and preserve already enabled pages, including workflow definitions, diagrams, configuration and authorized execution history. When building process rules, proactively declare appropriate thresholds and reviewer choices as validated, authorized business parameters and provide visible parameter forms in workflow management, with optional diagram-bound shortcuts to the same editor; the user need not ask for configurability. Apply the same check to non-workflow business policy, mutable dictionaries, business document numbering, important operation records and the other used capabilities in that reference. Follow its [business administration recipes](references/business-administration.md) for application-owned implementations and acceptance. The real execution must consume the saved values; source/deployment configuration retains its owner. This is part of implementing the feature, not a separate user request.
|
|
122
|
+
For every application feature, apply [system settings delivery](references/system-settings.md) and place every administration surface in the [System settings navigation](references/settings-navigation.md) (one sidebar entry, a home of cards by category, tabs inside a module): keep unused business settings disabled in a newly created application while retaining its restricted App Foundation entry; as the application develops beyond that basic shell, reconcile the template's prepared Users and Roles and permissions routes and the management surfaces for each capability actually used. Inspect this on every build or iteration, enable missing routes once and preserve already enabled pages, including workflow definitions, diagrams, configuration and authorized execution history. When building process rules, proactively declare appropriate thresholds and reviewer choices as validated, authorized business parameters and provide visible parameter forms in workflow management, with optional diagram-bound shortcuts to the same editor; the user need not ask for configurability. Apply the same check to non-workflow business policy, mutable dictionaries, business document numbering, important operation records and the other used capabilities in that reference. Follow its [business administration recipes](references/business-administration.md) for application-owned implementations and acceptance. The real execution must consume the saved values; source/deployment configuration retains its owner. This is part of implementing the feature, not a separate user request.
|
|
119
123
|
|
|
120
124
|
For initialization prerequisites introduced by the feature, apply [setup readiness](references/setup-readiness.md): wire real required-role membership and applicable business relationship checks with the standard contextual hint. Users should see what configuration is missing and an authorized path to fix it. Installed plugins, read failures and missing business configuration are different states; keep the bare app and its protected App Foundation entry unchanged.
|
|
121
125
|
|
|
@@ -193,7 +197,7 @@ Everything else — `client/routing/`, `client/layouts/`, `client/theme/`, the s
|
|
|
193
197
|
|
|
194
198
|
When the built-in mechanism genuinely cannot express the requirement, changing that structure is a legitimate answer. Comment what you changed and why the built-in path did not fit, and in the same change record the application-specific guidance in the matching `.agents/rules/<topic>.md`, adding its entry to the `AGENTS.md` index, so the guidance still describes the real application. Do not write the detail into `AGENTS.md` itself: it is a small always-on index of at most 32 KB that every agent loads on every start. The synchronized NocoBase Skills are package-owned; propose a change to their source package when the shared framework guidance itself is wrong.
|
|
195
199
|
|
|
196
|
-
When you do change the shell (`client/layouts/`, `client/routing/`), keep the behaviors listed in [customizing the shell](references/frontend/references/shell.md#1-behaviors-to-keep): a single App shell with administration pages
|
|
200
|
+
When you do change the shell (`client/layouts/`, `client/routing/`), keep the behaviors listed in [customizing the shell](references/frontend/references/shell.md#1-behaviors-to-keep): a single App shell with administration pages under its one System settings entry rather than a separate settings layout, the language submenu, navigation group state, permission refresh and sign-out handling.
|
|
197
201
|
|
|
198
202
|
## Ownership
|
|
199
203
|
|
|
@@ -3,6 +3,9 @@ import userEvent from '@testing-library/user-event';
|
|
|
3
3
|
import { expect, it } from 'vitest';
|
|
4
4
|
import { Route, Routes, Navigate } from 'react-router';
|
|
5
5
|
import { randomUUID } from 'node:crypto';
|
|
6
|
+
import type { ReactElement } from 'react';
|
|
7
|
+
import type { AppClientRegisteredRoute } from '@nocobase/app-client/plugins';
|
|
8
|
+
import { RouteTreeProvider } from '../../client/routing/route-context.js';
|
|
6
9
|
import OnboardingPage from '../../client/pages/onboarding/index.js';
|
|
7
10
|
import OnboardingWizard from '../../client/pages/onboarding/wizard.js';
|
|
8
11
|
import { renderAuthenticatedClient } from '../helpers/authenticated-client.js';
|
|
@@ -13,6 +16,26 @@ import {
|
|
|
13
16
|
type OnboardingInput,
|
|
14
17
|
type OnboardingDetail,
|
|
15
18
|
} from '../../shared/onboarding.js';
|
|
19
|
+
const routes: AppClientRegisteredRoute[] = [
|
|
20
|
+
{
|
|
21
|
+
id: 'onboarding',
|
|
22
|
+
name: 'onboarding',
|
|
23
|
+
path: '/onboarding',
|
|
24
|
+
packageName: '@nocobase/app-template-examples',
|
|
25
|
+
source: 'application',
|
|
26
|
+
authz: 'skip',
|
|
27
|
+
componentLoader: async () => ({ default: OnboardingPage }),
|
|
28
|
+
},
|
|
29
|
+
];
|
|
30
|
+
// The isolated page tree still supplies the registered list used by the safe return link.
|
|
31
|
+
const renderOnboardingClient = (
|
|
32
|
+
ui: ReactElement,
|
|
33
|
+
options: Parameters<typeof renderAuthenticatedClient>[1] = {},
|
|
34
|
+
) =>
|
|
35
|
+
renderAuthenticatedClient(
|
|
36
|
+
<RouteTreeProvider routes={routes}>{ui}</RouteTreeProvider>,
|
|
37
|
+
options,
|
|
38
|
+
);
|
|
16
39
|
const write = (input: unknown, method = 'POST') => ({
|
|
17
40
|
method,
|
|
18
41
|
headers: {
|
|
@@ -73,7 +96,7 @@ it('derives the first incomplete step with shared conditional and cross-step val
|
|
|
73
96
|
});
|
|
74
97
|
it('retains input while changing steps, validates conditions and recovers a private draft from the real API', async () => {
|
|
75
98
|
const writes: string[] = [];
|
|
76
|
-
await
|
|
99
|
+
await renderOnboardingClient(
|
|
77
100
|
<Routes>
|
|
78
101
|
<Route path='/onboarding' element={<OnboardingPage />}>
|
|
79
102
|
<Route path='new' element={<OnboardingWizard />} />
|
|
@@ -250,7 +273,7 @@ it('retains input while changing steps, validates conditions and recovers a priv
|
|
|
250
273
|
).not.toBeInTheDocument();
|
|
251
274
|
});
|
|
252
275
|
it('keeps unsaved child-page input until leaving is confirmed', async () => {
|
|
253
|
-
await
|
|
276
|
+
await renderOnboardingClient(
|
|
254
277
|
<Routes>
|
|
255
278
|
<Route path='/onboarding' element={<OnboardingPage />}>
|
|
256
279
|
<Route path='new' element={<OnboardingWizard />} />
|
|
@@ -300,7 +323,7 @@ it('locks save and submit through refresh and replays an uncertain submission wi
|
|
|
300
323
|
);
|
|
301
324
|
}
|
|
302
325
|
try {
|
|
303
|
-
const view = await
|
|
326
|
+
const view = await renderOnboardingClient(<RequestRoutes />, {
|
|
304
327
|
route: '/start',
|
|
305
328
|
async prepare(app, session) {
|
|
306
329
|
await app.connection.repository('onboardingDepartments').createOne({
|
|
@@ -20,7 +20,6 @@ import {
|
|
|
20
20
|
} from '../../shared/onboarding.js';
|
|
21
21
|
import { resetOnboarding } from '../../server/providers/onboarding-reset.js';
|
|
22
22
|
const test = createAppTest({
|
|
23
|
-
scope: 'test',
|
|
24
23
|
createServer: createStandaloneServer,
|
|
25
24
|
connections: ['main', 'analytics'],
|
|
26
25
|
config: {
|
|
@@ -31,6 +30,19 @@ const test = createAppTest({
|
|
|
31
30
|
emailAndPassword: { disableSignUp: false },
|
|
32
31
|
},
|
|
33
32
|
},
|
|
33
|
+
}).extend<{ resetData: void }>({
|
|
34
|
+
resetData: [
|
|
35
|
+
async ({ testApp }, use) => {
|
|
36
|
+
// Identities are unique per case; reset records and reference data before each one.
|
|
37
|
+
await resetOnboarding(testApp.connection, false);
|
|
38
|
+
await testApp.connection.query
|
|
39
|
+
.deleteFrom('onboardingDepartments')
|
|
40
|
+
.allowAllRows()
|
|
41
|
+
.execute();
|
|
42
|
+
await use(undefined);
|
|
43
|
+
},
|
|
44
|
+
{ auto: true },
|
|
45
|
+
],
|
|
34
46
|
});
|
|
35
47
|
const write = (
|
|
36
48
|
input: unknown,
|
|
@@ -11,7 +11,6 @@ import type { ProcurementDetail } from '../../shared/procurement.js';
|
|
|
11
11
|
import { resetProcurement } from '../../server/providers/procurement-reset.js';
|
|
12
12
|
|
|
13
13
|
const test = createAppTest({
|
|
14
|
-
scope: 'test',
|
|
15
14
|
createServer: createStandaloneServer,
|
|
16
15
|
connections: ['main', 'analytics'],
|
|
17
16
|
config: {
|
|
@@ -22,6 +21,21 @@ const test = createAppTest({
|
|
|
22
21
|
emailAndPassword: { disableSignUp: false },
|
|
23
22
|
},
|
|
24
23
|
},
|
|
24
|
+
}).extend<{ resetData: void }>({
|
|
25
|
+
resetData: [
|
|
26
|
+
async ({ testApp }, use) => {
|
|
27
|
+
// Keep the installed application, but start each case with empty business data.
|
|
28
|
+
await resetProcurement(testApp.connection, false);
|
|
29
|
+
for (const table of ['procurementMaterials', 'procurementSuppliers']) {
|
|
30
|
+
await testApp.connection.query
|
|
31
|
+
.deleteFrom(table)
|
|
32
|
+
.allowAllRows()
|
|
33
|
+
.execute();
|
|
34
|
+
}
|
|
35
|
+
await use(undefined);
|
|
36
|
+
},
|
|
37
|
+
{ auto: true },
|
|
38
|
+
],
|
|
25
39
|
});
|
|
26
40
|
const write = (
|
|
27
41
|
input: unknown,
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
resolveListState,
|
|
3
|
+
useApiClient,
|
|
4
|
+
useToaster,
|
|
5
|
+
} from '@nocobase/app-client';
|
|
2
6
|
import { useTranslation } from '@nocobase/i18n/client';
|
|
3
7
|
import { useEffect, useRef, useState } from 'react';
|
|
4
8
|
import {
|
|
@@ -9,13 +13,14 @@ import {
|
|
|
9
13
|
useParams,
|
|
10
14
|
} from 'react-router';
|
|
11
15
|
import type { ColumnDef } from '@tanstack/react-table';
|
|
12
|
-
import { MoreHorizontal
|
|
16
|
+
import { MoreHorizontal } from 'lucide-react';
|
|
13
17
|
import { RouteChildPage } from '#components/route-child-page';
|
|
14
18
|
import { BackButton } from '#components/back-button';
|
|
15
19
|
import { PageContainer } from '#components/page-container';
|
|
16
20
|
import { PageHeader } from '#components/page-header';
|
|
17
21
|
import { LongText } from '#components/long-text';
|
|
18
22
|
import { DataTable } from '#components/data-table';
|
|
23
|
+
import { RefreshIndicator } from '#components/loading';
|
|
19
24
|
import { RecordLink } from '#components/record-link';
|
|
20
25
|
import { StatusBadge } from '#components/status-badge';
|
|
21
26
|
import { Button } from '#components/ui/button';
|
|
@@ -83,6 +88,14 @@ export default function CustomerDetailPage() {
|
|
|
83
88
|
headingRef.current?.focus();
|
|
84
89
|
}, [active, request.loading]);
|
|
85
90
|
const customer = request.data?.data;
|
|
91
|
+
const contactState = resolveListState(
|
|
92
|
+
{
|
|
93
|
+
data: contacts.data,
|
|
94
|
+
error: contacts.error,
|
|
95
|
+
isPending: contacts.loading && !contacts.data,
|
|
96
|
+
},
|
|
97
|
+
contacts.data?.data.length ?? 0,
|
|
98
|
+
);
|
|
86
99
|
const writable = customer && customer.status !== 'closed';
|
|
87
100
|
const reload = () => {
|
|
88
101
|
request.reload();
|
|
@@ -206,14 +219,6 @@ export default function CustomerDetailPage() {
|
|
|
206
219
|
{t('customerContacts.edit')}
|
|
207
220
|
</Button>
|
|
208
221
|
)}
|
|
209
|
-
<Button
|
|
210
|
-
variant='outline'
|
|
211
|
-
disabled={request.loading}
|
|
212
|
-
onClick={reload}
|
|
213
|
-
>
|
|
214
|
-
<RefreshCw />
|
|
215
|
-
{t('customerContacts.refresh')}
|
|
216
|
-
</Button>
|
|
217
222
|
</>
|
|
218
223
|
)
|
|
219
224
|
}
|
|
@@ -224,28 +229,35 @@ export default function CustomerDetailPage() {
|
|
|
224
229
|
) : (
|
|
225
230
|
customer && (
|
|
226
231
|
<>
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
232
|
+
{/* The summary and the contacts table refresh independently; each owns its feedback. */}
|
|
233
|
+
<div className='relative'>
|
|
234
|
+
<RefreshIndicator pending={active && request.loading} />
|
|
235
|
+
<dl
|
|
236
|
+
className='grid grid-cols-[8rem_1fr] gap-4 text-sm'
|
|
237
|
+
aria-busy={active && request.loading}
|
|
238
|
+
>
|
|
239
|
+
<dt className='text-muted-foreground'>
|
|
240
|
+
{t('customerContacts.status')}
|
|
241
|
+
</dt>
|
|
242
|
+
<dd>
|
|
243
|
+
<StatusBadge>
|
|
244
|
+
{t(`customerContacts.${customer.status}`)}
|
|
245
|
+
</StatusBadge>
|
|
246
|
+
</dd>
|
|
247
|
+
<dt className='text-muted-foreground'>
|
|
248
|
+
{t('customerContacts.owner')}
|
|
249
|
+
</dt>
|
|
250
|
+
<dd>
|
|
251
|
+
<OwnerName id={customer.ownerId} />
|
|
252
|
+
</dd>
|
|
253
|
+
<dt className='text-muted-foreground'>
|
|
254
|
+
{t('customerContacts.notes')}
|
|
255
|
+
</dt>
|
|
256
|
+
<dd className='min-w-0 whitespace-pre-wrap break-words'>
|
|
257
|
+
<LongText>{customer.notes || '—'}</LongText>
|
|
258
|
+
</dd>
|
|
259
|
+
</dl>
|
|
260
|
+
</div>
|
|
249
261
|
{!writable && (
|
|
250
262
|
<p className='text-sm text-muted-foreground'>
|
|
251
263
|
{t('customerContacts.readOnly')}
|
|
@@ -272,29 +284,28 @@ export default function CustomerDetailPage() {
|
|
|
272
284
|
</Button>
|
|
273
285
|
)}
|
|
274
286
|
</div>
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
)}
|
|
287
|
+
<DataTable
|
|
288
|
+
columns={columns}
|
|
289
|
+
data={contacts.data?.data ?? []}
|
|
290
|
+
manualPagination
|
|
291
|
+
rowCount={contacts.data?.meta.total ?? 0}
|
|
292
|
+
paginationState={{ pageIndex: page, pageSize: 10 }}
|
|
293
|
+
onPaginationChange={(update) =>
|
|
294
|
+
setPage(
|
|
295
|
+
(old) =>
|
|
296
|
+
(typeof update === 'function'
|
|
297
|
+
? update({ pageIndex: old, pageSize: 10 })
|
|
298
|
+
: update
|
|
299
|
+
).pageIndex,
|
|
300
|
+
)
|
|
301
|
+
}
|
|
302
|
+
pageSizeOptions={[10]}
|
|
303
|
+
showSelectedCount={false}
|
|
304
|
+
loading={active && contacts.loading}
|
|
305
|
+
loadingIdentity={contacts.path}
|
|
306
|
+
listState={contactState}
|
|
307
|
+
onRetry={contacts.reload}
|
|
308
|
+
/>
|
|
298
309
|
</>
|
|
299
310
|
)
|
|
300
311
|
)}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { useQuery } from '@tanstack/react-query';
|
|
2
2
|
import { useAuthentication } from '@nocobase/app-plugin-authentication/client';
|
|
3
3
|
import {
|
|
4
|
+
resolveListState,
|
|
4
5
|
useApiClient,
|
|
5
6
|
useToaster,
|
|
6
|
-
ApiClientError,
|
|
7
|
-
type ListState,
|
|
8
7
|
} from '@nocobase/app-client';
|
|
9
8
|
import {
|
|
10
9
|
useCan,
|
|
@@ -14,7 +13,6 @@ import { useTranslation } from '@nocobase/i18n/client';
|
|
|
14
13
|
import { useEffect, useRef, useState } from 'react';
|
|
15
14
|
import { Link, Outlet, useLocation } from 'react-router';
|
|
16
15
|
import type { ColumnDef } from '@tanstack/react-table';
|
|
17
|
-
import { RefreshCw } from 'lucide-react';
|
|
18
16
|
import { DataTable } from '#components/data-table';
|
|
19
17
|
import { PageContainer } from '#components/page-container';
|
|
20
18
|
import { PageHeader } from '#components/page-header';
|
|
@@ -193,23 +191,15 @@ function CustomerContactsContent() {
|
|
|
193
191
|
cell: ({ row }) => <OwnerName id={row.original.ownerId} />,
|
|
194
192
|
},
|
|
195
193
|
];
|
|
196
|
-
const state
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
: request.error
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
? rows.length
|
|
206
|
-
? 'ready'
|
|
207
|
-
: 'loading'
|
|
208
|
-
: rows.length
|
|
209
|
-
? 'ready'
|
|
210
|
-
: search || status !== 'all' || owner
|
|
211
|
-
? 'no-results'
|
|
212
|
-
: 'empty';
|
|
194
|
+
const state = resolveListState(
|
|
195
|
+
{
|
|
196
|
+
data: currentData,
|
|
197
|
+
error: request.error,
|
|
198
|
+
isPending: request.loading && !currentData,
|
|
199
|
+
},
|
|
200
|
+
rows.length,
|
|
201
|
+
Boolean(search || status !== 'all' || owner),
|
|
202
|
+
);
|
|
213
203
|
const reload = () => {
|
|
214
204
|
setSelection({ key: '', ids: [] });
|
|
215
205
|
request.reload();
|
|
@@ -259,15 +249,6 @@ function CustomerContactsContent() {
|
|
|
259
249
|
{t('customerContacts.reset')}
|
|
260
250
|
</Button>
|
|
261
251
|
)}
|
|
262
|
-
<Button
|
|
263
|
-
variant='outline'
|
|
264
|
-
onClick={reload}
|
|
265
|
-
disabled={request.loading}
|
|
266
|
-
aria-label={t('customerContacts.refresh')}
|
|
267
|
-
>
|
|
268
|
-
<RefreshCw className={request.loading ? 'animate-spin' : ''} />
|
|
269
|
-
{t('customerContacts.refresh')}
|
|
270
|
-
</Button>
|
|
271
252
|
</>
|
|
272
253
|
}
|
|
273
254
|
/>
|
|
@@ -339,6 +320,7 @@ function CustomerContactsContent() {
|
|
|
339
320
|
showSelectedCount={false}
|
|
340
321
|
listState={state}
|
|
341
322
|
loading={active && request.loading}
|
|
323
|
+
loadingIdentity={path}
|
|
342
324
|
onRetry={reload}
|
|
343
325
|
/>
|
|
344
326
|
<AlertDialog
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export const enUS = {
|
|
2
|
-
refresh: 'Refresh',
|
|
3
2
|
signIn: 'Sign in',
|
|
4
3
|
title: 'Customers and contacts',
|
|
5
4
|
description:
|
|
@@ -77,7 +76,6 @@ export const enUS = {
|
|
|
77
76
|
invalid: 'Check the highlighted fields.',
|
|
78
77
|
};
|
|
79
78
|
export const zhCN: Record<keyof typeof enUS, string> = {
|
|
80
|
-
refresh: '刷新',
|
|
81
79
|
signIn: '登录',
|
|
82
80
|
title: '客户与联系人',
|
|
83
81
|
description: '练习按权限选择关联记录和批量修改当前页客户。',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useEffect, useId, useRef, useState, type Ref } from 'react';
|
|
2
|
-
import { useApiClient } from '@nocobase/app-client';
|
|
2
|
+
import { useApiClient, usePendingFeedback } from '@nocobase/app-client';
|
|
3
3
|
import { useTranslation } from '@nocobase/i18n/client';
|
|
4
4
|
import { useAuthorizationRevision } from '@nocobase/app-plugin-authorization/client';
|
|
5
5
|
import { useInfiniteQuery } from '@tanstack/react-query';
|
|
@@ -16,7 +16,8 @@ import {
|
|
|
16
16
|
PopoverContent,
|
|
17
17
|
PopoverTrigger,
|
|
18
18
|
} from '#components/ui/popover';
|
|
19
|
-
import {
|
|
19
|
+
import { Loading } from '#components/loading';
|
|
20
|
+
import { BrandLoadingMark } from '#components/brand-loading-mark';
|
|
20
21
|
import { ToggleGroup, ToggleGroupItem } from '#components/ui/toggle-group';
|
|
21
22
|
import { useListData } from '#hooks/use-list-data';
|
|
22
23
|
import { ReadFeedback } from './shared.js';
|
|
@@ -95,9 +96,14 @@ function Picker({
|
|
|
95
96
|
isFetchNextPageError,
|
|
96
97
|
fetchNextPage,
|
|
97
98
|
} = options;
|
|
99
|
+
// The application keeps previous query data as a placeholder; those options
|
|
100
|
+
// belong to the previous search or filter and must not appear as matches.
|
|
101
|
+
const current = !options.isPlaceholderData;
|
|
102
|
+
// A new search or filter restarts the display delay of its own wait.
|
|
103
|
+
const queryIdentity = JSON.stringify([search, filter ?? null]);
|
|
98
104
|
const items = [
|
|
99
105
|
...new Map(
|
|
100
|
-
(options.data?.pages
|
|
106
|
+
((current && options.data?.pages) || [])
|
|
101
107
|
.flatMap((page) => page.data)
|
|
102
108
|
.map((option) => [option.id, option]),
|
|
103
109
|
).values(),
|
|
@@ -212,16 +218,13 @@ function Picker({
|
|
|
212
218
|
</ToggleGroup>
|
|
213
219
|
)}
|
|
214
220
|
</div>
|
|
215
|
-
<div
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
<div className='flex justify-center py-6'>
|
|
223
|
-
<Spinner className='text-muted-foreground' />
|
|
224
|
-
</div>
|
|
221
|
+
<div ref={listRef} className='min-h-0 flex-1 overflow-y-auto p-1'>
|
|
222
|
+
{options.isPending || !current ? (
|
|
223
|
+
<Loading
|
|
224
|
+
identity={queryIdentity}
|
|
225
|
+
label={t('customerContacts.loading')}
|
|
226
|
+
className='py-6'
|
|
227
|
+
/>
|
|
225
228
|
) : options.isError && !isFetchNextPageError ? (
|
|
226
229
|
<div className='p-1'>
|
|
227
230
|
<ReadFeedback
|
|
@@ -258,11 +261,11 @@ function Picker({
|
|
|
258
261
|
/>
|
|
259
262
|
</div>
|
|
260
263
|
) : hasNextPage ? (
|
|
261
|
-
<
|
|
262
|
-
{
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
264
|
+
<NextPagePending
|
|
265
|
+
ref={endRef}
|
|
266
|
+
pending={isFetchingNextPage}
|
|
267
|
+
identity={queryIdentity}
|
|
268
|
+
/>
|
|
266
269
|
) : null}
|
|
267
270
|
</div>
|
|
268
271
|
) : (
|
|
@@ -279,3 +282,50 @@ function Picker({
|
|
|
279
282
|
</Popover>
|
|
280
283
|
);
|
|
281
284
|
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* The next page appends below kept options. Its mark follows the shared
|
|
288
|
+
* display delay and a slow page explains itself; the polite status stays
|
|
289
|
+
* mounted outside the busy row so the change is announced, not dropped.
|
|
290
|
+
*/
|
|
291
|
+
function NextPagePending({
|
|
292
|
+
pending,
|
|
293
|
+
identity,
|
|
294
|
+
ref,
|
|
295
|
+
}: {
|
|
296
|
+
pending: boolean;
|
|
297
|
+
identity: unknown;
|
|
298
|
+
ref: Ref<HTMLDivElement>;
|
|
299
|
+
}) {
|
|
300
|
+
const { t } = useTranslation();
|
|
301
|
+
const feedback = usePendingFeedback(pending, identity);
|
|
302
|
+
const message = feedback.longWaiting
|
|
303
|
+
? t('pendingFeedback.longWait')
|
|
304
|
+
: t('customerContacts.loading');
|
|
305
|
+
return (
|
|
306
|
+
<>
|
|
307
|
+
<div
|
|
308
|
+
ref={ref}
|
|
309
|
+
aria-busy={pending}
|
|
310
|
+
className='flex min-h-8 flex-col items-center justify-center gap-1 py-2'
|
|
311
|
+
>
|
|
312
|
+
{feedback.visible ? (
|
|
313
|
+
<>
|
|
314
|
+
<BrandLoadingMark className='size-4 text-muted-foreground' />
|
|
315
|
+
{feedback.longWaiting ? (
|
|
316
|
+
<span
|
|
317
|
+
aria-hidden='true'
|
|
318
|
+
className='text-xs text-muted-foreground'
|
|
319
|
+
>
|
|
320
|
+
{message}
|
|
321
|
+
</span>
|
|
322
|
+
) : null}
|
|
323
|
+
</>
|
|
324
|
+
) : null}
|
|
325
|
+
</div>
|
|
326
|
+
<span role='status' aria-live='polite' className='sr-only'>
|
|
327
|
+
{feedback.visible ? message : ''}
|
|
328
|
+
</span>
|
|
329
|
+
</>
|
|
330
|
+
);
|
|
331
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { ApiClientError } from '@nocobase/app-client';
|
|
1
|
+
import { ApiClientError, usePendingFeedback } from '@nocobase/app-client';
|
|
2
2
|
import { useTranslation } from '@nocobase/i18n/client';
|
|
3
3
|
import type { ReactNode } from 'react';
|
|
4
|
+
import { cn } from 'cn';
|
|
4
5
|
import { Link } from 'react-router';
|
|
5
6
|
import { Alert, AlertDescription } from '#components/ui/alert';
|
|
6
7
|
import { Button } from '#components/ui/button';
|
|
@@ -21,17 +22,7 @@ export function ReadFeedback({
|
|
|
21
22
|
retry: () => void;
|
|
22
23
|
}) {
|
|
23
24
|
const { t } = useTranslation();
|
|
24
|
-
if (!error)
|
|
25
|
-
return (
|
|
26
|
-
<div
|
|
27
|
-
role='status'
|
|
28
|
-
aria-label={t('customerContacts.loading')}
|
|
29
|
-
className='flex flex-col gap-4'
|
|
30
|
-
>
|
|
31
|
-
<Skeleton className='h-8 w-full' />
|
|
32
|
-
<Skeleton className='h-8 w-full' />
|
|
33
|
-
</div>
|
|
34
|
-
);
|
|
25
|
+
if (!error) return <ReadPending />;
|
|
35
26
|
const status = error instanceof ApiClientError ? error.status : 0;
|
|
36
27
|
return (
|
|
37
28
|
<Alert variant='destructive'>
|
|
@@ -54,6 +45,35 @@ export function ReadFeedback({
|
|
|
54
45
|
</Alert>
|
|
55
46
|
);
|
|
56
47
|
}
|
|
48
|
+
/** Skeleton rows keep the read's footprint at once and appear only after the shared display delay. */
|
|
49
|
+
function ReadPending() {
|
|
50
|
+
const { t } = useTranslation();
|
|
51
|
+
const feedback = usePendingFeedback(true);
|
|
52
|
+
const message = feedback.longWaiting
|
|
53
|
+
? t('pendingFeedback.longWait')
|
|
54
|
+
: t('customerContacts.loading');
|
|
55
|
+
return (
|
|
56
|
+
<>
|
|
57
|
+
<div
|
|
58
|
+
aria-busy='true'
|
|
59
|
+
className={cn('flex flex-col gap-4', !feedback.visible && 'invisible')}
|
|
60
|
+
>
|
|
61
|
+
<Skeleton aria-hidden='true' className='h-8 w-full' />
|
|
62
|
+
<Skeleton aria-hidden='true' className='h-8 w-full' />
|
|
63
|
+
</div>
|
|
64
|
+
{feedback.visible && (
|
|
65
|
+
<span
|
|
66
|
+
role='status'
|
|
67
|
+
aria-live='polite'
|
|
68
|
+
aria-label={message}
|
|
69
|
+
className='sr-only'
|
|
70
|
+
>
|
|
71
|
+
{message}
|
|
72
|
+
</span>
|
|
73
|
+
)}
|
|
74
|
+
</>
|
|
75
|
+
);
|
|
76
|
+
}
|
|
57
77
|
export function WriteFeedback({ error }: { error?: unknown }) {
|
|
58
78
|
const { t } = useTranslation();
|
|
59
79
|
if (!error) return null;
|