[desktop] fix bug 59925

This commit is contained in:
Maxim Kadushkin 2022-12-11 12:12:52 +03:00
parent a350d98f8f
commit 2c15f82cb9
3 changed files with 56 additions and 55 deletions

View file

@ -238,40 +238,42 @@ define([
} }
const _checkHelpAvailable = function () { const _checkHelpAvailable = function () {
const curr_lang = Common.Locale.getCurrentLanguage(); const me = this;
let url = 'resources/help/' + curr_lang; const build_url = function (arg1, arg2, arg3) {
fetch(url + '/Contents.json').then(function (response) { const re_ls = /\/$/;
return (re_ls.test(arg1) ? arg1 : arg1 + '/') + arg2 + arg3;
}
fetch(build_url('resources/help/', Common.Locale.getDefaultLanguage(), '/Contents.json'))
.then(function (response) {
if ( response.ok ) { if ( response.ok ) {
/* local help avail */ /* local help avail */
helpUrl = url; fetch(build_url('resources/help/', Common.Locale.getCurrentLanguage(), '/Contents.json'))
} else .then(function (response){
if ( curr_lang != Common.Locale.getDefaultLanguage() ) { if ( response.ok )
url = 'resources/help/' + Common.Locale.getDefaultLanguage(); helpUrl = build_url('resources/help/', Common.Locale.getCurrentLanguage(), '');
fetch(url + '/Contents.json').then(function (response){ })
if ( response.ok ) { .catch(function (e) {
/* local help avail. def lang */ helpUrl = build_url('resources/help/', Common.Locale.getDefaultLanguage(), '');
helpUrl = url; })
} else }
if ( this.helpUrl() ) { }).catch(function (e) {
url = this.helpUrl() + curr_lang; if ( me.helpUrl() ) {
fetch(url + '/Contents.json').then(function (response){ fetch(build_url(me.helpUrl(), Common.Locale.getDefaultLanguage(), '/Contents.json'))
.then(function (response) {
if ( response.ok ) { if ( response.ok ) {
/* remote help avail */ /* remote help avail */
helpUrl = url; fetch(build_url(me.helpUrl(), Common.Locale.getCurrentLanguage(), '/Contents.json'))
} else { .then(function (response) {
url = this.helpUrl() + Common.getDefaultLanguage();
fetch(url + '/Contents.json').then(function (response){
if ( response.ok ) { if ( response.ok ) {
/* remote help avail. def lang */ helpUrl = build_url(me.helpUrl(), Common.Locale.getCurrentLanguage(), '');
helpUrl = url;
} else {
/* no help avail. open help center */
} }
})
.catch(function (e) {
helpUrl = build_url(me.helpUrl(), Common.Locale.getDefaultLanguage(), '');
}); });
} }
}); })
}
});
} }
}); });
} }
@ -281,6 +283,7 @@ define([
_.extend(config, opts); _.extend(config, opts);
if ( config.isDesktopApp ) { if ( config.isDesktopApp ) {
const me = this;
let is_win_xp = nativevars && nativevars.os === 'winxp'; let is_win_xp = nativevars && nativevars.os === 'winxp';
Common.UI.Themes.setAvailable(!is_win_xp); Common.UI.Themes.setAvailable(!is_win_xp);
@ -322,7 +325,7 @@ define([
}).show(); }).show();
} }
_checkHelpAvailable(); _checkHelpAvailable.call(me);
} }
}); });

View file

@ -2027,22 +2027,10 @@ SSE.Views.FileMenuPanels.RecentFiles = Common.UI.BaseView.extend({
me.urlPref = 'resources/help/{{DEFAULT_LANG}}/'; me.urlPref = 'resources/help/{{DEFAULT_LANG}}/';
store.url = 'resources/help/{{DEFAULT_LANG}}/Contents.json'; store.url = 'resources/help/{{DEFAULT_LANG}}/Contents.json';
store.fetch(config); store.fetch(config);
} else {
if ( Common.Controllers.Desktop.isActive() ) {
if ( store.contentLang === '{{DEFAULT_LANG}}' || !Common.Controllers.Desktop.helpUrl() ) {
me.noHelpContents = true;
me.iFrame.src = '../../common/main/resources/help/download.html';
} else {
store.contentLang = store.contentLang === lang ? '{{DEFAULT_LANG}}' : lang;
me.urlPref = Common.Controllers.Desktop.helpUrl() + '/' + store.contentLang + '/';
store.url = me.urlPref + 'Contents.json';
store.fetch(config);
}
} else { } else {
me.urlPref = 'resources/help/{{DEFAULT_LANG}}/'; me.urlPref = 'resources/help/{{DEFAULT_LANG}}/';
store.reset(me.en_data); store.reset(me.en_data);
} }
}
}, },
success: function () { success: function () {
var rec = me.openUrl ? store.find(function(record){ var rec = me.openUrl ? store.find(function(record){
@ -2055,10 +2043,22 @@ SSE.Views.FileMenuPanels.RecentFiles = Common.UI.BaseView.extend({
me.onSelectItem(me.openUrl ? me.openUrl : rec.get('src')); me.onSelectItem(me.openUrl ? me.openUrl : rec.get('src'));
} }
}; };
if ( Common.Controllers.Desktop.isActive() ) {
if ( !Common.Controllers.Desktop.isHelpAvailable() ) {
me.noHelpContents = true;
me.iFrame.src = '../../common/main/resources/help/download.html';
} else {
me.urlPref = Common.Controllers.Desktop.helpUrl() + '/';
store.url = me.urlPref + 'Contents.json';
store.fetch(config);
}
} else {
store.url = 'resources/help/' + lang + '/Contents.json'; store.url = 'resources/help/' + lang + '/Contents.json';
store.fetch(config); store.fetch(config);
this.urlPref = 'resources/help/' + lang + '/'; this.urlPref = 'resources/help/' + lang + '/';
} }
}
}, },
show: function (url) { show: function (url) {

View file

@ -472,6 +472,7 @@ define([
window.open(_url_obj.toString(), '_blank'); window.open(_url_obj.toString(), '_blank');
} }
me.helpUrl = null;
return; return;
} }
} }
@ -489,10 +490,7 @@ define([
me.helpUrl = url; me.helpUrl = url;
me.showHelp(); me.showHelp();
} else { } else {
// me.helpUrl = null; me.helpUrl = null;
if ( Common.Controllers.Desktop.isActive() ) {
url = 'resources/help/' + lang + name;
}
} }
}); });
} }