Get selected profile vars despite pinned custom
This commit is contained in:
parent
4d44153316
commit
7bbbffbd3f
1 changed files with 46 additions and 35 deletions
|
|
@ -41,15 +41,11 @@ BR.Profile = L.Evented.extend({
|
|||
update: function (options, cb) {
|
||||
var profileName = options.profile,
|
||||
profileUrl,
|
||||
empty = !this.editor.getValue(),
|
||||
clean = this.editor.isClean(),
|
||||
loading = false;
|
||||
|
||||
if (profileName && BR.conf.profilesUrl) {
|
||||
// only synchronize profile editor/parameters with selection if no manual changes in full editor,
|
||||
// else keep custom profile pinned - to prevent changes in another profile overwriting previous ones
|
||||
if (empty || clean) {
|
||||
this.profileName = profileName;
|
||||
this.selectedProfileName = profileName;
|
||||
|
||||
if (!(profileName in this.cache)) {
|
||||
profileUrl = BR.conf.profilesUrl + profileName + '.brf';
|
||||
loading = true;
|
||||
|
|
@ -65,23 +61,14 @@ BR.Profile = L.Evented.extend({
|
|||
this.cache[profileName] = profileText;
|
||||
|
||||
// don't set when option has changed while loading
|
||||
if (!this.profileName || this.profileName === profileName) {
|
||||
this._setValue(profileText);
|
||||
if (!this.profileName || this.selectedProfileName === profileName) {
|
||||
this._updateProfile(profileName, profileText);
|
||||
}
|
||||
if (cb) cb();
|
||||
}, this)
|
||||
);
|
||||
} else {
|
||||
this._setValue(this.cache[profileName]);
|
||||
}
|
||||
|
||||
if (!this.pinned.hidden) {
|
||||
this.pinned.hidden = true;
|
||||
}
|
||||
} else {
|
||||
if (this.pinned.hidden) {
|
||||
this.pinned.hidden = false;
|
||||
}
|
||||
this._updateProfile(profileName, this.cache[profileName]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -107,7 +94,7 @@ BR.Profile = L.Evented.extend({
|
|||
}
|
||||
}
|
||||
|
||||
const profileText = this._getProfileText();
|
||||
const profileText = this._getSelectedProfileText();
|
||||
if (!profileText) return value;
|
||||
|
||||
const regex = new RegExp(`assign\\s*${name}\\s*=?\\s*([\\w\\.]*)`);
|
||||
|
|
@ -194,6 +181,26 @@ BR.Profile = L.Evented.extend({
|
|||
});
|
||||
},
|
||||
|
||||
_updateProfile: function (profileName, profileText) {
|
||||
const empty = !this.editor.getValue();
|
||||
const clean = this.editor.isClean();
|
||||
|
||||
// only synchronize profile editor/parameters with selection if no manual changes in full editor,
|
||||
// else keep custom profile pinned - to prevent changes in another profile overwriting previous ones
|
||||
if (empty || clean) {
|
||||
this.profileName = profileName;
|
||||
this._setValue(profileText);
|
||||
|
||||
if (!this.pinned.hidden) {
|
||||
this.pinned.hidden = true;
|
||||
}
|
||||
} else {
|
||||
if (this.pinned.hidden) {
|
||||
this.pinned.hidden = false;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_setValue: function (profileText) {
|
||||
profileText = profileText || '';
|
||||
|
||||
|
|
@ -369,4 +376,8 @@ BR.Profile = L.Evented.extend({
|
|||
_getProfileText: function () {
|
||||
return this.editor.getValue();
|
||||
},
|
||||
|
||||
_getSelectedProfileText: function () {
|
||||
return this.cache[this.selectedProfileName] ?? this.editor.getValue();
|
||||
},
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue