@livinglogic/livingapi 0.14.3 → 0.16.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/CHANGELOG.md +24 -2
- package/dist/esm-node/livingapi.js +1 -1
- package/dist/esm-node/livingapi.js.map +1 -1
- package/dist/esm-static/livingapi.js +1 -1
- package/dist/esm-static/livingapi.js.map +1 -1
- package/dist/umd/livingapi.js +1 -1
- package/dist/umd/livingapi.js.map +1 -1
- package/package.json +1 -1
- package/src/livingapi.js +168 -14
package/package.json
CHANGED
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
|
|
@@ -648,6 +722,11 @@ let viewtype = new ViewType("la", "View", "An input form for a LivingViews appli
|
|
|
648
722
|
|
|
649
723
|
export class View extends Base
|
|
650
724
|
{
|
|
725
|
+
get globals()
|
|
726
|
+
{
|
|
727
|
+
return this.app.globals;
|
|
728
|
+
}
|
|
729
|
+
|
|
651
730
|
[ul4.symbols.type]()
|
|
652
731
|
{
|
|
653
732
|
return viewtype;
|
|
@@ -903,6 +982,24 @@ export class Record extends Base
|
|
|
903
982
|
this.app.globals.handler.save(this);
|
|
904
983
|
}
|
|
905
984
|
|
|
985
|
+
template_url(identifier, params)
|
|
986
|
+
{
|
|
987
|
+
let url = "/gateway/apps/" + this.app.id + "/" + this.id;
|
|
988
|
+
return url_with_params(url, ['template', identifier], params);
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
edit_embedded_url(params)
|
|
992
|
+
{
|
|
993
|
+
let url = "/dateneingabe/" + this.app.id + "/" + this.id + "/edit";
|
|
994
|
+
return url_with_params(url, params);
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
edit_standalone_url(params)
|
|
998
|
+
{
|
|
999
|
+
let url = "/gateway/apps/" + this.app.id + "/" + this.id + "/edit";
|
|
1000
|
+
return url_with_params(url, params);
|
|
1001
|
+
}
|
|
1002
|
+
|
|
906
1003
|
search(search)
|
|
907
1004
|
{
|
|
908
1005
|
for (let identifier in search)
|
|
@@ -962,17 +1059,20 @@ export class Record extends Base
|
|
|
962
1059
|
else if (name.startsWith("v_"))
|
|
963
1060
|
this.fields.get(name.substr(2)).value = value;
|
|
964
1061
|
else
|
|
965
|
-
|
|
1062
|
+
super[ul4.symbols.setattr](name, value);
|
|
966
1063
|
}
|
|
967
1064
|
};
|
|
968
1065
|
|
|
969
1066
|
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"]);
|
|
1067
|
+
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
1068
|
ul4.expose(Record.prototype.is_dirty, []);
|
|
972
1069
|
ul4.expose(Record.prototype.has_errors, []);
|
|
973
1070
|
ul4.expose(Record.prototype.delete, []);
|
|
974
1071
|
ul4.expose(Record.prototype.save, []);
|
|
975
1072
|
ul4.expose(Record.prototype.update, ["values", "**"], {"needsobject": true});
|
|
1073
|
+
ul4.expose(Record.prototype.template_url, ["identifier", "p", "params", "**"]);
|
|
1074
|
+
ul4.expose(Record.prototype.edit_embedded_url, ["params", "**"]);
|
|
1075
|
+
ul4.expose(Record.prototype.edit_standalone_url, ["params", "**"]);
|
|
976
1076
|
|
|
977
1077
|
|
|
978
1078
|
class FieldType extends ul4.Type
|
|
@@ -1083,6 +1183,19 @@ export class Field extends Base
|
|
|
1083
1183
|
return this.errors.length !== 0;
|
|
1084
1184
|
}
|
|
1085
1185
|
|
|
1186
|
+
add_error(error)
|
|
1187
|
+
{
|
|
1188
|
+
this.errors.push(error);
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1191
|
+
set_error(error)
|
|
1192
|
+
{
|
|
1193
|
+
if (error !== null)
|
|
1194
|
+
this.errors = [error];
|
|
1195
|
+
else
|
|
1196
|
+
this.errors = [];
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1086
1199
|
search(searchvalue)
|
|
1087
1200
|
{
|
|
1088
1201
|
return this.control.search(this.value, searchvalue);
|
|
@@ -1284,7 +1397,7 @@ export class Field extends Base
|
|
|
1284
1397
|
else if (name === "writable")
|
|
1285
1398
|
this.writable = ul4._bool(value);
|
|
1286
1399
|
else
|
|
1287
|
-
|
|
1400
|
+
super[ul4.symbols.setattr](name, value);
|
|
1288
1401
|
}
|
|
1289
1402
|
};
|
|
1290
1403
|
|
|
@@ -3039,12 +3152,12 @@ export class AppLookupFieldBase extends ChoiceFieldBase
|
|
|
3039
3152
|
}
|
|
3040
3153
|
}
|
|
3041
3154
|
|
|
3042
|
-
[ul4.symbols.setattr](
|
|
3155
|
+
[ul4.symbols.setattr](name, value)
|
|
3043
3156
|
{
|
|
3044
|
-
if (
|
|
3157
|
+
if (name === "lookupdata")
|
|
3045
3158
|
this.lookupdata = value;
|
|
3046
3159
|
else
|
|
3047
|
-
super[ul4.symbols.setattr](
|
|
3160
|
+
super[ul4.symbols.setattr](name, value);
|
|
3048
3161
|
}
|
|
3049
3162
|
};
|
|
3050
3163
|
AppLookupFieldBase.prototype._ul4attrs = new Set([...Field.prototype._ul4attrs, "lookupdata"]);
|
|
@@ -4833,6 +4946,18 @@ let layoutcontroltype = new LayoutControlType("la", "LayoutControl", "A decorati
|
|
|
4833
4946
|
|
|
4834
4947
|
export class LayoutControl extends Base
|
|
4835
4948
|
{
|
|
4949
|
+
LayoutControl()
|
|
4950
|
+
{
|
|
4951
|
+
this.label = null;
|
|
4952
|
+
this.identifier = null;
|
|
4953
|
+
this.view = null;
|
|
4954
|
+
this.top = null;
|
|
4955
|
+
this.left = null;
|
|
4956
|
+
this.width = null;
|
|
4957
|
+
this.height = null;
|
|
4958
|
+
this._visible = true;
|
|
4959
|
+
}
|
|
4960
|
+
|
|
4836
4961
|
[ul4.symbols.type]()
|
|
4837
4962
|
{
|
|
4838
4963
|
return layoutcontroltype;
|
|
@@ -4845,7 +4970,7 @@ export class LayoutControl extends Base
|
|
|
4845
4970
|
|
|
4846
4971
|
get globals()
|
|
4847
4972
|
{
|
|
4848
|
-
return this.view.
|
|
4973
|
+
return this.view.globals;
|
|
4849
4974
|
}
|
|
4850
4975
|
|
|
4851
4976
|
get _sel_root()
|
|
@@ -4857,10 +4982,30 @@ export class LayoutControl extends Base
|
|
|
4857
4982
|
{
|
|
4858
4983
|
return document.querySelector(this._sel_root);
|
|
4859
4984
|
}
|
|
4985
|
+
|
|
4986
|
+
get visible()
|
|
4987
|
+
{
|
|
4988
|
+
return this._visible ?? true;
|
|
4989
|
+
}
|
|
4990
|
+
|
|
4991
|
+
set visible(value)
|
|
4992
|
+
{
|
|
4993
|
+
if (this.globals._in_form())
|
|
4994
|
+
this._dom_root.hidden = !value;
|
|
4995
|
+
this._visible = value;
|
|
4996
|
+
}
|
|
4997
|
+
|
|
4998
|
+
[ul4.symbols.setattr](name, value)
|
|
4999
|
+
{
|
|
5000
|
+
if (name === "visible")
|
|
5001
|
+
this.visible = ul4._bool(value);
|
|
5002
|
+
else
|
|
5003
|
+
super[ul4.symbols.setattr](name, value);
|
|
5004
|
+
}
|
|
4860
5005
|
};
|
|
4861
5006
|
|
|
4862
5007
|
LayoutControl.prototype._ul4onattrs = ["label", "identifier", "view", "top", "left", "width", "height"];
|
|
4863
|
-
LayoutControl.prototype._ul4attrs = new Set(["id", "label", "identifier", "view", "top", "left", "width", "height"]);
|
|
5008
|
+
LayoutControl.prototype._ul4attrs = new Set(["id", "label", "identifier", "view", "top", "left", "width", "height", "visible"]);
|
|
4864
5009
|
|
|
4865
5010
|
|
|
4866
5011
|
class HTMLLayoutControlType extends LayoutControlType
|
|
@@ -4903,11 +5048,11 @@ export class HTMLLayoutControl extends LayoutControl
|
|
|
4903
5048
|
if (name === "value")
|
|
4904
5049
|
this.value = value;
|
|
4905
5050
|
else
|
|
4906
|
-
|
|
5051
|
+
super[ul4.symbols.setattr](name, value);
|
|
4907
5052
|
}
|
|
4908
5053
|
};
|
|
4909
5054
|
|
|
4910
|
-
HTMLLayoutControl.prototype._ul4onattrs = [...LayoutControl.prototype._ul4onattrs, "_value"];
|
|
5055
|
+
HTMLLayoutControl.prototype._ul4onattrs = [...LayoutControl.prototype._ul4onattrs, "_value", "_visible"];
|
|
4911
5056
|
HTMLLayoutControl.prototype._ul4attrs = new Set([...LayoutControl.prototype._ul4attrs, "value"]);
|
|
4912
5057
|
|
|
4913
5058
|
|
|
@@ -4930,7 +5075,7 @@ export class ImageLayoutControl extends LayoutControl
|
|
|
4930
5075
|
}
|
|
4931
5076
|
};
|
|
4932
5077
|
|
|
4933
|
-
ImageLayoutControl.prototype._ul4onattrs = [...LayoutControl.prototype._ul4onattrs, "original", "scaled"];
|
|
5078
|
+
ImageLayoutControl.prototype._ul4onattrs = [...LayoutControl.prototype._ul4onattrs, "original", "scaled", "_visible"];
|
|
4934
5079
|
ImageLayoutControl.prototype._ul4attrs = new Set([...LayoutControl.prototype._ul4attrs, "original", "scaled"]);
|
|
4935
5080
|
|
|
4936
5081
|
|
|
@@ -4953,6 +5098,8 @@ export class ButtonLayoutControl extends LayoutControl
|
|
|
4953
5098
|
}
|
|
4954
5099
|
};
|
|
4955
5100
|
|
|
5101
|
+
ButtonLayoutControl.prototype._ul4onattrs = [...LayoutControl.prototype._ul4onattrs, "original", "scaled", "_visible"];
|
|
5102
|
+
|
|
4956
5103
|
|
|
4957
5104
|
class ViewControlType extends ul4.Type
|
|
4958
5105
|
{
|
|
@@ -5363,10 +5510,17 @@ export class AppParameter extends Base
|
|
|
5363
5510
|
{
|
|
5364
5511
|
return "<AppParameter id=" + ul4._repr(this.id) + " identifier=" + ul4._repr(this.identifier) + ">";
|
|
5365
5512
|
}
|
|
5513
|
+
|
|
5514
|
+
get app()
|
|
5515
|
+
{
|
|
5516
|
+
if (this.owner instanceof App)
|
|
5517
|
+
return this.owner;
|
|
5518
|
+
return null;
|
|
5519
|
+
}
|
|
5366
5520
|
};
|
|
5367
5521
|
|
|
5368
|
-
AppParameter.prototype._ul4onattrs = ["
|
|
5369
|
-
AppParameter.prototype._ul4attrs = new Set(["id", "app", "identifier", "description", "value"]);
|
|
5522
|
+
AppParameter.prototype._ul4onattrs = ["owner", "parent", "type", "order", "identifier", "description", "value", "createdat", "createdby", "updatedat", "updatedby"];
|
|
5523
|
+
AppParameter.prototype._ul4attrs = new Set(["id", "owner", "parent", "app", "type", "order", "identifier", "description", "value", "createdat", "createdby", "updatedat", "updatedby"]);
|
|
5370
5524
|
|
|
5371
5525
|
|
|
5372
5526
|
class FormType extends ul4.Type
|