docs: Write "Importing and Exporting Data" chapter and rewrite "Form Traversing" chapter#85
docs: Write "Importing and Exporting Data" chapter and rewrite "Form Traversing" chapter#85
Conversation
Co-authored-by: bitifet <1643647+bitifet@users.noreply.github.com>
|
Here you have my revison, @copilot Can you handle it, please? Small bug in the "Copy to shipping" button in the "Chaining export and import" exampleThe fix: diff --git docs/_advanced_concepts/data_import_and_export.md docs/_advanced_concepts/data_import_and_export.md
index 95c8a6f..9945096 100644
--- docs/_advanced_concepts/data_import_and_export.md
+++ docs/_advanced_concepts/data_import_and_export.md
@@ -445,7 +445,7 @@ into the shipping address section:
<button data-smark='{
"action":"export",
"context":"billing",
- "target":"shipping"
+ "target":"../shipping"
}'>📋 Copy to shipping</button>
</p>
<fieldset data-smark='{"type":"form","name":"shipping"}'>Explanation:
Note: Alternatively, the following would had also the same effect: <button data-smark='{
"action":"import",
"context":"shipping",
"target":"../billing"
}'>📋 Copy to shipping</button>...it is the reverse operation also reversing context and target. That is: It imports, into the shipping address the data from the billing address instead of exporting the data from the billing address to the shipping address. I reckon it worth to mention in a "hint" box because it could be illustrative and help to understand better the concepts. Also, we could have added an addigional button to the example for the reverse operation (Copy from shipping) by just switching the action from export to import and keeping context and target the same. Moreover, if we also add a Clear button to both subforms (and maybe add preloaded -different- data for the shipping address), it could be an excellent example to add to the Showcase section. In this section, though, that would be excessively bloated from my point of view. But I think adding the beforementioned hint, including the former snippet and then linking to the more bloated example if we add it to the Showcase section, it would be perfect. Don't you think so, @copilot? Question about the "Save and restore draft data"Wouldn't the example in this sectio be a perfect fit for using a "sampletabs" enhanced example to allow the reader play with it? |
…ft example Co-authored-by: bitifet <1643647+bitifet@users.noreply.github.com>
Done in commit Bug fix: Changed Corrected hint: The previous hint incorrectly said target paths are resolved relative to "the context component's parent". Updated to say they're resolved relative to the context component itself (matching the actual Added the import-based alternative hint: Included the snippet you suggested showing the reverse approach ( Interactive "Save and restore draft data" example: Converted the code-only section into a full sampletabs playground. The |
…tive draft example" This reverts commit 031cf99. Internals shouldn't be explainded in usage documentation. Also for the "Save and restore draft data" I prefer the original version.
|
Hey, @copilot Can you now review the existing "Form traversing" section? Keep in mind the bug we've just fixed: I won't be surprised if it were originated from an error or not so well explained detail in this document. I want you to:
|
…AGENTS Co-authored-by: bitifet <1643647+bitifet@users.noreply.github.com>
Done in commit
|
The
docs/_advanced_concepts/data_import_and_export.mdpage was a stub with only a "Work in Progress" placeholder. This PR fills it with a complete chapter documenting SmarkForm's core data I/O system. It also rewrites the existingform_traversing.mdchapter to fix factual errors discovered during this work, and updates the AGENTS knowledge files.Coverage — Importing and Exporting Data
exportaction — return value shape by component type (form→object, list→array, input→scalar);exportEmptiesoption with inheritance semantics and a concrete nested-list override exampleimportaction — accepted formats (plain object, JSON string, array, scalar);setDefaultfull behaviour table;focusoptionclear, andreset—valueinitialization, howimportupdatesdefaultValue,clearvsresetcomparison tabletargetoption) — declarative billing→shipping address copy with zero JS;targetsemantics on bothexportandimporttriggers; hint showing the equivalent import-based alternative (reversing context and target).actions.export/import()(full event lifecycle) vs direct prototype calls (bypass);await myForm.renderedrequirementInteractive examples
Five embedded playgrounds (using the existing
sampletabs_tpl.mdtemplate):export_structureimport_exampleclear_vs_resetvalue-initialized defaults, clear vs resetpipe_exampletargetdraft_examplelocalStorageon export; auto-restore on page loadAll examples are picked up by the docs collector and pass co-located Playwright validation.
Rewrite — Form Traversing chapter
contextpaths are resolved viatriggerParent.find(contextPath), i.e. relative to the trigger's parent componentcontext.find(targetPath), starting from the resolved context. Added a prominent rule box with the billing→shipping example explaining why"shipping"silently fails and"../shipping"is correct. Absolute paths shown as the unambiguous alternative.action:"export"withtarget:".-1"was labeled "← Copy from Previous" — that actually writes the current item into the previous. Fixed toaction:"import"(reads from previous, imports into current) with an explanatory paragraph..-N(was.--N) in the Navigation Direction listAGENTS knowledge files updated
Added a new "Action Target Resolution" section to both
AGENTS/SmarkForm-Usage.mdanddocs/_resources/AGENTS/SmarkForm-Usage.mdcovering:context.find(targetPath)rule and why it differs from context resolution../shippingvs brokenshipping)Bug fixes
pipe_exampletarget path: Fixed"target":"shipping"→"target":"../shipping". Thetargetoption is resolved viacontext.find(targetPath), so from abillingcontext"shipping"incorrectly looked for a child of billing."../shipping"correctly navigates up to billing's parent and finds the shipping sibling.Original prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.