Selaa lähdekoodia

fix: "You viewed/edited/created this" (#17365)

### Issues
In the form timeline we show events like “{user} {created/viewed/edited} this {some_time_ago}”. If user is the current user, we used “You” instead of “Jon Doe”. This works in English, but in other languages it messes up the rest of the sentence.

Because of this, people added wrong translations of “You” that made the grammar work, but also made the message less clear.

Also, the _last viewed_ message used to link to **View Log**. That can be read by system managers only and doesn't hold additional information. So it's just a source of errors for users trying to click on it.

### Fixes

- don't mix up users and salutations. Always show user's full name.
- change the _last viewed_ message to work like the other two, remove link to **View Log**

### Demo

Logged an as Administrator:

English

![Bildschirmfoto 2022-06-30 um 15 28 37](https://user-images.githubusercontent.com/14891507/176689772-dd878c90-4a2c-4a32-aa6c-d2e14a6340e1.png)

German

![Bildschirmfoto 2022-06-30 um 15 28 03](https://user-images.githubusercontent.com/14891507/176689812-ce13bb31-6c70-40f2-8699-6fb0db1d06f9.png)
version-14
Raffael Meyer 2 vuotta sitten
committed by GitHub
vanhempi
commit
f4fa4d303f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 muutettua tiedostoa jossa 44 lisäystä ja 20 poistoa
  1. +38
    -19
      frappe/public/js/frappe/form/footer/form_timeline.js
  2. +5
    -1
      frappe/public/js/frappe/utils/utils.js
  3. +1
    -0
      frappe/translations/de.csv

+ 38
- 19
frappe/public/js/frappe/form/footer/form_timeline.js Näytä tiedosto

@@ -103,20 +103,34 @@ class FormTimeline extends BaseTimeline {

set_document_info() {
// TODO: handle creation via automation
let creation_message = __("{0} created this {1}", [
this.get_user_link(this.frm.doc.owner),
comment_when(this.frm.doc.creation)
]);

let modified_message = __("{0} edited this {1}", [
this.get_user_link(this.frm.doc.modified_by),
comment_when(this.frm.doc.modified),
]);
const creation = comment_when(this.frm.doc.creation);
let creation_message =
frappe.utils.is_current_user(this.frm.doc.owner)
? __("You created this {0}", [creation], "Form timeline")
: __("{0} created this {1}",
[
this.get_user_link(this.frm.doc.owner),
creation
],
"Form timeline"
);

const modified = comment_when(this.frm.doc.modified);
let modified_message =
frappe.utils.is_current_user(this.frm.doc.modified_by)
? __("You edited this {0}", [modified], "Form timeline")
: __("{0} edited this {1}",
[
this.get_user_link(this.frm.doc.modified_by),
modified
],
"Form timeline"
);

if (this.frm.doc.route && cint(frappe.boot.website_tracking_enabled)) {
let route = this.frm.doc.route;
frappe.utils.get_page_view_count(route).then((res) => {
let page_view_count_message = __('{0} Page views', [res.message]);
let page_view_count_message = __('{0} Page views', [res.message], "Form timeline");
this.add_timeline_item({
content: `${creation_message} • ${modified_message} • ${page_view_count_message}`,
hide_timestamp: true
@@ -150,23 +164,28 @@ class FormTimeline extends BaseTimeline {
}

get_user_link(user) {
const user_display_text = (
(frappe.session.user == user ? __("You") : frappe.user_info(user).fullname) || ''
).bold();
const user_display_text = (frappe.user_info(user).fullname || '').bold();
return frappe.utils.get_form_link('User', user, true, user_display_text);
}

get_view_timeline_contents() {
let view_timeline_contents = [];
(this.doc_info.views || []).forEach(view => {
let view_content = `
<a href="${frappe.utils.get_form_link('View Log', view.name)}">
${__("{0} viewed", [this.get_user_link(view.owner)])}
</a>
`;
const view_time = comment_when(view.creation);
let view_message = frappe.utils.is_current_user(view.owner)
? __("You viewed this {0}", [view_time], "Form timeline")
: __("{0} viewed this {1}",
[
this.get_user_link(view.owner),
view_time
],
"Form timeline"
);

view_timeline_contents.push({
creation: view.creation,
content: view_content,
content: view_message,
hide_timestamp: true,
});
});
return view_timeline_contents;


+ 5
- 1
frappe/public/js/frappe/utils/utils.js Näytä tiedosto

@@ -1532,5 +1532,9 @@ Object.assign(frappe.utils, {

load_video_player() {
return frappe.require("video_player.bundle.js");
}
},

is_current_user(user) {
return user === frappe.session.user;
},
});

+ 1
- 0
frappe/translations/de.csv Näytä tiedosto

@@ -4728,6 +4728,7 @@ Hide Saved,Gespeicherte ausblenden,
Show Saved,Gespeicherte anzeigen,
{0} created this {1},{0} erstellte dies {1},
{0} edited this {1},{0} bearbeitete dies {1},
{0} viewed this {1},{0} sah sich dies {1} an,
Toggle Full Width,Toggle Volle Breite,
Documentation,Dokumentation,
About,Über,


Ladataan…
Peruuta
Tallenna