@livinglogic/livingapi 0.14.2 → 0.15.0

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@livinglogic/livingapi",
3
- "version": "0.14.2",
3
+ "version": "0.15.0",
4
4
  "description": "Javascript version of the LivingAPI classes of LivingApps",
5
5
  "repository": {
6
6
  "type": "git",
@@ -18,7 +18,7 @@
18
18
  "module": "dist/esm-node/livingapi.js",
19
19
  "browser": "dist/umd/livingapi.js",
20
20
  "dependencies": {
21
- "@livinglogic/ul4": "~1.12.1"
21
+ "@livinglogic/ul4": "~1.13.1"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@babel/core": "^7.14.6",
package/rollup.config.js CHANGED
@@ -46,7 +46,7 @@ export default [
46
46
  sourcemap: true,
47
47
  globals: {"@livinglogic/ul4": "ul4"},
48
48
  paths: {
49
- "@livinglogic/ul4": '/static/ul4/1.12.1/dist/esm/ul4.js'
49
+ "@livinglogic/ul4": '/static/ul4/1.13.1/dist/esm/ul4.js'
50
50
  }
51
51
  }
52
52
  ],
package/src/livingapi.js CHANGED
@@ -58,6 +58,57 @@ export function element(name, ...args)
58
58
  }
59
59
 
60
60
 
61
+ function _append_param_to_url(urlparams, name, value)
62
+ {
63
+ if (ul4._islist(value))
64
+ {
65
+ for (let v of value)
66
+ _append_param_to_url(urlparams, name, v);
67
+ }
68
+ else if (typeof(value) === "string")
69
+ urlparams.append(name, value);
70
+ else if (value !== null)
71
+ urlparams.append(name, ul4._str(value));
72
+ }
73
+
74
+ export function url_with_params(url, ...params)
75
+ {
76
+ let urlparams = new URLSearchParams();
77
+
78
+ for (let param of params)
79
+ {
80
+ if (ul4._islist(param) && param.length == 2)
81
+ {
82
+ _append_param_to_url(urlparams, ...param);
83
+ }
84
+ else if (Object.prototype.toString.call(param) === "[object Object]" && !(param instanceof ul4.Proto))
85
+ {
86
+ for (let name in param)
87
+ _append_param_to_url(urlparams, name, param[name]);
88
+ }
89
+ else if (param !== null && typeof(param) === "object" && typeof(param.__proto__) === "object" && param.__proto__ === Map.prototype)
90
+ {
91
+ for (let [name, value] of param)
92
+ _append_param_to_url(urlparams, name, value);
93
+ }
94
+ }
95
+ urlparams = urlparams.toString().replace("+", "%20");
96
+ if (urlparams.length > 0)
97
+ url += "?" + urlparams;
98
+ return url;
99
+ }
100
+
101
+ /*
102
+ let urlparams = new URLSearchParams({"template": identifier});
103
+ for (let [name, value] of params)
104
+ {
105
+ if (Object.prototype.toString.call(v) === "[object Array]")
106
+ {
107
+ for (let [n, v])
108
+ }
109
+ urlparams.append()
110
+ */
111
+
61
112
  export class Base extends ul4.Proto
62
113
  {
63
114
  constructor(id)
@@ -526,6 +577,26 @@ export class App extends Base
526
577
  return record;
527
578
  }
528
579
 
580
+ template_url(identifier, record=null, params)
581
+ {
582
+ let url = "/gateway/apps/" + this.id;
583
+ if (record !== null)
584
+ url += "/" + record.id;
585
+ return url_with_params(url, ['template', identifier], params);
586
+ }
587
+
588
+ new_embedded_url(params)
589
+ {
590
+ let url = "/dateneingabe/" + this.id + "/new";
591
+ return url_with_params(url, params);
592
+ }
593
+
594
+ new_standalone_url(params)
595
+ {
596
+ let url = "/gateway/apps/" + this.id + "/new";
597
+ return url_with_params(url, params);
598
+ }
599
+
529
600
  get layout_controls()
530
601
  {
531
602
  if (this.active_view === null)
@@ -630,9 +701,12 @@ export class App extends Base
630
701
 
631
702
 
632
703
  App.prototype._ul4onattrs = ["globals", "name", "description", "lang", "startlink", "iconlarge", "iconsmall", "createdby", "controls", "records", "recordcount", "installation", "categories", "params", "views", "datamanagement_identifier", "basetable", "primarykey", "insertprocedure", "updateprocedure", "deleteprocedure", "templates", "createdat", "updatedat", "updatedby", "superid", "favorite", "_active_view"];
633
- App.prototype._ul4attrs = new Set(["id", "globals", "name", "description", "lang", "startlink", "iconlarge", "iconsmall", "createdat", "createdby", "updatedat", "updatedby", "controls", "layout_controls", "records", "recordcount", "installation", "categories", "params", "views", "datamanagement_identifier", "insert", "favorite", "_active_view"]);
704
+ App.prototype._ul4attrs = new Set(["id", "globals", "name", "description", "lang", "startlink", "iconlarge", "iconsmall", "createdat", "createdby", "updatedat", "updatedby", "controls", "layout_controls", "records", "recordcount", "installation", "categories", "params", "views", "datamanagement_identifier", "insert", "favorite", "_active_view", "template_url", "new_embedded_url", "new_standalone_url"]);
634
705
  ul4.expose(App.prototype[ul4.symbols.call], ["values", "**"], {"needsobject": true});
635
706
  ul4.expose(App.prototype.insert, ["values", "**"], {"needsobject": true});
707
+ ul4.expose(App.prototype.template_url, ["identifier", "p", "record", "p=", null, "params", "**"]);
708
+ ul4.expose(App.prototype.new_embedded_url, ["params", "**"]);
709
+ ul4.expose(App.prototype.new_standalone_url, ["params", "**"]);
636
710
 
637
711
 
638
712
  class ViewType extends ul4.Type
@@ -903,6 +977,24 @@ export class Record extends Base
903
977
  this.app.globals.handler.save(this);
904
978
  }
905
979
 
980
+ template_url(identifier, params)
981
+ {
982
+ let url = "/gateway/apps/" + this.app.id + "/" + this.id;
983
+ return url_with_params(url, ['template', identifier], params);
984
+ }
985
+
986
+ edit_embedded_url(params)
987
+ {
988
+ let url = "/dateneingabe/" + this.app.id + "/" + this.id + "/edit";
989
+ return url_with_params(url, params);
990
+ }
991
+
992
+ edit_standalone_url(params)
993
+ {
994
+ let url = "/gateway/apps/" + this.app.id + "/" + this.id + "/edit";
995
+ return url_with_params(url, params);
996
+ }
997
+
906
998
  search(search)
907
999
  {
908
1000
  for (let identifier in search)
@@ -967,12 +1059,15 @@ export class Record extends Base
967
1059
  };
968
1060
 
969
1061
  Record.prototype._ul4onattrs = ["app", "createdat", "createdby", "updatedat", "updatedby", "updatecount", "_sparsevalues", "attachments", "children", "errors", "_sparsefielderrors", "_sparsefieldlookupdata"];
970
- Record.prototype._ul4attrs = new Set(["id", "app", "createdat", "createdby", "updatedat", "updatedby", "updatecount", "values", "fields", "attachments", "children", "errors"]);
1062
+ Record.prototype._ul4attrs = new Set(["id", "app", "createdat", "createdby", "updatedat", "updatedby", "updatecount", "values", "fields", "attachments", "children", "errors", "template_url", "edit_embedded_url", "edit_standalone_url"]);
971
1063
  ul4.expose(Record.prototype.is_dirty, []);
972
1064
  ul4.expose(Record.prototype.has_errors, []);
973
1065
  ul4.expose(Record.prototype.delete, []);
974
1066
  ul4.expose(Record.prototype.save, []);
975
1067
  ul4.expose(Record.prototype.update, ["values", "**"], {"needsobject": true});
1068
+ ul4.expose(Record.prototype.template_url, ["identifier", "p", "params", "**"]);
1069
+ ul4.expose(Record.prototype.edit_embedded_url, ["params", "**"]);
1070
+ ul4.expose(Record.prototype.edit_standalone_url, ["params", "**"]);
976
1071
 
977
1072
 
978
1073
  class FieldType extends ul4.Type
@@ -5363,10 +5458,17 @@ export class AppParameter extends Base
5363
5458
  {
5364
5459
  return "<AppParameter id=" + ul4._repr(this.id) + " identifier=" + ul4._repr(this.identifier) + ">";
5365
5460
  }
5461
+
5462
+ get app()
5463
+ {
5464
+ if (this.owner instanceof App)
5465
+ return this.owner;
5466
+ return null;
5467
+ }
5366
5468
  };
5367
5469
 
5368
- AppParameter.prototype._ul4onattrs = ["app", "identifier", "description", "value"];
5369
- AppParameter.prototype._ul4attrs = new Set(["id", "app", "identifier", "description", "value"]);
5470
+ AppParameter.prototype._ul4onattrs = ["owner", "parent", "type", "order", "identifier", "description", "value", "createdat", "createdby", "updatedat", "updatedby"];
5471
+ AppParameter.prototype._ul4attrs = new Set(["id", "owner", "parent", "app", "type", "order", "identifier", "description", "value", "createdat", "createdby", "updatedat", "updatedby"]);
5370
5472
 
5371
5473
 
5372
5474
  class FormType extends ul4.Type
@@ -5443,6 +5545,7 @@ export class Form extends ul4.Proto
5443
5545
  {
5444
5546
  let vars = {
5445
5547
  "record": this.globals.record,
5548
+ "app": this.globals.app,
5446
5549
  "fields": this.globals.record.fields,
5447
5550
  "identifier": identifier
5448
5551
  };