-
-
Notifications
You must be signed in to change notification settings - Fork 121
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
base: master
Are you sure you want to change the base?
Update Print.jsx #429
Conversation
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" } }
plugins/Print.jsx
Outdated
/** Alphabetical order for print layouts: asc or desc */ | ||
sortPrintlayouts: PropTypes.string, | ||
/** The default layout to display first */ | ||
defaultPrintlayout: PropTypes.string |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 => ( |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
As the print layouts are configured per theme and there some other theme related config parameters like the mentioned [1] https://qwc-services.github.io/master/topics/Printing/#layout-templates |
Deleted the 'defaultPrintlayout' option and cleaned up the code.
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:
config.json (example):
{
"name": "Print",
"cfg": #{
…
"hidePrintlayoutPrefix": "_hide",
"sortPrintlayouts": "desc",
"defaultPrintlayout": "A4 - Hochformat"
}
}