mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2025-12-31 10:32:54 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e5dd02eeca | ||
|
|
e7b4a426a9 | ||
|
|
7dd74af305 | ||
|
|
4409101647 |
11
CHANGELOG.md
11
CHANGELOG.md
@@ -1,3 +1,14 @@
|
||||
# [0.34.0](https://gitlab.com/openstapps/core/compare/v0.33.0...v0.34.0) (2020-04-21)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add [@sortable](https://gitlab.com/sortable) tags to certain translatable properties ([f5e8856](https://gitlab.com/openstapps/core/commit/f5e88569eb75578febbcde67259c0c14563e53fe))
|
||||
* annotate SCThing uid and url as filterable ([70c1a3e](https://gitlab.com/openstapps/core/commit/70c1a3eaa3d1c88f4b86f0df86d0d362ad1f930c))
|
||||
* Update src/things/book.ts - made ISBN optional ([6060113](https://gitlab.com/openstapps/core/commit/6060113df56b871bb5014a8a961974895e52158f))
|
||||
|
||||
|
||||
|
||||
# [0.33.0](https://gitlab.com/openstapps/core/compare/v0.32.0...v0.33.0) (2020-02-11)
|
||||
|
||||
|
||||
|
||||
2
package-lock.json
generated
2
package-lock.json
generated
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@openstapps/core",
|
||||
"version": "0.34.0",
|
||||
"version": "0.35.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@openstapps/core",
|
||||
"version": "0.34.0",
|
||||
"version": "0.35.0",
|
||||
"description": "StAppsCore - Generalized model of data",
|
||||
"keywords": [
|
||||
"Model",
|
||||
|
||||
@@ -218,15 +218,15 @@ export class SCThingTranslator {
|
||||
* All the values will be set to the known translations of the property/key name
|
||||
* @example
|
||||
* const translatedMetaDish = translator.translatedPropertyNames<SCCourseOfStudies>(SCThingType.CourseOfStudies);
|
||||
* @param thing The thing whose property names will be translated
|
||||
* @param type The type whose property names will be translated
|
||||
* @param language The language all property names will be translated to
|
||||
* @returns An object with the properties of the SCThingType where the values are the known property tranlations
|
||||
*/
|
||||
public translatedPropertyNames<T extends SCThing>(thing: T,
|
||||
public translatedPropertyNames<T extends SCThing>(type: SCThingType,
|
||||
language?: keyof SCTranslations<T>): T | undefined {
|
||||
const targetLanguage = (typeof language !== 'undefined') ? language : this.language;
|
||||
|
||||
return this.getAllMetaFieldTranslations(thing.type, targetLanguage) as T;
|
||||
return this.getAllMetaFieldTranslations(type, targetLanguage) as T;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -256,8 +256,8 @@ export class MetaTranslationSpec {
|
||||
|
||||
@test
|
||||
public consistencyWithMetaClass() {
|
||||
const dishMetaTranslationsDE = translator.translatedPropertyNames(dish);
|
||||
const dishMetaTranslationsEN = translator.translatedPropertyNames(dish, 'en');
|
||||
const dishMetaTranslationsDE = translator.translatedPropertyNames(dish.type);
|
||||
const dishMetaTranslationsEN = translator.translatedPropertyNames(dish.type, 'en');
|
||||
expect(dishMetaTranslationsEN).to.not.deep.equal(dishMetaTranslationsDE);
|
||||
expect(dishMetaTranslationsDE).to.deep.equal(SCDishMeta.getInstance().fieldTranslations.de);
|
||||
expect(dishMetaTranslationsEN).to.deep.equal(SCDishMeta.getInstance().fieldTranslations.en);
|
||||
@@ -269,7 +269,7 @@ export class MetaTranslationSpec {
|
||||
const typeNonExistant = eval("(x) => x + 'typeNonExistant';");
|
||||
// this will assign a non existant SCThingType to dishCopy
|
||||
dishCopy.type = typeNonExistant();
|
||||
const dishMetaTranslationsDE = translator.translatedPropertyNames(dishCopy);
|
||||
const dishMetaTranslationsDE = translator.translatedPropertyNames(dishCopy.type);
|
||||
expect(dishMetaTranslationsDE).to.be.undefined;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user