Skip to content

Update Print.jsx #429

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Update Print.jsx #429

wants to merge 2 commits into from

Conversation

hirtarmin
Copy link
Contributor

Prevents certain print layouts from being displayed in the layout list of the print dialog.

Several print layouts are defined for a QWC theme. Some of them shouldn't be displayed in the layout list of the print dialog, but are used to print an info portfolio site (special reports created with a custom service).
Therefore, I can't exclude these print layouts in QGIS.

So I defined a prefix for print layout names. All layouts starting with these prefix are not displayed in the print dialog.
The prefix is ​​specified in the config.json file. I also specified a sort order and a default layout:

Added plugin config variables:

  1. hidePrintlayoutPrefix: All layouts with this prefix will not be displayed in the print layoutlist
  2. sortPrintlayouts: Alphabetical order for print layouts: asc or desc
  3. defaultPrintlayout: The default layout to display first

config.json (example):
{
"name": "Print",
"cfg": #{

"hidePrintlayoutPrefix": "_hide",
"sortPrintlayouts": "desc",
"defaultPrintlayout": "A4 - Hochformat"
}
}

Prevents certain print layouts from being displayed in the layout list of the print dialog.

Several print layouts are defined for a QWC theme. Some of them shouldn't be displayed in the layout list of the print dialog, but are used to print an info portfolio site (special reports created with a custom service).
Therefore, I can't exclude these print layouts in QGIS.

So I defined a prefix for print layout names. All layouts starting with these prefix are not displayed in the print dialog.
The prefix is ​​specified in the config.json file. I also specified a sort order and a default layout:

Added plugin config variables:
1. hidePrintlayoutPrefix: All layouts with this prefix will not be displayed in the print layoutlist
2. sortPrintlayouts: Alphabetical order for print layouts: asc or desc
3. defaultPrintlayout: The default layout to display first

config.json:
{
  "name": "Print",
  "cfg":  #{
    …
    "hidePrintlayoutPrefix": "_hide",
    "sortPrintlayouts": "desc",
    "defaultPrintlayout": "A4 - Hochformat"
  }
}
/** Alphabetical order for print layouts: asc or desc */
sortPrintlayouts: PropTypes.string,
/** The default layout to display first */
defaultPrintlayout: PropTypes.string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There already exists the option defaultPrintLayout in the theme configuration item for this [1]

[1] https://qwc-services.github.io/master/configuration/ThemesConfiguration/#manual-theme-configuration

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I didn't know about the option yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made an additional commit to remove the intended defaultPrintlayout option.

@@ -237,7 +255,7 @@ class Print extends React.Component {
<td>{LocaleUtils.tr("print.layout")}</td>
<td>
<select onChange={this.changeLayout} value={this.state.layout.name}>
{this.state.layouts.map(item => {
{this.state.layouts.filter(item => item.name.startsWith(this.props.hidePrintlayoutPrefix)).map(item => (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is redundant (state.layouts is already filtered)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, there was still a line of original code... Thanks for correcting it.

@danceb
Copy link
Contributor

danceb commented May 27, 2025

As the print layouts are configured per theme and there some other theme related config parameters like the mentioned defaultPrintLayout and others like printLabelConfig, I would suggest to set the config parameters within the themesConfig.json and not the config.json.
If they should be set to all of the themes (i.e. in combination with using the QGIS Server Plugin "print_templates" [1]) this should be done with default Parameters like defaultHidePrintlayoutPrefix and defaultSortPrintLayouts.

[1] https://qwc-services.github.io/master/topics/Printing/#layout-templates

Deleted the 'defaultPrintlayout' option and cleaned up the code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants