Last fixes to the reviews
This commit is contained in:
parent
d80037e407
commit
a53c4119e5
8 changed files with 59 additions and 23 deletions
|
@ -135,7 +135,8 @@ export default class AllTranslationAssets {
|
|||
affiliated_reviewer_warning: new Translation( {"en":"(Affiliated review)","nl":"(Review door betrokkene)"} ),
|
||||
saving_review: new Translation( {"en":"Saving...","nl":"Opslaan..."} ),
|
||||
saved: new Translation( {"en":"<span class='thanks'>Review saved. Thanks for sharing!</span>","nl":"<span class='thanks'>Bedankt om je beoordeling te delen!</span>"} ),
|
||||
attribution: new Translation( {"en":"Reviews are powered by <a href='https://mangrove.reviews/' target='_blank'>Mangrove Reviews</a> and are available under <a href='https://mangrove.reviews/terms#8-licensing-of-content' target='_blank'>CC-BY 4.0</a>","nl":"De beoordelingen worden voorzien door <a href='https://mangrove.reviews/' target='_blank'>Mangrove Reviews</a> en zijn beschikbaar onder de<a href='https://mangrove.reviews/terms#8-licensing-of-content' target='_blank'>CC-BY 4.0-licentie</a> "} ),
|
||||
tos: new Translation( {"en":"If you create a review, you agree to <a href='https://mangrove.reviews/terms' target='_blank'>the TOS and privacy policy of Mangrove.reviews</a>","nl":"Als je je review publiceert, ga je akkoord met de <a href='https://mangrove.reviews/terms' target='_blank'>de gebruiksvoorwaarden en privacy policy van Mangrove.reviews</a>"} ),
|
||||
attribution: new Translation( {"en":"Reviews are powered by <a href='https://mangrove.reviews/' target='_blank'>Mangrove Reviews</a> and are available under <a href='https://mangrove.reviews/terms#8-licensing-of-content' target='_blank'>CC-BY 4.0</a>.","nl":"De beoordelingen worden voorzien door <a href='https://mangrove.reviews/' target='_blank'>Mangrove Reviews</a> en zijn beschikbaar onder de<a href='https://mangrove.reviews/terms#8-licensing-of-content' target='_blank'>CC-BY 4.0-licentie</a>. "} ),
|
||||
plz_login: new Translation( {"en":"Login to leave a review","nl":"Meld je aan om een beoordeling te geven"} ),
|
||||
},
|
||||
}}
|
|
@ -13,6 +13,7 @@ export class MangroveIdentity {
|
|||
if (str === undefined || str === "") {
|
||||
return;
|
||||
}
|
||||
console.log("JWK ", JSON.parse(str));
|
||||
mangrove.jwkToKeypair(JSON.parse(str)).then(keypair => {
|
||||
self.keypair = keypair;
|
||||
console.log("Identity loaded")
|
||||
|
@ -113,15 +114,24 @@ export default class MangroveReviews {
|
|||
mangrove.getReviews({sub: this.GetSubjectUri()}).then(
|
||||
(data) => {
|
||||
const reviews = [];
|
||||
const reviewsByUser = [];
|
||||
for (const review of data.reviews) {
|
||||
const r = review.payload;
|
||||
reviews.push({
|
||||
console.log("PublicKey is ",self._mangroveIdentity.keypair, "reviews is",review.signature);
|
||||
const byUser = self._mangroveIdentity.keypair.publicKey === review.signature;
|
||||
console.log("IS SAME: ", byUser);
|
||||
const rev: Review = {
|
||||
made_by_user: byUser,
|
||||
date: new Date(r.iat * 1000),
|
||||
comment: r.opinion,
|
||||
author: r.metadata.nickname,
|
||||
affiliated: r.metadata.is_affiliated,
|
||||
rating: r.rating // percentage points
|
||||
})
|
||||
};
|
||||
|
||||
|
||||
|
||||
(rev.made_by_user ? reviewsByUser : reviews).push(rev);
|
||||
}
|
||||
self._reviews.setData(reviews)
|
||||
}
|
||||
|
@ -141,18 +151,37 @@ export default class MangroveReviews {
|
|||
rating: r.rating,
|
||||
opinion: r.comment,
|
||||
metadata: {
|
||||
is_affiliated: r.affiliated,
|
||||
nickname: r.author,
|
||||
}
|
||||
};
|
||||
if (this._dryRun) {
|
||||
console.log("DRYRUNNING mangrove reviews: ", payload);
|
||||
} else {
|
||||
mangrove.signAndSubmitReview(this._mangroveIdentity.keypair, payload).then(callback)
|
||||
if (r.affiliated) {
|
||||
// @ts-ignore
|
||||
payload.metadata.is_affiliated = true;
|
||||
}
|
||||
this._reviews.data.push(r);
|
||||
this._reviews.ping();
|
||||
callback();
|
||||
if (this._dryRun) {
|
||||
console.warn("DRYRUNNING mangrove reviews: ", payload);
|
||||
if (callback) {
|
||||
if (callback) {
|
||||
console.log("Calling callback")
|
||||
callback();
|
||||
}
|
||||
this._reviews.data.push(r);
|
||||
this._reviews.ping();
|
||||
|
||||
}
|
||||
} else {
|
||||
mangrove.signAndSubmitReview(this._mangroveIdentity.keypair, payload).then(() => {
|
||||
if (callback) {
|
||||
console.log("Calling callback")
|
||||
callback();
|
||||
}
|
||||
this._reviews.data.push(r);
|
||||
this._reviews.ping();
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -3,5 +3,9 @@ export interface Review {
|
|||
author: string,
|
||||
date: Date,
|
||||
rating: number,
|
||||
affiliated: boolean
|
||||
affiliated: boolean,
|
||||
/**
|
||||
* True if the current logged in user is the creator of this comment
|
||||
*/
|
||||
made_by_user: boolean
|
||||
}
|
2
State.ts
2
State.ts
|
@ -24,7 +24,7 @@ export default class State {
|
|||
// The singleton of the global state
|
||||
public static state: State;
|
||||
|
||||
public static vNumber = "0.2.5-rc1";
|
||||
public static vNumber = "0.2.5-rc2";
|
||||
|
||||
// The user journey states thresholds when a new feature gets unlocked
|
||||
public static userJourney = {
|
||||
|
|
|
@ -27,6 +27,7 @@ export default class ReviewForm extends InputElement<Review> {
|
|||
this.userDetails = userDetails;
|
||||
const t = Translations.t.reviews;
|
||||
this._value = new UIEventSource({
|
||||
made_by_user: false,
|
||||
rating: undefined,
|
||||
comment: undefined,
|
||||
author: userDetails.data.name,
|
||||
|
@ -53,7 +54,7 @@ export default class ReviewForm extends InputElement<Review> {
|
|||
.onClick(() => {
|
||||
self._saveButton = Translations.t.reviews.saving_review;
|
||||
onSave(this._value.data, () => {
|
||||
self._saveButton = Translations.t.reviews.saved;
|
||||
self._saveButton = Translations.t.reviews.saved.SetClass("thanks");
|
||||
});
|
||||
})
|
||||
|
||||
|
@ -97,7 +98,9 @@ export default class ReviewForm extends InputElement<Review> {
|
|||
new Combine([
|
||||
this._isAffiliated,
|
||||
this._saveButton
|
||||
]).SetClass("review-form-bottom")
|
||||
]).SetClass("review-form-bottom"),
|
||||
"<br/>",
|
||||
Translations.t.reviews.tos.SetClass("subtle")
|
||||
])
|
||||
.SetClass("review-form")
|
||||
.Render();
|
||||
|
|
|
@ -168,7 +168,7 @@ export default class SpecialVisualizations {
|
|||
State.state.mangroveIdentity,
|
||||
State.state.osmConnection._dryRun
|
||||
);
|
||||
const form = new ReviewForm(r => mangrove.AddReview(r), State.state.osmConnection.userDetails);
|
||||
const form = new ReviewForm((r, whenDone) => mangrove.AddReview(r, whenDone), State.state.osmConnection.userDetails);
|
||||
return new ReviewElement(mangrove.GetSubjectUri(), mangrove.GetReviews(), form);
|
||||
}
|
||||
},
|
||||
|
|
|
@ -953,9 +953,13 @@
|
|||
"en": "<span class='thanks'>Review saved. Thanks for sharing!</span>",
|
||||
"nl": "<span class='thanks'>Bedankt om je beoordeling te delen!</span>"
|
||||
},
|
||||
"tos": {
|
||||
"en": "If you create a review, you agree to <a href='https://mangrove.reviews/terms' target='_blank'>the TOS and privacy policy of Mangrove.reviews</a>",
|
||||
"nl": "Als je je review publiceert, ga je akkoord met de <a href='https://mangrove.reviews/terms' target='_blank'>de gebruiksvoorwaarden en privacy policy van Mangrove.reviews</a>"
|
||||
},
|
||||
"attribution": {
|
||||
"en": "Reviews are powered by <a href='https://mangrove.reviews/' target='_blank'>Mangrove Reviews</a> and are available under <a href='https://mangrove.reviews/terms#8-licensing-of-content' target='_blank'>CC-BY 4.0</a>",
|
||||
"nl": "De beoordelingen worden voorzien door <a href='https://mangrove.reviews/' target='_blank'>Mangrove Reviews</a> en zijn beschikbaar onder de<a href='https://mangrove.reviews/terms#8-licensing-of-content' target='_blank'>CC-BY 4.0-licentie</a> "
|
||||
"en": "Reviews are powered by <a href='https://mangrove.reviews/' target='_blank'>Mangrove Reviews</a> and are available under <a href='https://mangrove.reviews/terms#8-licensing-of-content' target='_blank'>CC-BY 4.0</a>.",
|
||||
"nl": "De beoordelingen worden voorzien door <a href='https://mangrove.reviews/' target='_blank'>Mangrove Reviews</a> en zijn beschikbaar onder de<a href='https://mangrove.reviews/terms#8-licensing-of-content' target='_blank'>CC-BY 4.0-licentie</a>. "
|
||||
},
|
||||
"plz_login": {
|
||||
"en": "Login to leave a review",
|
||||
|
|
5
package-lock.json
generated
5
package-lock.json
generated
|
@ -6805,11 +6805,6 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"jose": {
|
||||
"version": "3.3.1",
|
||||
"resolved": "https://registry.npmjs.org/jose/-/jose-3.3.1.tgz",
|
||||
"integrity": "sha512-dMVfVKnyJyl2d9OBkwu/nvheGh9fbS1khhkJdvbGnINNe8IUfSJ/U+BXJOQvk65BCIJ58lp7xQKJTGQQ5dxrZA=="
|
||||
},
|
||||
"jquery": {
|
||||
"version": "3.5.1",
|
||||
"resolved": "https://registry.npmjs.org/jquery/-/jquery-3.5.1.tgz",
|
||||
|
|
Loading…
Reference in a new issue