@project-sunbird/sunbird-questionset-editor-web-component-react 0.1.19 → 0.1.20
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/api/hierarchy.d.ts +22 -4
- package/dist/hooks/useSaveHierarchy.d.ts +16 -0
- package/dist/hooks/useValidateAndSave.d.ts +21 -3
- package/dist/index.js +4267 -4205
- package/dist/locales/label.config.ar.json.d.ts +1 -0
- package/dist/locales/label.config.fr.json.d.ts +1 -0
- package/dist/locales/label.config.json.d.ts +1 -0
- package/dist/locales/label.config.pt.json.d.ts +1 -0
- package/dist/store/copyRegistry.store.d.ts +2 -0
- package/package.json +1 -1
package/dist/api/hierarchy.d.ts
CHANGED
|
@@ -7,10 +7,28 @@ export declare function readHierarchy(contentId: string): Promise<{
|
|
|
7
7
|
export declare function updateHierarchy(_contentId: string, nodesModified: Record<string, unknown>, hierarchy: Record<string, unknown>, lastUpdatedBy?: string): Promise<{
|
|
8
8
|
identifiers: Record<string, string>;
|
|
9
9
|
}>;
|
|
10
|
-
/**
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
/**
|
|
11
|
+
* `PATCH questionset/v2/add` — attaches existing questions to a collection; appends after maxIndex.
|
|
12
|
+
* `collectionId` is the target section id, or `null` to attach directly to the root QuestionSet
|
|
13
|
+
* (the backend's root-attach path, used when there is no section).
|
|
14
|
+
*
|
|
15
|
+
* `''` is rejected rather than treated as `null`: omitting collectionId routes to the backend's
|
|
16
|
+
* root path, so an accidental empty string would silently operate on the root instead of failing
|
|
17
|
+
* loudly with "collectionId ... does not exist". Only an explicit `null` may mean "the root".
|
|
18
|
+
*/
|
|
19
|
+
export declare function addQuestionsToSet(rootId: string, collectionId: string | null, children: string[]): Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* `DELETE questionset/v2/remove` — detaches questions from a collection (never retires them).
|
|
22
|
+
* `collectionId` is the section id, or `null` to detach a question that sits directly under the
|
|
23
|
+
* root (the backend's root-remove path). A root-level question's parent IS the root, so passing it
|
|
24
|
+
* as `collectionId` is rejected by the backend — pass `null` instead.
|
|
25
|
+
*
|
|
26
|
+
* `''` is rejected here for the same reason as in addQuestionsToSet, and the stakes are higher on
|
|
27
|
+
* this path: the backend's root-remove runs `childNodes.removeAll(children)` on the root
|
|
28
|
+
* unconditionally, so an empty string for a question that actually lives in a section would strip
|
|
29
|
+
* it from the questionset's childNodes while leaving it in the section — silent corruption.
|
|
30
|
+
*/
|
|
31
|
+
export declare function removeQuestionsFromSet(rootId: string, collectionId: string | null, children: string[]): Promise<void>;
|
|
14
32
|
export declare function publishContent(contentId: string, lastPublishedBy?: string): Promise<void>;
|
|
15
33
|
export declare function sendForReview(contentId: string): Promise<void>;
|
|
16
34
|
export declare function rejectContent(contentId: string, comment: string): Promise<void>;
|
|
@@ -1,5 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Outcome of a hierarchy save, for callers that need to tell the three cases
|
|
3
|
+
* apart rather than collapsing them into a boolean:
|
|
4
|
+
* - `saved` — the backend accepted the payload.
|
|
5
|
+
* - `not-attempted` — no request went out (no editor config / content id, or
|
|
6
|
+
* another save was already in flight). Nothing was sent
|
|
7
|
+
* and nothing was reverted, so the caller still owns any
|
|
8
|
+
* optimistic change it made.
|
|
9
|
+
* - `failed` — the request went out and was rejected. save() has
|
|
10
|
+
* ALREADY surfaced an error toast and called
|
|
11
|
+
* revertToSaved(), which discards every unsaved change
|
|
12
|
+
* since the last successful save — including the
|
|
13
|
+
* caller's own. There is nothing left to roll back.
|
|
14
|
+
*/
|
|
15
|
+
export type SaveOutcome = 'saved' | 'not-attempted' | 'failed';
|
|
1
16
|
export declare function useSaveHierarchy(): {
|
|
2
17
|
save: () => Promise<boolean>;
|
|
18
|
+
saveWithOutcome: () => Promise<SaveOutcome>;
|
|
3
19
|
isSaving: boolean;
|
|
4
20
|
isDirty: boolean;
|
|
5
21
|
lastSaved: string | null;
|
|
@@ -1,7 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Validates root + all sections' required fields (same check "Save as Draft"
|
|
3
|
-
* runs)
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* runs) and surfaces MissingRequiredFieldsModal via ui.store on failure.
|
|
4
|
+
* Purely local — never touches the network and never mutates the tree.
|
|
5
|
+
*
|
|
6
|
+
* Split out from useValidateAndSave so a caller can tell "the form isn't
|
|
7
|
+
* complete, so nothing was attempted" apart from "the save itself failed".
|
|
8
|
+
* useValidateAndSave collapses both into a single `false`, which is fine for
|
|
9
|
+
* validate-then-mutate callers but not for anything that has to decide
|
|
10
|
+
* whether there is something to roll back.
|
|
11
|
+
*/
|
|
12
|
+
export declare function useValidateRequiredFields(): () => boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Required-field check followed by a hierarchy save. Shared by the toolbar's
|
|
15
|
+
* Save-as-Draft and OutlineTree's auto-save-on-click (Add Section / Add
|
|
16
|
+
* Question).
|
|
17
|
+
*
|
|
18
|
+
* NOTE for callers: `false` means EITHER "required fields are missing, so no
|
|
19
|
+
* save was attempted" OR "the save failed". Only use this where those two
|
|
20
|
+
* warrant the same handling — i.e. validate-then-mutate, with nothing done
|
|
21
|
+
* yet that would need undoing. If you have already mutated the tree or
|
|
22
|
+
* created a backend object, use useValidateRequiredFields() up front and
|
|
23
|
+
* useSaveHierarchy().saveWithOutcome() afterwards instead.
|
|
6
24
|
*/
|
|
7
25
|
export declare function useValidateAndSave(): () => Promise<boolean>;
|