@fluid-topics/ft-reader-feedback 0.3.55 → 0.3.56

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.
@@ -13,6 +13,7 @@ export declare class FtReaderMapFeedback extends FtReaderComponent implements Ft
13
13
  configuration?: FtReaderFeedbackConfiguration;
14
14
  ratingSummary?: FtPublicationRatingSummary;
15
15
  user?: FtUserProfile;
16
+ hideTitle: boolean;
16
17
  iconVariant: FtIconVariants;
17
18
  emptyStarIcon?: string;
18
19
  filledStarIcon?: string;
@@ -25,8 +26,12 @@ export declare class FtReaderMapFeedback extends FtReaderComponent implements Ft
25
26
  protected render(): typeof nothing | import("lit-html").TemplateResult<1>;
26
27
  protected updated(props: PropertyValues): void;
27
28
  connectedCallback(): void;
29
+ onStoreAvailable(name?: string): void;
30
+ private updateDebouncer;
28
31
  private updateData;
32
+ private sendRatingDebouncer;
29
33
  private rate;
34
+ private sendRating;
30
35
  private sendFeedback;
31
36
  }
32
37
  //# sourceMappingURL=ft-reader-map-feedback.d.ts.map
@@ -5,11 +5,10 @@ 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, nothing } from "lit";
8
- import { property, query } from "lit/decorators.js";
9
- import { FtNotificationEvent, redux } from "@fluid-topics/ft-wc-utils";
8
+ import { property, query, state } from "lit/decorators.js";
9
+ import { Debouncer, FtNotificationEvent, redux } 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";
12
- import { state } from "lit/decorators";
13
12
  import { FtIconVariants } from "@fluid-topics/ft-icon";
14
13
  import { mapLabelResolver } from "./utils/labels";
15
14
  import { FeedbackMailLinkBuilder } from "./utils/mail";
@@ -17,6 +16,7 @@ export class FtReaderMapFeedback extends FtReaderComponent {
17
16
  constructor() {
18
17
  super(...arguments);
19
18
  this.editorMode = false;
19
+ this.hideTitle = false;
20
20
  this.iconVariant = FtIconVariants.fluid_topics;
21
21
  this.emptyStarIcon = "STAR";
22
22
  this.filledStarIcon = "STAR_PLAIN";
@@ -25,6 +25,8 @@ export class FtReaderMapFeedback extends FtReaderComponent {
25
25
  this.emptyDislikeIcon = "THUMBS_DOWN";
26
26
  this.filledDislikeIcon = "THUMBS_DOWN_PLAIN";
27
27
  this.feedbackLinkBuilder = new FeedbackMailLinkBuilder(mapLabelResolver.resolve("mailDisclaimer"));
28
+ this.updateDebouncer = new Debouncer(100);
29
+ this.sendRatingDebouncer = new Debouncer(500);
28
30
  }
29
31
  render() {
30
32
  if (this.map == null) {
@@ -33,7 +35,8 @@ export class FtReaderMapFeedback extends FtReaderComponent {
33
35
  return html `
34
36
  <ft-reader-feedback
35
37
  ratingAllowed
36
- .editorMode=${true}
38
+ .editorMode=${this.editorMode}
39
+ ?hideTitle=${this.hideTitle}
37
40
  .labelResolver=${mapLabelResolver}
38
41
  .ratingSummary=${this.ratingSummary}
39
42
  .user=${this.user}
@@ -53,7 +56,7 @@ export class FtReaderMapFeedback extends FtReaderComponent {
53
56
  updated(props) {
54
57
  var _a, _b, _c;
55
58
  super.updated(props);
56
- if (props.has("map")) {
59
+ if (props.has("map") && this.map) {
57
60
  this.updateData();
58
61
  }
59
62
  if (["map", "configuration", "user"].some(p => props.has(p)) && this.map && this.configuration) {
@@ -64,31 +67,41 @@ export class FtReaderMapFeedback extends FtReaderComponent {
64
67
  super.connectedCallback();
65
68
  this.updateData();
66
69
  }
67
- async updateData() {
68
- var _a, _b;
69
- this.user = await ((_a = this.service) === null || _a === void 0 ? void 0 : _a.getSession().then(s => s.profile));
70
- if (this.map) {
71
- this.ratingSummary = await ((_b = this.service) === null || _b === void 0 ? void 0 : _b.getMapRating());
70
+ onStoreAvailable(name) {
71
+ super.onStoreAvailable(name);
72
+ this.updateData();
73
+ }
74
+ updateData() {
75
+ this.updateDebouncer.run(async () => {
76
+ var _a, _b;
77
+ this.user = await ((_a = this.service) === null || _a === void 0 ? void 0 : _a.getSession().then(s => s.profile));
78
+ if (this.map) {
79
+ this.ratingSummary = await ((_b = this.service) === null || _b === void 0 ? void 0 : _b.getMapRating());
80
+ }
81
+ });
82
+ }
83
+ rate(ratingEvent) {
84
+ if (this.ratingSummary) {
85
+ this.ratingSummary = {
86
+ ...this.ratingSummary,
87
+ rating: ratingEvent.detail == null ? undefined : {
88
+ type: this.ratingSummary.type,
89
+ value: ratingEvent.detail,
90
+ date: new Date()
91
+ }
92
+ };
93
+ this.sendRatingDebouncer.run(() => this.sendRating(ratingEvent.detail));
72
94
  }
73
95
  }
74
- async rate(ratingEvent) {
96
+ async sendRating(value) {
75
97
  var _a, _b, _c;
76
- if (this.ratingSummary) {
98
+ if (!this.editorMode && this.ratingSummary) {
77
99
  try {
78
- if (ratingEvent.detail == null) {
79
- this.ratingSummary = { ...this.ratingSummary, rating: undefined };
100
+ if (value == null) {
80
101
  await ((_a = this.service) === null || _a === void 0 ? void 0 : _a.unrateMap());
81
102
  }
82
103
  else {
83
- this.ratingSummary = {
84
- ...this.ratingSummary,
85
- rating: {
86
- type: this.ratingSummary.type,
87
- value: ratingEvent.detail,
88
- date: new Date()
89
- }
90
- };
91
- await ((_b = this.service) === null || _b === void 0 ? void 0 : _b.rateMap((_c = this.ratingSummary) === null || _c === void 0 ? void 0 : _c.type, ratingEvent.detail));
104
+ await ((_b = this.service) === null || _b === void 0 ? void 0 : _b.rateMap((_c = this.ratingSummary) === null || _c === void 0 ? void 0 : _c.type, value));
92
105
  }
93
106
  }
94
107
  catch {
@@ -97,17 +110,31 @@ export class FtReaderMapFeedback extends FtReaderComponent {
97
110
  message: mapLabelResolver.resolve("ratingFailure")
98
111
  }));
99
112
  }
113
+ this.updateData();
114
+ }
115
+ else if (this.editorMode) {
116
+ this.dispatchEvent(new FtNotificationEvent({
117
+ type: "info",
118
+ message: mapLabelResolver.resolve("feedbackAndRatingDisabledInEditor")
119
+ }));
100
120
  }
101
- this.updateData();
102
121
  }
103
122
  async sendFeedback(ratingEvent) {
104
123
  var _a;
105
124
  try {
106
- await ((_a = this.service) === null || _a === void 0 ? void 0 : _a.sendMapFeedback(ratingEvent.detail));
107
- this.dispatchEvent(new FtNotificationEvent({
108
- type: "info",
109
- message: mapLabelResolver.resolve("feedbackSuccess")
110
- }));
125
+ if (!this.editorMode) {
126
+ await ((_a = this.service) === null || _a === void 0 ? void 0 : _a.sendMapFeedback(ratingEvent.detail));
127
+ this.dispatchEvent(new FtNotificationEvent({
128
+ type: "info",
129
+ message: mapLabelResolver.resolve("feedbackSuccess")
130
+ }));
131
+ }
132
+ else {
133
+ this.dispatchEvent(new FtNotificationEvent({
134
+ type: "info",
135
+ message: mapLabelResolver.resolve("feedbackAndRatingDisabledInEditor")
136
+ }));
137
+ }
111
138
  this.readerFeedback.clearFeedbackInput();
112
139
  }
113
140
  catch {
@@ -137,25 +164,28 @@ __decorate([
137
164
  state()
138
165
  ], FtReaderMapFeedback.prototype, "user", void 0);
139
166
  __decorate([
140
- property({ type: String })
167
+ property({ type: Boolean })
168
+ ], FtReaderMapFeedback.prototype, "hideTitle", void 0);
169
+ __decorate([
170
+ property()
141
171
  ], FtReaderMapFeedback.prototype, "iconVariant", void 0);
142
172
  __decorate([
143
- property({ type: String })
173
+ property()
144
174
  ], FtReaderMapFeedback.prototype, "emptyStarIcon", void 0);
145
175
  __decorate([
146
- property({ type: String })
176
+ property()
147
177
  ], FtReaderMapFeedback.prototype, "filledStarIcon", void 0);
148
178
  __decorate([
149
- property({ type: String })
179
+ property()
150
180
  ], FtReaderMapFeedback.prototype, "emptyLikeIcon", void 0);
151
181
  __decorate([
152
- property({ type: String })
182
+ property()
153
183
  ], FtReaderMapFeedback.prototype, "filledLikeIcon", void 0);
154
184
  __decorate([
155
- property({ type: String })
185
+ property()
156
186
  ], FtReaderMapFeedback.prototype, "emptyDislikeIcon", void 0);
157
187
  __decorate([
158
- property({ type: String })
188
+ property()
159
189
  ], FtReaderMapFeedback.prototype, "filledDislikeIcon", void 0);
160
190
  __decorate([
161
191
  query("ft-reader-feedback")
@@ -15,6 +15,7 @@ export declare class FtReaderTopicFeedback extends FtReaderTopicComponent implem
15
15
  configuration?: FtReaderFeedbackConfiguration;
16
16
  ratingSummary?: FtTopicRatingSummary;
17
17
  user?: FtUserProfile;
18
+ hideTitle: boolean;
18
19
  iconVariant: FtIconVariants;
19
20
  emptyStarIcon?: string;
20
21
  filledStarIcon?: string;
@@ -28,7 +29,9 @@ export declare class FtReaderTopicFeedback extends FtReaderTopicComponent implem
28
29
  protected updated(props: PropertyValues): void;
29
30
  connectedCallback(): void;
30
31
  private updateData;
32
+ private sendRatingDebouncer;
31
33
  private rate;
34
+ private sendRating;
32
35
  private sendFeedback;
33
36
  }
34
37
  //# sourceMappingURL=ft-reader-topic-feedback.d.ts.map
@@ -6,7 +6,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
6
6
  };
7
7
  import { html, nothing } from "lit";
8
8
  import { property, query, state } from "lit/decorators.js";
9
- import { FtNotificationEvent, redux } from "@fluid-topics/ft-wc-utils";
9
+ import { Debouncer, FtNotificationEvent, redux } 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";
12
12
  import { FtIconVariants } from "@fluid-topics/ft-icon";
@@ -16,6 +16,7 @@ export class FtReaderTopicFeedback extends FtReaderTopicComponent {
16
16
  constructor() {
17
17
  super(...arguments);
18
18
  this.editorMode = false;
19
+ this.hideTitle = false;
19
20
  this.iconVariant = FtIconVariants.fluid_topics;
20
21
  this.emptyStarIcon = "STAR";
21
22
  this.filledStarIcon = "STAR_PLAIN";
@@ -24,6 +25,7 @@ export class FtReaderTopicFeedback extends FtReaderTopicComponent {
24
25
  this.emptyDislikeIcon = "THUMBS_DOWN";
25
26
  this.filledDislikeIcon = "THUMBS_DOWN_PLAIN";
26
27
  this.feedbackLinkBuilder = new FeedbackMailLinkBuilder(topicLabelResolver.resolve("mailDisclaimer"));
28
+ this.sendRatingDebouncer = new Debouncer(500);
27
29
  }
28
30
  render() {
29
31
  if (this.map == null || this.tocNode == null) {
@@ -33,6 +35,7 @@ export class FtReaderTopicFeedback extends FtReaderTopicComponent {
33
35
  <ft-reader-feedback
34
36
  ?ratingAllowed=${this.tocNode.hasRating}
35
37
  .editorMode=${this.editorMode}
38
+ ?hideTitle=${this.hideTitle}
36
39
  .labelResolver=${topicLabelResolver}
37
40
  .ratingSummary=${this.ratingSummary}
38
41
  .user=${this.user}
@@ -70,25 +73,29 @@ export class FtReaderTopicFeedback extends FtReaderTopicComponent {
70
73
  this.ratingSummary = await ((_b = this.service) === null || _b === void 0 ? void 0 : _b.getTopicRating(this.tocNode.tocId));
71
74
  }
72
75
  }
73
- async rate(ratingEvent) {
74
- var _a, _b, _c;
76
+ rate(ratingEvent) {
75
77
  if (this.ratingSummary && this.tocNode) {
78
+ this.ratingSummary = {
79
+ ...this.ratingSummary,
80
+ rating: ratingEvent.detail == null ? undefined : {
81
+ tocId: this.tocNode.tocId,
82
+ type: this.ratingSummary.type,
83
+ value: ratingEvent.detail,
84
+ date: new Date()
85
+ }
86
+ };
87
+ this.sendRatingDebouncer.run(() => this.sendRating(ratingEvent.detail));
88
+ }
89
+ }
90
+ async sendRating(value) {
91
+ var _a, _b, _c;
92
+ if (!this.editorMode && this.ratingSummary && this.tocNode) {
76
93
  try {
77
- if (ratingEvent.detail == null) {
78
- this.ratingSummary = { ...this.ratingSummary, rating: undefined };
94
+ if (value == null) {
79
95
  await ((_a = this.service) === null || _a === void 0 ? void 0 : _a.unrateTopic(this.tocNode.tocId));
80
96
  }
81
97
  else {
82
- this.ratingSummary = {
83
- ...this.ratingSummary,
84
- rating: {
85
- tocId: this.tocNode.tocId,
86
- type: this.ratingSummary.type,
87
- value: ratingEvent.detail,
88
- date: new Date()
89
- }
90
- };
91
- await ((_b = this.service) === null || _b === void 0 ? void 0 : _b.rateTopic(this.tocNode.tocId, (_c = this.ratingSummary) === null || _c === void 0 ? void 0 : _c.type, ratingEvent.detail));
98
+ await ((_b = this.service) === null || _b === void 0 ? void 0 : _b.rateTopic(this.tocNode.tocId, (_c = this.ratingSummary) === null || _c === void 0 ? void 0 : _c.type, value));
92
99
  }
93
100
  }
94
101
  catch {
@@ -97,13 +104,19 @@ export class FtReaderTopicFeedback extends FtReaderTopicComponent {
97
104
  message: topicLabelResolver.resolve("ratingFailure")
98
105
  }));
99
106
  }
107
+ this.updateData();
108
+ }
109
+ else if (this.editorMode) {
110
+ this.dispatchEvent(new FtNotificationEvent({
111
+ type: "info",
112
+ message: topicLabelResolver.resolve("feedbackAndRatingDisabledInEditor")
113
+ }));
100
114
  }
101
- this.updateData();
102
115
  }
103
116
  async sendFeedback(ratingEvent) {
104
117
  var _a;
105
118
  try {
106
- if (this.tocNode) {
119
+ if (!this.editorMode && this.tocNode) {
107
120
  await ((_a = this.service) === null || _a === void 0 ? void 0 : _a.sendTopicFeedback(this.tocNode.tocId, ratingEvent.detail));
108
121
  this.dispatchEvent(new FtNotificationEvent({
109
122
  type: "info",
@@ -111,6 +124,12 @@ export class FtReaderTopicFeedback extends FtReaderTopicComponent {
111
124
  }));
112
125
  this.readerFeedback.clearFeedbackInput();
113
126
  }
127
+ else if (this.editorMode) {
128
+ this.dispatchEvent(new FtNotificationEvent({
129
+ type: "info",
130
+ message: topicLabelResolver.resolve("feedbackAndRatingDisabledInEditor")
131
+ }));
132
+ }
114
133
  }
115
134
  catch {
116
135
  this.dispatchEvent(new FtNotificationEvent({
@@ -138,6 +157,9 @@ __decorate([
138
157
  __decorate([
139
158
  state()
140
159
  ], FtReaderTopicFeedback.prototype, "user", void 0);
160
+ __decorate([
161
+ property({ type: Boolean })
162
+ ], FtReaderTopicFeedback.prototype, "hideTitle", void 0);
141
163
  __decorate([
142
164
  property()
143
165
  ], FtReaderTopicFeedback.prototype, "iconVariant", void 0);
@@ -23,6 +23,7 @@ export interface FtReaderFeedbackLabels extends ParametrizedLabels {
23
23
  feedbackFailure?: string;
24
24
  ratingSuccess?: string;
25
25
  ratingFailure?: string;
26
+ feedbackAndRatingDisabledInEditor?: string;
26
27
  }
27
28
  export declare const topicLabelResolver: ParametrizedLabelResolver<FtReaderFeedbackLabels>;
28
29
  export declare const mapLabelResolver: ParametrizedLabelResolver<FtReaderFeedbackLabels>;
@@ -25,6 +25,7 @@ const DEFAULT_MAP_LABELS = {
25
25
  dichotomousRatingSectionTitle: "Did it solve your problem?",
26
26
  feedbackSectionTitle: "Write your review",
27
27
  mailSubject: "Feedback about “{0}”",
28
+ feedbackAndRatingDisabledInEditor: "Feedback & rating disabled in the reader designer",
28
29
  };
29
30
  const DEFAULT_TOPIC_LABELS = {
30
31
  ...DEFAULT_LABELS,
@@ -33,6 +34,7 @@ const DEFAULT_TOPIC_LABELS = {
33
34
  dichotomousRatingSectionTitle: "Did this content solve your problem?",
34
35
  feedbackSectionTitle: "Write your review",
35
36
  mailSubject: "Feedback about “{0}” in “{1}”",
37
+ feedbackAndRatingDisabledInEditor: "Feedback & rating disabled in the topic template designer",
36
38
  };
37
39
  export const topicLabelResolver = new ParametrizedLabelResolver(DEFAULT_TOPIC_LABELS, {});
38
40
  export const mapLabelResolver = new ParametrizedLabelResolver(DEFAULT_MAP_LABELS, {});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-topics/ft-reader-feedback",
3
- "version": "0.3.55",
3
+ "version": "0.3.56",
4
4
  "description": "Feedback forms for a map and its topics in an integrated reader",
5
5
  "keywords": [
6
6
  "Lit"
@@ -19,8 +19,8 @@
19
19
  "url": "ssh://git@scm.mrs.antidot.net:2222/fluidtopics/ft-web-components.git"
20
20
  },
21
21
  "dependencies": {
22
- "@fluid-topics/ft-wc-utils": "0.3.55",
22
+ "@fluid-topics/ft-wc-utils": "0.3.56",
23
23
  "lit": "2.2.8"
24
24
  },
25
- "gitHead": "4106f01e238edeb1c85fba22d6d50a18757e0b3e"
25
+ "gitHead": "e86edee2b2660d806320bacca5c5156bb94ca2d6"
26
26
  }