@fluid-topics/ft-reader-feedback 0.3.57 → 0.3.60
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.
- package/build/ft-reader-feedback.d.ts +11 -4
- package/build/ft-reader-feedback.js +38 -31
- package/build/ft-reader-feedback.light.js +225 -219
- package/build/ft-reader-feedback.min.js +312 -306
- package/build/ft-reader-map-feedback.d.ts +8 -3
- package/build/ft-reader-map-feedback.js +41 -22
- package/build/ft-reader-topic-feedback.d.ts +9 -3
- package/build/ft-reader-topic-feedback.js +47 -25
- package/build/utils/InDesignerFeedbackComponentMessages.d.ts +11 -0
- package/build/utils/InDesignerFeedbackComponentMessages.js +10 -0
- package/build/utils/IntegratedFeedbackComponentMessages.d.ts +29 -0
- package/build/utils/IntegratedFeedbackComponentMessages.js +30 -0
- package/build/utils/ServerMessages.d.ts +21 -0
- package/build/utils/ServerMessages.js +3 -0
- package/build/utils/mail.d.ts +0 -2
- package/build/utils/mail.js +3 -3
- package/package.json +5 -3
- package/build/utils/labels.d.ts +0 -30
- package/build/utils/labels.js +0 -40
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
import { nothing } from "lit";
|
|
2
|
-
import { ElementDefinitionsMap
|
|
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
5
|
import type { FtPublicationRatingSummary, FtUserProfile } from "@fluid-topics/public-api";
|
|
6
6
|
import { FtTextArea } from "@fluid-topics/ft-text-area";
|
|
7
7
|
import { FtIconVariants } from "@fluid-topics/ft-icon/build/ft-icon.properties";
|
|
8
|
-
import {
|
|
9
|
-
export
|
|
8
|
+
import { FtLitElementWithI18n, I18nProperty } from "@fluid-topics/ft-i18n";
|
|
9
|
+
export interface FeedbackI18nProperties {
|
|
10
|
+
feedbackMainTitle: I18nProperty;
|
|
11
|
+
ratingSectionTitle: I18nProperty;
|
|
12
|
+
feedbackSectionTitle: I18nProperty;
|
|
13
|
+
dichotomousRatingSectionTitle: I18nProperty;
|
|
14
|
+
}
|
|
15
|
+
export declare class FtReaderFeedback extends FtLitElementWithI18n implements FtReaderFeedbackProperties {
|
|
10
16
|
static elementDefinitions: ElementDefinitionsMap;
|
|
11
17
|
static styles: import("lit").CSSResult;
|
|
12
18
|
editorMode: boolean;
|
|
13
19
|
hideTitle: boolean;
|
|
14
20
|
ratingAllowed: boolean;
|
|
15
|
-
|
|
21
|
+
i18nProperties: FeedbackI18nProperties;
|
|
16
22
|
ratingSummary?: FtPublicationRatingSummary | FtTopicRatingSummary;
|
|
17
23
|
user?: FtUserProfile;
|
|
18
24
|
feedbackInput: FtTextArea;
|
|
@@ -25,6 +31,7 @@ export declare class FtReaderFeedback extends FtLitElement implements FtReaderFe
|
|
|
25
31
|
emptyDislikeIcon?: string;
|
|
26
32
|
filledDislikeIcon?: string;
|
|
27
33
|
feedbackMailLinkBuilder: (feedbackMessage: string) => string | undefined;
|
|
34
|
+
constructor();
|
|
28
35
|
get canAccessFeedback(): boolean | undefined;
|
|
29
36
|
get canAccessRating(): boolean | undefined;
|
|
30
37
|
get userHasRatingRole(): boolean | undefined;
|
|
@@ -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 {
|
|
9
|
+
import { parseDate, } from "@fluid-topics/ft-wc-utils";
|
|
10
10
|
import { styles } from "./ft-reader-feedback.css";
|
|
11
11
|
import { FtTypography } from "@fluid-topics/ft-typography";
|
|
12
12
|
import { FtIcon } from "@fluid-topics/ft-icon";
|
|
@@ -16,9 +16,12 @@ import { FtTextArea } from "@fluid-topics/ft-text-area";
|
|
|
16
16
|
import { repeat } from "lit/directives/repeat.js";
|
|
17
17
|
import { FtButton } from "@fluid-topics/ft-button";
|
|
18
18
|
import { FtIconVariants } from "@fluid-topics/ft-icon/build/ft-icon.properties";
|
|
19
|
-
|
|
19
|
+
import { defaultMessages, feedback } from "./utils/IntegratedFeedbackComponentMessages";
|
|
20
|
+
import { FtLitElementWithI18n } from "@fluid-topics/ft-i18n";
|
|
21
|
+
import { defaultDesignerMessages, designer } from "./utils/InDesignerFeedbackComponentMessages";
|
|
22
|
+
export class FtReaderFeedback extends FtLitElementWithI18n {
|
|
20
23
|
constructor() {
|
|
21
|
-
super(
|
|
24
|
+
super();
|
|
22
25
|
this.editorMode = false;
|
|
23
26
|
this.hideTitle = false;
|
|
24
27
|
this.ratingAllowed = false;
|
|
@@ -30,6 +33,8 @@ export class FtReaderFeedback extends FtLitElement {
|
|
|
30
33
|
this.filledLikeIcon = "THUMBS_UP_PLAIN";
|
|
31
34
|
this.emptyDislikeIcon = "THUMBS_DOWN";
|
|
32
35
|
this.filledDislikeIcon = "THUMBS_DOWN_PLAIN";
|
|
36
|
+
this.addI18nContext(feedback, defaultMessages);
|
|
37
|
+
this.addI18nContext(designer, defaultDesignerMessages);
|
|
33
38
|
}
|
|
34
39
|
get canAccessFeedback() {
|
|
35
40
|
return this.user && this.user.roles.includes("FEEDBACK_USER");
|
|
@@ -65,7 +70,7 @@ export class FtReaderFeedback extends FtLitElement {
|
|
|
65
70
|
<div class="ft-reader-feedback">
|
|
66
71
|
${this.hideTitle ? nothing : html `
|
|
67
72
|
<ft-typography variant="title" part="main-title">
|
|
68
|
-
${this.
|
|
73
|
+
${this.i18n(this.i18nProperties.feedbackMainTitle)}
|
|
69
74
|
</ft-typography>
|
|
70
75
|
`}
|
|
71
76
|
${this.renderRatingSection()}
|
|
@@ -78,7 +83,7 @@ export class FtReaderFeedback extends FtLitElement {
|
|
|
78
83
|
return html `
|
|
79
84
|
<div class="ft-reader-feedback--rating" part="rating-container">
|
|
80
85
|
<ft-typography variant="title-dense" part="section-title" class="ft-reader-feedback--section-title">
|
|
81
|
-
${this.ratingSummary.type === "DICHOTOMOUS" ? this.
|
|
86
|
+
${this.i18n(this.ratingSummary.type === "DICHOTOMOUS" ? this.i18nProperties.dichotomousRatingSectionTitle : this.i18nProperties.ratingSectionTitle)}
|
|
82
87
|
</ft-typography>
|
|
83
88
|
${this.renderRating()}
|
|
84
89
|
<ft-typography variant="caption" class="ft-reader-feedback--rating-date" part="rating-date">
|
|
@@ -87,22 +92,22 @@ export class FtReaderFeedback extends FtLitElement {
|
|
|
87
92
|
</div>
|
|
88
93
|
`;
|
|
89
94
|
}
|
|
90
|
-
return this.placeholderInEditor(
|
|
95
|
+
return this.placeholderInEditor((this.userHasRatingRole ? designer.messages.ratingNotConfigured() : designer.messages.missingRatingRole()));
|
|
91
96
|
}
|
|
92
97
|
renderRatingDate() {
|
|
93
98
|
const ratingDate = this.ratingDate;
|
|
94
99
|
if (ratingDate == null) {
|
|
95
|
-
return
|
|
100
|
+
return feedback.messages.notRated();
|
|
96
101
|
}
|
|
97
102
|
if (ratingDate.getTime() > (new Date().getTime() - 60000)) { // Less than 1 min ago
|
|
98
|
-
return
|
|
103
|
+
return feedback.messages.ratedNow();
|
|
99
104
|
}
|
|
100
105
|
const today = new Date().toLocaleDateString();
|
|
101
106
|
const formattedDate = ratingDate.toLocaleDateString();
|
|
102
107
|
if (today === formattedDate) {
|
|
103
|
-
return
|
|
108
|
+
return feedback.messages.ratedToday();
|
|
104
109
|
}
|
|
105
|
-
return
|
|
110
|
+
return feedback.messages.ratedOn(ratingDate);
|
|
106
111
|
}
|
|
107
112
|
renderRating() {
|
|
108
113
|
switch (this.configuredRatingType) {
|
|
@@ -114,7 +119,7 @@ export class FtReaderFeedback extends FtLitElement {
|
|
|
114
119
|
const ratingValue = index + 1;
|
|
115
120
|
return html `
|
|
116
121
|
<ft-button round part="rating-stars-${ratingValue}"
|
|
117
|
-
label="${
|
|
122
|
+
label="${feedback.messages.starsRating(ratingValue)}"
|
|
118
123
|
tooltipPosition="top"
|
|
119
124
|
.iconVariant=${this.iconVariant}
|
|
120
125
|
icon="${active ? this.filledStarIcon : this.emptyStarIcon}"
|
|
@@ -130,17 +135,17 @@ export class FtReaderFeedback extends FtLitElement {
|
|
|
130
135
|
const liked = this.ratingType === "LIKE" && this.ratingValue === 1;
|
|
131
136
|
return html `
|
|
132
137
|
<ft-switch @change=${(e) => this.rate(e.detail)} part="rating rating-like">
|
|
133
|
-
<ft-switch-option .value=${0}
|
|
134
|
-
?selected=${disliked}
|
|
135
|
-
.iconVariant=${this.iconVariant}
|
|
136
|
-
icon="${disliked ? this.filledDislikeIcon : this.emptyDislikeIcon}">
|
|
137
|
-
${this.labelResolver.resolve("dislike")}
|
|
138
|
-
</ft-switch-option>
|
|
139
138
|
<ft-switch-option .value=${1}
|
|
140
139
|
?selected=${liked}
|
|
141
140
|
.iconVariant=${this.iconVariant}
|
|
142
141
|
icon="${liked ? this.filledLikeIcon : this.emptyLikeIcon}">
|
|
143
|
-
${
|
|
142
|
+
${feedback.messages.like()}
|
|
143
|
+
</ft-switch-option>
|
|
144
|
+
<ft-switch-option .value=${0}
|
|
145
|
+
?selected=${disliked}
|
|
146
|
+
.iconVariant=${this.iconVariant}
|
|
147
|
+
icon="${disliked ? this.filledDislikeIcon : this.emptyDislikeIcon}">
|
|
148
|
+
${feedback.messages.dislike()}
|
|
144
149
|
</ft-switch-option>
|
|
145
150
|
</ft-switch>
|
|
146
151
|
`;
|
|
@@ -150,13 +155,13 @@ export class FtReaderFeedback extends FtLitElement {
|
|
|
150
155
|
return html `
|
|
151
156
|
<ft-switch @change=${(e) => this.rate(e.detail)}
|
|
152
157
|
part="rating rating-dichotomous">
|
|
153
|
-
<ft-switch-option .value=${0}
|
|
154
|
-
?selected=${no}>
|
|
155
|
-
${this.labelResolver.resolve("dichotomousNo")}
|
|
156
|
-
</ft-switch-option>
|
|
157
158
|
<ft-switch-option .value=${1}
|
|
158
159
|
?selected=${yes}>
|
|
159
|
-
${
|
|
160
|
+
${feedback.messages.dichotomousYes()}
|
|
161
|
+
</ft-switch-option>
|
|
162
|
+
<ft-switch-option .value=${0}
|
|
163
|
+
?selected=${no}>
|
|
164
|
+
${feedback.messages.dichotomousNo()}
|
|
160
165
|
</ft-switch-option>
|
|
161
166
|
</ft-switch>
|
|
162
167
|
`;
|
|
@@ -164,7 +169,9 @@ export class FtReaderFeedback extends FtLitElement {
|
|
|
164
169
|
return nothing;
|
|
165
170
|
}
|
|
166
171
|
rate(value) {
|
|
167
|
-
|
|
172
|
+
if ((value !== null && value !== void 0 ? value : -1) !== this.ratingValue) {
|
|
173
|
+
this.dispatchEvent(new CustomEvent("rate", { detail: value }));
|
|
174
|
+
}
|
|
168
175
|
}
|
|
169
176
|
renderFeedbackSection() {
|
|
170
177
|
if (this.canAccessFeedback) {
|
|
@@ -175,7 +182,7 @@ export class FtReaderFeedback extends FtLitElement {
|
|
|
175
182
|
?disabled=${!this.feedbackMessage}
|
|
176
183
|
@click=${() => mailLink ? this.clearFeedbackInput() : this.sendFeedback()}
|
|
177
184
|
part="send-feedback">
|
|
178
|
-
${
|
|
185
|
+
${feedback.messages.okButton()}
|
|
179
186
|
</ft-button>
|
|
180
187
|
`;
|
|
181
188
|
if (mailLink) {
|
|
@@ -188,18 +195,18 @@ export class FtReaderFeedback extends FtLitElement {
|
|
|
188
195
|
return html `
|
|
189
196
|
<div class="ft-reader-feedback--feedback" part="feedback-container">
|
|
190
197
|
<ft-typography variant="title-dense" part="section-title" class="ft-reader-feedback--section-title">
|
|
191
|
-
${this.
|
|
198
|
+
${this.i18n(this.i18nProperties.feedbackSectionTitle)}
|
|
192
199
|
</ft-typography>
|
|
193
200
|
<ft-text-area outlined
|
|
194
201
|
class="ft-reader-feedback--feedback-input" part="feedback-input"
|
|
195
|
-
label="${
|
|
202
|
+
label="${feedback.messages.feedbackInputLabel()}"
|
|
196
203
|
@live-change=${(e) => this.feedbackMessage = e.detail.trim()}
|
|
197
204
|
></ft-text-area>
|
|
198
205
|
${button}
|
|
199
206
|
</div>
|
|
200
207
|
`;
|
|
201
208
|
}
|
|
202
|
-
return this.placeholderInEditor(
|
|
209
|
+
return this.placeholderInEditor(designer.messages.missingFeedbackRole());
|
|
203
210
|
}
|
|
204
211
|
sendFeedback() {
|
|
205
212
|
this.dispatchEvent(new CustomEvent("send-feedback", { detail: this.feedbackInput.value }));
|
|
@@ -209,7 +216,7 @@ export class FtReaderFeedback extends FtLitElement {
|
|
|
209
216
|
<div class="ft-reader-feedback--placeholder">
|
|
210
217
|
<ft-typography variant="caption">${message}</ft-typography>
|
|
211
218
|
<ft-tooltip position="left"
|
|
212
|
-
text="
|
|
219
|
+
text="${designer.messages.inDesignerOnlyNotice()}">
|
|
213
220
|
<ft-icon>INFO</ft-icon>
|
|
214
221
|
</ft-tooltip>
|
|
215
222
|
</div>
|
|
@@ -230,7 +237,7 @@ FtReaderFeedback.elementDefinitions = {
|
|
|
230
237
|
};
|
|
231
238
|
FtReaderFeedback.styles = styles;
|
|
232
239
|
__decorate([
|
|
233
|
-
property({
|
|
240
|
+
property({ type: Boolean })
|
|
234
241
|
], FtReaderFeedback.prototype, "editorMode", void 0);
|
|
235
242
|
__decorate([
|
|
236
243
|
property({ type: Boolean })
|
|
@@ -240,7 +247,7 @@ __decorate([
|
|
|
240
247
|
], FtReaderFeedback.prototype, "ratingAllowed", void 0);
|
|
241
248
|
__decorate([
|
|
242
249
|
property({ attribute: false })
|
|
243
|
-
], FtReaderFeedback.prototype, "
|
|
250
|
+
], FtReaderFeedback.prototype, "i18nProperties", void 0);
|
|
244
251
|
__decorate([
|
|
245
252
|
property({ attribute: false })
|
|
246
253
|
], FtReaderFeedback.prototype, "ratingSummary", void 0);
|