From 07425148ee60ee8bcaf629cb118774060fa0c60b Mon Sep 17 00:00:00 2001 From: Norbert Renner Date: Wed, 5 Feb 2020 19:59:55 +0100 Subject: [PATCH 1/3] Set custom profileName after post Otherwise next cache get after tab switching still uses original profile --- js/control/Profile.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/js/control/Profile.js b/js/control/Profile.js index b955bd3..574e533 100644 --- a/js/control/Profile.js +++ b/js/control/Profile.js @@ -86,6 +86,7 @@ BR.Profile = L.Evented.extend({ callback: L.bind(function(err, profileId, profileText) { $(button).blur(); if (!err) { + this.profileName = profileId; this.cache[profileId] = profileText; if (!this.saveWarningShown) { @@ -127,6 +128,7 @@ BR.Profile = L.Evented.extend({ profileText: profileText, callback: function(err, profileId, profileText) { if (!err) { + that.profileName = profileId; that.cache[profileId] = profileText; } } From c94a530f492fb4985257db817441d8df3924155a Mon Sep 17 00:00:00 2001 From: Norbert Renner Date: Thu, 6 Feb 2020 20:27:57 +0100 Subject: [PATCH 2/3] Fix overwriting editor changes when switching profile tabs --- js/control/Profile.js | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/js/control/Profile.js b/js/control/Profile.js index 574e533..29fbf08 100644 --- a/js/control/Profile.js +++ b/js/control/Profile.js @@ -28,6 +28,8 @@ BR.Profile = L.Evented.extend({ var button = evt.target || evt.srcElement; evt.preventDefault(); + + this.editor.markClean(); this._setValue(''); this.fire('clear'); @@ -98,8 +100,7 @@ BR.Profile = L.Evented.extend({ }); }, - _buildCustomProfile: function() { - var profileText = this.cache[this.profileName]; + _buildCustomProfile: function(profileText) { document.querySelectorAll('#profile_params input, #profile_params select').forEach(function(input) { var name = input.name; var value; @@ -122,7 +123,7 @@ BR.Profile = L.Evented.extend({ }, _save: function(evt) { - var profileText = this._buildCustomProfile(); + var profileText = this._buildCustomProfile(this.editor.getValue()); var that = this; this.fire('update', { profileText: profileText, @@ -135,16 +136,26 @@ BR.Profile = L.Evented.extend({ }); }, - _setValue: function(profileText, profileEditorActivated) { + _setValue: function(profileText) { profileText = profileText || ''; - if (L.DomUtil.get('profile_editor').classList.contains('active')) { - // Set value of the full editor and exit - this.editor.setValue(profileText); + var clean = this.editor.isClean(); + + // Always set value of the full editor, even if not active. + // Full editor is master, the parameter form always gets the text from it (not cache). + this.editor.setValue(profileText); + + // keep dirty state (manually modified; setValue also sets dirty) + if (clean) { this.editor.markClean(); - return; } + if (this._isParamsFormActive()) { + this._buildParamsForm(profileText); + } + }, + + _buildParamsForm: function(profileText) { if (!profileText) return; // Otherwise, create user friendly form @@ -280,11 +291,17 @@ BR.Profile = L.Evented.extend({ }); }, + _isParamsFormActive: function() { + return L.DomUtil.get('profile_params_container').classList.contains('active'); + }, + _activateSecondaryTab: function() { - if (L.DomUtil.get('profile_params_container').classList.contains('active')) { - this._setValue(this.editor.getValue()); + var profileText = this.editor.getValue(); + + if (this._isParamsFormActive()) { + this._buildParamsForm(profileText); } else { - this._setValue(this._buildCustomProfile()); + this._setValue(this._buildCustomProfile(profileText)); } } }); From 86d42de458fc4eda9114df151577b66ff85ab077 Mon Sep 17 00:00:00 2001 From: Norbert Renner Date: Fri, 7 Feb 2020 20:02:32 +0100 Subject: [PATCH 3/3] Show icon indicator when profile is pinned (modified in editor) --- css/style.css | 6 +++++ index.html | 1 + js/control/Profile.js | 52 +++++++++++++++++++++++++++---------------- 3 files changed, 40 insertions(+), 19 deletions(-) diff --git a/css/style.css b/css/style.css index 6611be4..ea11721 100644 --- a/css/style.css +++ b/css/style.css @@ -483,6 +483,12 @@ table.dataTable.display tbody tr:hover.selected { color: #737373; } +#profile-pinned { + margin-left: auto; + margin-right: 4px; + color: #777; +} + .leaflet-sidebar-content { /* for optional-layers-tree */ overflow-x: auto; diff --git a/index.html b/index.html index 5b0033b..c9a72bd 100644 --- a/index.html +++ b/index.html @@ -686,6 +686,7 @@ >Profile +