@livinglogic/livingapi 1.36.0 → 1.38.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": "1.36.0",
3
+ "version": "1.38.0",
4
4
  "description": "Javascript version of the LivingAPI classes of LivingApps",
5
5
  "repository": {
6
6
  "type": "git",
package/src/livingapi.js CHANGED
@@ -227,6 +227,7 @@ export class Globals extends Base
227
227
  this.platform = null;
228
228
  this.user = null;
229
229
  this.lang = null;
230
+ this.sys_lang = null;
230
231
  this.datasources = null;
231
232
  this.app = null;
232
233
  this.record = null;
@@ -530,8 +531,8 @@ export class Globals extends Base
530
531
  }
531
532
  };
532
533
 
533
- Globals.prototype._ul4onattrs = ["version", "platform", "user", "maxdbactions", "maxtemplateruntime", "lang", "datasources", "hostname", "free", "app", "record", "mode", "view_template_id", "email_template_id", "view_id"];
534
- Globals.prototype._ul4attrs = new Set(["id", "version", "hostname", "platform", "free", "mode", "form", "app", "record", "datasources", "externaldatasources", "groups", "user", "lang", "templates", "pparams", "geo", "dist", "maxdbactions", "maxtemplateruntime", "flashmessages", "scaled_url", "qrcode_url", "current_geo", "log_debug", "log_info", "log_warning", "log_error", "my_apps_url", "my_tasks_url", "catalog_url", "chats_url", "profile_url", "account_url", "logout_url"]);
534
+ Globals.prototype._ul4onattrs = ["version", "platform", "user", "maxdbactions", "maxtemplateruntime", "lang", "sys_lang", "datasources", "hostname", "free", "app", "record", "mode", "view_template_id", "email_template_id", "view_id"];
535
+ Globals.prototype._ul4attrs = new Set(["id", "version", "hostname", "platform", "free", "mode", "form", "app", "record", "datasources", "externaldatasources", "groups", "user", "lang", "sys_lang", "templates", "pparams", "geo", "dist", "maxdbactions", "maxtemplateruntime", "flashmessages", "scaled_url", "qrcode_url", "current_geo", "log_debug", "log_info", "log_warning", "log_error", "my_apps_url", "my_tasks_url", "catalog_url", "chats_url", "profile_url", "account_url", "logout_url"]);
535
536
  ul4.expose(Globals.prototype.log_debug, ["message", "*"]);
536
537
  ul4.expose(Globals.prototype.log_info, ["message", "*"]);
537
538
  ul4.expose(Globals.prototype.log_warning, ["message", "*"]);
@@ -1122,14 +1123,7 @@ export class App extends WithAttachments
1122
1123
 
1123
1124
  get typename_nominative_singular()
1124
1125
  {
1125
- let translation = this.translations.get();
1126
- if (translation !== null && translation.typenames !== null)
1127
- {
1128
- let value = translation.typenames.get("nom_sin");
1129
- if (value !== null && value !== undefined)
1130
- return value;
1131
- }
1132
- return this._typename_nominative_singular;
1126
+ return this.typename("nom_sin");
1133
1127
  }
1134
1128
 
1135
1129
  set typename_nominative_singular(value)
@@ -1139,14 +1133,7 @@ export class App extends WithAttachments
1139
1133
 
1140
1134
  get typename_genitive_singular()
1141
1135
  {
1142
- let translation = this.translations.get();
1143
- if (translation !== null && translation.typenames !== null)
1144
- {
1145
- let value = translation.typenames.get("gen_sin");
1146
- if (value !== null && value !== undefined)
1147
- return value;
1148
- }
1149
- return this._typename_genitive_singular;
1136
+ return this.typename("gen_sin");
1150
1137
  }
1151
1138
 
1152
1139
  set typename_genitive_singular(value)
@@ -1156,14 +1143,7 @@ export class App extends WithAttachments
1156
1143
 
1157
1144
  get typename_dative_singular()
1158
1145
  {
1159
- let translation = this.translations.get();
1160
- if (translation !== null && translation.typenames !== null)
1161
- {
1162
- let value = translation.typenames.get("dat_sin");
1163
- if (value !== null && value !== undefined)
1164
- return value;
1165
- }
1166
- return this._typename_dative_singular;
1146
+ return this.typename("dat_sin");
1167
1147
  }
1168
1148
 
1169
1149
  set typename_dative_singular(value)
@@ -1173,14 +1153,7 @@ export class App extends WithAttachments
1173
1153
 
1174
1154
  get typename_accusative_singular()
1175
1155
  {
1176
- let translation = this.translations.get();
1177
- if (translation !== null && translation.typenames !== null)
1178
- {
1179
- let value = translation.typenames.get("acc_sin");
1180
- if (value !== null && value !== undefined)
1181
- return value;
1182
- }
1183
- return this._typename_accusative_singular;
1156
+ return this.typename("acc_sin");
1184
1157
  }
1185
1158
 
1186
1159
  set typename_accusative_singular(value)
@@ -1190,14 +1163,7 @@ export class App extends WithAttachments
1190
1163
 
1191
1164
  get typename_nominative_plural()
1192
1165
  {
1193
- let translation = this.translations.get();
1194
- if (translation !== null && translation.typenames !== null)
1195
- {
1196
- let value = translation.typenames.get("nom_plu");
1197
- if (value !== null && value !== undefined)
1198
- return value;
1199
- }
1200
- return this._typename_nominative_plural;
1166
+ return this.typename("nom_plu");
1201
1167
  }
1202
1168
 
1203
1169
  set typename_nominative_plural(value)
@@ -1207,14 +1173,7 @@ export class App extends WithAttachments
1207
1173
 
1208
1174
  get typename_genitive_plural()
1209
1175
  {
1210
- let translation = this.translations.get();
1211
- if (translation !== null && translation.typenames !== null)
1212
- {
1213
- let value = translation.typenames.get("gen_plu");
1214
- if (value !== null && value !== undefined)
1215
- return value;
1216
- }
1217
- return this._typename_genitive_plural;
1176
+ return this.typename("gen_plu");
1218
1177
  }
1219
1178
 
1220
1179
  set typename_genitive_plural(value)
@@ -1224,14 +1183,7 @@ export class App extends WithAttachments
1224
1183
 
1225
1184
  get typename_dative_plural()
1226
1185
  {
1227
- let translation = this.translations.get();
1228
- if (translation !== null && translation.typenames !== null)
1229
- {
1230
- let value = translation.typenames.get("dat_plu");
1231
- if (value !== null && value !== undefined)
1232
- return value;
1233
- }
1234
- return this._typename_dative_plural;
1186
+ return this.typename("dat_plu");
1235
1187
  }
1236
1188
 
1237
1189
  set typename_dative_plural(value)
@@ -1241,14 +1193,7 @@ export class App extends WithAttachments
1241
1193
 
1242
1194
  get typename_accusative_plural()
1243
1195
  {
1244
- let translation = this.translations.get();
1245
- if (translation !== null && translation.typenames !== null)
1246
- {
1247
- let value = translation.typenames.get("acc_plu");
1248
- if (value !== null && value !== undefined)
1249
- return value;
1250
- }
1251
- return this._typename_accusative_plural;
1196
+ return this.typename("acc_plu");
1252
1197
  }
1253
1198
 
1254
1199
  set typename_accusative_plural(value)
@@ -1256,15 +1201,43 @@ export class App extends WithAttachments
1256
1201
  this._typename_accusative_plural = value;
1257
1202
  }
1258
1203
 
1259
- get typenames()
1204
+ // Return the type name in the noun form ``form`` (e.g. ``nom_sin`` for
1205
+ // nominative singular).
1206
+ //
1207
+ // The form from the translation for the current language (``globals.lang``)
1208
+ // wins, then the form from the translation for the system language
1209
+ // (``app.lang``), then the (German) form stored in the app itself.
1210
+ // If none of them has the form ``null`` is returned.
1211
+ typename(form)
1260
1212
  {
1261
- let translation = this.translations.get();
1262
- if (translation !== null && translation.typenames !== null && translation.typenames.size !== 0)
1263
- return translation.typenames;
1264
- translation = this.translations.get(this.lang);
1265
- if (translation !== null && translation.typenames !== null && translation.typenames.size !== 0)
1266
- return translation.typenames;
1267
- return null;
1213
+ if (form === null)
1214
+ return null;
1215
+ if (typeof(form) !== "string")
1216
+ throw new ul4.TypeError("form must be None or a string");
1217
+ let typename = this._translation_typename(this.translations.get(), form);
1218
+ if (typename === null)
1219
+ typename = this._translation_typename(this.translations.get(this.lang), form);
1220
+ if (typename === null)
1221
+ typename = this._legacy_typename(form);
1222
+ return typename;
1223
+ }
1224
+
1225
+ // Return the type name in the noun form ``form`` from the translation
1226
+ // ``translation`` (or ``null`` if the translation doesn't have it).
1227
+ _translation_typename(translation, form)
1228
+ {
1229
+ if (translation === null || translation.typenames === null)
1230
+ return null;
1231
+ let value = translation.typenames.get(form);
1232
+ return value !== undefined ? value : null;
1233
+ }
1234
+
1235
+ // Return the type name in the noun form ``form`` from the eight (German)
1236
+ // forms stored in the app itself (or ``null`` if ``form`` isn't one of them).
1237
+ _legacy_typename(form)
1238
+ {
1239
+ let name = App._legacy_typename_attrs.get(form);
1240
+ return name !== undefined ? this[name] : null;
1268
1241
  }
1269
1242
 
1270
1243
  _dumpUL4ONAttr(name)
@@ -1489,14 +1462,25 @@ export class App extends WithAttachments
1489
1462
  };
1490
1463
 
1491
1464
 
1465
+ App._legacy_typename_attrs = new Map([
1466
+ ["nom_sin", "_typename_nominative_singular"],
1467
+ ["gen_sin", "_typename_genitive_singular"],
1468
+ ["dat_sin", "_typename_dative_singular"],
1469
+ ["acc_sin", "_typename_accusative_singular"],
1470
+ ["nom_plu", "_typename_nominative_plural"],
1471
+ ["gen_plu", "_typename_genitive_plural"],
1472
+ ["dat_plu", "_typename_dative_plural"],
1473
+ ["acc_plu", "_typename_accusative_plural"],
1474
+ ]);
1492
1475
  App.prototype._ul4onattrs = ["globals", "internal_id", "_name", "_description", "lang", "appgroup", "_typename_grammatical_gender", "_typename_nominative_singular", "_typename_genitive_singular", "_typename_dative_singular", "_typename_accusative_singular", "_typename_nominative_plural", "_typename_genitive_plural", "_typename_dative_plural", "_typename_accusative_plural",
1493
1476
  "startlink", "image", "createdby", "controls", "records", "record_start", "record_count", "record_total", "installation", "categories", "params", "views", "datamanagement_identifier", "basetable", "primarykey", "insertprocedure", "updateprocedure", "deleteprocedure", "templates", "createdat", "updatedat", "updatedby", "superid", "favorite", "_active_view", "datasource", "main", "ai_generated", "viewtemplates", "filter_default", "sort_default", "filter_owndata", "_permissions", "data_actions", "attachments", "order", "translations"];
1494
- App.prototype._ul4attrs = new Set(["id", "globals", "name", "description", "translations", "lang", "appgroup", "group", "main", "order", "ai_generated", "typename_grammatical_gender", "typename_nominative_singular", "typename_genitive_singular", "typename_dative_singular", "typename_accusative_singular", "typename_nominative_plural", "typename_genitive_plural", "typename_dative_plural", "typename_accusative_plural", "typenames", "startlink", "image", "createdat", "createdby", "updatedat", "updatedby", "controls", "layout_controls", "records", "record_start", "record_count", "record_total", "installation", "categories", "params", "views", "menus", "panels", "datasource", "datamanagement_identifier", "insert", "favorite", "_active_view", "filter_default", "sort_default", "filter_owndata", "permissions", "data_actions", "attachments", "template_url", "new_embedded_url", "new_standalone_url", "home_url", "datamanagement_url", "import_url", "tasks_url", /*"formbuilder_url", "tasks_config_url",*/ "datamanagement_config_url", "permissions_url", "datamanageview_url"]);
1477
+ App.prototype._ul4attrs = new Set(["id", "globals", "name", "description", "translations", "lang", "appgroup", "group", "main", "order", "ai_generated", "typename_grammatical_gender", "typename_nominative_singular", "typename_genitive_singular", "typename_dative_singular", "typename_accusative_singular", "typename_nominative_plural", "typename_genitive_plural", "typename_dative_plural", "typename_accusative_plural", "typename", "startlink", "image", "createdat", "createdby", "updatedat", "updatedby", "controls", "layout_controls", "records", "record_start", "record_count", "record_total", "installation", "categories", "params", "views", "menus", "panels", "datasource", "datamanagement_identifier", "insert", "favorite", "_active_view", "filter_default", "sort_default", "filter_owndata", "permissions", "data_actions", "attachments", "template_url", "new_embedded_url", "new_standalone_url", "home_url", "datamanagement_url", "import_url", "tasks_url", /*"formbuilder_url", "tasks_config_url",*/ "datamanagement_config_url", "permissions_url", "datamanageview_url"]);
1495
1478
  ul4.expose(App.prototype[ul4.symbols.call], ["values", "**"], {"needsobject": true});
1496
1479
  ul4.expose(App.prototype.insert, ["values", "**"], {"needsobject": true});
1497
1480
  ul4.expose(App.prototype.template_url, ["identifier", "p", "record", "p=", null, "params", "**"]);
1498
1481
  ul4.expose(App.prototype.new_embedded_url, ["params", "**"]);
1499
1482
  ul4.expose(App.prototype.new_standalone_url, ["params", "**"]);
1483
+ ul4.expose(App.prototype.typename, ["form", "pk"]);
1500
1484
 
1501
1485
 
1502
1486
  class AppGroupType extends ul4.Type