@riboseinc/paneron-registry-kit 2.0.0-dev8 → 2.0.0
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/common.d.ts +1 -1
- package/common.js +1 -1
- package/common.js.map +1 -1
- package/index.d.ts +3 -3
- package/index.js +3 -3
- package/index.js.map +1 -1
- package/package.json +26 -18
- package/types/cr.d.ts +216 -0
- package/types/cr.js +175 -0
- package/types/cr.js.map +1 -0
- package/types/index.d.ts +1 -0
- package/types/index.js +19 -0
- package/types/index.js.map +1 -1
- package/types/item.d.ts +13 -3
- package/types/item.js +11 -1
- package/types/item.js.map +1 -1
- package/types/proposal.d.ts +31 -14
- package/types/proposal.js +1 -1
- package/types/proposal.js.map +1 -1
- package/types/register.d.ts +6 -5
- package/types/register.js +19 -1
- package/types/register.js.map +1 -1
- package/types/registry.d.ts +8 -3
- package/types/registry.js +8 -1
- package/types/registry.js.map +1 -1
- package/types/stakeholder.d.ts +40 -16
- package/types/stakeholder.js +47 -3
- package/types/stakeholder.js.map +1 -1
- package/types/views.d.ts +98 -24
- package/types/views.js.map +1 -1
- package/views/AnnotatedChange.d.ts +7 -0
- package/views/AnnotatedChange.js +91 -0
- package/views/AnnotatedChange.js.map +1 -0
- package/views/BrowserCtx.d.ts +66 -2
- package/views/BrowserCtx.js +13 -2
- package/views/BrowserCtx.js.map +1 -1
- package/views/FilterCriteria/CRITERIA_CONFIGURATION.d.ts +17 -0
- package/views/FilterCriteria/CRITERIA_CONFIGURATION.js +202 -0
- package/views/FilterCriteria/CRITERIA_CONFIGURATION.js.map +1 -0
- package/views/FilterCriteria/criteriaGroupToQueryExpression.d.ts +6 -0
- package/views/FilterCriteria/criteriaGroupToQueryExpression.js +50 -0
- package/views/FilterCriteria/criteriaGroupToQueryExpression.js.map +1 -0
- package/views/FilterCriteria/criteriaGroupToSummary.d.ts +5 -0
- package/views/FilterCriteria/criteriaGroupToSummary.js +62 -0
- package/views/FilterCriteria/criteriaGroupToSummary.js.map +1 -0
- package/views/FilterCriteria/criteriaToNodes.d.ts +24 -0
- package/views/FilterCriteria/criteriaToNodes.js +159 -0
- package/views/FilterCriteria/criteriaToNodes.js.map +1 -0
- package/views/FilterCriteria/index.d.ts +23 -0
- package/views/FilterCriteria/index.js +130 -0
- package/views/FilterCriteria/index.js.map +1 -0
- package/views/FilterCriteria/models.d.ts +68 -0
- package/views/FilterCriteria/models.js +34 -0
- package/views/FilterCriteria/models.js.map +1 -0
- package/views/FilterCriteria/mutateGroup.d.ts +17 -0
- package/views/FilterCriteria/mutateGroup.js +59 -0
- package/views/FilterCriteria/mutateGroup.js.map +1 -0
- package/views/GenericRelatedItemView.d.ts +1 -1
- package/views/GenericRelatedItemView.js +143 -101
- package/views/GenericRelatedItemView.js.map +1 -1
- package/views/RegisterStakeholder.d.ts +9 -0
- package/views/RegisterStakeholder.js +40 -0
- package/views/RegisterStakeholder.js.map +1 -0
- package/views/RegisterVersion.d.ts +9 -0
- package/views/RegisterVersion.js +41 -0
- package/views/RegisterVersion.js.map +1 -0
- package/views/SearchQuery.d.ts +13 -0
- package/views/SearchQuery.js +137 -0
- package/views/SearchQuery.js.map +1 -0
- package/views/change-request/ChangeRequestContext.d.ts +20 -0
- package/views/change-request/ChangeRequestContext.js +56 -0
- package/views/change-request/ChangeRequestContext.js.map +1 -0
- package/views/change-request/Proposals.d.ts +21 -0
- package/views/change-request/Proposals.js +331 -0
- package/views/change-request/Proposals.js.map +1 -0
- package/views/change-request/objectChangeset.d.ts +31 -0
- package/views/change-request/objectChangeset.js +229 -0
- package/views/change-request/objectChangeset.js.map +1 -0
- package/views/detail/ChangeRequest/Proposal.d.ts +0 -0
- package/views/detail/ChangeRequest/Proposal.js +142 -0
- package/views/detail/ChangeRequest/Proposal.js.map +1 -0
- package/views/detail/ChangeRequest/index.d.ts +13 -0
- package/views/detail/ChangeRequest/index.js +207 -0
- package/views/detail/ChangeRequest/index.js.map +1 -0
- package/views/detail/ChangeRequest/transitions.d.ts +28 -0
- package/views/detail/ChangeRequest/transitions.js +530 -0
- package/views/detail/ChangeRequest/transitions.js.map +1 -0
- package/views/detail/CustomView/index.d.ts +13 -0
- package/views/detail/CustomView/index.js +68 -0
- package/views/detail/CustomView/index.js.map +1 -0
- package/views/detail/RegisterHome/index.d.ts +5 -0
- package/views/detail/RegisterHome/index.js +128 -0
- package/views/detail/RegisterHome/index.js.map +1 -0
- package/views/detail/RegisterItem/RelatedItems.d.ts +13 -0
- package/views/detail/RegisterItem/RelatedItems.js +61 -0
- package/views/detail/RegisterItem/RelatedItems.js.map +1 -0
- package/views/detail/RegisterItem/SupersedingItemMenu.d.ts +13 -0
- package/views/detail/RegisterItem/SupersedingItemMenu.js +56 -0
- package/views/detail/RegisterItem/SupersedingItemMenu.js.map +1 -0
- package/views/detail/RegisterItem/index.d.ts +13 -0
- package/views/detail/RegisterItem/index.js +356 -0
- package/views/detail/RegisterItem/index.js.map +1 -0
- package/views/detail/RegisterMeta/RegisterMetaForm.d.ts +10 -0
- package/views/detail/RegisterMeta/RegisterMetaForm.js +331 -0
- package/views/detail/RegisterMeta/RegisterMetaForm.js.map +1 -0
- package/views/detail/RegisterMeta/index.d.ts +10 -0
- package/views/detail/RegisterMeta/index.js +111 -0
- package/views/detail/RegisterMeta/index.js.map +1 -0
- package/views/detail/index.d.ts +1 -0
- package/views/detail/index.js +24 -0
- package/views/detail/index.js.map +1 -0
- package/views/diffing/InlineDiff.d.ts +12 -0
- package/views/diffing/InlineDiff.js +58 -0
- package/views/diffing/InlineDiff.js.map +1 -0
- package/views/diffing/StructuredDiff.d.ts +11 -0
- package/views/diffing/StructuredDiff.js +65 -0
- package/views/diffing/StructuredDiff.js.map +1 -0
- package/views/hooks/useCustomView.d.ts +3 -0
- package/views/hooks/useCustomView.js +24 -0
- package/views/hooks/useCustomView.js.map +1 -0
- package/views/hooks/useItemClassConfig.d.ts +3 -0
- package/views/hooks/useItemClassConfig.js +24 -0
- package/views/hooks/useItemClassConfig.js.map +1 -0
- package/views/hooks/useItemRef.d.ts +3 -0
- package/views/hooks/useItemRef.js +39 -0
- package/views/hooks/useItemRef.js.map +1 -0
- package/views/hooks/useSingleRegisterItemData.d.ts +3 -0
- package/views/hooks/useSingleRegisterItemData.js +32 -0
- package/views/hooks/useSingleRegisterItemData.js.map +1 -0
- package/views/index.d.ts +2 -2
- package/views/index.js +161 -130
- package/views/index.js.map +1 -1
- package/views/itemPathUtils.d.ts +45 -2
- package/views/itemPathUtils.js +101 -14
- package/views/itemPathUtils.js.map +1 -1
- package/views/itemQueryUtils.d.ts +11 -0
- package/views/itemQueryUtils.js +48 -0
- package/views/itemQueryUtils.js.map +1 -0
- package/views/protocolRegistry.d.ts +12 -0
- package/views/protocolRegistry.js +42 -0
- package/views/protocolRegistry.js.map +1 -0
- package/views/sidebar/Browse/index.d.ts +11 -0
- package/views/sidebar/Browse/index.js +453 -0
- package/views/sidebar/Browse/index.js.map +1 -0
- package/views/sidebar/Export/index.d.ts +5 -0
- package/views/sidebar/Export/index.js +94 -0
- package/views/sidebar/Export/index.js.map +1 -0
- package/views/sidebar/ListItem.d.ts +10 -0
- package/views/sidebar/ListItem.js +43 -0
- package/views/sidebar/ListItem.js.map +1 -0
- package/views/sidebar/Registration/index.d.ts +5 -0
- package/views/sidebar/Registration/index.js +163 -0
- package/views/sidebar/Registration/index.js.map +1 -0
- package/views/sidebar/Search/index.d.ts +18 -0
- package/views/sidebar/Search/index.js +177 -0
- package/views/sidebar/Search/index.js.map +1 -0
- package/views/sidebar/index.d.ts +6 -0
- package/views/sidebar/index.js +104 -0
- package/views/sidebar/index.js.map +1 -0
- package/views/util.d.ts +29 -5
- package/views/util.js +92 -6
- package/views/util.js.map +1 -1
- package/views/ChangeRequest.d.ts +0 -12
- package/views/ChangeRequest.js +0 -689
- package/views/ChangeRequest.js.map +0 -1
- package/views/FilterCriteria.d.ts +0 -27
- package/views/FilterCriteria.js +0 -410
- package/views/FilterCriteria.js.map +0 -1
- package/views/ItemBrowser.d.ts +0 -12
- package/views/ItemBrowser.js +0 -255
- package/views/ItemBrowser.js.map +0 -1
- package/views/ItemDetails.d.ts +0 -14
- package/views/ItemDetails.js +0 -128
- package/views/ItemDetails.js.map +0 -1
- package/views/MainView.d.ts +0 -8
- package/views/MainView.js +0 -34
- package/views/MainView.js.map +0 -1
- package/views/RegisterInformation.d.ts +0 -7
- package/views/RegisterInformation.js +0 -264
- package/views/RegisterInformation.js.map +0 -1
- package/views/RegisterItemGrid.d.ts +0 -25
- package/views/RegisterItemGrid.js +0 -248
- package/views/RegisterItemGrid.js.map +0 -1
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ObjectChangeset } from '@riboseinc/paneron-extension-kit/types/objects';
|
|
2
|
+
import type { RegisterItem, ChangeRequest, ChangeProposal } from '../../types';
|
|
3
|
+
import type { Version as RegisterVersion } from '../../types/register';
|
|
4
|
+
import { type Drafted, type ReturnedForClarificationByManager, type ReturnedForClarificationByControlBody } from '../../types/cr';
|
|
5
|
+
/** Takes a justification and ID, returns an object changeset. */
|
|
6
|
+
export declare function newCRObjectChangeset(id: string, justification: string, registerVersion: RegisterVersion, stakeholderGitServerUsername: string): ObjectChangeset;
|
|
7
|
+
/**
|
|
8
|
+
* Returns an object changeset to update CR with new given proposal items.
|
|
9
|
+
* Only applicable to CR at draft edit stage.
|
|
10
|
+
*/
|
|
11
|
+
export declare function updateCRObjectChangeset(
|
|
12
|
+
/**
|
|
13
|
+
* Change request data.
|
|
14
|
+
*/
|
|
15
|
+
cr: Drafted | ReturnedForClarificationByManager | ReturnedForClarificationByControlBody,
|
|
16
|
+
/**
|
|
17
|
+
* Proposals by item path.
|
|
18
|
+
* Will be merged with those already existing in `cr`.
|
|
19
|
+
* If a proposal is undefined, it will be removed.
|
|
20
|
+
*/
|
|
21
|
+
proposalItems: Record<string, ChangeProposal | null>,
|
|
22
|
+
/**
|
|
23
|
+
* New item data must be provided for additions and clarifications,
|
|
24
|
+
* keyed by item path.
|
|
25
|
+
*/
|
|
26
|
+
itemData?: Record<string, RegisterItem<any>>): ObjectChangeset;
|
|
27
|
+
/**
|
|
28
|
+
* Given change proposals, returns applicable changes
|
|
29
|
+
* to objects in the dataset.
|
|
30
|
+
*/
|
|
31
|
+
export declare function proposalsToObjectChangeset(crID: string, hasSubregisters: boolean, proposals: ChangeRequest["proposals"], itemData: Record<string, RegisterItem<any> | null>, newItemData: Record<string, RegisterItem<any> | null>): Promise<ObjectChangeset>;
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.newCRObjectChangeset = newCRObjectChangeset;
|
|
7
|
+
exports.updateCRObjectChangeset = updateCRObjectChangeset;
|
|
8
|
+
exports.proposalsToObjectChangeset = proposalsToObjectChangeset;
|
|
9
|
+
|
|
10
|
+
var _types = require("../../types");
|
|
11
|
+
|
|
12
|
+
var _cr = require("../../types/cr");
|
|
13
|
+
|
|
14
|
+
var _itemPathUtils = require("../itemPathUtils");
|
|
15
|
+
|
|
16
|
+
/** Takes a justification and ID, returns an object changeset. */
|
|
17
|
+
function newCRObjectChangeset(id, justification, registerVersion, stakeholderGitServerUsername) {
|
|
18
|
+
const timeStarted = new Date();
|
|
19
|
+
const cr = {
|
|
20
|
+
id,
|
|
21
|
+
timeStarted,
|
|
22
|
+
timeEdited: timeStarted,
|
|
23
|
+
justification,
|
|
24
|
+
submittingStakeholderGitServerUsername: stakeholderGitServerUsername,
|
|
25
|
+
items: {},
|
|
26
|
+
state: _cr.State.DRAFT,
|
|
27
|
+
registerVersion: registerVersion.id
|
|
28
|
+
};
|
|
29
|
+
const crObjectPath = (0, _itemPathUtils.crIDToCRPath)(id);
|
|
30
|
+
return {
|
|
31
|
+
[crObjectPath]: {
|
|
32
|
+
oldValue: null,
|
|
33
|
+
newValue: cr
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Returns an object changeset to update CR with new given proposal items.
|
|
39
|
+
* Only applicable to CR at draft edit stage.
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
function updateCRObjectChangeset(
|
|
44
|
+
/**
|
|
45
|
+
* Change request data.
|
|
46
|
+
*/
|
|
47
|
+
cr,
|
|
48
|
+
/**
|
|
49
|
+
* Proposals by item path.
|
|
50
|
+
* Will be merged with those already existing in `cr`.
|
|
51
|
+
* If a proposal is undefined, it will be removed.
|
|
52
|
+
*/
|
|
53
|
+
proposalItems,
|
|
54
|
+
/**
|
|
55
|
+
* New item data must be provided for additions and clarifications,
|
|
56
|
+
* keyed by item path.
|
|
57
|
+
*/
|
|
58
|
+
itemData = {}) {
|
|
59
|
+
const changeset = {};
|
|
60
|
+
const newItems = { ...cr.items
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
for (const [itemPath, proposal] of Object.entries(proposalItems)) {
|
|
64
|
+
// Update proposals on CR
|
|
65
|
+
if (proposal !== null) {
|
|
66
|
+
newItems[itemPath] = proposal;
|
|
67
|
+
} else if (newItems[itemPath]) {
|
|
68
|
+
delete newItems[itemPath];
|
|
69
|
+
} // Add/remove item data
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
if ((proposal === null || proposal === void 0 ? void 0 : proposal.type) === 'addition' || (proposal === null || proposal === void 0 ? void 0 : proposal.type) === 'clarification') {
|
|
73
|
+
const proposedItemData = itemData[itemPath];
|
|
74
|
+
|
|
75
|
+
if (proposedItemData === null || !(0, _types.isRegisterItem)(proposedItemData)) {
|
|
76
|
+
console.error("Unable to convert proposals to object changeset: original item data is missing", itemPath);
|
|
77
|
+
throw new Error("Unable to convert proposals to object changeset: original item data is missing");
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
changeset[(0, _itemPathUtils.itemPathInCR)(itemPath, cr.id)] = {
|
|
81
|
+
// When editing a draft, we don’t care
|
|
82
|
+
// about overwriting proposed item data so we omit oldValue.
|
|
83
|
+
newValue: proposedItemData
|
|
84
|
+
};
|
|
85
|
+
} else {
|
|
86
|
+
changeset[(0, _itemPathUtils.itemPathInCR)(itemPath, cr.id)] = {
|
|
87
|
+
// When editing a draft, we don’t care
|
|
88
|
+
// about overwriting proposed item data so we omit oldValue.
|
|
89
|
+
newValue: null
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
} // Update main CR data
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
const crPath = (0, _itemPathUtils.crIDToCRPath)(cr.id);
|
|
96
|
+
changeset[crPath] = {
|
|
97
|
+
oldValue: cr,
|
|
98
|
+
newValue: { ...cr,
|
|
99
|
+
items: newItems,
|
|
100
|
+
timeEdited: new Date()
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
return changeset;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Given change proposals, returns applicable changes
|
|
107
|
+
* to objects in the dataset.
|
|
108
|
+
*/
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
async function proposalsToObjectChangeset(crID, hasSubregisters, proposals, itemData, newItemData) {
|
|
112
|
+
const cs = {};
|
|
113
|
+
|
|
114
|
+
for (const [itemPath, proposal] of Object.entries(proposals)) {
|
|
115
|
+
//const originalItem: RegisterItem<any> | undefined = (itemData[itemPath] ?? undefined);
|
|
116
|
+
const itemRef = (0, _itemPathUtils.itemPathToItemRef)(hasSubregisters, itemPath);
|
|
117
|
+
|
|
118
|
+
if (proposal.type !== 'addition') {
|
|
119
|
+
if (itemData[itemPath] === undefined) {
|
|
120
|
+
console.error("Unable to convert proposals to object changeset: original item data is missing", itemPath);
|
|
121
|
+
throw new Error("Unable to convert proposals to object changeset: original item data is missing");
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (proposal.type === 'amendment' && proposal.amendmentType === 'supersession') {
|
|
125
|
+
Object.assign(cs, await proposalToObjectChangeset(crID, proposal, itemRef, itemPath, itemData, newItemData));
|
|
126
|
+
} else {
|
|
127
|
+
Object.assign(cs, await proposalToObjectChangeset(crID, proposal, itemRef, itemPath, itemData, newItemData));
|
|
128
|
+
}
|
|
129
|
+
} else {
|
|
130
|
+
Object.assign(cs, await proposalToObjectChangeset(crID, proposal, itemRef, itemPath, itemData, newItemData));
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return cs;
|
|
135
|
+
} // TODO: Refactor out the business logic of proposal approval.
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Given a change proposal, returns applicable changes
|
|
139
|
+
* to objects in the dataset.
|
|
140
|
+
* Core logic of approving a proposal.
|
|
141
|
+
* Takes a proposal and extra options (depending on proposal type).
|
|
142
|
+
* Returns a Changeset containing register items at appropriate paths.
|
|
143
|
+
*/
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
async function proposalToObjectChangeset(crID, proposal, itemRef, itemPath, itemData, newItemData) {
|
|
147
|
+
let updatedItem;
|
|
148
|
+
const changeset = {};
|
|
149
|
+
const origItem = itemData[itemPath] ?? null;
|
|
150
|
+
const newItem = newItemData[(0, _itemPathUtils.itemPathInCR)(itemPath, crID)] ?? null;
|
|
151
|
+
|
|
152
|
+
if (proposal.type !== 'addition') {
|
|
153
|
+
if (origItem === null) {
|
|
154
|
+
throw new Error("proposalToObjectChangeset() requires original item data for non-additions");
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
updatedItem = { ...origItem
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
switch (proposal.type) {
|
|
161
|
+
case 'clarification':
|
|
162
|
+
if (newItem === null) {
|
|
163
|
+
throw new Error("proposalToObjectChangeset() requires new item data for clarifications");
|
|
164
|
+
} //const clarification = proposal as Clarification;
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
updatedItem.data = newItem.data; //clarification.payload;
|
|
168
|
+
|
|
169
|
+
break;
|
|
170
|
+
|
|
171
|
+
case 'amendment':
|
|
172
|
+
const amendment = proposal;
|
|
173
|
+
updatedItem.amendedInCR = crID;
|
|
174
|
+
|
|
175
|
+
switch (amendment.amendmentType) {
|
|
176
|
+
case 'retirement':
|
|
177
|
+
updatedItem.status = 'retired';
|
|
178
|
+
break;
|
|
179
|
+
|
|
180
|
+
case 'invalidation':
|
|
181
|
+
updatedItem.status = 'invalid';
|
|
182
|
+
break;
|
|
183
|
+
|
|
184
|
+
case 'supersession':
|
|
185
|
+
const supersession = proposal;
|
|
186
|
+
updatedItem.status = 'superseded';
|
|
187
|
+
updatedItem.supersededBy = supersession.supersedingItemIDs.map(itemID => ({
|
|
188
|
+
itemID,
|
|
189
|
+
classID: itemRef.classID,
|
|
190
|
+
subregisterID: itemRef.subregisterID
|
|
191
|
+
}));
|
|
192
|
+
|
|
193
|
+
for (const supersedingItemPath of updatedItem.supersededBy.map(ip => (0, _itemPathUtils.itemRefToItemPath)(ip))) {
|
|
194
|
+
const supersedingItemData = itemData[supersedingItemPath];
|
|
195
|
+
|
|
196
|
+
if (supersedingItemData) {
|
|
197
|
+
changeset[supersedingItemPath] = {
|
|
198
|
+
oldValue: supersedingItemData,
|
|
199
|
+
newValue: { ...supersedingItemData,
|
|
200
|
+
supersedes: [...(supersedingItemData.supersedes ?? []), itemRef]
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
break;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
break;
|
|
210
|
+
}
|
|
211
|
+
} else {
|
|
212
|
+
if (newItem === null) {
|
|
213
|
+
throw new Error("proposalToObjectChangeset() requires new item data for additions");
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
updatedItem = {
|
|
217
|
+
id: itemRef.itemID,
|
|
218
|
+
data: newItem.data,
|
|
219
|
+
status: 'valid',
|
|
220
|
+
dateAccepted: new Date()
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
changeset[itemPath] = {
|
|
225
|
+
oldValue: origItem,
|
|
226
|
+
newValue: updatedItem
|
|
227
|
+
};
|
|
228
|
+
return changeset;
|
|
229
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objectChangeset.js","sourceRoot":"","sources":["../../../src/views/change-request/objectChangeset.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,OAAO,EACL,KAAK,GAIN,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGpG,iEAAiE;AACjE,MAAM,UAAU,oBAAoB,CAClC,EAAU,EACV,aAAqB,EACrB,eAAgC,EAChC,4BAAoC;IAGpC,MAAM,WAAW,GAAG,IAAI,IAAI,EAAE,CAAC;IAC/B,MAAM,EAAE,GAAY;QAClB,EAAE;QACF,WAAW;QACX,UAAU,EAAE,WAAW;QACvB,aAAa;QACb,sCAAsC,EAAE,4BAA4B;QACpE,KAAK,EAAE,EAAE;QACT,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,eAAe,EAAE,eAAgB,CAAC,EAAE;KACrC,CAAC;IACF,MAAM,YAAY,GAAG,YAAY,CAAC,EAAE,CAAC,CAAC;IACtC,OAAO;QACL,CAAC,YAAY,CAAC,EAAE;YACd,QAAQ,EAAE,IAAI;YACd,QAAQ,EAAE,EAAE;SACb;KACF,CAAA;AACH,CAAC;AAGD;;;GAGG;AACH,MAAM,UAAU,uBAAuB;AACrC;;GAEG;AACH,EAAuF;AAEvF;;;;GAIG;AACH,aAAoD;AAEpD;;;GAGG;AACH,WAA8C,EAAE;IAEhD,MAAM,SAAS,GAAoB,EAAE,CAAC;IACtC,MAAM,QAAQ,GAAG,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC;IACjC,KAAK,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE;QAChE,yBAAyB;QACzB,I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AC,OAAO;4BACxB,aAAa,EAAE,OAAO,CAAC,aAAa;yBACrC,CAAC,CAAC,CAAC;wBACJ,KAAK,MAAM,mBAAmB,IAAI,WAAW,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC,EAAE;4BAC3F,MAAM,mBAAmB,GAAG,QAAQ,CAAC,mBAAmB,CAAC,CAAC;4BAC1D,IAAI,mBAAmB,EAAE;gCACvB,SAAS,CAAC,mBAAmB,CAAC,GAAG;oCAC/B,QAAQ,EAAE,mBAAmB;oCAC7B,QAAQ,EAAE;wCACR,GAAG,mBAAmB;wCACtB,UAAU,EAAE,CAAE,GAAG,CAAC,mBAAmB,CAAC,UAAU,IAAI,EAAE,CAAC,EAAE,OAAO,CAAE;qCACnE;iCACF,CAAC;6BACH;yBACF;wBACD,MAAM;iBACT;gBACD,MAAM;SACT;KACF;SAAM;QACL,IAAI,OAAO,KAAK,IAAI,EAAE;YACpB,MAAM,IAAI,KAAK,CAAC,kEAAkE,CAAC,CAAC;SACrF;QACD,WAAW,GAAG;YACZ,EAAE,EAAE,OAAO,CAAC,MAAM;YAClB,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,MAAM,EAAE,OAAO;YACf,YAAY,EAAE,IAAI,IAAI,EAAE;SACzB,CAAC;KACH;IAED,SAAS,CAAC,QAAQ,CAAC,GAAG;QACpB,QAAQ,EAAE,QAAQ;QAClB,QAAQ,EAAE,WAAW;KACtB,CAAC;IAEF,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import type { Change, Changeset } from '@riboseinc/paneron-extension-kit/types/changes';\nimport type { ObjectChangeset } from '@riboseinc/paneron-extension-kit/types/objects';\nimport type {\n InternalItemReference,\n RegisterItem,\n ChangeRequest,\n ChangeProposal,\n Amendment,\n Supersession,\n} from '../../types';\nimport { isRegisterItem } from '../../types';\nimport type { Version as RegisterVersion } from '../../types/register';\nimport {\n State,\n type Drafted,\n type ReturnedForClarificationByManager,\n type ReturnedForClarificationByControlBody,\n} from '../../types/cr';\nimport { crIDToCRPath, itemPathInCR, itemPathToItemRef, itemRefToItemPath } from '../itemPathUtils';\n\n\n/** Takes a justification and ID, returns an object changeset. */\nexport function newCRObjectChangeset(\n id: string,\n justification: string,\n registerVersion: RegisterVersion,\n stakeholderGitServerUsername: string,\n): ObjectChangeset {\n\n const timeStarted = new Date();\n const cr: Drafted = {\n id,\n timeStarted,\n timeEdited: timeStarted,\n justification,\n submittingStakeholderGitServerUsername: stakeholderGitServerUsername,\n items: {},\n state: State.DRAFT,\n registerVersion: registerVersion!.id,\n };\n const crObjectPath = crIDToCRPath(id);\n return {\n [crObjectPath]: {\n oldValue: null,\n newValue: cr,\n },\n }\n}\n\n\n/**\n * Returns an object changeset to update CR with new given proposal items.\n * Only applicable to CR at draft edit stage.\n */\nexport function updateCRObjectChangeset(\n /**\n * Change request data.\n */\n cr: Drafted | ReturnedForClarificationByManager | ReturnedForClarificationByControlBody,\n\n /**\n * Proposals by item path.\n * Will be merged with those already existing in `cr`.\n * If a proposal is undefined, it will be removed.\n */\n proposalItems: Record<string, ChangeProposal | null>,\n\n /**\n * New item data must be provided for additions and clarifications,\n * keyed by item path.\n */\n itemData: Record<string, RegisterItem<any>> = {},\n): ObjectChangeset {\n const changeset: ObjectChangeset = {};\n const newItems = { ...cr.items };\n for (const [itemPath, proposal] of Object.entries(proposalItems)) {\n // Update proposals on CR\n if (proposal !== null) {\n newItems[itemPath] = proposal;\n } else if (newItems[itemPath]) {\n delete newItems[itemPath];\n }\n // Add/remove item data\n if (proposal?.type === 'addition' || proposal?.type === 'clarification') {\n const proposedItemData = itemData[itemPath];\n if (proposedItemData === null || !isRegisterItem(proposedItemData)) {\n console.error(\"Unable to convert proposals to object changeset: original item data is missing\", itemPath);\n throw new Error(\"Unable to convert proposals to object changeset: original item data is missing\");\n }\n changeset[itemPathInCR(itemPath, cr.id)] = {\n // When editing a draft, we don’t care\n // about overwriting proposed item data so we omit oldValue.\n newValue: proposedItemData,\n };\n } else {\n changeset[itemPathInCR(itemPath, cr.id)] = {\n // When editing a draft, we don’t care\n // about overwriting proposed item data so we omit oldValue.\n newValue: null,\n };\n }\n }\n // Update main CR data\n const crPath = crIDToCRPath(cr.id);\n changeset[crPath] = {\n oldValue: cr,\n newValue: { ...cr, items: newItems, timeEdited: new Date() },\n };\n return changeset;\n}\n\n\n/**\n * Given change proposals, returns applicable changes\n * to objects in the dataset.\n */\nexport async function proposalsToObjectChangeset(\n crID: string,\n hasSubregisters: boolean,\n proposals: ChangeRequest[\"proposals\"],\n itemData: Record<string, RegisterItem<any> | null>,\n newItemData: Record<string, RegisterItem<any> | null>,\n): Promise<ObjectChangeset> {\n const cs: ObjectChangeset = {};\n\n for (const [itemPath, proposal] of Object.entries(proposals)) {\n //const originalItem: RegisterItem<any> | undefined = (itemData[itemPath] ?? undefined);\n const itemRef = itemPathToItemRef(hasSubregisters, itemPath);\n\n if (proposal.type !== 'addition') {\n if (itemData[itemPath] === undefined) {\n console.error(\"Unable to convert proposals to object changeset: original item data is missing\", itemPath);\n throw new Error(\"Unable to convert proposals to object changeset: original item data is missing\");\n }\n if (proposal.type === 'amendment' && proposal.amendmentType === 'supersession') {\n Object.assign(cs, await proposalToObjectChangeset(crID, proposal, itemRef, itemPath, itemData, newItemData));\n } else {\n Object.assign(cs, await proposalToObjectChangeset(crID, proposal, itemRef, itemPath, itemData, newItemData));\n }\n } else {\n Object.assign(cs, await proposalToObjectChangeset(crID, proposal, itemRef, itemPath, itemData, newItemData));\n }\n }\n\n return cs;\n}\n\n// TODO: Refactor out the business logic of proposal approval.\n/**\n * Given a change proposal, returns applicable changes\n * to objects in the dataset.\n * Core logic of approving a proposal.\n * Takes a proposal and extra options (depending on proposal type).\n * Returns a Changeset containing register items at appropriate paths.\n */\nasync function proposalToObjectChangeset(\n crID: string,\n proposal: ChangeProposal,\n itemRef: InternalItemReference,\n itemPath: string,\n itemData: Record<string, RegisterItem<any> | null>,\n newItemData: Record<string, RegisterItem<any> | null>,\n): Promise<Changeset<Change<RegisterItem<any>>>> {\n let updatedItem: RegisterItem<any>;\n const changeset: Changeset<Change<RegisterItem<any>>> = {};\n\n const origItem = itemData[itemPath] ?? null;\n const newItem = newItemData[itemPathInCR(itemPath, crID)] ?? null;\n\n if (proposal.type !== 'addition') {\n if (origItem === null) {\n throw new Error(\"proposalToObjectChangeset() requires original item data for non-additions\");\n }\n\n updatedItem = { ...origItem };\n\n switch (proposal.type) {\n case 'clarification':\n if (newItem === null) {\n throw new Error(\"proposalToObjectChangeset() requires new item data for clarifications\");\n }\n //const clarification = proposal as Clarification;\n updatedItem.data = newItem.data //clarification.payload;\n break;\n case 'amendment':\n const amendment = proposal as Amendment;\n updatedItem.amendedInCR = crID;\n\n switch (amendment.amendmentType) {\n case 'retirement':\n updatedItem.status = 'retired';\n break;\n case 'invalidation':\n updatedItem.status = 'invalid';\n break;\n case 'supersession':\n const supersession = proposal as Supersession;\n updatedItem.status = 'superseded';\n updatedItem.supersededBy = supersession.supersedingItemIDs.map(itemID => ({\n itemID,\n classID: itemRef.classID,\n subregisterID: itemRef.subregisterID,\n }));\n for (const supersedingItemPath of updatedItem.supersededBy.map(ip => itemRefToItemPath(ip))) {\n const supersedingItemData = itemData[supersedingItemPath];\n if (supersedingItemData) {\n changeset[supersedingItemPath] = {\n oldValue: supersedingItemData,\n newValue: {\n ...supersedingItemData,\n supersedes: [ ...(supersedingItemData.supersedes ?? []), itemRef ],\n },\n };\n }\n }\n break;\n }\n break;\n }\n } else {\n if (newItem === null) {\n throw new Error(\"proposalToObjectChangeset() requires new item data for additions\");\n }\n updatedItem = {\n id: itemRef.itemID,\n data: newItem.data,\n status: 'valid',\n dateAccepted: new Date(),\n };\n }\n\n changeset[itemPath] = {\n oldValue: origItem,\n newValue: updatedItem,\n };\n\n return changeset;\n}\n"]}
|
|
File without changes
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict"; // /** @jsx jsx */
|
|
2
|
+
// /** @jsxFrag React.Fragment */
|
|
3
|
+
//
|
|
4
|
+
//
|
|
5
|
+
// import React from 'react';
|
|
6
|
+
//
|
|
7
|
+
// import { jsx, css } from '@emotion/react';
|
|
8
|
+
//
|
|
9
|
+
// import {
|
|
10
|
+
// FormGroup,
|
|
11
|
+
// InputGroup,
|
|
12
|
+
// NonIdealState,
|
|
13
|
+
// HTMLSelect,
|
|
14
|
+
// H4,
|
|
15
|
+
// } from '@blueprintjs/core';
|
|
16
|
+
//
|
|
17
|
+
// import useItemClassConfig from '../../hooks/useItemClassConfig';
|
|
18
|
+
//
|
|
19
|
+
// import type {
|
|
20
|
+
// ChangeProposal,
|
|
21
|
+
// Payload,
|
|
22
|
+
// InternalItemReference,
|
|
23
|
+
// } from '../../../types';
|
|
24
|
+
//
|
|
25
|
+
// import { PROPOSAL_TYPES } from '../../../types';
|
|
26
|
+
//
|
|
27
|
+
//
|
|
28
|
+
// const ProposalDetails: React.FC<{
|
|
29
|
+
// itemRef: InternalItemReference
|
|
30
|
+
// proposal: ChangeProposal
|
|
31
|
+
//
|
|
32
|
+
// existingItemData?: Payload
|
|
33
|
+
//
|
|
34
|
+
// onAccept?: (itemID: string, clsID: string) => void
|
|
35
|
+
// onChange?: (val: ChangeProposal) => void
|
|
36
|
+
// onDelete?: () => void
|
|
37
|
+
// }> = function ({
|
|
38
|
+
// itemRef,
|
|
39
|
+
// proposal,
|
|
40
|
+
// onChange,
|
|
41
|
+
// existingItemData,
|
|
42
|
+
// }) {
|
|
43
|
+
// const { value: classConfig } = useItemClassConfig(itemRef.classID ?? 'NONEXISTENT_CLASS_ID');
|
|
44
|
+
// const itemClass = classConfig;
|
|
45
|
+
//
|
|
46
|
+
// let itemView: JSX.Element;
|
|
47
|
+
// let proposalProperties: JSX.Element | null;
|
|
48
|
+
//
|
|
49
|
+
// if (proposal.type === 'amendment') {
|
|
50
|
+
// proposalProperties = (
|
|
51
|
+
// <FormGroup inline label="Supersede with:">
|
|
52
|
+
// <InputGroup
|
|
53
|
+
// value={proposal.amendmentType === 'supersession' ? proposal.supersedingItemID : ''}
|
|
54
|
+
// disabled={!onChange}
|
|
55
|
+
// placeholder="Item ID"
|
|
56
|
+
// onChange={onChange
|
|
57
|
+
// ? (evt: React.FormEvent<HTMLInputElement>) => {
|
|
58
|
+
// if (!onChange) { return; }
|
|
59
|
+
// const itemID = evt.currentTarget.value;
|
|
60
|
+
// if (itemID.trim() === '') {
|
|
61
|
+
// const newVal = update(proposal, { $unset: ['supersedingItemID'] });
|
|
62
|
+
// onChange({ ...newVal, amendmentType: 'retirement' });
|
|
63
|
+
// } else {
|
|
64
|
+
// onChange({ ...proposal, amendmentType: 'supersession', supersedingItemID: itemID });
|
|
65
|
+
// }
|
|
66
|
+
// }
|
|
67
|
+
// : undefined}/>
|
|
68
|
+
// </FormGroup>
|
|
69
|
+
// );
|
|
70
|
+
// } else {
|
|
71
|
+
// proposalProperties = null;
|
|
72
|
+
// }
|
|
73
|
+
//
|
|
74
|
+
// const itemData: Payload | undefined = proposal.type === 'addition'
|
|
75
|
+
// ? proposal.payload
|
|
76
|
+
// : existingItemData;
|
|
77
|
+
//
|
|
78
|
+
// if (itemData === undefined || !itemClass) {
|
|
79
|
+
// itemView = <NonIdealState icon="heart-broken" title="Unable to display this item" />;
|
|
80
|
+
// } else if (onChange && proposal.type !== 'amendment') {
|
|
81
|
+
// const EditView = itemClass.views.editView;// as ItemEditView<any>;
|
|
82
|
+
// itemView = <EditView
|
|
83
|
+
// itemRef={itemRef}
|
|
84
|
+
// itemData={itemData}
|
|
85
|
+
// onChange={onChange
|
|
86
|
+
// ? (payload) => onChange ? onChange({ ...proposal, payload }) : void 0
|
|
87
|
+
// : undefined} />;
|
|
88
|
+
// } else {
|
|
89
|
+
// const DetailView = itemClass.views.detailView ?? itemClass!.views.editView;// as ItemDetailView<any>;
|
|
90
|
+
// itemView = <DetailView
|
|
91
|
+
// itemRef={itemRef}
|
|
92
|
+
// itemData={itemData} />;
|
|
93
|
+
// }
|
|
94
|
+
//
|
|
95
|
+
// const canChangeProposalType = proposal.type !== 'addition';
|
|
96
|
+
//
|
|
97
|
+
// function handleTypeChange(type: string) {
|
|
98
|
+
// const pt = type as typeof PROPOSAL_TYPES[number];
|
|
99
|
+
//
|
|
100
|
+
// if (PROPOSAL_TYPES.indexOf(pt) < 0) { return; }
|
|
101
|
+
// if (!onChange || !canChangeProposalType || pt === 'addition' || existingItemData === undefined) { return; }
|
|
102
|
+
//
|
|
103
|
+
// if (pt === 'amendment') {
|
|
104
|
+
// onChange(update(proposal, {
|
|
105
|
+
// type: { $set: pt },
|
|
106
|
+
// amendmentType: { $set: 'retirement' },
|
|
107
|
+
// $unset: ['payload'],
|
|
108
|
+
// }));
|
|
109
|
+
// } else {
|
|
110
|
+
// onChange(update(proposal, {
|
|
111
|
+
// type: { $set: pt },
|
|
112
|
+
// payload: existingItemData,
|
|
113
|
+
// }));
|
|
114
|
+
// }
|
|
115
|
+
// }
|
|
116
|
+
//
|
|
117
|
+
// return (
|
|
118
|
+
// <div css={css`flex: 1; display: flex; flex-flow: column nowrap;`}>
|
|
119
|
+
// <div css={css`flex-shrink: 0; display: flex; flex-flow: row nowrap; align-items: center; margin-bottom: 1rem;`}>
|
|
120
|
+
// <HTMLSelect
|
|
121
|
+
// options={PROPOSAL_TYPES.map(pt => ({ value: pt, label: pt }))}
|
|
122
|
+
// //iconProps={{ icon: PROPOSAL_ICON[proposal.type] }}
|
|
123
|
+
// value={proposal.type}
|
|
124
|
+
// disabled={!onChange || !canChangeProposalType || existingItemData === undefined}
|
|
125
|
+
// onChange={(onChange && canChangeProposalType && existingItemData !== undefined)
|
|
126
|
+
// ? (evt) => handleTypeChange(evt.currentTarget.value)
|
|
127
|
+
// : undefined} />
|
|
128
|
+
//  
|
|
129
|
+
// of a
|
|
130
|
+
//  
|
|
131
|
+
// <H4 css={css`margin: 0;`}>{classConfig?.meta.title ?? 'unknown class'}</H4>
|
|
132
|
+
// {proposalProperties}
|
|
133
|
+
// </div>
|
|
134
|
+
//
|
|
135
|
+
// <div css={css`flex: 1; overflow-y: auto;`}>
|
|
136
|
+
// {itemView}
|
|
137
|
+
// </div>
|
|
138
|
+
// </div>
|
|
139
|
+
// );
|
|
140
|
+
// };
|
|
141
|
+
//
|
|
142
|
+
// export default ProposalDetails;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Proposal.js","sourceRoot":"","sources":["../../../../src/views/detail/ChangeRequest/Proposal.tsx"],"names":[],"mappings":";AAAA,kBAAkB;AAClB,iCAAiC;AACjC,GAAG;AACH,GAAG;AACH,6BAA6B;AAC7B,GAAG;AACH,6CAA6C;AAC7C,GAAG;AACH,WAAW;AACX,eAAe;AACf,gBAAgB;AAChB,mBAAmB;AACnB,gBAAgB;AAChB,QAAQ;AACR,8BAA8B;AAC9B,GAAG;AACH,mEAAmE;AACnE,GAAG;AACH,gBAAgB;AAChB,oBAAoB;AACpB,aAAa;AACb,2BAA2B;AAC3B,2BAA2B;AAC3B,GAAG;AACH,mDAAmD;AACnD,GAAG;AACH,GAAG;AACH,oCAAoC;AACpC,mCAAmC;AACnC,6BAA6B;AAC7B,GAAG;AACH,+BAA+B;AAC/B,GAAG;AACH,uDAAuD;AACvD,6CAA6C;AAC7C,0BAA0B;AAC1B,mBAAmB;AACnB,aAAa;AACb,cAAc;AACd,cAAc;AACd,sBAAsB;AACtB,OAAO;AACP,kGAAkG;AAClG,mCAAmC;AACnC,GAAG;AACH,+BAA+B;AAC/B,gDAAgD;AAChD,GAAG;AACH,yCAAyC;AACzC,6BAA6B;AAC7B,mDAAmD;AACnD,sBAAsB;AACtB,gGAAgG;AAChG,iCAAiC;AACjC,kCAAkC;AAClC,+BAA+B;AAC/B,8DAA8D;AAC9D,6CAA6C;AAC7C,0DAA0D;AAC1D,8CAA8C;AAC9C,wFAAwF;AACxF,0EAA0E;AAC1E,2BAA2B;AAC3B,yGAAyG;AACzG,oBAAoB;AACpB,kBAAkB;AAClB,6BAA6B;AAC7B,qBAAqB;AACrB,SAAS;AACT,aAAa;AACb,iCAAiC;AACjC,MAAM;AACN,GAAG;AACH,uEAAuE;AACvE,yBAAyB;AACzB,0BAA0B;AAC1B,GAAG;AACH,gDAAgD;AAChD,4FAA4F;AAC5F,4DAA4D;AAC5D,yEAAyE;AACzE,2BAA2B;AAC3B,0BAA0B;AAC1B,4BAA4B;AAC5B,2BAA2B;AAC3B,gFAAgF;AAChF,2BAA2B;AAC3B,aAAa;AACb,4GAA4G;AAC5G,6BAA6B;AAC7B,0BAA0B;AAC1B,gCAAgC;AAChC,MAAM;AACN,GAAG;AACH,gEAAgE;AAChE,GAAG;AACH,8CAA8C;AAC9C,wDAAwD;AACxD,GAAG;AACH,sDAAsD;AACtD,kHAAkH;AAClH,GAAG;AACH,gCAAgC;AAChC,oCAAoC;AACpC,8BAA8B;AAC9B,iDAAiD;AACjD,+BAA+B;AAC/B,aAAa;AACb,eAAe;AACf,oCAAoC;AACpC,8BAA8B;AAC9B,qCAAqC;AACrC,aAAa;AACb,QAAQ;AACR,MAAM;AACN,GAAG;AACH,aAAa;AACb,yEAAyE;AACzE,yHAAyH;AACzH,sBAAsB;AACtB,2EAA2E;AAC3E,iEAAiE;AACjE,kCAAkC;AAClC,6FAA6F;AAC7F,4FAA4F;AAC5F,mEAAmE;AACnE,8BAA8B;AAC9B,iBAAiB;AACjB,eAAe;AACf,iBAAiB;AACjB,sFAAsF;AACtF,+BAA+B;AAC/B,eAAe;AACf,GAAG;AACH,oDAAoD;AACpD,qBAAqB;AACrB,eAAe;AACf,aAAa;AACb,OAAO;AACP,KAAK;AACL,GAAG;AACH,kCAAkC","sourcesContent":["// /** @jsx jsx */\n// /** @jsxFrag React.Fragment */\n// \n// \n// import React from 'react';\n// \n// import { jsx, css } from '@emotion/react';\n// \n// import {\n// FormGroup,\n// InputGroup,\n// NonIdealState,\n// HTMLSelect,\n// H4,\n// } from '@blueprintjs/core';\n// \n// import useItemClassConfig from '../../hooks/useItemClassConfig';\n// \n// import type {\n// ChangeProposal,\n// Payload,\n// InternalItemReference,\n// } from '../../../types';\n// \n// import { PROPOSAL_TYPES } from '../../../types';\n// \n// \n// const ProposalDetails: React.FC<{\n// itemRef: InternalItemReference\n// proposal: ChangeProposal\n// \n// existingItemData?: Payload\n// \n// onAccept?: (itemID: string, clsID: string) => void\n// onChange?: (val: ChangeProposal) => void\n// onDelete?: () => void\n// }> = function ({\n// itemRef,\n// proposal,\n// onChange,\n// existingItemData,\n// }) {\n// const { value: classConfig } = useItemClassConfig(itemRef.classID ?? 'NONEXISTENT_CLASS_ID');\n// const itemClass = classConfig;\n// \n// let itemView: JSX.Element;\n// let proposalProperties: JSX.Element | null;\n// \n// if (proposal.type === 'amendment') {\n// proposalProperties = (\n// <FormGroup inline label=\"Supersede with:\">\n// <InputGroup\n// value={proposal.amendmentType === 'supersession' ? proposal.supersedingItemID : ''}\n// disabled={!onChange}\n// placeholder=\"Item ID\"\n// onChange={onChange\n// ? (evt: React.FormEvent<HTMLInputElement>) => {\n// if (!onChange) { return; }\n// const itemID = evt.currentTarget.value;\n// if (itemID.trim() === '') {\n// const newVal = update(proposal, { $unset: ['supersedingItemID'] });\n// onChange({ ...newVal, amendmentType: 'retirement' });\n// } else {\n// onChange({ ...proposal, amendmentType: 'supersession', supersedingItemID: itemID });\n// }\n// }\n// : undefined}/>\n// </FormGroup>\n// );\n// } else {\n// proposalProperties = null;\n// }\n// \n// const itemData: Payload | undefined = proposal.type === 'addition'\n// ? proposal.payload\n// : existingItemData;\n// \n// if (itemData === undefined || !itemClass) {\n// itemView = <NonIdealState icon=\"heart-broken\" title=\"Unable to display this item\" />;\n// } else if (onChange && proposal.type !== 'amendment') {\n// const EditView = itemClass.views.editView;// as ItemEditView<any>;\n// itemView = <EditView\n// itemRef={itemRef}\n// itemData={itemData}\n// onChange={onChange\n// ? (payload) => onChange ? onChange({ ...proposal, payload }) : void 0\n// : undefined} />;\n// } else {\n// const DetailView = itemClass.views.detailView ?? itemClass!.views.editView;// as ItemDetailView<any>;\n// itemView = <DetailView\n// itemRef={itemRef}\n// itemData={itemData} />;\n// }\n// \n// const canChangeProposalType = proposal.type !== 'addition';\n// \n// function handleTypeChange(type: string) {\n// const pt = type as typeof PROPOSAL_TYPES[number];\n// \n// if (PROPOSAL_TYPES.indexOf(pt) < 0) { return; }\n// if (!onChange || !canChangeProposalType || pt === 'addition' || existingItemData === undefined) { return; }\n// \n// if (pt === 'amendment') {\n// onChange(update(proposal, {\n// type: { $set: pt },\n// amendmentType: { $set: 'retirement' },\n// $unset: ['payload'],\n// }));\n// } else {\n// onChange(update(proposal, {\n// type: { $set: pt },\n// payload: existingItemData,\n// }));\n// }\n// }\n// \n// return (\n// <div css={css`flex: 1; display: flex; flex-flow: column nowrap;`}>\n// <div css={css`flex-shrink: 0; display: flex; flex-flow: row nowrap; align-items: center; margin-bottom: 1rem;`}>\n// <HTMLSelect\n// options={PROPOSAL_TYPES.map(pt => ({ value: pt, label: pt }))}\n// //iconProps={{ icon: PROPOSAL_ICON[proposal.type] }}\n// value={proposal.type}\n// disabled={!onChange || !canChangeProposalType || existingItemData === undefined}\n// onChange={(onChange && canChangeProposalType && existingItemData !== undefined)\n// ? (evt) => handleTypeChange(evt.currentTarget.value)\n// : undefined} />\n//  \n// of a\n//  \n// <H4 css={css`margin: 0;`}>{classConfig?.meta.title ?? 'unknown class'}</H4>\n// {proposalProperties}\n// </div>\n// \n// <div css={css`flex: 1; overflow-y: auto;`}>\n// {itemView}\n// </div>\n// </div>\n// );\n// };\n// \n// export default ProposalDetails;\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
/** @jsxFrag React.Fragment */
|
|
3
|
+
import React from 'react';
|
|
4
|
+
declare const _default: {
|
|
5
|
+
main: React.FC<{
|
|
6
|
+
uri: string;
|
|
7
|
+
}>;
|
|
8
|
+
title: React.FC<{
|
|
9
|
+
uri: string;
|
|
10
|
+
}>;
|
|
11
|
+
plainTitle: (uri: string) => Promise<string>;
|
|
12
|
+
};
|
|
13
|
+
export default _default;
|