@livinglogic/livingapi 0.15.0 → 1.0.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.15.0",
3
+ "version": "1.0.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.13.1"
21
+ "@livinglogic/ul4": "~1.15.1"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@babel/core": "^7.14.6",
package/src/livingapi.js CHANGED
@@ -722,6 +722,11 @@ let viewtype = new ViewType("la", "View", "An input form for a LivingViews appli
722
722
 
723
723
  export class View extends Base
724
724
  {
725
+ get globals()
726
+ {
727
+ return this.app.globals;
728
+ }
729
+
725
730
  [ul4.symbols.type]()
726
731
  {
727
732
  return viewtype;
@@ -1054,7 +1059,7 @@ export class Record extends Base
1054
1059
  else if (name.startsWith("v_"))
1055
1060
  this.fields.get(name.substr(2)).value = value;
1056
1061
  else
1057
- return super[ul4.symbols.setattr](name, value);
1062
+ super[ul4.symbols.setattr](name, value);
1058
1063
  }
1059
1064
  };
1060
1065
 
@@ -1178,6 +1183,19 @@ export class Field extends Base
1178
1183
  return this.errors.length !== 0;
1179
1184
  }
1180
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
+
1181
1199
  search(searchvalue)
1182
1200
  {
1183
1201
  return this.control.search(this.value, searchvalue);
@@ -1379,7 +1397,7 @@ export class Field extends Base
1379
1397
  else if (name === "writable")
1380
1398
  this.writable = ul4._bool(value);
1381
1399
  else
1382
- return super[ul4.symbols.getattr](name);
1400
+ super[ul4.symbols.setattr](name, value);
1383
1401
  }
1384
1402
  };
1385
1403
 
@@ -3134,12 +3152,12 @@ export class AppLookupFieldBase extends ChoiceFieldBase
3134
3152
  }
3135
3153
  }
3136
3154
 
3137
- [ul4.symbols.setattr](key, value)
3155
+ [ul4.symbols.setattr](name, value)
3138
3156
  {
3139
- if (key === "lookupdata")
3157
+ if (name === "lookupdata")
3140
3158
  this.lookupdata = value;
3141
3159
  else
3142
- super[ul4.symbols.setattr](key, value);
3160
+ super[ul4.symbols.setattr](name, value);
3143
3161
  }
3144
3162
  };
3145
3163
  AppLookupFieldBase.prototype._ul4attrs = new Set([...Field.prototype._ul4attrs, "lookupdata"]);
@@ -4928,6 +4946,18 @@ let layoutcontroltype = new LayoutControlType("la", "LayoutControl", "A decorati
4928
4946
 
4929
4947
  export class LayoutControl extends Base
4930
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
+
4931
4961
  [ul4.symbols.type]()
4932
4962
  {
4933
4963
  return layoutcontroltype;
@@ -4940,7 +4970,7 @@ export class LayoutControl extends Base
4940
4970
 
4941
4971
  get globals()
4942
4972
  {
4943
- return this.view.app.globals;
4973
+ return this.view.globals;
4944
4974
  }
4945
4975
 
4946
4976
  get _sel_root()
@@ -4952,10 +4982,30 @@ export class LayoutControl extends Base
4952
4982
  {
4953
4983
  return document.querySelector(this._sel_root);
4954
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
+ }
4955
5005
  };
4956
5006
 
4957
5007
  LayoutControl.prototype._ul4onattrs = ["label", "identifier", "view", "top", "left", "width", "height"];
4958
- 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"]);
4959
5009
 
4960
5010
 
4961
5011
  class HTMLLayoutControlType extends LayoutControlType
@@ -4998,11 +5048,11 @@ export class HTMLLayoutControl extends LayoutControl
4998
5048
  if (name === "value")
4999
5049
  this.value = value;
5000
5050
  else
5001
- return super[ul4.symbols.getattr](name);
5051
+ super[ul4.symbols.setattr](name, value);
5002
5052
  }
5003
5053
  };
5004
5054
 
5005
- HTMLLayoutControl.prototype._ul4onattrs = [...LayoutControl.prototype._ul4onattrs, "_value"];
5055
+ HTMLLayoutControl.prototype._ul4onattrs = [...LayoutControl.prototype._ul4onattrs, "_value", "_visible"];
5006
5056
  HTMLLayoutControl.prototype._ul4attrs = new Set([...LayoutControl.prototype._ul4attrs, "value"]);
5007
5057
 
5008
5058
 
@@ -5023,9 +5073,41 @@ export class ImageLayoutControl extends LayoutControl
5023
5073
  {
5024
5074
  return imagelayoutcontroltype;
5025
5075
  }
5076
+
5077
+ get original()
5078
+ {
5079
+ return this._original;
5080
+ }
5081
+
5082
+ set original(original)
5083
+ {
5084
+ this._original = original;
5085
+ if (this.globals._in_form())
5086
+ this._set_dom_value(this._original);
5087
+ }
5088
+
5089
+ _set_dom_value(value)
5090
+ {
5091
+ let img = this._dom_root.querySelector("img");
5092
+ if (img !== null)
5093
+ {
5094
+ let url = (value === null) ?
5095
+ "data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" :
5096
+ this.globals.scaled_url(value, this.width, this.height);
5097
+ img.setAttribute("src", url);
5098
+ }
5099
+ }
5100
+
5101
+ [ul4.symbols.setattr](name, value)
5102
+ {
5103
+ if (name === "original")
5104
+ this.original = value;
5105
+ else
5106
+ super[ul4.symbols.setattr](name, value);
5107
+ }
5026
5108
  };
5027
5109
 
5028
- ImageLayoutControl.prototype._ul4onattrs = [...LayoutControl.prototype._ul4onattrs, "original", "scaled"];
5110
+ ImageLayoutControl.prototype._ul4onattrs = [...LayoutControl.prototype._ul4onattrs, "_original", "scaled", "_visible"];
5029
5111
  ImageLayoutControl.prototype._ul4attrs = new Set([...LayoutControl.prototype._ul4attrs, "original", "scaled"]);
5030
5112
 
5031
5113
 
@@ -5048,6 +5130,8 @@ export class ButtonLayoutControl extends LayoutControl
5048
5130
  }
5049
5131
  };
5050
5132
 
5133
+ ButtonLayoutControl.prototype._ul4onattrs = [...LayoutControl.prototype._ul4onattrs, "original", "scaled", "_visible"];
5134
+
5051
5135
 
5052
5136
  class ViewControlType extends ul4.Type
5053
5137
  {