diff --git a/DOCX_TEMPLATES_README.md b/DOCX_TEMPLATES_README.md index 1d5ff07..4132a94 100644 --- a/DOCX_TEMPLATES_README.md +++ b/DOCX_TEMPLATES_README.md @@ -49,11 +49,16 @@ This system allows you to generate DOCX documents by filling templates with proj #### Financial - `{wartosc_zlecenia}`, `{wartosc_zlecenia_1}`, `{wartosc_zlecenia_2}` - Contract value -#### Contacts -- `{contacts}` - Array of contacts (use loops in advanced templates) -- `{primary_contact}` - Primary contact name -- `{primary_contact_phone}` - Primary contact phone -- `{primary_contact_email}` - Primary contact email +#### Standard Custom Fields (Pre-filled but Editable) +- `{zk}` - ZK field +- `{nr_zk}` - ZK number +- `{kabel}` - Cable information +- `{dlugosc}` - Length +- `{data_wykonania}` - Execution date +- `{st_nr}` - Station number +- `{obw}` - Circuit +- `{wp_short}` - Short WP reference +- `{plomba}` - Seal/plomb information ## Example Template Content @@ -78,6 +83,17 @@ Meeting Notes: {meeting_notes} Special Instructions: {special_instructions} Additional Comments: {additional_comments} +Technical Details: +ZK: {zk} +ZK Number: {nr_zk} +Cable: {kabel} +Length: {dlugosc} +Execution Date: {data_wykonania} +Station Number: {st_nr} +Circuit: {obw} +WP Short: {wp_short} +Seal: {plomba} + Primary Contact: Name: {primary_contact} Phone: {primary_contact_phone} @@ -100,7 +116,7 @@ Generated on: {today_date} 2. In the sidebar, find the "Generate Document" section 3. Select a template from the dropdown 4. **Optional**: Click "Pokaż dodatkowe pola" to add custom data -5. Add any custom fields you need (e.g., `custom_note`, `additional_info`) +5. Fill in the standard fields (zk, nr_zk, kabel, etc.) and any additional custom fields 6. Click "Generate Document" 7. The filled document will be downloaded automatically with filename: `{template_name}_{project_name}_{timestamp}.docx` @@ -108,10 +124,16 @@ Generated on: {today_date} During document generation, you can add custom data that will be merged with the project data: +### Standard Fields (Pre-filled but Fully Editable) +These fields are pre-filled with common names but can be modified or removed: +- `zk`, `nr_zk`, `kabel`, `dlugosc`, `data_wykonania`, `st_nr`, `obw`, `wp_short`, `plomba` + +### Additional Custom Fields - **Custom fields** override project data if they have the same name - Use descriptive names like `meeting_notes`, `special_instructions`, `custom_date` - Custom fields are available in templates as `{custom_field_name}` - Empty custom fields are ignored +- All fields can be removed if not needed ### Example Custom Fields: - `meeting_notes`: "Please bring project documentation" diff --git a/src/components/DocumentGenerator.js b/src/components/DocumentGenerator.js index 4d835c1..fb5ee0c 100644 --- a/src/components/DocumentGenerator.js +++ b/src/components/DocumentGenerator.js @@ -9,7 +9,17 @@ export default function DocumentGenerator({ projectId }) { const [selectedTemplate, setSelectedTemplate] = useState(""); const [generating, setGenerating] = useState(false); const [loading, setLoading] = useState(true); - const [customFields, setCustomFields] = useState([{ key: "", value: "" }]); + const [customFields, setCustomFields] = useState([ + { key: "zk", value: "" }, + { key: "nr_zk", value: "" }, + { key: "kabel", value: "" }, + { key: "dlugosc", value: "" }, + { key: "data_wykonania", value: "" }, + { key: "st_nr", value: "" }, + { key: "obw", value: "" }, + { key: "wp_short", value: "" }, + { key: "plomba", value: "" } + ]); const [showCustomFields, setShowCustomFields] = useState(false); useEffect(() => { @@ -41,6 +51,7 @@ export default function DocumentGenerator({ projectId }) { }; const removeCustomField = (index) => { + // Allow removing any field, but keep at least one empty field if (customFields.length > 1) { setCustomFields(customFields.filter((_, i) => i !== index)); } @@ -183,11 +194,14 @@ export default function DocumentGenerator({ projectId }) { {showCustomFields && (
- {customFields.map((field, index) => ( +
+ Standardowe pola (można edytować i usuwać): +
+ {customFields.slice(0, 9).map((field, index) => (
handleCustomFieldChange(index, 'key', e.target.value)} className="flex-1 px-2 py-1 text-sm border border-gray-300 rounded focus:ring-1 focus:ring-blue-500 focus:border-transparent" @@ -199,32 +213,68 @@ export default function DocumentGenerator({ projectId }) { onChange={(e) => handleCustomFieldChange(index, 'value', e.target.value)} className="flex-1 px-2 py-1 text-sm border border-gray-300 rounded focus:ring-1 focus:ring-blue-500 focus:border-transparent" /> - {customFields.length > 1 && ( - - )} +
))} + + {customFields.length > 9 && ( + <> +
+ Dodatkowe pola: +
+ {customFields.slice(9).map((field, index) => ( +
+ handleCustomFieldChange(index + 9, 'key', e.target.value)} + className="flex-1 px-2 py-1 text-sm border border-gray-300 rounded focus:ring-1 focus:ring-blue-500 focus:border-transparent" + /> + handleCustomFieldChange(index + 9, 'value', e.target.value)} + className="flex-1 px-2 py-1 text-sm border border-gray-300 rounded focus:ring-1 focus:ring-blue-500 focus:border-transparent" + /> + +
+ ))} + + )} +
- Wprowadź dodatkowe dane, które będą dostępne w szablonie jako {"{custom_note}"}, {"{additional_info}"} itp. + Standardowe pola są wstępnie wypełnione, ale można je edytować lub usuwać. Wszystkie pola będą dostępne w szablonie jako {"{nazwa_pola}"}.
)}