@fluid-topics/ft-reader-feedback 1.2.13 → 1.2.14

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.
@@ -2,8 +2,7 @@ import { nothing } from "lit";
2
2
  import { ElementDefinitionsMap } from "@fluid-topics/ft-wc-utils";
3
3
  import { FtReaderFeedbackProperties } from "./ft-reader-feedback.properties";
4
4
  import { FtTopicRatingSummary } from "@fluid-topics/ft-reader-context/build/store/model";
5
- import type { FtPublicationRatingSummary, FtSession } from "@fluid-topics/public-api";
6
- import { FtReaderFeedbackConfiguration } from "@fluid-topics/public-api";
5
+ import { FtPublicationRatingSummary, FtRatingType, FtReaderFeedbackConfiguration, FtSession } from "@fluid-topics/public-api";
7
6
  import { FtTextArea } from "@fluid-topics/ft-text-area";
8
7
  import { FtIconVariants } from "@fluid-topics/ft-icon/build/ft-icon.properties";
9
8
  import { I18nPropertyInit } from "@fluid-topics/ft-i18n";
@@ -39,9 +38,9 @@ export declare class FtReaderFeedback extends FtReaderFeedback_base implements F
39
38
  feedbackMailLinkBuilder: (feedbackMessage: string) => string | undefined;
40
39
  constructor();
41
40
  get canAccessFeedback(): boolean | undefined;
42
- get canAccessRating(): boolean | undefined;
43
- get configuredRatingType(): import("@fluid-topics/public-api").FtRatingType | "STARS" | "LIKE" | "DICHOTOMOUS" | "NO_RATING";
44
- get ratingType(): "STARS" | "LIKE" | "DICHOTOMOUS" | "NO_RATING";
41
+ get canRateThisContent(): boolean | undefined;
42
+ get configuredRatingType(): FtRatingType | "STARS" | "LIKE" | "DICHOTOMOUS" | "NO_RATING";
43
+ get ratingTypeOfDoneRatingOfThisContent(): FtRatingType.NO_RATING | "STARS" | "LIKE" | "DICHOTOMOUS" | "NO_RATING";
45
44
  get ratingValue(): number;
46
45
  get ratingDate(): Date | undefined;
47
46
  protected render(): typeof nothing | import("lit").TemplateResult<1>;
@@ -8,6 +8,7 @@ import { html, nothing } from "lit";
8
8
  import { property, query, state } from "lit/decorators.js";
9
9
  import { parseDate, redux, } from "@fluid-topics/ft-wc-utils";
10
10
  import { styles } from "./ft-reader-feedback.styles";
11
+ import { FtRatingType } from "@fluid-topics/public-api";
11
12
  import { FtTypography } from "@fluid-topics/ft-typography";
12
13
  import { FtSwitch, FtSwitchOption } from "@fluid-topics/ft-switch";
13
14
  import { FtTextArea } from "@fluid-topics/ft-text-area";
@@ -40,17 +41,18 @@ class FtReaderFeedback extends withI18n(FtReaderComponent) {
40
41
  var _a;
41
42
  return (_a = this.service) === null || _a === void 0 ? void 0 : _a.isFeatureAccessible(FtReaderFeatures.FEEDBACK, { session: this.session });
42
43
  }
43
- get canAccessRating() {
44
- var _a, _b;
45
- return (_a = this.service) === null || _a === void 0 ? void 0 : _a.isFeatureAccessible(FtReaderFeatures.RATING, { session: this.session, ratingType: (_b = this.ratingSummary) === null || _b === void 0 ? void 0 : _b.type });
44
+ get canRateThisContent() {
45
+ var _a;
46
+ const canAccessRating = (_a = this.service) === null || _a === void 0 ? void 0 : _a.isFeatureAccessible(FtReaderFeatures.RATING, { session: this.session });
47
+ return canAccessRating && this.ratingAllowed && this.configuredRatingType != FtRatingType.NO_RATING;
46
48
  }
47
49
  get configuredRatingType() {
48
50
  var _a, _b;
49
- return (_b = (this.ratingAllowed ? (_a = this.ratingSummary) === null || _a === void 0 ? void 0 : _a.type : "NO_RATING")) !== null && _b !== void 0 ? _b : "NO_RATING";
51
+ return (_b = (_a = this.ratingSummary) === null || _a === void 0 ? void 0 : _a.type) !== null && _b !== void 0 ? _b : FtRatingType.NO_RATING;
50
52
  }
51
- get ratingType() {
53
+ get ratingTypeOfDoneRatingOfThisContent() {
52
54
  var _a, _b, _c;
53
- return (_c = (_b = (_a = this.ratingSummary) === null || _a === void 0 ? void 0 : _a.rating) === null || _b === void 0 ? void 0 : _b.type) !== null && _c !== void 0 ? _c : "NO_RATING";
55
+ return (_c = (_b = (_a = this.ratingSummary) === null || _a === void 0 ? void 0 : _a.rating) === null || _b === void 0 ? void 0 : _b.type) !== null && _c !== void 0 ? _c : FtRatingType.NO_RATING;
54
56
  }
55
57
  get ratingValue() {
56
58
  var _a, _b, _c;
@@ -62,7 +64,7 @@ class FtReaderFeedback extends withI18n(FtReaderComponent) {
62
64
  return typeof date === "string" ? parseDate(date) : date;
63
65
  }
64
66
  render() {
65
- if (!this.canAccessFeedback && !this.canAccessRating) {
67
+ if (!this.canAccessFeedback && !this.canRateThisContent) {
66
68
  return nothing;
67
69
  }
68
70
  return html `
@@ -78,11 +80,11 @@ class FtReaderFeedback extends withI18n(FtReaderComponent) {
78
80
  `;
79
81
  }
80
82
  renderRatingSection() {
81
- if (this.canAccessRating) {
83
+ if (this.canRateThisContent) {
82
84
  return html `
83
85
  <div class="ft-reader-feedback--rating" part="rating-container">
84
86
  <ft-typography variant="title-dense" part="section-title" class="ft-reader-feedback--section-title">
85
- ${this.i18n(this.ratingSummary.type === "DICHOTOMOUS"
87
+ ${this.i18n(this.ratingSummary.type === FtRatingType.DICHOTOMOUS
86
88
  ? this.i18nProperties.dichotomousRatingSectionTitle
87
89
  : this.i18nProperties.ratingSectionTitle)}
88
90
  </ft-typography>
@@ -112,11 +114,11 @@ class FtReaderFeedback extends withI18n(FtReaderComponent) {
112
114
  }
113
115
  renderRating() {
114
116
  switch (this.configuredRatingType) {
115
- case "STARS":
117
+ case FtRatingType.STARS:
116
118
  return html `
117
119
  <div class="ft-reader-feedback--stars" part="rating rating-stars">
118
120
  ${repeat(new Array(5), (_, index) => index, (_, index) => {
119
- let active = this.ratingType === "STARS" && this.ratingValue > index;
121
+ let active = this.ratingTypeOfDoneRatingOfThisContent === FtRatingType.STARS && this.ratingValue > index;
120
122
  const ratingValue = index + 1;
121
123
  return html `
122
124
  <ft-button round part="rating-stars-${ratingValue}"
@@ -131,9 +133,9 @@ class FtReaderFeedback extends withI18n(FtReaderComponent) {
131
133
  })}
132
134
  </div>
133
135
  `;
134
- case "LIKE":
135
- const disliked = this.ratingType === "LIKE" && this.ratingValue === 0;
136
- const liked = this.ratingType === "LIKE" && this.ratingValue === 1;
136
+ case FtRatingType.LIKE:
137
+ const disliked = this.ratingTypeOfDoneRatingOfThisContent === FtRatingType.LIKE && this.ratingValue === 0;
138
+ const liked = this.ratingTypeOfDoneRatingOfThisContent === FtRatingType.LIKE && this.ratingValue === 1;
137
139
  return html `
138
140
  <ft-switch unselectable
139
141
  @change=${(e) => this.rate(e.detail)}
@@ -155,9 +157,9 @@ class FtReaderFeedback extends withI18n(FtReaderComponent) {
155
157
  </ft-switch-option>
156
158
  </ft-switch>
157
159
  `;
158
- case "DICHOTOMOUS":
159
- const no = this.ratingType === "DICHOTOMOUS" && this.ratingValue === 0;
160
- const yes = this.ratingType === "DICHOTOMOUS" && this.ratingValue === 1;
160
+ case FtRatingType.DICHOTOMOUS:
161
+ const no = this.ratingTypeOfDoneRatingOfThisContent === FtRatingType.DICHOTOMOUS && this.ratingValue === 0;
162
+ const yes = this.ratingTypeOfDoneRatingOfThisContent === FtRatingType.DICHOTOMOUS && this.ratingValue === 1;
161
163
  return html `
162
164
  <ft-switch unselectable
163
165
  @change=${(e) => this.rate(e.detail)}
@@ -200,15 +202,17 @@ class FtReaderFeedback extends withI18n(FtReaderComponent) {
200
202
  </a>
201
203
  `;
202
204
  }
203
- let moreOptionsButton = this.withMoreOptionsButton && (((_a = this.configuration) === null || _a === void 0 ? void 0 : _a.mailsSentByFluidTopics) || ((_b = this.configuration) === null || _b === void 0 ? void 0 : _b.mailsSentByFluidTopicsForUnauthenticatedUsers)) ? html `
204
- <ft-button outlined
205
- type="button" name="more-options"
206
- class="ft-reader-feedback--more-options"
207
- @click="${this.onOpenMoreDetails}"
208
- part="more-options">
209
- ${feedback.messages.moreOptionsButton()}
210
- </ft-button>
211
- ` : nothing;
205
+ let moreOptionsButton = this.withMoreOptionsButton && (((_a = this.configuration) === null || _a === void 0 ? void 0 : _a.mailsSentByFluidTopics) || ((_b = this.configuration) === null || _b === void 0 ? void 0 : _b.mailsSentByFluidTopicsForUnauthenticatedUsers))
206
+ ? html `
207
+ <ft-button outlined
208
+ type="button" name="more-options"
209
+ class="ft-reader-feedback--more-options"
210
+ @click="${this.onOpenMoreDetails}"
211
+ part="more-options">
212
+ ${feedback.messages.moreOptionsButton()}
213
+ </ft-button>
214
+ `
215
+ : nothing;
212
216
  return html `
213
217
  <form class="ft-reader-feedback--feedback" part="feedback-container" autocomplete="on"
214
218
  @submit="${(e) => this.onFormSubmitEvent(e, !!mailLink)}">