@nnkogift/dhis2-form-utils-devtools 0.1.0-alpha.2 → 0.1.0-alpha.4
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/index.cjs +28 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +29 -6
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -1356,6 +1356,10 @@ function countObservedRules(entries) {
|
|
|
1356
1356
|
return ruleIds.size;
|
|
1357
1357
|
}
|
|
1358
1358
|
var PANEL_TAB_KEYS = ["rules", "trace", "graph"];
|
|
1359
|
+
var SCOPE_FILTER_OPTIONS = [
|
|
1360
|
+
{ label: translate("In scope"), value: "scoped" },
|
|
1361
|
+
{ label: translate("All"), value: "all" }
|
|
1362
|
+
];
|
|
1359
1363
|
function resolveTabLabel(key) {
|
|
1360
1364
|
switch (key) {
|
|
1361
1365
|
case "rules":
|
|
@@ -1374,6 +1378,7 @@ function RulesPanel({ metadata, showConditions = true }) {
|
|
|
1374
1378
|
const [selectedEntryId, setSelectedEntryId] = react.useState(null);
|
|
1375
1379
|
const [highlightRuleId, setHighlightRuleId] = react.useState(null);
|
|
1376
1380
|
const [graphModalOpen, setGraphModalOpen] = react.useState(false);
|
|
1381
|
+
const [scopeFilter, setScopeFilter] = react.useState("scoped");
|
|
1377
1382
|
const labelLookup = react.useMemo(() => createLabelLookup(metadata), [metadata]);
|
|
1378
1383
|
const catalog = react.useMemo(() => resolveProgramRulesList(metadata), [metadata]);
|
|
1379
1384
|
const scopeStageId = react.useMemo(() => resolveScopeStageId(metadata), [metadata]);
|
|
@@ -1466,10 +1471,22 @@ function RulesPanel({ metadata, showConditions = true }) {
|
|
|
1466
1471
|
),
|
|
1467
1472
|
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "m-0 text-base font-bold leading-[1.35] text-dhis2-grey-900", children: translate("Rules") })
|
|
1468
1473
|
] }),
|
|
1469
|
-
/* @__PURE__ */ jsxRuntime.
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1474
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex shrink-0 items-center gap-dp8", children: [
|
|
1475
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-dhis2-grey-600", children: translate("{{scoped}} in scope \xB7 {{firing}} firing", {
|
|
1476
|
+
scoped: scopedRules.length,
|
|
1477
|
+
firing: firingCount
|
|
1478
|
+
}) }),
|
|
1479
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1480
|
+
ui.SegmentedControl,
|
|
1481
|
+
{
|
|
1482
|
+
options: SCOPE_FILTER_OPTIONS,
|
|
1483
|
+
selected: scopeFilter,
|
|
1484
|
+
onChange: ({ value }) => {
|
|
1485
|
+
setScopeFilter(value);
|
|
1486
|
+
}
|
|
1487
|
+
}
|
|
1488
|
+
)
|
|
1489
|
+
] })
|
|
1473
1490
|
] }),
|
|
1474
1491
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex", children: PANEL_TAB_KEYS.map((key) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1475
1492
|
"button",
|
|
@@ -1509,6 +1526,7 @@ function RulesPanel({ metadata, showConditions = true }) {
|
|
|
1509
1526
|
{
|
|
1510
1527
|
catalog,
|
|
1511
1528
|
scopeStageId,
|
|
1529
|
+
scopeFilter,
|
|
1512
1530
|
activeRuleIds,
|
|
1513
1531
|
selectedRuleId: highlightRuleId,
|
|
1514
1532
|
showConditions,
|
|
@@ -1565,6 +1583,7 @@ function RulesPanel({ metadata, showConditions = true }) {
|
|
|
1565
1583
|
function RulesTab({
|
|
1566
1584
|
catalog,
|
|
1567
1585
|
scopeStageId,
|
|
1586
|
+
scopeFilter,
|
|
1568
1587
|
activeRuleIds,
|
|
1569
1588
|
selectedRuleId,
|
|
1570
1589
|
showConditions,
|
|
@@ -1574,7 +1593,11 @@ function RulesTab({
|
|
|
1574
1593
|
if (!catalog.length) {
|
|
1575
1594
|
return /* @__PURE__ */ jsxRuntime.jsx("p", { className: "m-0 text-sm leading-normal text-dhis2-grey-600", children: translate("This program has no rules.") });
|
|
1576
1595
|
}
|
|
1577
|
-
|
|
1596
|
+
const visibleRules = scopeFilter === "all" ? catalog : catalog.filter((rule) => isRuleInScope(rule, scopeStageId));
|
|
1597
|
+
if (!visibleRules.length) {
|
|
1598
|
+
return /* @__PURE__ */ jsxRuntime.jsx("p", { className: "m-0 text-sm leading-normal text-dhis2-grey-600", children: translate("No rules are in scope for this stage.") });
|
|
1599
|
+
}
|
|
1600
|
+
return /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "m-0 flex list-none flex-col gap-[10px] p-0", children: visibleRules.map((rule) => {
|
|
1578
1601
|
const inScope = isRuleInScope(rule, scopeStageId);
|
|
1579
1602
|
const firing = activeRuleIds.has(rule.id);
|
|
1580
1603
|
const isSelected = selectedRuleId === rule.id;
|