fix: scroll, translations, naming series, placeholder and variable definition

This commit is contained in:
pateljannat 2021-09-28 12:51:28 +05:30
parent bd184ccec3
commit 47fab75bcd
8 changed files with 63 additions and 64 deletions

View file

@ -1,7 +1,7 @@
{% if frappe.session.user != "Guest" and
(condition is not defined or (condition is defined and condition )) %}
<span class="button is-secondary reply">
{{ cta_title }}
<svg class="icon icon-sm ml-1"><use href="#icon-add" style="stroke: #4C5A67;"></use></svg>
{{ _(cta_title) }}
<svg class="icon icon-sm ml-1"><use href="#icon-add" style="stroke: var(--gray-700)"></use></svg>
</span>
{% endif %}

View file

@ -4,7 +4,7 @@
<div class="control-input-wrapper">
<div class="control-input">
<input type="text" autocomplete="off" class="input-with-feedback form-control topic-title" data-fieldtype="Data"
data-fieldname="feedback_comments" placeholder="Title" spellcheck="false"></input>
data-fieldname="feedback_comments" placeholder="{{ _('Type title') }}" spellcheck="false"></input>
</div>
</div>
</div>
@ -13,7 +13,7 @@
<div class="control-input-wrapper">
<div class="control-input">
<textarea type="text" autocomplete="off" class="input-with-feedback form-control comment-field"
data-fieldtype="Text" data-fieldname="feedback_comments" placeholder="Enter your comment here..."
data-fieldtype="Text" data-fieldname="feedback_comments" placeholder="{{ _('Type here. Use markdown to format.') }}"
spellcheck="false"></textarea>
</div>
</div>
@ -21,12 +21,12 @@
<div class="comment-footer">
<div class="small flex-grow-1">
Press Cmd+Enter to post your comment
{{ _("Press Cmd+Enter to post your comment") }}
</div>
<a class="dark-links cancel-comment hide"> Cancel </a>
<a class="dark-links cancel-comment hide"> {{ _("Cancel") }} </a>
<div class="button is-default submit-discussion pull-right mb-1" data-doctype="{{ doctype | urlencode }}"
data-docname="{{ docname | urlencode }}">
Post</div>
{{ _("Post") }} </div>
</div>
</form>

View file

@ -62,14 +62,14 @@ frappe.ready(() => {
});
var show_new_topic_modal = (e) => {
const show_new_topic_modal = (e) => {
e.preventDefault();
$("#discussion-modal").modal("show");
var topic = $(e.currentTarget).attr("data-topic");
let topic = $(e.currentTarget).attr("data-topic");
$("#submit-discussion").attr("data-topic", topic ? topic : "");
};
var setup_socket_io = () => {
const setup_socket_io = () => {
const assets = [
"/assets/frappe/js/lib/socket.io.min.js",
"/assets/frappe/js/frappe/socketio_client.js"
@ -86,7 +86,7 @@ var setup_socket_io = () => {
});
};
var publish_message = (data) => {
const publish_message = (data) => {
if ($(`.discussion-on-page[data-topic=${data.topic_info.name}]`).length) {
post_message_cleanup();
@ -112,7 +112,7 @@ var publish_message = (data) => {
update_reply_count(data.topic_info.name);
};
var post_message_cleanup = () => {
const post_message_cleanup = () => {
$(".topic-title").val("");
$(".comment-field").val("");
$(".discussion-on-page .comment-field").css("height", "48px");
@ -121,13 +121,13 @@ var post_message_cleanup = () => {
$(".cancel-comment").addClass("hide");
};
var update_reply_count = (topic) => {
var reply_count = $(`[data-target='#t${topic}']`).find(".reply-count").text();
const update_reply_count = (topic) => {
let reply_count = $(`[data-target='#t${topic}']`).find(".reply-count").text();
reply_count = parseInt(reply_count) + 1;
$(`[data-target='#t${topic}']`).find(".reply-count").text(reply_count);
};
var expand_first_discussion = () => {
const expand_first_discussion = () => {
if ($(document).width() > 550) {
$($(".discussions-parent .collapse")[0]).addClass("show");
$($(".discussions-sidebar [data-toggle='collapse']")[0]).attr("aria-expanded", true);
@ -136,22 +136,22 @@ var expand_first_discussion = () => {
}
};
var search_topic = (e) => {
var input = $(e.currentTarget).val();
const search_topic = (e) => {
let input = $(e.currentTarget).val();
var topics = $(".discussions-parent .discussion-topic-title");
let topics = $(".discussions-parent .discussion-topic-title");
if (input.length < 3 || input.trim() == "") {
topics.closest(".sidebar-parent").removeClass("hide");
return;
}
topics.each((i, elem) => {
var topic_id = $(elem).parent().attr("data-target");
let topic_id = $(elem).parent().attr("data-target");
/* Check match in replies */
var match_in_reply = false;
var replies = $(`${topic_id}`);
for (var reply of replies.find(".reply-text")) {
let match_in_reply = false;
const replies = $(`${topic_id}`);
for (const reply of replies.find(".reply-text")) {
if (has_common_substring($(reply).text(), input)) {
match_in_reply = true;
break;
@ -167,13 +167,13 @@ var search_topic = (e) => {
});
};
var has_common_substring = (str1, str2) => {
var str1_arr = str1.toLowerCase().split(" ");
var str2_arr = str2.toLowerCase().split(" ");
const has_common_substring = (str1, str2) => {
const str1_arr = str1.toLowerCase().split(" ");
const str2_arr = str2.toLowerCase().split(" ");
var substring_found = false;
for (var first_word of str1_arr) {
for (var second_word of str2_arr) {
let substring_found = false;
for (const first_word of str1_arr) {
for (const second_word of str2_arr) {
if (first_word.indexOf(second_word) > -1) {
substring_found = true;
break;
@ -183,18 +183,18 @@ var has_common_substring = (str1, str2) => {
return substring_found;
};
var submit_discussion = (e) => {
const submit_discussion = (e) => {
e.preventDefault();
e.stopImmediatePropagation();
var title = $(".topic-title:visible").length ? $(".topic-title:visible").val().trim() : "";
var reply = $(".comment-field:visible").val().trim();
const title = $(".topic-title:visible").length ? $(".topic-title:visible").val().trim() : "";
const reply = $(".comment-field:visible").val().trim();
if (reply) {
var doctype = $(e.currentTarget).attr("data-doctype");
let doctype = $(e.currentTarget).attr("data-doctype");
doctype = doctype ? decodeURIComponent(doctype) : doctype;
var docname = $(e.currentTarget).attr("data-docname");
let docname = $(e.currentTarget).attr("data-docname");
docname = docname ? decodeURIComponent(docname) : docname;
frappe.call({
@ -210,14 +210,14 @@ var submit_discussion = (e) => {
}
};
var login_from_discussion = (e) => {
const login_from_discussion = (e) => {
e.preventDefault();
var redirect = $(e.currentTarget).attr("data-redirect") || window.location.href;
const redirect = $(e.currentTarget).attr("data-redirect") || window.location.href;
window.location.href = `/login?redirect-to=${redirect}`;
};
var add_color_to_avatars = () => {
var avatars = $(".avatar-frame");
const add_color_to_avatars = () => {
const avatars = $(".avatar-frame");
avatars.each((i, avatar) => {
if (!$(avatar).attr("style")) {
$(avatar).css(get_color_from_palette($(avatar)));
@ -225,31 +225,29 @@ var add_color_to_avatars = () => {
});
};
var get_color_from_palette = (element) => {
var palette = frappe.get_palette(element.attr("title"));
const get_color_from_palette = (element) => {
const palette = frappe.get_palette(element.attr("title"));
return {"background-color": `var(${palette[0]})`, "color": `var(${palette[1]})` };
};
var style_avatar_frame = (template) => {
var $template = $(template);
const style_avatar_frame = (template) => {
const $template = $(template);
$template.find(".avatar-frame").css(get_color_from_palette($template.find(".avatar-frame")));
return $template.prop("outerHTML");
};
var clear_comment_box = () => {
if ($(".discussion-modal").hasClass("show")) {
$("#discussion-modal").modal("hide");
} else {
$(".discussion-on-page .comment-field").val("");
}
const clear_comment_box = () => {
$(".discussion-on-page .comment-field").val("");
$(".cancel-comment").removeClass("show").addClass("hide");
$(".discussion-on-page .comment-field").css("height", "48px");
};
var hide_sidebar = () => {
const hide_sidebar = () => {
$(".discussions-sidebar").addClass("hide");
$("#discussion-group").removeClass("hide");
};
var back_to_sidebar = () => {
const back_to_sidebar = () => {
$(".discussions-sidebar").removeClass("hide");
$("#discussion-group").addClass("hide");
$(".discussion-on-page").collapse("hide");

View file

@ -35,7 +35,7 @@
<div class="small mt-3 mb-3">There are no {{ title | lower }} for this {{ doctype | lower }}, why don't you start
one! </div>
{% if frappe.session.user == "Guest" %}
<div class="button is-primary mt-3" id="login-from-discussion">Log In</div>
<div class="button is-primary mt-3" id="login-from-discussion"> {{ _("Log In") }} </div>
{% elif condition is defined and not condition %}
<a class="button is-primary mt-3" id="login-from-discussion" href="" data-redirect="{{ redirect_to }}">
{{ button_name }}

View file

@ -7,7 +7,7 @@
data-parent="#discussion-group">
<div class="button is-default back">
Back
{{ _("Back") }}
</div>
<div class="course-home-headings p-0">{{ topic.title }}</div>
@ -21,9 +21,9 @@
{% if frappe.session.user == "Guest" or (condition is defined and not condition) %}
<div class="d-flex flex-column align-items-center small">
Want to join the discussion?
{{ _("Want to join the discussion?") }}
{% if frappe.session.user == "Guest" %}
<div class="button is-primary mt-3 mb-3" id="login-from-discussion">Log In</div>
<div class="button is-primary mt-3 mb-3" id="login-from-discussion">{{ _("Log In") }}</div>
{% elif not condition %}
<div class="button is-primary mt-3 mb-3" id="login-from-discussion" data-redirect="{{ redirect_to }}">{{ button_name }}
</div>

View file

@ -69,8 +69,6 @@
background-color: #F4F5F6;
padding: 0.75rem;
border-radius: 4px;
max-height: 700px;
overflow-y: auto;
}
@media (max-width: 550px) {
@ -79,11 +77,6 @@
}
}
#discussion-group {
max-height: 700px;
overflow-y: auto;
}
.sidebar-topic {
padding: 0.75rem;
margin: 0.75rem 0;

View file

@ -1,5 +1,6 @@
{
"actions": [],
"autoname": "REPLY.####",
"creation": "2021-08-11 10:59:38.597046",
"doctype": "DocType",
"editable_grid": 1,
@ -26,10 +27,11 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2021-08-27 15:06:51.362715",
"modified": "2021-09-28 12:09:10.875927",
"modified_by": "Administrator",
"module": "Website",
"name": "Discussion Reply",
"naming_rule": "Expression (old style)",
"owner": "Administrator",
"permissions": [
{
@ -48,4 +50,4 @@
"sort_field": "modified",
"sort_order": "DESC",
"track_changes": 1
}
}

View file

@ -1,5 +1,6 @@
{
"actions": [],
"autoname": "TOPIC.####",
"creation": "2021-08-11 10:55:29.341674",
"doctype": "DocType",
"editable_grid": 1,
@ -18,22 +19,27 @@
{
"fieldname": "reference_doctype",
"fieldtype": "Link",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Reference Doctype",
"options": "DocType"
},
{
"fieldname": "reference_docname",
"fieldtype": "Dynamic Link",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Reference Docname",
"options": "reference_doctype"
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2021-08-11 12:29:43.564126",
"modified": "2021-09-28 12:11:50.016352",
"modified_by": "Administrator",
"module": "Website",
"name": "Discussion Topic",
"naming_rule": "Expression (old style)",
"owner": "Administrator",
"permissions": [
{
@ -54,4 +60,4 @@
"sort_order": "DESC",
"title_field": "title",
"track_changes": 1
}
}