backend-plus 2.1.4 → 2.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -436,19 +436,6 @@ myOwn.displayMenu = function displayMenu(layout, menu, addrParams, parents){
436
436
  {underElement:this}
437
437
  );
438
438
  }),
439
- my.light('airplane', function(){
440
- if(my.ldb && my.offline){
441
- if(my.offline.mode && !my.server.connected){
442
- promptPromise("Si desea salir del modo avión puede forzarlo").then(function(texto){
443
- if (texto == 'forzar') {
444
- my.changeOfflineMode();
445
- }
446
- });
447
- }else{
448
- my.changeOfflineMode();
449
- }
450
- }
451
- }, {hidden:true})
452
439
  ]));
453
440
  elements.push(status);
454
441
  }
@@ -501,9 +488,6 @@ myOwn.displayMainMenu = function(addrParams){
501
488
  }
502
489
  }
503
490
  setTimeout(my.doMenuRealigns,10);
504
- setTimeout(function(){
505
- my.offlineModeRefresh();
506
- },10);
507
491
  return menu;
508
492
  };
509
493
 
@@ -547,101 +531,37 @@ myOwn.informDetectedStatus = function informDetectedStatus(statusCode, logged) {
547
531
  }
548
532
  }
549
533
 
550
- myOwn.setOnlineOfflineUrl = function setOnlineOfflineUrl(){
551
- var actualHref=location.href;
552
- var hrefSplit = actualHref.split(my.menuSeparator)
553
- var newHref = my.offline.mode?'ext':my.menuName;
554
- newHref = (hrefSplit.length > 1)?newHref+my.menuSeparator+hrefSplit[1]:newHref;
555
- history.pushState(null, null, newHref);
556
- }
557
-
558
- myOwn.offlineModeRefresh = function offlineModeRefresh(){
559
- var my=this;
560
- /** @type {HTMLImageElement} */
561
- // @ts-ignore
562
- var imgLight = document.getElementById('light-airplane');
563
- if (imgLight != null) {
564
- var skin=((my.config||{}).config||{}).skin;
565
- if(my.offline.mode){
566
- imgLight.src=my.path.img+'airplane-on.png';
567
- }else{
568
- imgLight.src=my.path.img+'airplane-off.png';
569
- }
570
- }
571
- }
572
-
573
- myOwn.changeOfflineMode = function changeOfflineMode(){
574
- my.offline.mode=!my.offline.mode;
575
- my.offlineModeRefresh();
576
- my.setOnlineOfflineUrl();
577
- if(my.offline.mode){
578
- var fkToStoreData = [];
579
- var promiseArray1 = [];
580
- var promiseChain = my.ldb.getAllStructures().then(function(tablesDef){
581
- tablesDef.forEach(function(tableDef){
582
- promiseArray1.push(
583
- my.ldb.isEmpty(tableDef.name).then(function(isEmpty){
584
- if(!isEmpty){
585
- var fkToStoreSearch = tableDef.foreignKeys.filter(function(fk){
586
- return fk.fields.find(function(field){
587
- return !tableDef.primaryKey.includes(field.source)
588
- })
589
- });
590
- fkToStoreData = fkToStoreData.concat(fkToStoreSearch);
591
- }
592
- })
593
- );
594
- });
595
- });
596
- var promiseArray2 = [];
597
- promiseChain = promiseChain.then(function(){
598
- return Promise.all(promiseArray1).then(function(){
599
- return fkToStoreData.forEach(function(fk){
600
- var conn = new my.TableConnector({tableName: fk.references, my:my});
601
- var opts = { registerInLocalDB: false };
602
- conn.getStructure(opts)
603
- promiseArray2.push(
604
- Promise.resolve().then(function(){
605
- return conn.getData().then(function(rows){
606
- return my.ldb.putMany(fk.references, rows)
607
- })
608
- })
609
- );
610
- });
611
- });
612
- });
613
- promiseChain = promiseChain.then(function(){
614
- Promise.all(promiseArray2).then(function(){
615
- location.reload();
616
- })
617
- });
618
- }else{
619
- my.showPage();
620
- location.reload();
621
- }
622
- }
623
-
534
+ var lastUrl = window.location.href;
535
+ //TODO: desacoplar de BP
624
536
  window.addEventListener('popstate', function(){
625
- if(!my.config){
626
- my.autoSetup().then(function(){
627
- my.setOnlineOfflineUrl();
628
- my.showPage();
629
- })
630
- }else{
631
- my.showPage();
537
+ function checkReactUrl(url){
538
+ const regex = /\/react(\/.*)?$/;
539
+ return regex.test(url);
632
540
  }
541
+ const currentUrl = window.location.href;
542
+ if(checkReactUrl(currentUrl)){
543
+ if(!checkReactUrl(lastUrl))
544
+ location.reload();
545
+ }else{
546
+ setTimeout(function(){
547
+ if(!my.config){
548
+ my.autoSetup().then(function(){
549
+ my.showPage();
550
+ })
551
+ }else{
552
+ my.showPage();
553
+ }
554
+ },10)
555
+ }
556
+ lastUrl = currentUrl;
633
557
  });
634
558
 
635
559
  window.addEventListener('load', function(){
636
560
  window.my = myOwn;
637
561
  my.autoSetup().then(function(){
638
- my.setOnlineOfflineUrl();
639
562
  my.showPage();
640
563
  })
641
564
  document.body.appendChild(html.div({id:'cached-images'},[
642
- html.img({src:my.path.img+'airplane-on.png'}),
643
- html.img({src:my.path.img+'airplane-off.png'}),
644
- html.img({src:my.path.img+'airplane.png'}),
645
565
  html.img({src:my.path.img+'server.png'}),
646
566
  html.img({src:my.path.img+'network-signal.png'}),
647
567
  html.img({src:my.path.img+'server-error.png'}),
@@ -1,12 +1,12 @@
1
- create or replace function semver_to_decimal(p_semver text) returns decimal
2
- stable language sql
3
- as
4
- $sql$
5
- select regexp_replace(p_semver, '^(\d+(\.\d*)?)(\D.*|$)$','\1')::decimal;
6
- $sql$;
7
-
8
- select *, semver_to_decimal(semver), 'ERROR semver_to_decimal!!!!!!!!!!!!!'
9
- from (select '12.3.4' semver, 12.3 result
10
- union values ('12', 12),('12.3',12.3),('12.3.3-r12',12.3),('12b',12)
11
- )
1
+ create or replace function semver_to_decimal(p_semver text) returns decimal
2
+ stable language sql
3
+ as
4
+ $sql$
5
+ select regexp_replace(p_semver, '^(\d+(\.\d*)?)(\D.*|$)$','\1')::decimal;
6
+ $sql$;
7
+
8
+ select *, semver_to_decimal(semver), 'ERROR semver_to_decimal!!!!!!!!!!!!!'
9
+ from (select '12.3.4' semver, 12.3 result
10
+ union values ('12', 12),('12.3',12.3),('12.3.3-r12',12.3),('12b',12)
11
+ )
12
12
  where semver_to_decimal(semver) is distinct from result;
@@ -368,6 +368,7 @@ export interface OptsClientPage {
368
368
  extraFiles?:ClientModuleDefinition[]
369
369
  icon?:string
370
370
  icons?:Record<string,string>
371
+ baseUrlForRelativePaths?:boolean
371
372
  }
372
373
 
373
374
  export type DumpOptions={complete?:boolean, skipEnance?:boolean, disableDBFunctions?:boolean}
@@ -2240,11 +2240,13 @@ AppBackend.prototype.mainPage = function mainPage(req, offlineMode, opts){
2240
2240
  if(offlineMode){
2241
2241
  cssList.push('css/offline-mode.css');
2242
2242
  }
2243
+ cssList = cssList.concat((opts.extraFiles ?? []).filter((extraFile)=>extraFile.type == 'css').map((extraFile)=>extraFile.file));
2243
2244
  return html.html(attr,[
2244
2245
  html.head([
2245
2246
  html.title(be.config["client-setup"]?.title),
2246
2247
  html.meta({charset:"utf-8"}),
2247
2248
  viewportAttrs?html.meta(viewportAttrs):null,
2249
+ opts.baseUrlForRelativePaths?html.base({href:`${be.config.server["base-url"]}/`}):null,
2248
2250
  html.link({href: opts.icons.iconShortcut , rel: "shortcut icon", type: "image/png"}),
2249
2251
  html.link({href: opts.icons.icon , rel: "icon", type: "image/png"}),
2250
2252
  html.link({href: opts.icons.iconApple , rel: "apple-touch-icon"}),
@@ -2268,7 +2270,9 @@ AppBackend.prototype.mainPage = function mainPage(req, offlineMode, opts){
2268
2270
  html.div(be.messages.unlogged.loading),
2269
2271
  req.useragent.os=='iOS'&&req.useragent.version.split('.')[0]<9?html.div(`La versión del dispositivo ${req.useragent.version} no es compatible`):null
2270
2272
  ]),
2271
- html.div({id: "total-scripts"}, be.clientModules(req,opts).scripts.map(function(scriptDef){
2273
+ html.div({id: "total-scripts"}, be.clientModules(req,opts).scripts.concat(
2274
+ (opts?.extraFiles ?? []).filter((extraFile)=>be.esJavascript(extraFile.type)).map((extraFile)=>({...extraFile,type:null}))
2275
+ ).map(function(scriptDef){
2272
2276
  return html.script(scriptDef);
2273
2277
  }).concat([html.script({src:'client/menu.js'})]))
2274
2278
  ]),