@fluid-topics/ft-reader-feedback 1.0.57 → 1.0.59
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 +3 -2
- package/build/ft-reader-feedback.js +37 -32
- package/build/ft-reader-feedback.light.js +349 -340
- package/build/ft-reader-feedback.min.js +393 -384
- package/build/ft-reader-map-feedback.d.ts +2 -2
- package/build/ft-reader-map-feedback.js +12 -15
- package/build/ft-reader-topic-feedback.d.ts +2 -2
- package/build/ft-reader-topic-feedback.js +12 -14
- package/package.json +5 -5
|
@@ -2,7 +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,
|
|
5
|
+
import type { FtPublicationRatingSummary, FtSession } from "@fluid-topics/public-api";
|
|
6
6
|
import { FtReaderFeedbackConfiguration } from "@fluid-topics/public-api";
|
|
7
7
|
import { FtTextArea } from "@fluid-topics/ft-text-area";
|
|
8
8
|
import { FtIconVariants } from "@fluid-topics/ft-icon/build/ft-icon.properties";
|
|
@@ -27,7 +27,7 @@ export declare class FtReaderFeedback extends FtReaderFeedback_base implements F
|
|
|
27
27
|
ratingAllowed: boolean;
|
|
28
28
|
i18nProperties: FeedbackI18nProperties;
|
|
29
29
|
ratingSummary?: FtPublicationRatingSummary | FtTopicRatingSummary;
|
|
30
|
-
|
|
30
|
+
session?: FtSession;
|
|
31
31
|
feedbackInput: FtTextArea;
|
|
32
32
|
from: string;
|
|
33
33
|
feedbackMessage: string;
|
|
@@ -54,6 +54,7 @@ export declare class FtReaderFeedback extends FtReaderFeedback_base implements F
|
|
|
54
54
|
private renderRating;
|
|
55
55
|
private rate;
|
|
56
56
|
private renderFeedbackSection;
|
|
57
|
+
private onFormSubmitEvent;
|
|
57
58
|
private validFromEmail;
|
|
58
59
|
private sendFeedback;
|
|
59
60
|
private placeholderInEditor;
|
|
@@ -21,7 +21,7 @@ import { withI18n } from "@fluid-topics/ft-i18n";
|
|
|
21
21
|
import { defaultDesignerMessages, designer } from "./utils/InDesignerFeedbackComponentMessages";
|
|
22
22
|
import { FtTextField } from "@fluid-topics/ft-text-field";
|
|
23
23
|
import { FtReaderComponent } from "@fluid-topics/ft-reader-context/build/registration";
|
|
24
|
-
import { FtReaderFeatures } from "@fluid-topics/ft-reader-context
|
|
24
|
+
import { FtReaderFeatures } from "@fluid-topics/ft-reader-context";
|
|
25
25
|
class FtReaderFeedback extends withI18n(FtReaderComponent) {
|
|
26
26
|
constructor() {
|
|
27
27
|
super();
|
|
@@ -41,14 +41,14 @@ class FtReaderFeedback extends withI18n(FtReaderComponent) {
|
|
|
41
41
|
}
|
|
42
42
|
get canAccessFeedback() {
|
|
43
43
|
var _a;
|
|
44
|
-
return
|
|
44
|
+
return (_a = this.service) === null || _a === void 0 ? void 0 : _a.isFeatureAccessible(FtReaderFeatures.FEEDBACK, { session: this.session });
|
|
45
45
|
}
|
|
46
46
|
get canAccessRating() {
|
|
47
|
-
var _a;
|
|
48
|
-
return
|
|
47
|
+
var _a, _b;
|
|
48
|
+
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 });
|
|
49
49
|
}
|
|
50
50
|
get userHasRatingRole() {
|
|
51
|
-
return this.
|
|
51
|
+
return this.session && userHasRole(this.session, "RATING_USER");
|
|
52
52
|
}
|
|
53
53
|
get configuredRatingType() {
|
|
54
54
|
var _a, _b;
|
|
@@ -74,10 +74,10 @@ class FtReaderFeedback extends withI18n(FtReaderComponent) {
|
|
|
74
74
|
return html `
|
|
75
75
|
<div class="ft-reader-feedback">
|
|
76
76
|
${this.hideTitle ? nothing : html `
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
<ft-typography variant="title" part="main-title">
|
|
78
|
+
${this.i18n(this.i18nProperties.feedbackMainTitle)}
|
|
79
|
+
</ft-typography>
|
|
80
|
+
`}
|
|
81
81
|
${this.renderRatingSection()}
|
|
82
82
|
${this.renderFeedbackSection()}
|
|
83
83
|
</div>
|
|
@@ -127,17 +127,17 @@ class FtReaderFeedback extends withI18n(FtReaderComponent) {
|
|
|
127
127
|
let active = this.ratingType === "STARS" && this.ratingValue > index;
|
|
128
128
|
const ratingValue = index + 1;
|
|
129
129
|
return html `
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
130
|
+
<ft-button round part="rating-stars-${ratingValue}"
|
|
131
|
+
label="${feedback.messages.starsRating(ratingValue)}"
|
|
132
|
+
tooltipPosition="top"
|
|
133
|
+
.iconVariant=${this.iconVariant}
|
|
134
|
+
icon="${active ? this.filledStarIcon : this.emptyStarIcon}"
|
|
135
|
+
class="ft-reader-feedback--${active ? "active" : "inactive"}"
|
|
136
|
+
@click=${() => this.rate(this.ratingValue === ratingValue
|
|
137
137
|
? undefined
|
|
138
138
|
: ratingValue)}
|
|
139
|
-
|
|
140
|
-
|
|
139
|
+
></ft-button>
|
|
140
|
+
`;
|
|
141
141
|
})}
|
|
142
142
|
</div>
|
|
143
143
|
`;
|
|
@@ -188,14 +188,14 @@ class FtReaderFeedback extends withI18n(FtReaderComponent) {
|
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
190
|
renderFeedbackSection() {
|
|
191
|
-
var _a, _b;
|
|
191
|
+
var _a, _b, _c;
|
|
192
192
|
if (this.canAccessFeedback) {
|
|
193
193
|
const mailLink = this.feedbackMailLinkBuilder(this.feedbackMessage);
|
|
194
194
|
let button = html `
|
|
195
195
|
<ft-button primary
|
|
196
|
+
type="submit" name="submit"
|
|
196
197
|
class="ft-reader-feedback--send-feedback"
|
|
197
198
|
?disabled=${!this.feedbackMessage || !this.validFromEmail()}
|
|
198
|
-
@click=${() => mailLink ? this.onMailerFeedbackSent() : this.sendFeedback()}
|
|
199
199
|
part="send-feedback">
|
|
200
200
|
${feedback.messages.okButton()}
|
|
201
201
|
</ft-button>
|
|
@@ -208,17 +208,18 @@ class FtReaderFeedback extends withI18n(FtReaderComponent) {
|
|
|
208
208
|
`;
|
|
209
209
|
}
|
|
210
210
|
return html `
|
|
211
|
-
<
|
|
211
|
+
<form class="ft-reader-feedback--feedback" part="feedback-container" autocomplete="on"
|
|
212
|
+
@submit="${(e) => this.onFormSubmitEvent(e, !!mailLink)}">
|
|
212
213
|
<ft-typography variant="title-dense" part="section-title" class="ft-reader-feedback--section-title">
|
|
213
214
|
${this.i18n(this.i18nProperties.feedbackSectionTitle)}
|
|
214
215
|
</ft-typography>
|
|
215
|
-
${((_a = this.
|
|
216
|
-
<ft-text-field outlined
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
216
|
+
${((_b = (_a = this.session) === null || _a === void 0 ? void 0 : _a.profile) === null || _b === void 0 ? void 0 : _b.userId) == null && ((_c = this.configuration) === null || _c === void 0 ? void 0 : _c.mailsSentByFluidTopicsForUnauthenticatedUsers) ? html `
|
|
217
|
+
<ft-text-field outlined name="email" type="email" autocomplete="email"
|
|
218
|
+
class="ft-reader-feedback--from-input"
|
|
219
|
+
label=${feedback.messages.feedbackfromEmail()}
|
|
220
|
+
@change=${(e) => this.from = e.detail.trim()}
|
|
221
|
+
?error=${this.from && !this.validFromEmail()}
|
|
222
|
+
helper=${this.from && !this.validFromEmail() ? feedback.messages.feedbackfromEmailInvalid() : ""}
|
|
222
223
|
/>
|
|
223
224
|
` : nothing}
|
|
224
225
|
<ft-text-area outlined
|
|
@@ -227,15 +228,19 @@ class FtReaderFeedback extends withI18n(FtReaderComponent) {
|
|
|
227
228
|
@live-change=${(e) => this.feedbackMessage = e.detail.trim()}
|
|
228
229
|
></ft-text-area>
|
|
229
230
|
${button}
|
|
230
|
-
</
|
|
231
|
+
</form>
|
|
231
232
|
`;
|
|
232
233
|
}
|
|
233
234
|
return this.placeholderInEditor(designer.messages.missingFeedbackRole());
|
|
234
235
|
}
|
|
236
|
+
onFormSubmitEvent(event, isUsingMailLink) {
|
|
237
|
+
event.preventDefault();
|
|
238
|
+
isUsingMailLink ? this.onMailerFeedbackSent() : this.sendFeedback();
|
|
239
|
+
}
|
|
235
240
|
validFromEmail() {
|
|
236
|
-
var _a, _b;
|
|
241
|
+
var _a, _b, _c;
|
|
237
242
|
const expression = /^[a-zA-Z0-9_+&*-]+(?:\.[a-zA-Z0-9_+&*-]+)*@(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}$/;
|
|
238
|
-
return !(((_a = this.
|
|
243
|
+
return !(((_b = (_a = this.session) === null || _a === void 0 ? void 0 : _a.profile) === null || _b === void 0 ? void 0 : _b.userId) == null && ((_c = this.configuration) === null || _c === void 0 ? void 0 : _c.mailsSentByFluidTopicsForUnauthenticatedUsers))
|
|
239
244
|
|| expression.test(this.from);
|
|
240
245
|
}
|
|
241
246
|
sendFeedback() {
|
|
@@ -293,7 +298,7 @@ __decorate([
|
|
|
293
298
|
], FtReaderFeedback.prototype, "ratingSummary", void 0);
|
|
294
299
|
__decorate([
|
|
295
300
|
property({ attribute: false })
|
|
296
|
-
], FtReaderFeedback.prototype, "
|
|
301
|
+
], FtReaderFeedback.prototype, "session", void 0);
|
|
297
302
|
__decorate([
|
|
298
303
|
query(".ft-reader-feedback--feedback-input")
|
|
299
304
|
], FtReaderFeedback.prototype, "feedbackInput", void 0);
|