@aglyn/plugins-crm 1.19.0 → 1.20.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/package.json +14 -14
- package/src/lib/components/log-activity-dialog.d.ts +2 -0
- package/src/lib/components/log-activity-dialog.js +11 -2
- package/src/lib/components/log-activity-dialog.js.map +1 -1
- package/src/lib/components/record-sharing-card.js +8 -7
- package/src/lib/components/record-sharing-card.js.map +1 -1
- package/src/lib/components/settings-section.d.ts +10 -3
- package/src/lib/components/settings-section.js +286 -35
- package/src/lib/components/settings-section.js.map +1 -1
- package/src/lib/components/share-records-dialog.d.ts +17 -3
- package/src/lib/components/share-records-dialog.js +59 -45
- package/src/lib/components/share-records-dialog.js.map +1 -1
- package/src/lib/components/sharing-rule-drawer.d.ts +13 -3
- package/src/lib/components/sharing-rule-drawer.js +51 -40
- package/src/lib/components/sharing-rule-drawer.js.map +1 -1
- package/src/lib/components/sharing-rules-card.js +2 -1
- package/src/lib/components/sharing-rules-card.js.map +1 -1
- package/src/lib/declarations.server.js +10 -1
- package/src/lib/declarations.server.js.map +1 -1
- package/src/lib/hooks/use-campaign-filing-log.js +10 -2
- package/src/lib/hooks/use-campaign-filing-log.js.map +1 -1
- package/src/lib/hooks/use-crm-sharing.d.ts +8 -0
- package/src/lib/hooks/use-crm-sharing.js +20 -0
- package/src/lib/hooks/use-crm-sharing.js.map +1 -1
- package/src/lib/model/crm-sharing-api.d.ts +5 -2
- package/src/lib/model/crm-sharing-api.js +3 -0
- package/src/lib/model/crm-sharing-api.js.map +1 -1
- package/src/lib/model/crm-sharing.d.ts +153 -5
- package/src/lib/model/crm-sharing.js +243 -20
- package/src/lib/model/crm-sharing.js.map +1 -1
- package/src/lib/model/lead-filters.d.ts +1 -1
- package/src/lib/server/add-contact-by-hand.js +11 -4
- package/src/lib/server/add-contact-by-hand.js.map +1 -1
- package/src/lib/server/api-v1/crm-activities.js +2 -2
- package/src/lib/server/api-v1/crm-activities.js.map +1 -1
- package/src/lib/server/api-v1/crm-companies.js +2 -2
- package/src/lib/server/api-v1/crm-companies.js.map +1 -1
- package/src/lib/server/api-v1/crm-deals.js +2 -2
- package/src/lib/server/api-v1/crm-deals.js.map +1 -1
- package/src/lib/server/api-v1/crm-shared.d.ts +16 -0
- package/src/lib/server/api-v1/crm-shared.js +12 -1
- package/src/lib/server/api-v1/crm-shared.js.map +1 -1
- package/src/lib/server/api-v1/crm-tasks.js +2 -2
- package/src/lib/server/api-v1/crm-tasks.js.map +1 -1
- package/src/lib/server/associate-company-by-domain.d.ts +1 -1
- package/src/lib/server/associate-company-by-domain.js +4 -4
- package/src/lib/server/associate-company-by-domain.js.map +1 -1
- package/src/lib/server/automation-steps.js +24 -12
- package/src/lib/server/automation-steps.js.map +1 -1
- package/src/lib/server/campaign-filing-activity.js +7 -3
- package/src/lib/server/campaign-filing-activity.js.map +1 -1
- package/src/lib/server/convert-host-lead.js +13 -4
- package/src/lib/server/convert-host-lead.js.map +1 -1
- package/src/lib/server/crm-default-sharing.d.ts +86 -0
- package/src/lib/server/crm-default-sharing.js +409 -0
- package/src/lib/server/crm-default-sharing.js.map +1 -0
- package/src/lib/server/crm-inbound-email.js +2 -2
- package/src/lib/server/crm-inbound-email.js.map +1 -1
- package/src/lib/server/crm-sharing-runs.d.ts +71 -0
- package/src/lib/server/crm-sharing-runs.js +221 -0
- package/src/lib/server/crm-sharing-runs.js.map +1 -0
- package/src/lib/server/crm-sharing.d.ts +24 -1
- package/src/lib/server/crm-sharing.js +183 -31
- package/src/lib/server/crm-sharing.js.map +1 -1
- package/src/lib/server/email-send.js +5 -2
- package/src/lib/server/email-send.js.map +1 -1
- package/src/lib/server/record-timeline.d.ts +2 -1
- package/src/lib/server/record-timeline.js +11 -6
- package/src/lib/server/record-timeline.js.map +1 -1
- package/src/lib/server/task-routes.js +10 -6
- package/src/lib/server/task-routes.js.map +1 -1
- package/src/lib/server.js +23 -1
- package/src/lib/server.js.map +1 -1
- package/src/lib/transfer/common.d.ts +5 -1
- package/src/lib/transfer/common.js +8 -5
- package/src/lib/transfer/common.js.map +1 -1
|
@@ -15,18 +15,23 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/ 'use client';
|
|
17
17
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
18
|
-
import { CRM_ASSIGNMENT_RULES_MAX, CRM_ASSIGNMENT_RULES_PATH, CRM_AUTO_CREATE_COMPANIES_PATH, CRM_DEFAULT_RECORD_SCOPE_PATH, CRM_ROUND_ROBIN_POOL_MAX, CRM_ROUND_ROBIN_POOL_PATH,
|
|
18
|
+
import { CRM_ASSIGNMENT_RULES_MAX, CRM_ASSIGNMENT_RULES_PATH, CRM_AUTO_CREATE_COMPANIES_PATH, CRM_DEFAULT_MAX_INCLUDED, CRM_DEFAULT_RECORD_EXCEPT_AT_PATH, CRM_DEFAULT_RECORD_EXCEPT_PATH, CRM_DEFAULT_RECORD_SCOPE_PATH, CRM_ROUND_ROBIN_POOL_MAX, CRM_ROUND_ROBIN_POOL_PATH, crmDefaultExceptOf, crmDefaultSharingOf, crmHostDefaultOwnerSegments, describeAssignmentRule, isOrgWideMember, orgAutoCreatesCompanies, pluginDocsHelp, readCrmAssignmentSettings, resolveOrgPermissions, roundRobinOrder, crmMemberPickerLabel } from "@aglyn/aglyn";
|
|
19
19
|
import { mdiArrowDown, mdiArrowUp, mdiDeleteOutline } from "@aglyn/shared-data-mdi";
|
|
20
|
-
import {
|
|
20
|
+
import { sharingFromChoice } from "@aglyn/aglyn/app-utils/scope-tokens";
|
|
21
|
+
import { CardDisplay, MdiIcon, SrOnly, useConfirmationContext } from "@aglyn/shared-ui-jsx";
|
|
22
|
+
import { BlockedControl } from "@aglyn/shared-ui-jsx/components/blocked-control.component";
|
|
21
23
|
import RowActionsMenu from "@aglyn/shared-ui-jsx/components/row-actions-menu.component";
|
|
22
24
|
import { ScrollTable } from "@aglyn/shared-ui-jsx/components/scroll-table.component";
|
|
23
25
|
import { useSnackbar } from "@aglyn/shared-ui-snackstack";
|
|
24
26
|
import { useFirestore, useFirestoreDoc, useUser } from "@aglyn/tenant-feature-instance";
|
|
25
|
-
import { Button, Checkbox, FormControlLabel, FormGroup, FormHelperText, IconButton, MenuItem, Stack, Switch, TableBody, TableCell, TableHead, TableRow, TextField, Typography } from "@mui/material";
|
|
26
|
-
import { deleteField, doc, FieldPath, updateDoc } from "firebase/firestore";
|
|
27
|
+
import { Button, Checkbox, FormControl, FormControlLabel, FormGroup, FormHelperText, FormLabel, IconButton, MenuItem, Radio, RadioGroup, Stack, Switch, TableBody, TableCell, TableHead, TableRow, TextField, Typography } from "@mui/material";
|
|
28
|
+
import { deleteField, doc, FieldPath, serverTimestamp, updateDoc } from "firebase/firestore";
|
|
27
29
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
28
30
|
import { useCrmOrgMount } from "../hooks/use-crm-org-mount.js";
|
|
29
31
|
import { useCrmScope } from "../hooks/use-crm-scope.js";
|
|
32
|
+
import { useCrmSharingSites } from "../hooks/use-crm-sharing.js";
|
|
33
|
+
import { readCrmDefaultApplyRun } from "../model/crm-sharing.js";
|
|
34
|
+
import { callCrmSharing } from "../model/crm-sharing-api.js";
|
|
30
35
|
import { CRM_SETTINGS_PERMISSION, crmSettingsPermissionRefusal } from "../model/crm-permissions.js";
|
|
31
36
|
import { useOrgMemberDirectory } from "../hooks/use-org-member-directory.js";
|
|
32
37
|
import AssignmentRuleDrawer from "./assignment-rule-drawer.js";
|
|
@@ -181,38 +186,76 @@ AutoCreateCompaniesCard.displayName = 'AutoCreateCompaniesCard';
|
|
|
181
186
|
* defaults for new datasets and media.
|
|
182
187
|
*
|
|
183
188
|
* Changes nothing that already exists: narrowing an address book from a
|
|
184
|
-
*
|
|
185
|
-
* confirmation. Each record's own sharing is where that is decided
|
|
189
|
+
* setting would hide records from sites already working them, with no
|
|
190
|
+
* confirmation. Each record's own sharing is where that is decided, and
|
|
191
|
+
* under "All sites except…" (AGL-4047) the explicit "Apply to existing
|
|
192
|
+
* records" run below, which says what it does before it starts.
|
|
186
193
|
*
|
|
187
|
-
* Reads `
|
|
194
|
+
* Reads `crmDefaultSharingOf`, the same reader the capture door and every CRM
|
|
188
195
|
* creator stamp from, so the control cannot show one thing while records
|
|
189
196
|
* get another — including for an org that has never set it, which shares
|
|
190
197
|
* with every site unless it set the older dataset default to keep them
|
|
191
198
|
* apart. Keeping each site's records apart is the agency's choice: one
|
|
192
199
|
* client's collaborator then sees only that client's people.
|
|
200
|
+
*
|
|
201
|
+
* Radios and a visible list of sites, never a dropdown: the sites left out
|
|
202
|
+
* are the part people come to check. "All sites except…" is stored beside
|
|
203
|
+
* `defaultRecordScope: 'host'`, so a reader that predates it keeps new
|
|
204
|
+
* records to the site they came in on rather than sharing them wider.
|
|
193
205
|
*/ export function DefaultRecordSharingCard(props) {
|
|
194
|
-
var
|
|
206
|
+
var _crmDefaultSharingOf, _run_error;
|
|
195
207
|
const { hostId, org } = props;
|
|
196
208
|
const firestore = useFirestore();
|
|
209
|
+
const { data: user } = useUser();
|
|
197
210
|
const { enqueueSnackbar } = useSnackbar();
|
|
211
|
+
const { confirm } = useConfirmationContext();
|
|
198
212
|
const { orgId, ready: scopeReady } = useCrmScope({
|
|
199
213
|
hostId,
|
|
200
214
|
org
|
|
201
215
|
});
|
|
202
216
|
const { canManage, ready: roleReady } = useCanManageCrmSettings(orgId);
|
|
203
|
-
const
|
|
204
|
-
|
|
217
|
+
const sites = useCrmSharingSites({
|
|
218
|
+
hostId,
|
|
219
|
+
orgId: orgId != null ? orgId : null,
|
|
220
|
+
enabled: canManage
|
|
221
|
+
});
|
|
222
|
+
const orgDocument = org;
|
|
223
|
+
const storedMode = (_crmDefaultSharingOf = crmDefaultSharingOf(orgDocument)) != null ? _crmDefaultSharingOf : 'org';
|
|
224
|
+
const storedExcept = useMemo(()=>{
|
|
225
|
+
var _crmDefaultExceptOf;
|
|
226
|
+
return (_crmDefaultExceptOf = crmDefaultExceptOf(orgDocument)) != null ? _crmDefaultExceptOf : [];
|
|
227
|
+
}, [
|
|
228
|
+
orgDocument
|
|
229
|
+
]);
|
|
230
|
+
const [mode, setMode] = useState(storedMode);
|
|
231
|
+
const [except, setExcept] = useState(storedExcept);
|
|
205
232
|
const [busy, setBusy] = useState(false);
|
|
206
|
-
|
|
207
|
-
|
|
233
|
+
const [applying, setApplying] = useState(false);
|
|
234
|
+
const [pass, setPass] = useState(null);
|
|
235
|
+
useEffect(()=>setMode(storedMode), [
|
|
236
|
+
storedMode
|
|
208
237
|
]);
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
238
|
+
useEffect(()=>setExcept(storedExcept), [
|
|
239
|
+
storedExcept
|
|
240
|
+
]);
|
|
241
|
+
const siteIds = sites.sites.map((site)=>site.id);
|
|
242
|
+
const exceptOff = !canManage ? null : !sites.ready ? 'Reading this workspace’s sites…' : sites.sites.length < 2 ? 'This workspace has one site, so there is nothing to leave out.' : sites.sites.length > CRM_DEFAULT_MAX_INCLUDED ? `This works up to ${CRM_DEFAULT_MAX_INCLUDED} sites, and this workspace has ${sites.sites.length}. Choose another option.` : null;
|
|
243
|
+
// The answer the stamp gives, from the same helper the server uses.
|
|
244
|
+
const problem = mode === 'allExcept' && sites.ready ? sharingFromChoice({
|
|
245
|
+
mode: 'allExcept',
|
|
246
|
+
exceptHostIds: except
|
|
247
|
+
}, siteIds).problem : null;
|
|
248
|
+
const changed = mode !== storedMode || mode === 'allExcept' && (except.length !== storedExcept.length || except.some((id)=>!storedExcept.includes(id)));
|
|
249
|
+
const ready = scopeReady && roleReady;
|
|
250
|
+
const canSave = ready && canManage && !busy && changed && !problem && (mode !== 'allExcept' || !exceptOff);
|
|
251
|
+
const save = async ()=>{
|
|
252
|
+
if (!orgId || !canSave) return;
|
|
212
253
|
setBusy(true);
|
|
213
254
|
try {
|
|
214
255
|
await updateDoc(doc(firestore, 'orgs', orgId), {
|
|
215
|
-
[CRM_DEFAULT_RECORD_SCOPE_PATH]:
|
|
256
|
+
[CRM_DEFAULT_RECORD_SCOPE_PATH]: mode === 'org' ? 'org' : 'host',
|
|
257
|
+
[CRM_DEFAULT_RECORD_EXCEPT_PATH]: mode === 'allExcept' ? except.filter((id)=>siteIds.includes(id)) : deleteField(),
|
|
258
|
+
[CRM_DEFAULT_RECORD_EXCEPT_AT_PATH]: mode === 'allExcept' ? serverTimestamp() : deleteField()
|
|
216
259
|
});
|
|
217
260
|
enqueueSnackbar('Default sharing updated', {
|
|
218
261
|
variant: 'success',
|
|
@@ -220,7 +263,8 @@ AutoCreateCompaniesCard.displayName = 'AutoCreateCompaniesCard';
|
|
|
220
263
|
});
|
|
221
264
|
} catch (error) {
|
|
222
265
|
console.error(error);
|
|
223
|
-
|
|
266
|
+
setMode(storedMode);
|
|
267
|
+
setExcept(storedExcept);
|
|
224
268
|
enqueueSnackbar('The setting could not be saved', {
|
|
225
269
|
variant: 'error',
|
|
226
270
|
allowDuplicate: true
|
|
@@ -229,39 +273,246 @@ AutoCreateCompaniesCard.displayName = 'AutoCreateCompaniesCard';
|
|
|
229
273
|
setBusy(false);
|
|
230
274
|
}
|
|
231
275
|
};
|
|
232
|
-
const
|
|
276
|
+
const storedRun = readCrmDefaultApplyRun(orgDocument);
|
|
277
|
+
const run = pass != null ? pass : storedRun;
|
|
278
|
+
const running = applying || (run == null ? void 0 : run.status) === 'running';
|
|
279
|
+
const applyOff = storedMode !== 'allExcept' ? 'Choose All sites except… and save it first.' : changed ? 'Save the default first.' : running ? 'Applying now.' : null;
|
|
280
|
+
const apply = async (action)=>{
|
|
281
|
+
if (!orgId) return;
|
|
282
|
+
if (action === 'default-apply') {
|
|
283
|
+
const leftOut = storedExcept.map(sites.siteName).join(', ');
|
|
284
|
+
const confirmed = await confirm({
|
|
285
|
+
title: 'Apply to existing records?',
|
|
286
|
+
description: `Every contact, lead, company, deal, task and logged activity this workspace has is shared ` + `with every site except ${leftOut}. The site that captured a person keeps them. ` + 'Sites left out stop seeing the rest. Records shared by hand or by a sharing rule keep those shares.',
|
|
287
|
+
confirmationText: 'Apply to existing records'
|
|
288
|
+
}).then(()=>true).catch(()=>false);
|
|
289
|
+
if (!confirmed) return;
|
|
290
|
+
}
|
|
291
|
+
setApplying(true);
|
|
292
|
+
try {
|
|
293
|
+
var _answer_applyRun;
|
|
294
|
+
var _answer_applyRun1;
|
|
295
|
+
let answer = await callCrmSharing(user, {
|
|
296
|
+
orgId
|
|
297
|
+
}, action);
|
|
298
|
+
setPass((_answer_applyRun = answer.applyRun) != null ? _answer_applyRun : null);
|
|
299
|
+
while(answer.more){
|
|
300
|
+
answer = await callCrmSharing(user, {
|
|
301
|
+
orgId
|
|
302
|
+
}, 'default-apply-continue');
|
|
303
|
+
if (answer.applyRun) setPass(answer.applyRun);
|
|
304
|
+
}
|
|
305
|
+
if (((_answer_applyRun1 = answer.applyRun) == null ? void 0 : _answer_applyRun1.status) === 'done') {
|
|
306
|
+
enqueueSnackbar('The default sharing is applied to existing records', {
|
|
307
|
+
variant: 'success',
|
|
308
|
+
persist: false
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
} catch (error) {
|
|
312
|
+
enqueueSnackbar(error.message, {
|
|
313
|
+
variant: 'error',
|
|
314
|
+
allowDuplicate: true
|
|
315
|
+
});
|
|
316
|
+
} finally{
|
|
317
|
+
setApplying(false);
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
const toggle = (hostIdToToggle)=>()=>setExcept((current)=>current.includes(hostIdToToggle) ? current.filter((id)=>id !== hostIdToToggle) : [
|
|
321
|
+
...current,
|
|
322
|
+
hostIdToToggle
|
|
323
|
+
]);
|
|
324
|
+
const stillIn = siteIds.filter((id)=>!except.includes(id));
|
|
325
|
+
const editable = ready && canManage && !busy;
|
|
233
326
|
return /*#__PURE__*/ _jsx(CardDisplay, {
|
|
234
327
|
header: 'Default sharing for new records',
|
|
235
328
|
help: pluginDocsHelp('crmSharing', {
|
|
236
|
-
anchor: '#
|
|
329
|
+
anchor: '#default-sharing-for-new-records'
|
|
237
330
|
}),
|
|
238
331
|
contentGutterX: true,
|
|
239
332
|
contentGutterY: true,
|
|
240
333
|
children: /*#__PURE__*/ _jsxs(Stack, {
|
|
241
|
-
spacing: 1,
|
|
334
|
+
spacing: 1.5,
|
|
242
335
|
sx: {
|
|
243
|
-
maxWidth:
|
|
336
|
+
maxWidth: 520
|
|
244
337
|
},
|
|
245
338
|
children: [
|
|
246
|
-
/*#__PURE__*/ _jsxs(
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
label: "New contacts, companies, deals and tasks are shared with",
|
|
250
|
-
value: value,
|
|
251
|
-
disabled: !ready || !canManage || busy,
|
|
252
|
-
onChange: (event)=>void handleChange(event.target.value),
|
|
253
|
-
helperText: 'Only affects records created from now on. Datasets and media ' + 'have defaults of their own, on the organization Data and ' + 'Media pages.',
|
|
339
|
+
/*#__PURE__*/ _jsxs(FormControl, {
|
|
340
|
+
component: "fieldset",
|
|
341
|
+
disabled: !editable,
|
|
254
342
|
children: [
|
|
255
|
-
/*#__PURE__*/ _jsx(
|
|
256
|
-
|
|
257
|
-
|
|
343
|
+
/*#__PURE__*/ _jsx(FormLabel, {
|
|
344
|
+
component: "legend",
|
|
345
|
+
sx: {
|
|
346
|
+
typography: 'caption'
|
|
347
|
+
},
|
|
348
|
+
children: 'New contacts, companies, deals and tasks are shared with'
|
|
349
|
+
}),
|
|
350
|
+
/*#__PURE__*/ _jsxs(RadioGroup, {
|
|
351
|
+
value: mode,
|
|
352
|
+
onChange: (event)=>{
|
|
353
|
+
const next = event.target.value;
|
|
354
|
+
setMode(next);
|
|
355
|
+
if (next === 'allExcept' && storedMode !== 'allExcept') setExcept([]);
|
|
356
|
+
},
|
|
357
|
+
children: [
|
|
358
|
+
/*#__PURE__*/ _jsx(FormControlLabel, {
|
|
359
|
+
value: "org",
|
|
360
|
+
control: /*#__PURE__*/ _jsx(Radio, {
|
|
361
|
+
size: "small"
|
|
362
|
+
}),
|
|
363
|
+
label: "All sites in the organization"
|
|
364
|
+
}),
|
|
365
|
+
/*#__PURE__*/ _jsx(FormControlLabel, {
|
|
366
|
+
value: "host",
|
|
367
|
+
control: /*#__PURE__*/ _jsx(Radio, {
|
|
368
|
+
size: "small"
|
|
369
|
+
}),
|
|
370
|
+
label: /*#__PURE__*/ _jsxs(Stack, {
|
|
371
|
+
children: [
|
|
372
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
373
|
+
variant: "body2",
|
|
374
|
+
children: 'Only the site they came in on'
|
|
375
|
+
}),
|
|
376
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
377
|
+
variant: "caption",
|
|
378
|
+
color: "text.secondary",
|
|
379
|
+
children: 'Keeps clients apart, for agencies.'
|
|
380
|
+
})
|
|
381
|
+
]
|
|
382
|
+
})
|
|
383
|
+
}),
|
|
384
|
+
/*#__PURE__*/ _jsx(FormControlLabel, {
|
|
385
|
+
value: "allExcept",
|
|
386
|
+
// The saved choice stays on: nobody is told they can't have what they have.
|
|
387
|
+
disabled: !editable || Boolean(exceptOff) && storedMode !== 'allExcept',
|
|
388
|
+
control: /*#__PURE__*/ _jsx(Radio, {
|
|
389
|
+
size: "small"
|
|
390
|
+
}),
|
|
391
|
+
label: /*#__PURE__*/ _jsxs(Stack, {
|
|
392
|
+
children: [
|
|
393
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
394
|
+
variant: "body2",
|
|
395
|
+
children: 'All sites except…'
|
|
396
|
+
}),
|
|
397
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
398
|
+
variant: "caption",
|
|
399
|
+
color: "text.secondary",
|
|
400
|
+
children: exceptOff != null ? exceptOff : 'Every site but the ones you leave out, including sites added later. The site a person came in on always keeps them.'
|
|
401
|
+
})
|
|
402
|
+
]
|
|
403
|
+
})
|
|
404
|
+
})
|
|
405
|
+
]
|
|
258
406
|
}),
|
|
259
|
-
/*#__PURE__*/
|
|
260
|
-
|
|
261
|
-
|
|
407
|
+
mode === 'allExcept' ? /*#__PURE__*/ _jsxs(Stack, {
|
|
408
|
+
spacing: 0.5,
|
|
409
|
+
sx: {
|
|
410
|
+
pl: 3.5
|
|
411
|
+
},
|
|
412
|
+
children: [
|
|
413
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
414
|
+
variant: "caption",
|
|
415
|
+
color: "text.secondary",
|
|
416
|
+
children: 'Sites to leave out'
|
|
417
|
+
}),
|
|
418
|
+
/*#__PURE__*/ _jsx(FormGroup, {
|
|
419
|
+
sx: {
|
|
420
|
+
flexWrap: 'nowrap',
|
|
421
|
+
maxHeight: (theme)=>theme.spacing(30),
|
|
422
|
+
overflowY: 'auto'
|
|
423
|
+
},
|
|
424
|
+
children: sites.sites.map((site)=>{
|
|
425
|
+
const locked = stillIn.length === 1 && stillIn[0] === site.id;
|
|
426
|
+
return /*#__PURE__*/ _jsx(FormControlLabel, {
|
|
427
|
+
disabled: !editable || locked,
|
|
428
|
+
control: /*#__PURE__*/ _jsx(Checkbox, {
|
|
429
|
+
size: "small",
|
|
430
|
+
checked: except.includes(site.id),
|
|
431
|
+
onChange: toggle(site.id)
|
|
432
|
+
}),
|
|
433
|
+
label: /*#__PURE__*/ _jsxs(Stack, {
|
|
434
|
+
children: [
|
|
435
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
436
|
+
variant: "body2",
|
|
437
|
+
children: site.name
|
|
438
|
+
}),
|
|
439
|
+
locked ? /*#__PURE__*/ _jsx(Typography, {
|
|
440
|
+
variant: "caption",
|
|
441
|
+
color: "text.secondary",
|
|
442
|
+
children: 'At least one site has to stay in.'
|
|
443
|
+
}) : null
|
|
444
|
+
]
|
|
445
|
+
})
|
|
446
|
+
}, site.id);
|
|
447
|
+
})
|
|
448
|
+
})
|
|
449
|
+
]
|
|
450
|
+
}) : null,
|
|
451
|
+
problem ? /*#__PURE__*/ _jsx(FormHelperText, {
|
|
452
|
+
error: true,
|
|
453
|
+
children: problem
|
|
454
|
+
}) : null,
|
|
455
|
+
/*#__PURE__*/ _jsx(FormHelperText, {
|
|
456
|
+
children: 'Only affects records created from now on. Datasets and media ' + 'have defaults of their own, on the organization Data and ' + 'Media pages.'
|
|
262
457
|
})
|
|
263
458
|
]
|
|
264
459
|
}),
|
|
460
|
+
/*#__PURE__*/ _jsx(Stack, {
|
|
461
|
+
direction: "row",
|
|
462
|
+
spacing: 1,
|
|
463
|
+
children: /*#__PURE__*/ _jsx(BlockedControl, {
|
|
464
|
+
blocked: ready && !canManage,
|
|
465
|
+
reason: crmSettingsPermissionRefusal(),
|
|
466
|
+
children: /*#__PURE__*/ _jsx(Button, {
|
|
467
|
+
variant: "contained",
|
|
468
|
+
size: "small",
|
|
469
|
+
disabled: !canSave,
|
|
470
|
+
onClick: ()=>void save(),
|
|
471
|
+
children: 'Save'
|
|
472
|
+
})
|
|
473
|
+
})
|
|
474
|
+
}),
|
|
475
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
476
|
+
variant: "subtitle2",
|
|
477
|
+
children: 'Records you already have'
|
|
478
|
+
}),
|
|
479
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
480
|
+
variant: "body2",
|
|
481
|
+
color: "text.secondary",
|
|
482
|
+
children: 'Saving changes only new records. To share the ones you already have the same way, ' + 'apply it to them. The site that captured each person keeps them.'
|
|
483
|
+
}),
|
|
484
|
+
/*#__PURE__*/ _jsxs(Stack, {
|
|
485
|
+
direction: "row",
|
|
486
|
+
spacing: 1,
|
|
487
|
+
sx: {
|
|
488
|
+
alignItems: 'center'
|
|
489
|
+
},
|
|
490
|
+
children: [
|
|
491
|
+
/*#__PURE__*/ _jsx(BlockedControl, {
|
|
492
|
+
blocked: ready && !canManage || Boolean(applyOff),
|
|
493
|
+
reason: ready && !canManage ? crmSettingsPermissionRefusal() : applyOff != null ? applyOff : '',
|
|
494
|
+
children: /*#__PURE__*/ _jsx(Button, {
|
|
495
|
+
size: "small",
|
|
496
|
+
variant: "outlined",
|
|
497
|
+
disabled: !ready || !canManage || Boolean(applyOff),
|
|
498
|
+
onClick: ()=>void apply('default-apply'),
|
|
499
|
+
children: 'Apply to existing records…'
|
|
500
|
+
})
|
|
501
|
+
}),
|
|
502
|
+
(run == null ? void 0 : run.status) === 'failed' && storedMode === 'allExcept' && !applying ? /*#__PURE__*/ _jsx(Button, {
|
|
503
|
+
size: "small",
|
|
504
|
+
disabled: !canManage,
|
|
505
|
+
onClick: ()=>void apply('default-apply-continue'),
|
|
506
|
+
children: 'Resume'
|
|
507
|
+
}) : null
|
|
508
|
+
]
|
|
509
|
+
}),
|
|
510
|
+
run ? /*#__PURE__*/ _jsx(Typography, {
|
|
511
|
+
variant: "caption",
|
|
512
|
+
color: run.status === 'failed' ? 'error' : 'text.secondary',
|
|
513
|
+
role: "status",
|
|
514
|
+
children: run.status === 'running' ? `Applying: ${run.processed} records checked, ${run.changed} changed so far.` : run.status === 'done' ? `Applied: ${run.processed} records checked, ${run.changed} changed${run.capped ? `, ${run.capped} left as they were because they would reach more than ${CRM_DEFAULT_MAX_INCLUDED} sites` : ''}.` : (_run_error = run.error) != null ? _run_error : 'Applying stopped.'
|
|
515
|
+
}) : null,
|
|
265
516
|
/*#__PURE__*/ _jsx(ManagersOnlyNote, {
|
|
266
517
|
ready: ready,
|
|
267
518
|
canManage: canManage
|