tbar0970 / jethro-pmm

Jethro Pastoral Ministry Manager
GNU General Public License v3.0
35 stars 25 forks source link

Contact list: keep family all on one page #885

Closed jefft closed 3 months ago

jefft commented 1 year ago

In Families -> Contact List one can generate a church directory-style contact list, and then 'Download as..' DOCX.

It would be nice if family members could be kept together on a page, rather than being split on pagebreaks:

image

jefft commented 1 year ago

The PR improves this a bit by at least keeping each row together:

image

tbar0970 commented 1 year ago

PR is a good step in the right direction. Unfortunately solving this properly would be really tricky. The way we currently assemble the DOCX doesn't have any awareness of where the page breaks are. For my part I just manually break pages as required before printing.

tim-pearce commented 1 year ago

The solution is to put the whole family within a table of just one cell then set the option to not split the table across page or column breaks. I can't find that option in Word 2010 but it honours the option when I create the document with Libreoffice.

Screenshot_2023-03-22_00-38-28

Attached are the two documents I feed into the document merge process. Families2.docx Families2.odt The only 'fiddle' was to change the font size of the line after the table to 0 and reduce the font size of the last line inside the table by 1.

tbar0970 commented 1 year ago

Attached are the two documents I feed into the document merge process.

Ah yes I can see this would work for a document merge. But this issue is actually talking about the "contact list" page which does merging differently, with more sophisticated layout per family.

The solution is to put the whole family within a table of just one cell then set the option to not split the table across page or column breaks. I can't find that option in Word 2010 but it honours the option when I create the document with Libreoffice.

The downside of this approach in the contact list, and the reason for not building it this way, was that by using nested tables you'd lose global control over the layout. If you decide you want the mobile column a bit wider, currently you can adjust it and every family is affected because it's one big table. If it was separate nested table for every family, you'd have to manually adjust every one separately.

tbar0970 commented 1 year ago

@jefft When photos are included, there is a cell containing the photo which spans all the rows in the family. If cantSplit=true affects that cell, I think that will end up keeping the whole family together when photos are included.

jefft commented 1 year ago

@tbar0970 no, the photo cell is only in the first row. This is probably a separate bug:

image

image

tbar0970 commented 1 year ago

Eww. Dunno what's happened there...

tim-pearce commented 1 year ago

The solution is to put the whole family within a table of just one cell then set the option to not split the table across page or column breaks. I can't find that option in Word 2010 but it honours the option when I create the document with Libreoffice.

The downside of this approach in the contact list, and the reason for not building it this way, was that by using nested tables you'd lose global control over the layout. If you decide you want the mobile column a bit wider, currently you can adjust it and every family is affected because it's one big table. If it was separate nested table for every family, you'd have to manually adjust every one separately.

Would a solution to that be to have some parameters to the process that can specify things like column widths, borders and padding?

jefft commented 1 year ago

Would a solution to that be to have some parameters to the process that can specify things like column widths, borders and padding?

That probably is the only fix. There doesn't appear to be a way, in PHPWord, just to say "keep these table rows altogether".

Manually specifying widths would be a cure would be worse than the disease I reckon. IMO this is a "close can't fix" bug. Keeping row contents from being split fixes the most egregious symptom.

tim-pearce commented 1 year ago

Document merge (or rather TinyButStrong which it uses) might provide a way. I've been using 'simple'' blocks but it does allow for sub blocks. See https://www.tinybutstrong.com/manual.php#html_block_subblock I had previously ruled it out for a contact list because I didn't think it could be used for sub-data. Using TinyButStrong would allow 'shipping' of a standard template based on the current contact list but then be able to use your own template so it looks exactly as you want.

tim-pearce commented 1 year ago

I am currently working on a 'use document template' feature for the contact list. At present I have a modal box (similar to the one I have for rosters) and a document_merge_contacts call based on document_merge. All a bit rough and incomplete at this point.

tim-pearce commented 1 year ago

I've got it working. The code is pretty messy at present and I haven't figured out what to do about images - not sure if they are possible.