Skip to content

Commit 00dbe58

Browse files
Add support for formatting .pgerd ERD project file. #8912
1 parent abdcd98 commit 00dbe58

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed
-15.4 KB
Loading

docs/en_US/preferences.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,12 @@ Use the fields on the *Options* panel to manage ERD preferences.
254254
* Use *Cardinality Notation* to change the cardinality notation format
255255
used to present relationship links.
256256

257+
* Use *Format ERD Project File?* if you want to format the .pgerd ERD
258+
project file. It's a JSON file which will be formatted.
259+
260+
* Use *Image Download Resolution* to change the ERD image download
261+
resolution. Higher values will use higher memory and slower rendering.
262+
257263
* When the *SQL With DROP Table* switch is set to *True*, the SQL
258264
generated by the ERD Tool will add DROP table DDL before each CREATE
259265
table DDL.

web/pgadmin/tools/erd/__init__.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,19 @@ def register_preferences(self):
457457
)
458458
)
459459

460+
self.preference.register(
461+
'options',
462+
'format_pgerd',
463+
gettext('Format ERD Project File?'),
464+
'boolean',
465+
False,
466+
category_label=PREF_LABEL_OPTIONS,
467+
help_str=gettext(
468+
'If enabled, the .pgerd project file of the ERD tool will '
469+
'be formatted before saving.'
470+
)
471+
)
472+
460473

461474
blueprint = ERDModule(MODULE_NAME, __name__, static_url_path='/static')
462475

web/pgadmin/tools/erd/static/js/erd_tool/components/ERDTool.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,9 +677,10 @@ export default class ERDTool extends React.Component {
677677

678678
saveFile(fileName) {
679679
this.setLoading(gettext('Saving...'));
680+
const serialFile = this.diagram.serialize(this.props.pgAdmin.Browser.utils.app_version_int);
680681
this.apiObj.post(url_for('file_manager.save_file'), {
681682
'file_name': decodeURI(fileName),
682-
'file_content': JSON.stringify(this.diagram.serialize(this.props.pgAdmin.Browser.utils.app_version_int)),
683+
'file_content': JSON.stringify(serialFile, null, this.state.preferences.format_pgerd ? 4 : null),
683684
}).then(()=>{
684685
this.props.pgAdmin.Browser.notifier.success(gettext('Project saved successfully.'));
685686
this.setState({

0 commit comments

Comments
 (0)