dbm 1.2.1 → 1.2.2

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.
Files changed (53) hide show
  1. package/flow/controllers/select/InArray.js +67 -0
  2. package/flow/controllers/select/index.js +2 -1
  3. package/flow/index.js +13 -3
  4. package/flow/updatefunctions/basic/MappedList.js +49 -0
  5. package/flow/updatefunctions/basic/PropertyOf.js +1 -1
  6. package/flow/updatefunctions/basic/PropertyOfWithDefault.js +28 -0
  7. package/flow/updatefunctions/basic/Translation.js +71 -0
  8. package/flow/updatefunctions/basic/index.js +77 -0
  9. package/flow/updatefunctions/thirdparty/google/maps/PlaceDetails.js +80 -0
  10. package/flow/updatefunctions/thirdparty/google/maps/index.js +1 -0
  11. package/graphapi/webclient/ApiConnection.js +1 -0
  12. package/graphapi/webclient/WebSocketConnection.js +1 -0
  13. package/graphapi/webclient/admin/EditorGroup.js +1 -1
  14. package/graphapi/webclient/admin/ItemEditor.js +39 -0
  15. package/graphapi/webclient/admin/ItemSaveData.js +6 -0
  16. package/graphapi/webclient/admin/SaveFunctions.js +4 -0
  17. package/graphapi/webclient/admin/ValueEditor.js +15 -0
  18. package/graphapi/webclient/decode/DecodeBaseObject.js +4 -0
  19. package/graphapi/webclient/decode/index.js +17 -2
  20. package/graphapi/webclient/index.js +41 -0
  21. package/package.json +1 -1
  22. package/react/admin/EditObject.js +52 -0
  23. package/react/admin/EditObjectById.js +2 -3
  24. package/react/admin/EditPage.js +16 -0
  25. package/react/admin/EditorGroup.js +23 -0
  26. package/react/admin/SaveAllButton.js +34 -0
  27. package/react/admin/editorsgroup/EditField.js +2 -2
  28. package/react/admin/editorsgroup/EditFieldTranslation.js +27 -0
  29. package/react/admin/editorsgroup/EditIdentifer.js +3 -3
  30. package/react/admin/editorsgroup/EditItem.js +1 -1
  31. package/react/admin/editorsgroup/EditRelation.js +2 -2
  32. package/react/admin/editorsgroup/EditVisibility.js +2 -2
  33. package/react/admin/editorsgroup/index.js +2 -1
  34. package/react/admin/index.js +3 -0
  35. package/react/admin/objects/EditObject.js +9 -7
  36. package/react/admin/objects/itemeditors/Name.js +31 -29
  37. package/react/blocks/admin/objects/RunObjectCommands.js +0 -14
  38. package/react/blocks/admin/objects/User.js +29 -1
  39. package/react/blocks/faq/AskAQuestion.js +1 -1
  40. package/react/blocks/index.js +12 -0
  41. package/react/text/TranslatedText.js +25 -0
  42. package/react/text/TranslationGroup.js +24 -0
  43. package/react/text/index.js +8 -2
  44. package/site/SiteDataLoader.js +8 -13
  45. package/site/index.js +2 -0
  46. package/site/translation/TranslationLoader.js +59 -0
  47. package/site/translation/index.js +27 -0
  48. package/utils/CompareFunctions.js +10 -0
  49. package/utils/StringFunctions.js +18 -3
  50. package/utils/index.js +3 -1
  51. package/utils/thirdparty/index.js +1 -0
  52. package/utils/thirdparty/wprrapi/WprrApiParser.js +31 -0
  53. package/utils/thirdparty/wprrapi/index.js +3 -0
@@ -4,15 +4,11 @@ export default class SiteDataLoader extends Dbm.core.BaseObject {
4
4
  _construct() {
5
5
  super._construct();
6
6
 
7
- this.item.setValue("status", 0);
7
+ this.item.setValue("status", Dbm.loading.LoadingStatus.NOT_STARTED);
8
8
  this.item.setValue("url", null);
9
9
  this.item.setValue("currentPage", null);
10
-
11
- let urlUpdate = new Dbm.flow.updatefunctions.basic.RunCommand();
12
- urlUpdate.input.properties.value.connectInput(this.item.properties.url);
13
- urlUpdate.input.command = Dbm.commands.callFunction(this._loadUrl.bind(this), []);
14
10
 
15
- urlUpdate.output.properties.value.startUpdating();
11
+ Dbm.flow.addUpdateCommand(this.item.properties.url, Dbm.commands.callFunction(this._loadUrl.bind(this), []));
16
12
  }
17
13
 
18
14
  _loadUrl() {
@@ -23,19 +19,18 @@ export default class SiteDataLoader extends Dbm.core.BaseObject {
23
19
  let parsedUrl = new URL(url);
24
20
  let pathName = parsedUrl.pathname;
25
21
 
26
- let pageData = Dbm.getInstance().repository.getItem(pathName);
22
+ let pageData = Dbm.getRepositoryItem(pathName);
27
23
  pageData.setValue("url", url);
28
24
 
29
- let graphApi = Dbm.getInstance().repository.getItem("graphApi").controller;
30
- let request = graphApi.requestUrl(pathName);
25
+ let request = Dbm.getGraphApi().requestUrl(pathName);
31
26
 
32
- this.item.setValue("status", 2);
33
- Dbm.flow.addUpdateCommandWhenMatched(request.properties.status, 1, Dbm.commands.callFunction(this._pageDataLoaded.bind(this), [pageData, request]))
27
+ this.item.setValue("status", Dbm.loading.LoadingStatus.LOADING);
28
+ Dbm.flow.addUpdateCommandWhenMatched(request.properties.status, Dbm.loading.LoadingStatus.LOADED, Dbm.commands.callFunction(this._pageDataLoaded.bind(this), [pageData, request]))
34
29
 
35
30
  }
36
31
  else {
37
32
  this.item.currentPage = null;
38
- this.item.setValue("status", 0);
33
+ this.item.setValue("status", Dbm.loading.LoadingStatus.NOT_STARTED);
39
34
  }
40
35
  }
41
36
 
@@ -48,7 +43,7 @@ export default class SiteDataLoader extends Dbm.core.BaseObject {
48
43
 
49
44
  if(this.item.url === aPageData.url) {
50
45
  this.item.currentPage = aPageData;
51
- this.item.setValue("status", 1);
46
+ this.item.setValue("status", Dbm.loading.LoadingStatus.LOADED);
52
47
 
53
48
  }
54
49
 
package/site/index.js CHANGED
@@ -1,5 +1,7 @@
1
1
  import Dbm from "../index.js";
2
2
 
3
+ export * as translation from "./translation/index.js";
4
+
3
5
  export {default as SiteNavigation} from "./SiteNavigation.js";
4
6
  export {default as SiteDataLoader} from "./SiteDataLoader.js";
5
7
  export {default as BrowserUpdater} from "./BrowserUpdater.js";
@@ -0,0 +1,59 @@
1
+ import Dbm from "../../index.js";
2
+
3
+ export default class TranslationLoader extends Dbm.core.BaseObject {
4
+ _construct() {
5
+ super._construct();
6
+
7
+ this.item.setValue("language", null);
8
+ this.item.setValue("baseUrl", "/assets/translations/");
9
+ this.item.setValue("ready", false);
10
+
11
+ Dbm.flow.addUpdateCommand(this.item.properties.language, Dbm.commands.callFunction(this._loadTranslation.bind(this), []));
12
+ }
13
+
14
+ _loadTranslation() {
15
+ console.log("_loadTranslation");
16
+
17
+ let language = this.item.language;
18
+
19
+ if(language) {
20
+ if(language.translations) {
21
+ this._updateTranslationManager();
22
+ }
23
+ else {
24
+ let baseUrl = this.item.baseUrl;
25
+
26
+ let fullUrl = baseUrl + language.code + ".json?version=" + Dbm.getRepositoryItem("site").version;
27
+
28
+ let loader = new Dbm.loading.JsonLoader();
29
+ loader.setUrl(fullUrl);
30
+ Dbm.flow.addUpdateCommandWhenMatched(loader.item.properties.status, Dbm.loading.LoadingStatus.LOADED, Dbm.commands.callFunction(this._translationLoaded.bind(this), [language, loader]));
31
+ this.item.ready = false;
32
+ loader.load();
33
+ }
34
+ }
35
+ else {
36
+ Dbm.getRepositoryItem("site/translations").setValue("data", {});
37
+ this.item.ready = true;
38
+ }
39
+ }
40
+
41
+ _translationLoaded(aLanguage, aLoader) {
42
+ console.log("_translationLoaded");
43
+ console.log(aLanguage, aLoader);
44
+
45
+ let data = aLoader.item.data;
46
+ aLanguage.setValue("translations", data);
47
+
48
+ if(aLanguage === this.item.language) {
49
+ this._updateTranslationManager();
50
+ }
51
+ }
52
+
53
+ _updateTranslationManager() {
54
+
55
+ Dbm.getRepositoryItem("site/translations").setValue("data", this.item.language.translations);
56
+
57
+ this.item.ready = true;
58
+ }
59
+ }
@@ -0,0 +1,27 @@
1
+ import Dbm from "../../index.js";
2
+
3
+ export {default as TranslationLoader} from "./TranslationLoader.js";
4
+
5
+ export const setupTranslationLoader = function(aUrlBase = "/assets/translations/") {
6
+
7
+ Dbm.getRepositoryItem("site/translations").requireProperty("data", {});
8
+
9
+ let controller = new Dbm.site.translation.TranslationLoader();
10
+ controller.item.register("site/translationLoader");
11
+
12
+ controller.item.setValue("baseUrl", aUrlBase);
13
+
14
+ controller.item.properties.language.connectInput(Dbm.getRepositoryItem("site").properties.currentLanguage);
15
+
16
+ return controller;
17
+ }
18
+
19
+ export const getLanguage = function(aLanguageCode) {
20
+ let item = Dbm.getRepositoryItem("languages/" + aLanguageCode);
21
+
22
+ if(!item.code) {
23
+ item.setValue("code", aLanguageCode);
24
+ }
25
+
26
+ return item;
27
+ }
@@ -39,6 +39,14 @@ export const inArray = function(aA, aB) {
39
39
  return false;
40
40
  }
41
41
 
42
+ export const notEmpty = function(aA, aB) {
43
+ if(aA && aA.length > 0) {
44
+ return true
45
+ }
46
+
47
+ return false;
48
+ }
49
+
42
50
  export const fullSetup = function() {
43
51
  Dbm.getInstance().repository.getItem("compareFunctions/objectExists").setValue("compare", objectExists);
44
52
 
@@ -56,4 +64,6 @@ export const fullSetup = function() {
56
64
 
57
65
  Dbm.getInstance().repository.getItem("compareFunctions/arrayContains").setValue("compare", arrayContains);
58
66
  Dbm.getInstance().repository.getItem("compareFunctions/inArray").setValue("compare", inArray);
67
+
68
+ Dbm.getInstance().repository.getItem("compareFunctions/notEmpty").setValue("compare", notEmpty);
59
69
  }
@@ -1,4 +1,4 @@
1
- export let createNiceFileName = function(aFileName) {
1
+ export const createNiceFileName = function(aFileName) {
2
2
  let fileName = aFileName.toLowerCase();
3
3
 
4
4
  fileName = fileName.replace(/[åäã]/gi, 'a');
@@ -11,7 +11,7 @@ export let createNiceFileName = function(aFileName) {
11
11
  return fileName;
12
12
  }
13
13
 
14
- export let createNiceFilePath = function(aFileName) {
14
+ export const createNiceFilePath = function(aFileName) {
15
15
  let fileName = aFileName.toLowerCase();
16
16
 
17
17
  fileName = fileName.replace(/[åäã]/gi, 'a');
@@ -22,4 +22,19 @@ export let createNiceFilePath = function(aFileName) {
22
22
  fileName = fileName.replace(/\-+/gi, '-');
23
23
 
24
24
  return fileName;
25
- }
25
+ }
26
+
27
+ export const convertToCamelCase = function(aText) {
28
+ let currentArray = aText.split(" ");
29
+ let currentArrayLength = currentArray.length;
30
+ let returnText = currentArray[0].toLowerCase();
31
+ //METODO: handle special characters
32
+ for(let i = 1; i < currentArrayLength; i++) { //MENOTE: first iteration is done outside of loop
33
+ let currentString = currentArray[i].toLowerCase();
34
+ if(currentString.length > 0) {
35
+ returnText += currentString[0].toUpperCase() + currentString.substring(1, currentString.length);
36
+ }
37
+ }
38
+
39
+ return returnText;
40
+ };
package/utils/index.js CHANGED
@@ -2,4 +2,6 @@ export * as ArrayFunctions from "./ArrayFunctions.js";
2
2
  export * as NumberFunctions from "./NumberFunctions.js";
3
3
  export * as StringFunctions from "./StringFunctions.js";
4
4
  export * as UrlFunctions from "./UrlFunctions.js";
5
- export * as CompareFunctions from "./CompareFunctions.js";
5
+ export * as CompareFunctions from "./CompareFunctions.js";
6
+
7
+ export * as thirdparty from "./thirdparty/index.js";
@@ -0,0 +1 @@
1
+ export * as wprrapi from "./wprrapi/index.js";
@@ -0,0 +1,31 @@
1
+ import Dbm from "../../../index.js";
2
+
3
+ export default class WprrApiParser extends Dbm.core.BaseObject {
4
+
5
+ constructor() {
6
+ super();
7
+
8
+ this.items = {};
9
+ }
10
+
11
+ setItems(aItems) {
12
+ this.items = aItems;
13
+
14
+ return this;
15
+ }
16
+
17
+ getItem(aId) {
18
+ return this.items[aId];
19
+ }
20
+
21
+ getItems(aIds) {
22
+ let returnArray = [];
23
+ let currentArray = aIds;
24
+ let currentArrayLength = currentArray.length;
25
+ for(let i = 0; i < currentArrayLength; i++) {
26
+ returnArray.push(this.getItem(currentArray[i]));
27
+ }
28
+
29
+ return returnArray;
30
+ }
31
+ }
@@ -0,0 +1,3 @@
1
+ import Dbm from "../../../index.js";
2
+
3
+ export {default as WprrApiParser} from "./WprrApiParser.js";