@fluid-topics/ft-reader-feedback 1.2.49 → 1.2.51

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.
@@ -1,11 +1,12 @@
1
1
  import { PropertyValues } from "lit";
2
- import { ElementDefinitionsMap } from "@fluid-topics/ft-wc-utils";
2
+ import { Debouncer, ElementDefinitionsMap } from "@fluid-topics/ft-wc-utils";
3
3
  import { FtReaderFeedbackProperties } from "./ft-reader-feedback.properties";
4
4
  import { FtReaderComponent } from "@fluid-topics/ft-reader-context/build/registration";
5
5
  import { FeedbackI18nProperties, FtReaderFeedback } from "./ft-reader-feedback";
6
6
  import { FtMap, FtPublicationRatingSummary, FtReaderFeedbackConfiguration, FtSession } from "@fluid-topics/public-api";
7
7
  import { FtIconVariants } from "@fluid-topics/ft-icon";
8
8
  import { FeedbackMailLinkBuilder } from "./utils/mail";
9
+ import { SendFeedbackEvent } from "./utils/events";
9
10
  declare const FtReaderMapFeedback_base: typeof FtReaderComponent & import("@fluid-topics/ft-wc-utils").Constructor<import("@fluid-topics/ft-i18n").FtLitElementWithI18nInterface>;
10
11
  export declare class FtReaderMapFeedback extends FtReaderMapFeedback_base implements FtReaderFeedbackProperties {
11
12
  static elementDefinitions: ElementDefinitionsMap;
@@ -29,17 +30,15 @@ export declare class FtReaderMapFeedback extends FtReaderMapFeedback_base implem
29
30
  i18nProperties: FeedbackI18nProperties;
30
31
  constructor();
31
32
  protected render(): import("lit-html").TemplateResult<1>;
32
- protected update(props: PropertyValues): void;
33
+ protected willUpdate(props: PropertyValues): void;
33
34
  connectedCallback(): void;
34
35
  onStoreAvailable(name?: string): void;
35
- private updateDebouncer;
36
- private updateData;
37
- private fetchRatingSummary;
38
- private sendRatingDebouncer;
39
- private rate;
40
- private sendRating;
41
- private sendFeedback;
42
- private onMailerFeedbackSent;
43
- private openMoreOptions;
36
+ protected fetchRatingSummary(): Promise<void>;
37
+ protected sendRatingDebouncer: Debouncer;
38
+ protected rate(ratingEvent: CustomEvent<number | undefined>): void;
39
+ protected sendRating(value: number | undefined): Promise<void>;
40
+ protected sendFeedback(ratingEvent: SendFeedbackEvent): Promise<void>;
41
+ protected onMailerFeedbackSent(): void;
42
+ protected openMoreOptions(): void;
44
43
  }
45
44
  export {};
@@ -5,7 +5,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
7
  import { html } from "lit";
8
- import { property, query, state } from "lit/decorators.js";
8
+ import { property, query } from "lit/decorators.js";
9
9
  import { Debouncer, FtNotificationEvent, redux, reduxEventListener } from "@fluid-topics/ft-wc-utils";
10
10
  import { FtReaderComponent } from "@fluid-topics/ft-reader-context/build/registration";
11
11
  import { FtReaderFeedback } from "./ft-reader-feedback";
@@ -38,67 +38,57 @@ class FtReaderMapFeedback extends withI18n(FtReaderComponent) {
38
38
  dichotomousRatingSectionTitle: feedback.properties.mapDichotomousRatingSectionTitle(),
39
39
  feedbackSectionTitle: feedback.properties.mapFeedbackSectionTitle(),
40
40
  };
41
- this.updateDebouncer = new Debouncer(100);
42
41
  this.sendRatingDebouncer = new Debouncer(500);
43
42
  this.addStore(ftAppInfoStore);
44
43
  }
45
44
  render() {
46
45
  return html `
47
46
  <ft-reader-feedback
48
- ratingAllowed
49
- .i18nProperties=${this.i18nProperties}
50
- .editorMode=${this.editorMode}
51
- ?hideTitle=${this.hideTitle}
52
- ?withMoreOptionsButton=${this.withMoreOptionsButton}
53
- .ratingSummary=${this.ratingSummary}
54
- .session=${this.session}
55
- .iconVariant=${this.iconVariant}
56
- .emptyStarIcon=${this.emptyStarIcon}
57
- .filledStarIcon=${this.filledStarIcon}
58
- .emptyLikeIcon=${this.emptyLikeIcon}
59
- .filledLikeIcon=${this.filledLikeIcon}
60
- .emptyDislikeIcon=${this.emptyDislikeIcon}
61
- .filledDislikeIcon=${this.filledDislikeIcon}
62
- .feedbackMailLinkBuilder=${(feedbackMessage) => this.feedbackLinkBuilder.build(feedbackMessage)}
63
- @rate=${this.rate}
64
- @send-feedback=${this.sendFeedback}
65
- @mailer-feedback=${this.onMailerFeedbackSent}
66
- @open-more-options=${this.openMoreOptions}
47
+ ratingAllowed
48
+ .i18nProperties=${this.i18nProperties}
49
+ .editorMode=${this.editorMode}
50
+ ?hideTitle=${this.hideTitle}
51
+ ?withMoreOptionsButton=${this.withMoreOptionsButton}
52
+ .ratingSummary=${this.ratingSummary}
53
+ .session=${this.session}
54
+ .iconVariant=${this.iconVariant}
55
+ .emptyStarIcon=${this.emptyStarIcon}
56
+ .filledStarIcon=${this.filledStarIcon}
57
+ .emptyLikeIcon=${this.emptyLikeIcon}
58
+ .filledLikeIcon=${this.filledLikeIcon}
59
+ .emptyDislikeIcon=${this.emptyDislikeIcon}
60
+ .filledDislikeIcon=${this.filledDislikeIcon}
61
+ .feedbackMailLinkBuilder=${(feedbackMessage) => this.feedbackLinkBuilder.build(feedbackMessage)}
62
+ @rate=${this.rate}
63
+ @send-feedback=${this.sendFeedback}
64
+ @mailer-feedback=${this.onMailerFeedbackSent}
65
+ @open-more-options=${this.openMoreOptions}
67
66
  ></ft-reader-feedback>
68
67
  `;
69
68
  }
70
- update(props) {
71
- var _a, _b, _c, _d;
72
- super.update(props);
69
+ willUpdate(props) {
70
+ var _a, _b, _c, _d, _e;
71
+ super.willUpdate(props);
73
72
  if (props.has("map") && this.map) {
74
- this.updateData();
73
+ (_a = this.stateManager) === null || _a === void 0 ? void 0 : _a.fetchMapRating();
75
74
  }
76
75
  if (props.has("editorMode") && this.editorMode) {
77
76
  this.addI18nContext(designer, defaultDesignerMessages);
78
77
  }
79
78
  if (["map", "configuration", "user", "mailSubject"].some(p => props.has(p)) && this.map && this.configuration) {
80
- this.feedbackLinkBuilder.update(this.mailSubject, (_b = (_a = this.service) === null || _a === void 0 ? void 0 : _a.getLink()) !== null && _b !== void 0 ? _b : "", this.map.metadata, this.configuration, ((_d = (_c = this.session) === null || _c === void 0 ? void 0 : _c.profile) === null || _d === void 0 ? void 0 : _d.userId) != null);
79
+ this.feedbackLinkBuilder.update(this.mailSubject, (_c = (_b = this.service) === null || _b === void 0 ? void 0 : _b.getLink()) !== null && _c !== void 0 ? _c : "", this.map.metadata, this.configuration, ((_e = (_d = this.session) === null || _d === void 0 ? void 0 : _d.profile) === null || _e === void 0 ? void 0 : _e.userId) != null);
81
80
  }
82
81
  }
83
82
  connectedCallback() {
84
83
  super.connectedCallback();
85
- this.updateData();
86
84
  }
87
85
  onStoreAvailable(name) {
88
86
  super.onStoreAvailable(name);
89
- this.updateData();
90
- }
91
- updateData() {
92
- this.updateDebouncer.run(async () => {
93
- var _a, _b;
94
- if (this.map && (((_b = (_a = this.session) === null || _a === void 0 ? void 0 : _a.profile) === null || _b === void 0 ? void 0 : _b.userId) || this.ratingSummary == null)) {
95
- await this.fetchRatingSummary();
96
- }
97
- });
98
87
  }
88
+ // Used in GWT
99
89
  async fetchRatingSummary() {
100
90
  var _a;
101
- this.ratingSummary = await ((_a = this.service) === null || _a === void 0 ? void 0 : _a.getMapRating());
91
+ await ((_a = this.stateManager) === null || _a === void 0 ? void 0 : _a.fetchMapRating());
102
92
  }
103
93
  rate(ratingEvent) {
104
94
  if (this.ratingSummary) {
@@ -114,7 +104,7 @@ class FtReaderMapFeedback extends withI18n(FtReaderComponent) {
114
104
  }
115
105
  }
116
106
  async sendRating(value) {
117
- var _a, _b, _c;
107
+ var _a, _b, _c, _d;
118
108
  if (!this.editorMode && this.ratingSummary) {
119
109
  try {
120
110
  if (value == null) {
@@ -130,7 +120,7 @@ class FtReaderMapFeedback extends withI18n(FtReaderComponent) {
130
120
  message: feedback.messages.ratingFailure()
131
121
  }));
132
122
  }
133
- this.updateData();
123
+ await ((_d = this.stateManager) === null || _d === void 0 ? void 0 : _d.fetchMapRating());
134
124
  }
135
125
  else if (this.editorMode) {
136
126
  this.dispatchEvent(new FtNotificationEvent({
@@ -197,7 +187,10 @@ __decorate([
197
187
  })
198
188
  ], FtReaderMapFeedback.prototype, "configuration", void 0);
199
189
  __decorate([
200
- state()
190
+ redux({
191
+ store: "reader",
192
+ selector: (state) => state.mapRating
193
+ })
201
194
  ], FtReaderMapFeedback.prototype, "ratingSummary", void 0);
202
195
  __decorate([
203
196
  property({ type: Boolean })
@@ -1,5 +1,5 @@
1
1
  import { PropertyValues } from "lit";
2
- import { ElementDefinitionsMap } from "@fluid-topics/ft-wc-utils";
2
+ import { Debouncer, ElementDefinitionsMap } from "@fluid-topics/ft-wc-utils";
3
3
  import { FtReaderFeedbackProperties } from "./ft-reader-feedback.properties";
4
4
  import { FeedbackI18nProperties, FtReaderFeedback } from "./ft-reader-feedback";
5
5
  import { FtReaderTopicComponent } from "@fluid-topics/ft-reader-topic-context/build/registration";
@@ -8,6 +8,7 @@ import { FtReaderFeedbackConfiguration } from "@fluid-topics/public-api";
8
8
  import { FtTopicRatingSummary } from "@fluid-topics/ft-reader-context/build/store/model";
9
9
  import { FtIconVariants } from "@fluid-topics/ft-icon";
10
10
  import { FeedbackMailLinkBuilder } from "./utils/mail";
11
+ import { SendFeedbackEvent } from "./utils/events";
11
12
  declare const FtReaderTopicFeedback_base: typeof FtReaderTopicComponent & import("@fluid-topics/ft-wc-utils").Constructor<import("@fluid-topics/ft-i18n").FtLitElementWithI18nInterface>;
12
13
  export declare class FtReaderTopicFeedback extends FtReaderTopicFeedback_base implements FtReaderFeedbackProperties {
13
14
  static elementDefinitions: ElementDefinitionsMap;
@@ -31,16 +32,14 @@ export declare class FtReaderTopicFeedback extends FtReaderTopicFeedback_base im
31
32
  i18nProperties: FeedbackI18nProperties;
32
33
  constructor();
33
34
  protected render(): import("lit-html").TemplateResult<1>;
34
- protected update(props: PropertyValues): void;
35
+ protected willUpdate(props: PropertyValues): void;
35
36
  connectedCallback(): void;
36
- private updateDebouncer;
37
- private updateData;
38
- private fetchRatingSummary;
39
- private sendRatingDebouncer;
40
- private rate;
41
- private sendRating;
42
- private sendFeedback;
43
- private onMailerFeedbackSent;
44
- private openMoreOptions;
37
+ protected fetchRatingSummary(): Promise<void>;
38
+ protected sendRatingDebouncer: Debouncer;
39
+ protected rate(ratingEvent: CustomEvent<number | undefined>): void;
40
+ protected sendRating(value: number | undefined): Promise<void>;
41
+ protected sendFeedback(ratingEvent: SendFeedbackEvent): Promise<void>;
42
+ protected onMailerFeedbackSent(): void;
43
+ protected openMoreOptions(): void;
45
44
  }
46
45
  export {};
@@ -5,7 +5,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
7
  import { html } from "lit";
8
- import { property, query, state } from "lit/decorators.js";
8
+ import { property, query } from "lit/decorators.js";
9
9
  import { Debouncer, FtNotificationEvent, redux, reduxEventListener } from "@fluid-topics/ft-wc-utils";
10
10
  import { FtReaderFeedback } from "./ft-reader-feedback";
11
11
  import { FtReaderTopicComponent } from "@fluid-topics/ft-reader-topic-context/build/registration";
@@ -38,7 +38,6 @@ class FtReaderTopicFeedback extends withI18n(FtReaderTopicComponent) {
38
38
  dichotomousRatingSectionTitle: feedback.properties.topicDichotomousRatingSectionTitle(),
39
39
  feedbackSectionTitle: feedback.properties.topicFeedbackSectionTitle(),
40
40
  };
41
- this.updateDebouncer = new Debouncer(100);
42
41
  this.sendRatingDebouncer = new Debouncer(500);
43
42
  this.addStore(ftAppInfoStore);
44
43
  }
@@ -46,56 +45,48 @@ class FtReaderTopicFeedback extends withI18n(FtReaderTopicComponent) {
46
45
  var _a;
47
46
  return html `
48
47
  <ft-reader-feedback
49
- .i18nProperties=${this.i18nProperties}
50
- ?ratingAllowed=${(_a = this.tocNode) === null || _a === void 0 ? void 0 : _a.hasRating}
51
- .editorMode=${this.editorMode}
52
- ?hideTitle=${this.hideTitle}
53
- ?withMoreOptionsButton=${this.withMoreOptionsButton}
54
- .ratingSummary=${this.ratingSummary}
55
- .session=${this.session}
56
- .iconVariant=${this.iconVariant}
57
- .emptyStarIcon=${this.emptyStarIcon}
58
- .filledStarIcon=${this.filledStarIcon}
59
- .emptyLikeIcon=${this.emptyLikeIcon}
60
- .filledLikeIcon=${this.filledLikeIcon}
61
- .emptyDislikeIcon=${this.emptyDislikeIcon}
62
- .filledDislikeIcon=${this.filledDislikeIcon}
63
- .feedbackMailLinkBuilder=${(feedbackMessage) => this.feedbackLinkBuilder.build(feedbackMessage)}
64
- @rate=${this.rate}
65
- @send-feedback=${this.sendFeedback}
66
- @mailer-feedback=${this.onMailerFeedbackSent}
67
- @open-more-options=${this.openMoreOptions}
48
+ .i18nProperties=${this.i18nProperties}
49
+ ?ratingAllowed=${(_a = this.tocNode) === null || _a === void 0 ? void 0 : _a.hasRating}
50
+ .editorMode=${this.editorMode}
51
+ ?hideTitle=${this.hideTitle}
52
+ ?withMoreOptionsButton=${this.withMoreOptionsButton}
53
+ .ratingSummary=${this.ratingSummary}
54
+ .session=${this.session}
55
+ .iconVariant=${this.iconVariant}
56
+ .emptyStarIcon=${this.emptyStarIcon}
57
+ .filledStarIcon=${this.filledStarIcon}
58
+ .emptyLikeIcon=${this.emptyLikeIcon}
59
+ .filledLikeIcon=${this.filledLikeIcon}
60
+ .emptyDislikeIcon=${this.emptyDislikeIcon}
61
+ .filledDislikeIcon=${this.filledDislikeIcon}
62
+ .feedbackMailLinkBuilder=${(feedbackMessage) => this.feedbackLinkBuilder.build(feedbackMessage)}
63
+ @rate=${this.rate}
64
+ @send-feedback=${this.sendFeedback}
65
+ @mailer-feedback=${this.onMailerFeedbackSent}
66
+ @open-more-options=${this.openMoreOptions}
68
67
  ></ft-reader-feedback>
69
68
  `;
70
69
  }
71
- update(props) {
72
- var _a, _b, _c, _d;
73
- super.update(props);
70
+ willUpdate(props) {
71
+ var _a, _b, _c, _d, _e;
72
+ super.willUpdate(props);
74
73
  if (["tocNode", "user"].some(p => props.has(p)) && this.tocNode) {
75
- this.updateData();
74
+ (_a = this.stateManager) === null || _a === void 0 ? void 0 : _a.fetchTopicRating(this.tocNode.tocId);
76
75
  }
77
76
  if (props.has("editorMode") && this.editorMode) {
78
77
  this.addI18nContext(designer, defaultDesignerMessages);
79
78
  }
80
79
  if (["map", "tocNode", "configuration", "user", "mailSubject"].some(p => props.has(p)) && this.map && this.tocNode && this.configuration) {
81
- this.feedbackLinkBuilder.update(this.mailSubject, (_b = (_a = this.service) === null || _a === void 0 ? void 0 : _a.getLink(this.tocNode.tocId)) !== null && _b !== void 0 ? _b : "", this.map.metadata, this.configuration, ((_d = (_c = this.session) === null || _c === void 0 ? void 0 : _c.profile) === null || _d === void 0 ? void 0 : _d.userId) != null);
80
+ this.feedbackLinkBuilder.update(this.mailSubject, (_c = (_b = this.service) === null || _b === void 0 ? void 0 : _b.getLink(this.tocNode.tocId)) !== null && _c !== void 0 ? _c : "", this.map.metadata, this.configuration, ((_e = (_d = this.session) === null || _d === void 0 ? void 0 : _d.profile) === null || _e === void 0 ? void 0 : _e.userId) != null);
82
81
  }
83
82
  }
84
83
  connectedCallback() {
85
84
  super.connectedCallback();
86
- this.updateData();
87
- }
88
- updateData() {
89
- this.updateDebouncer.run(async () => {
90
- var _a, _b;
91
- if (this.tocNode && (((_b = (_a = this.session) === null || _a === void 0 ? void 0 : _a.profile) === null || _b === void 0 ? void 0 : _b.userId) || this.ratingSummary == null)) {
92
- await this.fetchRatingSummary();
93
- }
94
- });
95
85
  }
86
+ // Used in GWT
96
87
  async fetchRatingSummary() {
97
88
  var _a;
98
- this.ratingSummary = await ((_a = this.service) === null || _a === void 0 ? void 0 : _a.getTopicRating(this.tocNode.tocId));
89
+ await ((_a = this.stateManager) === null || _a === void 0 ? void 0 : _a.fetchTopicRating(this.tocNode.tocId));
99
90
  }
100
91
  rate(ratingEvent) {
101
92
  if (this.ratingSummary && this.tocNode) {
@@ -112,7 +103,7 @@ class FtReaderTopicFeedback extends withI18n(FtReaderTopicComponent) {
112
103
  }
113
104
  }
114
105
  async sendRating(value) {
115
- var _a, _b, _c;
106
+ var _a, _b, _c, _d;
116
107
  if (!this.editorMode && this.ratingSummary && this.tocNode) {
117
108
  try {
118
109
  if (value == null) {
@@ -128,7 +119,7 @@ class FtReaderTopicFeedback extends withI18n(FtReaderTopicComponent) {
128
119
  message: feedback.messages.ratingFailure()
129
120
  }));
130
121
  }
131
- this.updateData();
122
+ await ((_d = this.stateManager) === null || _d === void 0 ? void 0 : _d.fetchTopicRating(this.tocNode.tocId));
132
123
  }
133
124
  else if (this.editorMode) {
134
125
  this.dispatchEvent(new FtNotificationEvent({
@@ -200,7 +191,10 @@ __decorate([
200
191
  })
201
192
  ], FtReaderTopicFeedback.prototype, "configuration", void 0);
202
193
  __decorate([
203
- state()
194
+ redux({
195
+ store: "reader",
196
+ selector: (state, self) => { var _a, _b; return state.topicsRating[(_b = (_a = self.tocNode) === null || _a === void 0 ? void 0 : _a.tocId) !== null && _b !== void 0 ? _b : '']; }
197
+ })
204
198
  ], FtReaderTopicFeedback.prototype, "ratingSummary", void 0);
205
199
  __decorate([
206
200
  property({ type: Boolean })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-topics/ft-reader-feedback",
3
- "version": "1.2.49",
3
+ "version": "1.2.51",
4
4
  "description": "Feedback forms for a map and its topics in an integrated reader",
5
5
  "keywords": [
6
6
  "Lit"
@@ -19,13 +19,13 @@
19
19
  "url": "ssh://git@scm.mrs.antidot.net:2222/fluidtopics/ft-web-components.git"
20
20
  },
21
21
  "dependencies": {
22
- "@fluid-topics/ft-app-context": "1.2.49",
23
- "@fluid-topics/ft-reader-context": "1.2.49",
24
- "@fluid-topics/ft-wc-utils": "1.2.49",
22
+ "@fluid-topics/ft-app-context": "1.2.51",
23
+ "@fluid-topics/ft-reader-context": "1.2.51",
24
+ "@fluid-topics/ft-wc-utils": "1.2.51",
25
25
  "lit": "3.1.0"
26
26
  },
27
27
  "devDependencies": {
28
- "@fluid-topics/public-api": "1.0.89"
28
+ "@fluid-topics/public-api": "1.0.90"
29
29
  },
30
- "gitHead": "eac6d1d34424e5f5ca7e20068e646caeba2e15a7"
30
+ "gitHead": "f37803963479545409bdddea3571d34dbad90413"
31
31
  }