profile-pane 1.2.1-5b4e9ddd → 1.2.1-5f322a8d

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 (64) hide show
  1. package/README.md +1 -21
  2. package/lib/0SAVED-CVCard.d.ts +4 -0
  3. package/lib/0SAVED-CVCard.js +48 -45
  4. package/lib/CVCard.d.ts +4 -0
  5. package/lib/CVCard.js +53 -46
  6. package/lib/CVPresenter.d.ts +24 -0
  7. package/lib/CVPresenter.js +87 -81
  8. package/lib/ChatWithMe.d.ts +4 -0
  9. package/lib/ChatWithMe.js +39 -62
  10. package/lib/FriendList.d.ts +5 -0
  11. package/lib/FriendList.js +32 -30
  12. package/lib/ProfileCard.d.ts +3 -0
  13. package/lib/ProfileCard.js +29 -13
  14. package/lib/ProfileView.d.ts +4 -0
  15. package/lib/ProfileView.js +57 -51
  16. package/lib/QRCodeCard.d.ts +4 -0
  17. package/lib/QRCodeCard.js +45 -29
  18. package/lib/SocialCard.d.ts +4 -0
  19. package/lib/SocialCard.js +38 -26
  20. package/lib/SocialPresenter.d.ts +11 -0
  21. package/lib/SocialPresenter.js +74 -69
  22. package/lib/StuffCard.d.ts +5 -0
  23. package/lib/StuffCard.js +37 -28
  24. package/lib/StuffPresenter.d.ts +13 -0
  25. package/lib/StuffPresenter.js +46 -40
  26. package/lib/addMeToYourFriends.d.ts +10 -0
  27. package/lib/addMeToYourFriends.js +83 -104
  28. package/lib/addMeToYourFriendsHelper.d.ts +5 -0
  29. package/lib/addMeToYourFriendsHelper.js +17 -14
  30. package/lib/baseStyles.d.ts +70 -0
  31. package/lib/baseStyles.js +47 -30
  32. package/lib/editProfilePane/editProfile.view.d.ts +12 -0
  33. package/lib/editProfilePane/editProfile.view.js +122 -117
  34. package/lib/editProfilePane/profile.dom.d.ts +3 -0
  35. package/lib/editProfilePane/profile.dom.js +29 -13
  36. package/lib/index.d.ts +11 -0
  37. package/lib/index.js +65 -75
  38. package/lib/presenter.d.ts +13 -0
  39. package/lib/presenter.js +51 -51
  40. package/lib/texts.d.ts +9 -0
  41. package/lib/texts.js +16 -12
  42. package/package.json +20 -9
  43. package/lib/0SAVED-CVCard.js.map +0 -1
  44. package/lib/CVCard.js.map +0 -1
  45. package/lib/CVPresenter.js.map +0 -1
  46. package/lib/ChatWithMe.js.map +0 -1
  47. package/lib/FriendList.js.map +0 -1
  48. package/lib/ProfileCard.js.map +0 -1
  49. package/lib/ProfileView.js.map +0 -1
  50. package/lib/QRCodeCard.js.map +0 -1
  51. package/lib/SocialCard.js.map +0 -1
  52. package/lib/SocialPresenter.js.map +0 -1
  53. package/lib/StuffCard.js.map +0 -1
  54. package/lib/StuffPresenter.js.map +0 -1
  55. package/lib/addMeToYourFriends.js.map +0 -1
  56. package/lib/addMeToYourFriendsHelper.js.map +0 -1
  57. package/lib/baseStyles.js.map +0 -1
  58. package/lib/editProfilePane/editProfile.view.js.map +0 -1
  59. package/lib/editProfilePane/profile.dom.js.map +0 -1
  60. package/lib/editProfilePane/wrapped-profileFormText.js +0 -755
  61. package/lib/editProfilePane/wrapped-profileFormText.js.map +0 -1
  62. package/lib/index.js.map +0 -1
  63. package/lib/presenter.js.map +0 -1
  64. package/lib/texts.js.map +0 -1
package/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # profile-pane
2
2
  SolidOS pane that displays a personal profile page
3
3
 
4
- This is a re-write that is going to replace the current profile pane
5
-
6
4
  ![CI](https://github.com/solid/profile-pane/workflows/CI/badge.svg)
7
5
 
8
6
  ## Contribute
@@ -29,10 +27,6 @@ If this is the case, simply run "npm audit fix" and upgrade the repository. It s
29
27
 
30
28
  Unit tests use `jest` and are placed next to the tested file as `*.spec.ts` files.
31
29
 
32
- #### Integration tests
33
-
34
- Integration tests verify the rendering of the whole pane (with mocked HTTP requests) and are placed under `./src/integration-tests`.
35
-
36
30
  ### Dev Server
37
31
 
38
32
  Start a webpack dev server:
@@ -41,8 +35,7 @@ Start a webpack dev server:
41
35
  npm start
42
36
  ```
43
37
 
44
- Visit `http://localhost:8080/` to render the pane. Adjust `const webIdToShow` in `./dev/index.ts` to show a
45
- different profile.
38
+ Visit `http://localhost:8080/` to render the pane. Adjust `const webIdToShow` in `./dev/index.ts` to show a different profile.
46
39
 
47
40
  ### Build
48
41
 
@@ -52,16 +45,3 @@ npm run build
52
45
 
53
46
  The build is done by `tsc`, webpack is only used as dev server and not for production build.
54
47
 
55
- ### Check before committing
56
-
57
- ```
58
- npm run check
59
- ```
60
-
61
- This does lint, build and test.
62
-
63
- ### Notes
64
-
65
- If suddenly many tests fail, it may be that the installation has ended up with
66
- two different instances of solid-logic. Run `npm list solid-logic` and make sure there is only one.
67
- Otherwise `rm -rf node_modules package-lock.json && npm install` should fix it.
@@ -0,0 +1,4 @@
1
+ import { TemplateResult } from 'lit-html';
2
+ import { ProfilePresentation } from './presenter';
3
+ import { CVPresentation } from './CVPresenter';
4
+ export declare const CVCard: (profileBasics: ProfilePresentation, cvData: CVPresentation) => TemplateResult;
@@ -1,23 +1,37 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
3
6
  exports.CVCard = void 0;
4
- const lit_html_1 = require("lit-html");
5
- const baseStyles_1 = require("./baseStyles");
6
- const style_map_js_1 = require("lit-html/directives/style-map.js");
7
- const baseStyles_2 = require("./baseStyles");
7
+ var _litHtml = require("lit-html");
8
+ var _baseStyles = require("./baseStyles");
9
+ var _styleMap = require("lit-html/directives/style-map.js");
8
10
  const styles = {
9
- image: (0, style_map_js_1.styleMap)((0, baseStyles_1.fullWidth)()),
10
- intro: (0, style_map_js_1.styleMap)(Object.assign(Object.assign({}, (0, baseStyles_1.textGray)()), (0, baseStyles_1.textCenter)())),
11
- card: (0, style_map_js_1.styleMap)((0, baseStyles_2.card)()),
12
- info: (0, style_map_js_1.styleMap)(Object.assign(Object.assign({}, (0, baseStyles_1.paddingSmall)()), (0, baseStyles_1.textLeft)())),
11
+ image: (0, _styleMap.styleMap)((0, _baseStyles.fullWidth)()),
12
+ intro: (0, _styleMap.styleMap)({
13
+ ...(0, _baseStyles.textGray)(),
14
+ ...(0, _baseStyles.textCenter)()
15
+ }),
16
+ card: (0, _styleMap.styleMap)((0, _baseStyles.card)()),
17
+ info: (0, _styleMap.styleMap)({
18
+ ...(0, _baseStyles.paddingSmall)(),
19
+ ...(0, _baseStyles.textLeft)()
20
+ })
13
21
  };
14
22
  const CVCard = (profileBasics, cvData) => {
15
- const { rolesByType, skills, languages } = cvData;
16
- const nameStyle = (0, style_map_js_1.styleMap)(Object.assign(Object.assign({}, (0, baseStyles_1.heading)()), {
17
- // "text-decoration": "underline",
18
- color: profileBasics.highlightColor }));
19
- if (renderRoles(rolesByType['FutureRole']) || renderRoles(rolesByType['CurrentRole']) || renderRoles(rolesByType['PastRole']) || renderSkills(skills) || renderLanguages(languages)) {
20
- return (0, lit_html_1.html) `
23
+ const {
24
+ rolesByType,
25
+ skills,
26
+ languages
27
+ } = cvData;
28
+ const nameStyle = (0, _styleMap.styleMap)({
29
+ ...(0, _baseStyles.heading)(),
30
+ // "text-decoration": "underline",
31
+ color: profileBasics.highlightColor // was "text-decoration-color"
32
+ });
33
+ if (renderRoles(rolesByType['FutureRole']) || renderRoles(rolesByType['CurrentRole']) || renderRoles(rolesByType['PastRole']) || renderSkills(skills) || renderLanguages(languages)) {
34
+ return (0, _litHtml.html)`
21
35
  <div data-testid="curriculum-vitae" style="${styles.card}">
22
36
  <div style=${styles.info}>
23
37
  <h3 style=${nameStyle}>Bio</h3>
@@ -34,54 +48,43 @@ const CVCard = (profileBasics, cvData) => {
34
48
  </div>
35
49
  </div>
36
50
  `;
37
- }
38
- return (0, lit_html_1.html) ``;
51
+ }
52
+ return (0, _litHtml.html)``;
39
53
  };
40
54
  exports.CVCard = CVCard;
41
55
  function renderRole(role) {
42
- return role
43
- ? (0, lit_html_1.html) `<div style="margin-top: 0.3em; margin-bottom: 0.3em;">
56
+ return role ? (0, _litHtml.html)`<div style="margin-top: 0.3em; margin-bottom: 0.3em;">
44
57
  <b>${role.orgName}</b>
45
58
  <span>${strToUpperCase(role.roleText)}</span>
46
59
  <span>${role.dates}</span>
47
- </div> `
48
- : (0, lit_html_1.html) ``;
60
+ </div> ` : (0, _litHtml.html)``;
49
61
  }
50
62
  function renderRoles(roles) {
51
- if (roles[0] > '')
52
- return (0, lit_html_1.html) `${renderRole(roles[0])}${roles.length > 1 ? renderRoles(roles.slice(1)) : (0, lit_html_1.html) ``}`;
63
+ if (roles[0] > '') return (0, _litHtml.html)`${renderRole(roles[0])}${roles.length > 1 ? renderRoles(roles.slice(1)) : (0, _litHtml.html)``}`;
53
64
  }
54
65
  function renderSkill(skill) {
55
- return skill
56
- ? (0, lit_html_1.html) `<div style="margin: 0.5em;">
66
+ return skill ? (0, _litHtml.html)`<div style="margin: 0.5em;">
57
67
  <p style="text-align: center;">${skill}</p>
58
- </div> `
59
- : (0, lit_html_1.html) ``;
68
+ </div> ` : (0, _litHtml.html)``;
60
69
  }
61
70
  function renderSkills(skills) {
62
- if (skills[0] > '')
63
- return (0, lit_html_1.html) `${renderSkill(strToUpperCase(skills[0]))} ${skills.length > 1 ? renderSkills(skills.slice(1)) : (0, lit_html_1.html) ``}`;
71
+ if (skills[0] > '') return (0, _litHtml.html)`${renderSkill(strToUpperCase(skills[0]))} ${skills.length > 1 ? renderSkills(skills.slice(1)) : (0, _litHtml.html)``}`;
64
72
  }
65
73
  function renderLan(language) {
66
- return language
67
- ? (0, lit_html_1.html) `<div style="margin: 0.5em;">
74
+ return language ? (0, _litHtml.html)`<div style="margin: 0.5em;">
68
75
  <p style="text-align: center;">${language}</p>
69
- </div> `
70
- : (0, lit_html_1.html) ``;
76
+ </div> ` : (0, _litHtml.html)``;
71
77
  }
72
78
  function renderLanguages(languages) {
73
- if (languages[0] > '')
74
- return (0, lit_html_1.html) `${renderLan(languages[0])}${languages.length > 1 ? renderLanguages(languages.slice(1)) : (0, lit_html_1.html) ``}`;
79
+ if (languages[0] > '') return (0, _litHtml.html)`${renderLan(languages[0])}${languages.length > 1 ? renderLanguages(languages.slice(1)) : (0, _litHtml.html)``}`;
75
80
  }
76
81
  function strToUpperCase(str) {
77
- if (str && str[0] > '') {
78
- const strCase = str.split(' ');
79
- for (let i = 0; i < strCase.length; i++) {
80
- strCase[i] = strCase[i].charAt(0).toUpperCase() +
81
- strCase[i].substring(1);
82
- }
83
- return strCase.join(' ');
82
+ if (str && str[0] > '') {
83
+ const strCase = str.split(' ');
84
+ for (let i = 0; i < strCase.length; i++) {
85
+ strCase[i] = strCase[i].charAt(0).toUpperCase() + strCase[i].substring(1);
84
86
  }
85
- return '';
86
- }
87
- //# sourceMappingURL=0SAVED-CVCard.js.map
87
+ return strCase.join(' ');
88
+ }
89
+ return '';
90
+ }
@@ -0,0 +1,4 @@
1
+ import { TemplateResult } from 'lit-html';
2
+ import { ProfilePresentation } from './presenter';
3
+ import { CVPresentation } from './CVPresenter';
4
+ export declare const CVCard: (profileBasics: ProfilePresentation, cvData: CVPresentation) => TemplateResult;
package/lib/CVCard.js CHANGED
@@ -1,24 +1,41 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
3
6
  exports.CVCard = void 0;
4
- const lit_html_1 = require("lit-html");
5
- const baseStyles_1 = require("./baseStyles");
6
- const style_map_js_1 = require("lit-html/directives/style-map.js");
7
- const baseStyles_2 = require("./baseStyles");
7
+ var _litHtml = require("lit-html");
8
+ var _baseStyles = require("./baseStyles");
9
+ var _styleMap = require("lit-html/directives/style-map.js");
8
10
  const styles = {
9
- image: (0, style_map_js_1.styleMap)((0, baseStyles_1.fullWidth)()),
10
- intro: (0, style_map_js_1.styleMap)(Object.assign(Object.assign({}, (0, baseStyles_1.textGray)()), (0, baseStyles_1.textCenter)())),
11
- card: (0, style_map_js_1.styleMap)((0, baseStyles_2.card)()),
12
- info: (0, style_map_js_1.styleMap)(Object.assign(Object.assign({}, (0, baseStyles_1.paddingSmall)()), (0, baseStyles_1.textLeft)())),
13
- tools: (0, style_map_js_1.styleMap)(Object.assign(Object.assign({}, (0, baseStyles_1.paddingSmall)()), (0, baseStyles_1.textRight)())),
11
+ image: (0, _styleMap.styleMap)((0, _baseStyles.fullWidth)()),
12
+ intro: (0, _styleMap.styleMap)({
13
+ ...(0, _baseStyles.textGray)(),
14
+ ...(0, _baseStyles.textCenter)()
15
+ }),
16
+ card: (0, _styleMap.styleMap)((0, _baseStyles.card)()),
17
+ info: (0, _styleMap.styleMap)({
18
+ ...(0, _baseStyles.paddingSmall)(),
19
+ ...(0, _baseStyles.textLeft)()
20
+ }),
21
+ tools: (0, _styleMap.styleMap)({
22
+ ...(0, _baseStyles.paddingSmall)(),
23
+ ...(0, _baseStyles.textRight)()
24
+ })
14
25
  };
15
26
  const CVCard = (profileBasics, cvData) => {
16
- const { rolesByType, skills, languages } = cvData;
17
- const nameStyle = (0, style_map_js_1.styleMap)(Object.assign(Object.assign({}, (0, baseStyles_1.heading)()), {
18
- // "text-decoration": "underline",
19
- color: profileBasics.highlightColor }));
20
- if (renderRoles(rolesByType['FutureRole']) || renderRoles(rolesByType['CurrentRole']) || renderRoles(rolesByType['PastRole']) || renderSkills(skills) || renderLanguages(languages)) {
21
- return (0, lit_html_1.html) `
27
+ const {
28
+ rolesByType,
29
+ skills,
30
+ languages
31
+ } = cvData;
32
+ const nameStyle = (0, _styleMap.styleMap)({
33
+ ...(0, _baseStyles.heading)(),
34
+ // "text-decoration": "underline",
35
+ color: profileBasics.highlightColor // was "text-decoration-color"
36
+ });
37
+ if (renderRoles(rolesByType['FutureRole']) || renderRoles(rolesByType['CurrentRole']) || renderRoles(rolesByType['PastRole']) || renderSkills(skills) || renderLanguages(languages)) {
38
+ return (0, _litHtml.html)`
22
39
  <div>
23
40
  <div data-testid="curriculum-vitae" style="${styles.card}">
24
41
  <div style=${styles.info}>
@@ -38,55 +55,45 @@ const CVCard = (profileBasics, cvData) => {
38
55
  </div>
39
56
  </div>
40
57
  `;
41
- }
42
- return (0, lit_html_1.html) ``;
58
+ }
59
+ return (0, _litHtml.html)``;
43
60
  };
44
61
  exports.CVCard = CVCard;
45
62
  function renderRole(role) {
46
- return role
47
- ? (0, lit_html_1.html) `<div style="margin-top: 0.3em; margin-bottom: 0.3em;">
63
+ return role ? (0, _litHtml.html)`<div style="margin-top: 0.3em; margin-bottom: 0.3em;">
48
64
  <b>${role.orgName}</b>
49
65
  <span>${strToUpperCase(role.roleText)}</span>
50
66
  <span>${role.dates}</span>
51
- </div> `
52
- : (0, lit_html_1.html) ``;
67
+ </div> ` : (0, _litHtml.html)``;
53
68
  }
54
69
  function renderRoles(roles) {
55
- if (roles[0] > '')
56
- return (0, lit_html_1.html) `${renderRole(roles[0])}${roles.length > 1 ? renderRoles(roles.slice(1)) : (0, lit_html_1.html) ``}`;
70
+ if (roles[0] > '') return (0, _litHtml.html)`${renderRole(roles[0])}${roles.length > 1 ? renderRoles(roles.slice(1)) : (0, _litHtml.html)``}`;
57
71
  }
58
72
  function renderSkill(skill) {
59
- return skill
60
- ? (0, lit_html_1.html) `<div style="margin: 0.5em;">
73
+ return skill ? (0, _litHtml.html)`<div style="margin: 0.5em;">
61
74
  <p style="text-align: center;">${skill}</p>
62
- </div> `
63
- : (0, lit_html_1.html) ``;
75
+ </div> ` : (0, _litHtml.html)``;
64
76
  }
65
77
  function renderSkills(skills) {
66
- if (skills[0] > '')
67
- return (0, lit_html_1.html) `${renderSkill(strToUpperCase(skills[0]))} ${skills.length > 1 ? renderSkills(skills.slice(1)) : (0, lit_html_1.html) ``}`;
78
+ if (skills[0] > '') return (0, _litHtml.html)`${renderSkill(strToUpperCase(skills[0]))} ${skills.length > 1 ? renderSkills(skills.slice(1)) : (0, _litHtml.html)``}`;
68
79
  }
69
80
  function renderLan(language) {
70
- return language
71
- ? (0, lit_html_1.html) `<div style="margin: 0.5em;">
81
+ return language ? (0, _litHtml.html)`<div style="margin: 0.5em;">
72
82
  <p style="text-align: center;">${language}</p>
73
- </div> `
74
- : (0, lit_html_1.html) ``;
83
+ </div> ` : (0, _litHtml.html)``;
75
84
  }
76
85
  function renderLanguages(languages) {
77
- if (languages[0] > '')
78
- return (0, lit_html_1.html) `${renderLan(languages[0])}${languages.length > 1 ? renderLanguages(languages.slice(1)) : (0, lit_html_1.html) ``}`;
86
+ if (languages[0] > '') return (0, _litHtml.html)`${renderLan(languages[0])}${languages.length > 1 ? renderLanguages(languages.slice(1)) : (0, _litHtml.html)``}`;
79
87
  }
80
88
  function strToUpperCase(str) {
81
- if (str && str[0] > '') {
82
- const strCase = str.split(' ');
83
- for (let i = 0; i < strCase.length; i++) {
84
- strCase[i] = strCase[i].charAt(0).toUpperCase() +
85
- strCase[i].substring(1);
86
- }
87
- return strCase.join(' ');
89
+ if (str && str[0] > '') {
90
+ const strCase = str.split(' ');
91
+ for (let i = 0; i < strCase.length; i++) {
92
+ strCase[i] = strCase[i].charAt(0).toUpperCase() + strCase[i].substring(1);
88
93
  }
89
- return '';
94
+ return strCase.join(' ');
95
+ }
96
+ return '';
90
97
  }
91
- // ends
92
- //# sourceMappingURL=CVCard.js.map
98
+
99
+ // ends
@@ -0,0 +1,24 @@
1
+ import { LiveStore, NamedNode, Literal, Node, Store } from 'rdflib';
2
+ export interface Role {
3
+ startDate?: Literal;
4
+ endDate: Literal;
5
+ dates: string;
6
+ orgName: string;
7
+ roleText: string;
8
+ orgHomePage?: string;
9
+ }
10
+ export interface CVPresentation {
11
+ rolesByType: RolesByType;
12
+ skills: string[];
13
+ languages: string[];
14
+ }
15
+ export interface RolesByType {
16
+ PastRole: Role[];
17
+ CurrentRole: Role[];
18
+ FutureRole: Role[];
19
+ }
20
+ export declare const typesOfRole: string[];
21
+ export declare function skillAsText(store: Store, sk: Node): string;
22
+ export declare function languageAsText(store: Store, lan: Node): string;
23
+ export declare function datesAsText(startDate?: Literal, endDate?: Literal): string;
24
+ export declare function presentCV(subject: NamedNode, store: LiveStore): CVPresentation;
@@ -1,94 +1,100 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.typesOfRole = void 0;
4
- exports.skillAsText = skillAsText;
5
- exports.languageAsText = languageAsText;
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
6
  exports.datesAsText = datesAsText;
7
+ exports.languageAsText = languageAsText;
7
8
  exports.presentCV = presentCV;
8
- const rdflib_1 = require("rdflib");
9
- const solid_ui_1 = require("solid-ui");
10
- const ORG = (0, rdflib_1.Namespace)('http://www.w3.org/ns/org#');
11
- exports.typesOfRole = ['PastRole', 'CurrentRole', 'FutureRole'];
9
+ exports.skillAsText = skillAsText;
10
+ exports.typesOfRole = void 0;
11
+ var _rdflib = require("rdflib");
12
+ var _solidUi = require("solid-ui");
13
+ const ORG = (0, _rdflib.Namespace)('http://www.w3.org/ns/org#');
14
+ const typesOfRole = exports.typesOfRole = ['PastRole', 'CurrentRole', 'FutureRole'];
12
15
  function skillAsText(store, sk) {
13
- if (sk.termType === 'Literal')
14
- return sk.value; // Not normal but allow this
15
- const publicId = store.anyJS(sk, solid_ui_1.ns.solid('publicId'));
16
- if (publicId) {
17
- const name = store.anyJS(publicId, solid_ui_1.ns.schema('name'));
18
- if (name)
19
- return name; // @@ check language and get name in diff language if necessary
20
- }
21
- const manual = store.anyJS(sk, solid_ui_1.ns.vcard('role'));
22
- if (manual && manual[0] > '')
23
- return manual;
24
- return '¿¿¿ skill ???';
16
+ if (sk.termType === 'Literal') return sk.value; // Not normal but allow this
17
+ const publicId = store.anyJS(sk, _solidUi.ns.solid('publicId'));
18
+ if (publicId) {
19
+ const name = store.anyJS(publicId, _solidUi.ns.schema('name'));
20
+ if (name) return name; // @@ check language and get name in diff language if necessary
21
+ }
22
+ const manual = store.anyJS(sk, _solidUi.ns.vcard('role'));
23
+ if (manual && manual[0] > '') return manual;
24
+ return '¿¿¿ skill ???';
25
25
  }
26
26
  function languageAsText(store, lan) {
27
- if (lan.termType === 'Literal')
28
- return lan.value; // Not normal but allow this
29
- const publicId = store.anyJS(lan, solid_ui_1.ns.solid('publicId'));
30
- if (publicId)
31
- return solid_ui_1.utils.label(publicId, true); // @@ check language and get name in diff language if necessary
32
- return '-';
27
+ if (lan.termType === 'Literal') return lan.value; // Not normal but allow this
28
+ const publicId = store.anyJS(lan, _solidUi.ns.solid('publicId'));
29
+ if (publicId) return _solidUi.utils.label(publicId, true); // @@ check language and get name in diff language if necessary
30
+ return '-';
33
31
  }
34
32
  function datesAsText(startDate, endDate) {
35
- return startDate ? '(' + startDate.value.slice(0, 10) + ' to ' +
36
- (endDate ? endDate.value.slice(0, 10) : '') + ')'
37
- : '';
33
+ return startDate ? '(' + startDate.value.slice(0, 10) + ' to ' + (endDate ? endDate.value.slice(0, 10) : '') + ')' : '';
38
34
  }
39
35
  function getRolesByType(store, subject) {
40
- const memberships = store.each(null, ORG('member'), subject, null);
41
- const rolesByType = { PastRole: [], CurrentRole: [], FutureRole: [] };
42
- for (const membership of memberships) {
43
- let orgHomePage, orgNameGiven, publicIdName, roleName, publicId;
44
- // Things should have start dates but we will be very lenient in this view
45
- const startDate = store.any(membership, solid_ui_1.ns.schema('startDate'));
46
- const endDate = store.any(membership, solid_ui_1.ns.schema('endDate'));
47
- const dates = datesAsText(startDate, endDate);
48
- const organization = store.any(membership, ORG('organization'));
49
- if (organization) {
50
- orgNameGiven = store.anyJS(organization, solid_ui_1.ns.schema('name'));
51
- orgHomePage = store.any(organization, solid_ui_1.ns.schema('uri'));
52
- publicId = store.any(organization, solid_ui_1.ns.solid('publicId'));
53
- }
54
- if (publicId) {
55
- publicIdName = store.anyJS(publicId, solid_ui_1.ns.schema('name'));
56
- }
57
- const orgName = publicIdName || orgNameGiven;
58
- const escoRole = store.any(membership, ORG('role'));
59
- if (escoRole) {
60
- roleName = store.anyJS(escoRole, solid_ui_1.ns.schema('name'));
61
- }
62
- const roleText0 = store.anyJS(membership, solid_ui_1.ns.vcard('role'));
63
- const roleText = (roleText0 && roleName) ? roleName + ' - ' + roleText0
64
- : roleText0 || roleName;
65
- const item = {
66
- startDate: startDate, endDate, orgName, roleText, dates, orgHomePage
67
- };
68
- for (const t of exports.typesOfRole) {
69
- if (store.holds(membership, solid_ui_1.ns.rdf('type'), solid_ui_1.ns.solid(t))) {
70
- rolesByType[t].push(item);
71
- }
72
- }
36
+ const memberships = store.each(null, ORG('member'), subject, null);
37
+ const rolesByType = {
38
+ PastRole: [],
39
+ CurrentRole: [],
40
+ FutureRole: []
41
+ };
42
+ for (const membership of memberships) {
43
+ let orgHomePage, orgNameGiven, publicIdName, roleName, publicId;
44
+ // Things should have start dates but we will be very lenient in this view
45
+ const startDate = store.any(membership, _solidUi.ns.schema('startDate'));
46
+ const endDate = store.any(membership, _solidUi.ns.schema('endDate'));
47
+ const dates = datesAsText(startDate, endDate);
48
+ const organization = store.any(membership, ORG('organization'));
49
+ if (organization) {
50
+ orgNameGiven = store.anyJS(organization, _solidUi.ns.schema('name'));
51
+ orgHomePage = store.any(organization, _solidUi.ns.schema('uri'));
52
+ publicId = store.any(organization, _solidUi.ns.solid('publicId'));
73
53
  }
74
- return rolesByType;
75
- }
76
- function presentCV(subject, store) {
77
- const rolesByType = getRolesByType(store, subject);
78
- // Most recent thing most relevant -> sort by end date
79
- for (const t of exports.typesOfRole) {
80
- rolesByType[t].sort(function (x, y) {
81
- if (x.endDate && y.endDate) {
82
- return x.endDate > y.endDate ? -1 : 1;
83
- }
84
- return x.startDate > y.startDate ? -1 : 1;
85
- });
54
+ if (publicId) {
55
+ publicIdName = store.anyJS(publicId, _solidUi.ns.schema('name'));
86
56
  }
87
- const skills = store.each(subject, solid_ui_1.ns.schema('skills')).map(sk => skillAsText(store, sk));
88
- const languagesInStore = store.anyJS(subject, solid_ui_1.ns.schema('knowsLanguage'));
89
- let languages = [];
90
- if (languagesInStore)
91
- languages = languagesInStore.map(lan => languageAsText(store, lan));
92
- return { rolesByType, skills, languages };
57
+ const orgName = publicIdName || orgNameGiven;
58
+ const escoRole = store.any(membership, ORG('role'));
59
+ if (escoRole) {
60
+ roleName = store.anyJS(escoRole, _solidUi.ns.schema('name'));
61
+ }
62
+ const roleText0 = store.anyJS(membership, _solidUi.ns.vcard('role'));
63
+ const roleText = roleText0 && roleName ? roleName + ' - ' + roleText0 : roleText0 || roleName;
64
+ const item = {
65
+ startDate: startDate,
66
+ endDate,
67
+ orgName,
68
+ roleText,
69
+ dates,
70
+ orgHomePage
71
+ };
72
+ for (const t of typesOfRole) {
73
+ if (store.holds(membership, _solidUi.ns.rdf('type'), _solidUi.ns.solid(t))) {
74
+ rolesByType[t].push(item);
75
+ }
76
+ }
77
+ }
78
+ return rolesByType;
93
79
  }
94
- //# sourceMappingURL=CVPresenter.js.map
80
+ function presentCV(subject, store) {
81
+ const rolesByType = getRolesByType(store, subject);
82
+ // Most recent thing most relevant -> sort by end date
83
+ for (const t of typesOfRole) {
84
+ rolesByType[t].sort(function (x, y) {
85
+ if (x.endDate && y.endDate) {
86
+ return x.endDate > y.endDate ? -1 : 1;
87
+ }
88
+ return x.startDate > y.startDate ? -1 : 1;
89
+ });
90
+ }
91
+ const skills = store.each(subject, _solidUi.ns.schema('skills')).map(sk => skillAsText(store, sk));
92
+ const languagesInStore = store.anyJS(subject, _solidUi.ns.schema('knowsLanguage'));
93
+ let languages = [];
94
+ if (languagesInStore) languages = languagesInStore.map(lan => languageAsText(store, lan));
95
+ return {
96
+ rolesByType,
97
+ skills,
98
+ languages
99
+ };
100
+ }
@@ -0,0 +1,4 @@
1
+ import { TemplateResult } from 'lit-html';
2
+ import { DataBrowserContext } from 'pane-registry';
3
+ import { NamedNode } from 'rdflib';
4
+ export declare const ChatWithMe: (subject: NamedNode, context: DataBrowserContext) => TemplateResult;
package/lib/ChatWithMe.js CHANGED
@@ -1,67 +1,44 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
12
- var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
13
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
14
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
15
- return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
16
- function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
17
- function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
18
- function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
19
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
20
- function fulfill(value) { resume("next", value); }
21
- function reject(value) { resume("throw", value); }
22
- function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
23
- };
24
- Object.defineProperty(exports, "__esModule", { value: true });
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
25
6
  exports.ChatWithMe = void 0;
26
- const lit_html_1 = require("lit-html");
27
- const solid_ui_1 = require("solid-ui");
28
- const async_replace_js_1 = require("lit-html/directives/async-replace.js");
29
- const texts_1 = require("./texts");
7
+ var _litHtml = require("lit-html");
8
+ var _solidUi = require("solid-ui");
9
+ var _asyncReplace = require("lit-html/directives/async-replace.js");
10
+ var _texts = require("./texts");
30
11
  const ChatWithMe = (subject, context) => {
31
- const logic = context.session.logic;
32
- const longChatPane = context.session.paneRegistry.byName('long chat');
33
- function chatContainer() {
34
- return __asyncGenerator(this, arguments, function* chatContainer_1() {
35
- const chatContainer = context.dom.createElement('div');
36
- let exists;
37
- try {
38
- yield yield __await(texts_1.loadingMessage), (exists = yield __await(logic.chat.getChat(subject, false)));
39
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
40
- }
41
- catch (e) {
42
- exists = false;
43
- }
44
- if (exists) {
45
- chatContainer.appendChild(longChatPane.render(exists, context, {}));
46
- yield yield __await(chatContainer);
47
- }
48
- else {
49
- const button = solid_ui_1.widgets.button(context.dom, undefined, texts_1.chatWithMeButtonText, () => __awaiter(this, void 0, void 0, function* () {
50
- try {
51
- const chat = yield logic.chat.getChat(subject, true);
52
- chatContainer.innerHTML = '';
53
- chatContainer.appendChild(longChatPane.render(chat, context, {}));
54
- }
55
- catch (e) {
56
- chatContainer.appendChild(solid_ui_1.widgets.errorMessageBlock(context.dom, e.message));
57
- }
58
- }), { needsBorder: true });
59
- chatContainer.appendChild(button);
60
- yield yield __await(chatContainer);
61
- }
62
- });
12
+ const logic = context.session.logic;
13
+ const longChatPane = context.session.paneRegistry.byName('long chat');
14
+ async function* chatContainer() {
15
+ const chatContainer = context.dom.createElement('div');
16
+ let exists;
17
+ try {
18
+ yield _texts.loadingMessage, exists = await logic.chat.getChat(subject, false);
19
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
20
+ } catch (e) {
21
+ exists = false;
22
+ }
23
+ if (exists) {
24
+ chatContainer.appendChild(longChatPane.render(exists, context, {}));
25
+ yield chatContainer;
26
+ } else {
27
+ const button = _solidUi.widgets.button(context.dom, undefined, _texts.chatWithMeButtonText, async () => {
28
+ try {
29
+ const chat = await logic.chat.getChat(subject, true);
30
+ chatContainer.innerHTML = '';
31
+ chatContainer.appendChild(longChatPane.render(chat, context, {}));
32
+ } catch (e) {
33
+ chatContainer.appendChild(_solidUi.widgets.errorMessageBlock(context.dom, e.message));
34
+ }
35
+ }, {
36
+ needsBorder: true
37
+ });
38
+ chatContainer.appendChild(button);
39
+ yield chatContainer;
63
40
  }
64
- return (0, lit_html_1.html) ` ${(0, async_replace_js_1.asyncReplace)(chatContainer())} `;
41
+ }
42
+ return (0, _litHtml.html)` ${(0, _asyncReplace.asyncReplace)(chatContainer())} `;
65
43
  };
66
- exports.ChatWithMe = ChatWithMe;
67
- //# sourceMappingURL=ChatWithMe.js.map
44
+ exports.ChatWithMe = ChatWithMe;