@livinglogic/livingapi 1.36.0 → 1.37.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.37.0",
4
4
  "description": "Javascript version of the LivingAPI classes of LivingApps",
5
5
  "repository": {
6
6
  "type": "git",
package/src/livingapi.js CHANGED
@@ -1122,14 +1122,7 @@ export class App extends WithAttachments
1122
1122
 
1123
1123
  get typename_nominative_singular()
1124
1124
  {
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;
1125
+ return this.typename("nom_sin");
1133
1126
  }
1134
1127
 
1135
1128
  set typename_nominative_singular(value)
@@ -1139,14 +1132,7 @@ export class App extends WithAttachments
1139
1132
 
1140
1133
  get typename_genitive_singular()
1141
1134
  {
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;
1135
+ return this.typename("gen_sin");
1150
1136
  }
1151
1137
 
1152
1138
  set typename_genitive_singular(value)
@@ -1156,14 +1142,7 @@ export class App extends WithAttachments
1156
1142
 
1157
1143
  get typename_dative_singular()
1158
1144
  {
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;
1145
+ return this.typename("dat_sin");
1167
1146
  }
1168
1147
 
1169
1148
  set typename_dative_singular(value)
@@ -1173,14 +1152,7 @@ export class App extends WithAttachments
1173
1152
 
1174
1153
  get typename_accusative_singular()
1175
1154
  {
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;
1155
+ return this.typename("acc_sin");
1184
1156
  }
1185
1157
 
1186
1158
  set typename_accusative_singular(value)
@@ -1190,14 +1162,7 @@ export class App extends WithAttachments
1190
1162
 
1191
1163
  get typename_nominative_plural()
1192
1164
  {
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;
1165
+ return this.typename("nom_plu");
1201
1166
  }
1202
1167
 
1203
1168
  set typename_nominative_plural(value)
@@ -1207,14 +1172,7 @@ export class App extends WithAttachments
1207
1172
 
1208
1173
  get typename_genitive_plural()
1209
1174
  {
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;
1175
+ return this.typename("gen_plu");
1218
1176
  }
1219
1177
 
1220
1178
  set typename_genitive_plural(value)
@@ -1224,14 +1182,7 @@ export class App extends WithAttachments
1224
1182
 
1225
1183
  get typename_dative_plural()
1226
1184
  {
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;
1185
+ return this.typename("dat_plu");
1235
1186
  }
1236
1187
 
1237
1188
  set typename_dative_plural(value)
@@ -1241,14 +1192,7 @@ export class App extends WithAttachments
1241
1192
 
1242
1193
  get typename_accusative_plural()
1243
1194
  {
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;
1195
+ return this.typename("acc_plu");
1252
1196
  }
1253
1197
 
1254
1198
  set typename_accusative_plural(value)
@@ -1256,15 +1200,43 @@ export class App extends WithAttachments
1256
1200
  this._typename_accusative_plural = value;
1257
1201
  }
1258
1202
 
1259
- get typenames()
1203
+ // Return the type name in the noun form ``form`` (e.g. ``nom_sin`` for
1204
+ // nominative singular).
1205
+ //
1206
+ // The form from the translation for the current language (``globals.lang``)
1207
+ // wins, then the form from the translation for the system language
1208
+ // (``app.lang``), then the (German) form stored in the app itself.
1209
+ // If none of them has the form ``null`` is returned.
1210
+ typename(form)
1260
1211
  {
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;
1212
+ if (form === null)
1213
+ return null;
1214
+ if (typeof(form) !== "string")
1215
+ throw new ul4.TypeError("form must be None or a string");
1216
+ let typename = this._translation_typename(this.translations.get(), form);
1217
+ if (typename === null)
1218
+ typename = this._translation_typename(this.translations.get(this.lang), form);
1219
+ if (typename === null)
1220
+ typename = this._legacy_typename(form);
1221
+ return typename;
1222
+ }
1223
+
1224
+ // Return the type name in the noun form ``form`` from the translation
1225
+ // ``translation`` (or ``null`` if the translation doesn't have it).
1226
+ _translation_typename(translation, form)
1227
+ {
1228
+ if (translation === null || translation.typenames === null)
1229
+ return null;
1230
+ let value = translation.typenames.get(form);
1231
+ return value !== undefined ? value : null;
1232
+ }
1233
+
1234
+ // Return the type name in the noun form ``form`` from the eight (German)
1235
+ // forms stored in the app itself (or ``null`` if ``form`` isn't one of them).
1236
+ _legacy_typename(form)
1237
+ {
1238
+ let name = App._legacy_typename_attrs.get(form);
1239
+ return name !== undefined ? this[name] : null;
1268
1240
  }
1269
1241
 
1270
1242
  _dumpUL4ONAttr(name)
@@ -1489,14 +1461,25 @@ export class App extends WithAttachments
1489
1461
  };
1490
1462
 
1491
1463
 
1464
+ App._legacy_typename_attrs = new Map([
1465
+ ["nom_sin", "_typename_nominative_singular"],
1466
+ ["gen_sin", "_typename_genitive_singular"],
1467
+ ["dat_sin", "_typename_dative_singular"],
1468
+ ["acc_sin", "_typename_accusative_singular"],
1469
+ ["nom_plu", "_typename_nominative_plural"],
1470
+ ["gen_plu", "_typename_genitive_plural"],
1471
+ ["dat_plu", "_typename_dative_plural"],
1472
+ ["acc_plu", "_typename_accusative_plural"],
1473
+ ]);
1492
1474
  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
1475
  "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"]);
1476
+ 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
1477
  ul4.expose(App.prototype[ul4.symbols.call], ["values", "**"], {"needsobject": true});
1496
1478
  ul4.expose(App.prototype.insert, ["values", "**"], {"needsobject": true});
1497
1479
  ul4.expose(App.prototype.template_url, ["identifier", "p", "record", "p=", null, "params", "**"]);
1498
1480
  ul4.expose(App.prototype.new_embedded_url, ["params", "**"]);
1499
1481
  ul4.expose(App.prototype.new_standalone_url, ["params", "**"]);
1482
+ ul4.expose(App.prototype.typename, ["form", "pk"]);
1500
1483
 
1501
1484
 
1502
1485
  class AppGroupType extends ul4.Type