Merge pull request #205 from pateljannat/discussions-shift
This commit is contained in:
@@ -1,8 +0,0 @@
|
||||
// Copyright (c) 2021, FOSS United and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on('Discussion Reply', {
|
||||
// refresh: function(frm) {
|
||||
|
||||
// }
|
||||
});
|
||||
@@ -1,51 +0,0 @@
|
||||
{
|
||||
"actions": [],
|
||||
"creation": "2021-08-11 10:59:38.597046",
|
||||
"doctype": "DocType",
|
||||
"editable_grid": 1,
|
||||
"engine": "InnoDB",
|
||||
"field_order": [
|
||||
"topic",
|
||||
"reply"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
"fieldname": "reply",
|
||||
"fieldtype": "Long Text",
|
||||
"in_list_view": 1,
|
||||
"label": "Reply"
|
||||
},
|
||||
{
|
||||
"fieldname": "topic",
|
||||
"fieldtype": "Link",
|
||||
"in_list_view": 1,
|
||||
"in_standard_filter": 1,
|
||||
"label": "Topic",
|
||||
"options": "Discussion Topic"
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2021-08-27 15:06:51.362714",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Community",
|
||||
"name": "Discussion Reply",
|
||||
"owner": "Administrator",
|
||||
"permissions": [
|
||||
{
|
||||
"create": 1,
|
||||
"delete": 1,
|
||||
"email": 1,
|
||||
"export": 1,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "System Manager",
|
||||
"share": 1,
|
||||
"write": 1
|
||||
}
|
||||
],
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC",
|
||||
"track_changes": 1
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
# Copyright (c) 2021, FOSS United and contributors
|
||||
# For license information, please see license.txt
|
||||
|
||||
import frappe
|
||||
from frappe.model.document import Document
|
||||
from community.widgets import Widgets
|
||||
|
||||
class DiscussionReply(Document):
|
||||
def after_insert(self):
|
||||
data = {
|
||||
"reply": self,
|
||||
"topic": {
|
||||
"name": self.topic
|
||||
},
|
||||
"widgets": Widgets()
|
||||
}
|
||||
template = frappe.render_template("community/templates/discussions/reply_card.html", data)
|
||||
topic_info = frappe.get_all("Discussion Topic", {"name": self.topic}, ["reference_doctype", "reference_docname", "name", "title", "owner", "creation"])
|
||||
sidebar = frappe.render_template("community/templates/discussions/sidebar.html", { "topic": topic_info[0], "widgets": Widgets() })
|
||||
new_topic_template = frappe.render_template("community/templates/discussions/reply_section.html", { "topics": topic_info, "widgets": Widgets() })
|
||||
|
||||
frappe.publish_realtime(event="publish_message",
|
||||
message = {
|
||||
"template": template,
|
||||
"topic_info": topic_info[0],
|
||||
"sidebar": sidebar,
|
||||
"new_topic_template": new_topic_template
|
||||
},
|
||||
after_commit=True)
|
||||
@@ -1,8 +0,0 @@
|
||||
# Copyright (c) 2021, FOSS United and Contributors
|
||||
# See license.txt
|
||||
|
||||
# import frappe
|
||||
import unittest
|
||||
|
||||
class TestDiscussionReply(unittest.TestCase):
|
||||
pass
|
||||
@@ -1,8 +0,0 @@
|
||||
// Copyright (c) 2021, FOSS United and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on('Discussion Topic', {
|
||||
// refresh: function(frm) {
|
||||
|
||||
// }
|
||||
});
|
||||
@@ -1,57 +0,0 @@
|
||||
{
|
||||
"actions": [],
|
||||
"creation": "2021-08-11 10:55:29.341674",
|
||||
"doctype": "DocType",
|
||||
"editable_grid": 1,
|
||||
"engine": "InnoDB",
|
||||
"field_order": [
|
||||
"title",
|
||||
"reference_doctype",
|
||||
"reference_docname"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
"fieldname": "title",
|
||||
"fieldtype": "Data",
|
||||
"label": "Title"
|
||||
},
|
||||
{
|
||||
"fieldname": "reference_doctype",
|
||||
"fieldtype": "Link",
|
||||
"label": "Reference Doctype",
|
||||
"options": "DocType"
|
||||
},
|
||||
{
|
||||
"fieldname": "reference_docname",
|
||||
"fieldtype": "Dynamic Link",
|
||||
"label": "Reference Docname",
|
||||
"options": "reference_doctype"
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2021-08-11 12:29:43.564123",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Community",
|
||||
"name": "Discussion Topic",
|
||||
"owner": "Administrator",
|
||||
"permissions": [
|
||||
{
|
||||
"create": 1,
|
||||
"delete": 1,
|
||||
"email": 1,
|
||||
"export": 1,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "System Manager",
|
||||
"share": 1,
|
||||
"write": 1
|
||||
}
|
||||
],
|
||||
"search_fields": "title",
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC",
|
||||
"title_field": "title",
|
||||
"track_changes": 1
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
# Copyright (c) 2021, FOSS United and contributors
|
||||
# For license information, please see license.txt
|
||||
|
||||
import frappe
|
||||
from frappe.model.document import Document
|
||||
|
||||
class DiscussionTopic(Document):
|
||||
pass
|
||||
|
||||
@frappe.whitelist()
|
||||
def submit_discussion(doctype, docname, reply, title, topic_name=None):
|
||||
if topic_name:
|
||||
save_message(reply, topic_name)
|
||||
return topic_name
|
||||
|
||||
topic = frappe.get_doc({
|
||||
"doctype": "Discussion Topic",
|
||||
"title": title,
|
||||
"reference_doctype": doctype,
|
||||
"reference_docname": docname
|
||||
})
|
||||
topic.save(ignore_permissions=True)
|
||||
save_message(reply, topic.name)
|
||||
return topic.name
|
||||
|
||||
def save_message(reply, topic):
|
||||
frappe.get_doc({
|
||||
"doctype": "Discussion Reply",
|
||||
"reply": reply,
|
||||
"topic": topic
|
||||
}).save(ignore_permissions=True)
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_docname(route):
|
||||
return frappe.db.get_value("Web Page", {"route": route}, ["name"])
|
||||
@@ -1,8 +0,0 @@
|
||||
# Copyright (c) 2021, FOSS United and Contributors
|
||||
# See license.txt
|
||||
|
||||
# import frappe
|
||||
import unittest
|
||||
|
||||
class TestDiscussionTopic(unittest.TestCase):
|
||||
pass
|
||||
@@ -1,2 +0,0 @@
|
||||
{% set docname = frappe.db.get_value("Web Page", {"route": ""}, ["name"])%}
|
||||
{{ widgets.DiscussionMessage(doctype="Web Page", docname=docname) }}
|
||||
@@ -1,17 +0,0 @@
|
||||
{
|
||||
"__islocal": true,
|
||||
"__unsaved": 1,
|
||||
"creation": "2021-08-30 12:42:31.550200",
|
||||
"docstatus": 0,
|
||||
"doctype": "Web Template",
|
||||
"fields": [],
|
||||
"idx": 0,
|
||||
"modified": "2021-08-30 12:42:31.550200",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Community",
|
||||
"name": "Discussions",
|
||||
"owner": "Administrator",
|
||||
"standard": 1,
|
||||
"template": "",
|
||||
"type": "Section"
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
<form class="discussion-form">
|
||||
|
||||
<div class="form-group">
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<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 a comment..."
|
||||
spellcheck="false"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="comment-footer">
|
||||
<div class="button is-default pull-right mb-5 submit-discussion" data-doctype="{{ doctype | urlencode }}"
|
||||
data-docname="{{ docname | urlencode }}">
|
||||
Post</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
@@ -1,54 +0,0 @@
|
||||
{% set topics = frappe.get_all("Discussion Topic",
|
||||
{"reference_doctype": doctype, "reference_docname": docname}, ["name", "title", "owner", "creation"]) %}
|
||||
|
||||
{% include "community/templates/discussions/topic_modal.html" %}
|
||||
|
||||
<div class="discussions-parent">
|
||||
<div class="discussions-header">
|
||||
<span class="course-home-headings">{{_('Discussions')}}</span>
|
||||
{% if topics %}
|
||||
{% include "community/templates/discussions/button.html" %}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% if topics %}
|
||||
<div class="common-card-style thread-card course-content-parent" data-doctype="{{ doctype }}"
|
||||
data-docname="{{ docname }}">
|
||||
|
||||
<div class="discussions-sidebar">
|
||||
{% include "community/templates/discussions/search.html" %}
|
||||
{% for topic in topics %}
|
||||
{% set replies = frappe.get_all("Discussion Reply", {"topic": topic.name})%}
|
||||
{% include "community/templates/discussions/sidebar.html" %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
<div class="mr-2" id="discussion-group">
|
||||
{% include "community/templates/discussions/reply_section.html" %}
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
|
||||
<div id="no-discussions" class="common-card-style thread-card">
|
||||
<div class="no-discussions">
|
||||
<div class="font-weight-bold">No Discussions</div>
|
||||
<div class="muted-text mt-3 mb-3">There are no discussions 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>
|
||||
{% elif not condition %}
|
||||
<div class="button is-primary mt-3" id="login-from-discussion" data-redirect="{{ redirect_to }}">
|
||||
{{ button_name }}
|
||||
</div>
|
||||
{% else %}
|
||||
{% include "community/templates/discussions/button.html" %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% block script %}
|
||||
<script>{% include "community/templates/discussions/discussions.js" %}</script>
|
||||
{% endblock %}
|
||||
@@ -167,9 +167,9 @@ jinja = {
|
||||
## subclass of community.community.plugins.PageExtension
|
||||
# community_lesson_page_extension = None
|
||||
|
||||
community_lesson_page_extensions = [
|
||||
"community.plugins.LiveCodeExtension"
|
||||
]
|
||||
#community_lesson_page_extensions = [
|
||||
# "community.plugins.LiveCodeExtension"
|
||||
#]
|
||||
|
||||
## Markdown Macros for Lessons
|
||||
community_markdown_macro_renderers = {
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
<div class="breadcrumb">
|
||||
|
||||
|
||||
{% if course %}
|
||||
<a class="dark-links" href="/courses">All Courses</a>
|
||||
<img class="ml-1 mr-1" src="/assets/community/icons/chevron-right.svg">
|
||||
@@ -12,10 +10,4 @@
|
||||
<span class="muted-text">{{ course.title }}</span>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if thread %}
|
||||
<a class="dark-links" href="/discussions">Discussions</a>
|
||||
<img class="ml-1 mr-1" src="/assets/community/icons/chevron-right.svg">
|
||||
<span class="muted-text">{{ thread.title }}</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
rotate_chapter_icon(e);
|
||||
});
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
var expand_the_first_chapter = () => {
|
||||
var elements = $(".course-outline .collapse");
|
||||
|
||||
@@ -1299,106 +1299,6 @@ pre {
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
.thread-card {
|
||||
flex-direction: column;
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.discussions-parent .form-control {
|
||||
background-color: #FFFFFF;
|
||||
font-size: inherit;
|
||||
color: inherit;
|
||||
padding: 0.75rem 1rem;
|
||||
}
|
||||
|
||||
.discussion-on-page .comment-field {
|
||||
height: 48px;
|
||||
box-shadow: inset 0px 0px 4px rgba(0, 0, 0, 0.2);
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.modal .comment-field {
|
||||
height: 300px;
|
||||
}
|
||||
|
||||
.no-discussions {
|
||||
width: 250px;
|
||||
margin: 0 auto;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.no-discussions .button {
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
.discussions-header {
|
||||
margin: 2.5rem 0 1.25rem;
|
||||
}
|
||||
|
||||
.discussions-header .button {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.discussions-parent .search-field {
|
||||
background-color: #E2E6E9;
|
||||
background-image: url(/assets/community/icons/search.svg);
|
||||
background-repeat: no-repeat;
|
||||
text-indent: 1.5rem;
|
||||
background-position: 1rem 0.7rem;
|
||||
height: 36px;
|
||||
font-size: 12px;
|
||||
padding: 0.65rem 0.9rem;
|
||||
}
|
||||
|
||||
.discussions-sidebar {
|
||||
background-color: #F4F5F6;
|
||||
padding: 0.75rem;
|
||||
border-radius: 4px;
|
||||
max-height: 700px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
#discussion-group {
|
||||
max-height: 700px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.sidebar-topic {
|
||||
padding: 0.75rem;
|
||||
margin: 0.75rem 0;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.sidebar-topic[aria-expanded="true"] {
|
||||
background: #FFFFFF;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.comment-footer {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.reply-card {
|
||||
margin-bottom: 40px;
|
||||
}
|
||||
|
||||
.discussions-parent .collapsing {
|
||||
transition: height 0s;
|
||||
}
|
||||
|
||||
.discussion-topic-title {
|
||||
color: var(--text-color);
|
||||
}
|
||||
|
||||
.discussion-on-page .topic-title {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.discussions-sidebar .sidebar-parent:last-child .card-divider {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.certificate-content {
|
||||
padding: 2.5rem 3rem;
|
||||
}
|
||||
@@ -1463,3 +1363,8 @@ pre {
|
||||
width: 1.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
.thread-card {
|
||||
flex-direction: column;
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
{% if frappe.session.user != "Guest" and
|
||||
(condition is not defined or (condition is defined and condition )) %}
|
||||
<span class="button is-secondary reply">
|
||||
New Discussion
|
||||
<img src="/assets/community/icons/small-add-black.svg">
|
||||
</span>
|
||||
{% endif %}
|
||||
@@ -1,198 +0,0 @@
|
||||
frappe.ready(() => {
|
||||
setup_socket_io();
|
||||
|
||||
set_docname_if_missing();
|
||||
|
||||
expand_first_discussion();
|
||||
|
||||
$(".search-field").keyup((e) => {
|
||||
search_topic(e);
|
||||
});
|
||||
|
||||
$(".reply").click((e) => {
|
||||
show_new_topic_modal(e);
|
||||
});
|
||||
|
||||
$("#login-from-discussion").click((e) => {
|
||||
login_from_discussion(e);
|
||||
});
|
||||
|
||||
$(".sidebar-topic").click((e) => {
|
||||
if ($(e.currentTarget).attr("aria-expanded") == "true") {
|
||||
e.stopPropagation();
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on("click", ".submit-discussion", (e) => {
|
||||
submit_discussion(e);
|
||||
});
|
||||
})
|
||||
|
||||
var show_new_topic_modal = (e) => {
|
||||
e.preventDefault();
|
||||
$("#discussion-modal").modal("show");
|
||||
var topic = $(e.currentTarget).attr("data-topic");
|
||||
$(".modal-headings").text(topic ? "Reply" : "Start a Discussion");
|
||||
topic ? $(".topic-title").addClass("hide") : $(".topic-title").removeClass("hide");
|
||||
$("#submit-discussion").attr("data-topic", topic ? topic : "");
|
||||
}
|
||||
|
||||
var setup_socket_io = () => {
|
||||
const assets = [
|
||||
"/assets/frappe/js/lib/socket.io.min.js",
|
||||
"/assets/frappe/js/frappe/socketio_client.js",
|
||||
]
|
||||
|
||||
frappe.require(assets, () => {
|
||||
if (window.dev_server) {
|
||||
frappe.boot.socketio_port = "9000";
|
||||
}
|
||||
frappe.socketio.init(9000);
|
||||
frappe.socketio.socket.on("publish_message", (data) => {
|
||||
publish_message(data);
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
var publish_message = (data) => {
|
||||
post_message_cleanup();
|
||||
|
||||
if ($(`.discussion-on-page[data-topic=${data.topic_info.name}]`).length) {
|
||||
if ($(`.discussion-on-page[data-topic=${data.topic_info.name}] .card-divider-dark`).length) {
|
||||
$(data.template).insertAfter(`.discussion-on-page[data-topic=${data.topic_info.name}] .card-divider-dark`);
|
||||
}
|
||||
else {
|
||||
|
||||
$('<div class="card-divider-dark mb-10"></div>' + data.template).insertAfter(`.discussion-on-page[data-topic=${data.topic_info.name}] .discussion-form`);
|
||||
}
|
||||
}
|
||||
else if ((decodeURIComponent($(".discussions-parent .course-content-parent").attr("data-doctype")) == data.topic_info.reference_doctype
|
||||
&& decodeURIComponent($(".discussions-parent .course-content-parent").attr("data-docname")) == data.topic_info.reference_docname)) {
|
||||
$(data.sidebar).insertAfter(`.discussions-sidebar .form-group`);
|
||||
$(`#discussion-group`).prepend(data.new_topic_template);
|
||||
|
||||
if (data.topic_info.owner == frappe.session.user) {
|
||||
$(".discussion-on-page").collapse();
|
||||
$(".sidebar-topic").first().click();
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
window.location.reload();
|
||||
}
|
||||
|
||||
update_reply_count(data.topic_info.name);
|
||||
}
|
||||
|
||||
var post_message_cleanup = () => {
|
||||
$(".comment-field").val("");
|
||||
$("#discussion-modal").modal("hide");
|
||||
$("#no-discussions").addClass("hide");
|
||||
}
|
||||
|
||||
var update_reply_count = (topic) => {
|
||||
var 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 set_docname_if_missing = () => {
|
||||
if ($("[data-docname='None']").length) {
|
||||
frappe.call({
|
||||
method: "community.community.doctype.discussion_topic.discussion_topic.get_docname",
|
||||
args: {
|
||||
"route": window.location.href.split("/").slice(-1)[0]
|
||||
},
|
||||
callback: (data) => {
|
||||
$("[data-docname='None']").attr("data-docname", data.message);
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
var expand_first_discussion = () => {
|
||||
$($(".discussions-parent .collapse")[0]).addClass("show");
|
||||
$($(".discussions-sidebar [data-toggle='collapse']")[0]).attr("aria-expanded", true);
|
||||
}
|
||||
|
||||
var search_topic = (e) => {
|
||||
var input = $(e.currentTarget).val();
|
||||
|
||||
var 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");
|
||||
|
||||
/* Check match in replies */
|
||||
var match_in_reply = false;
|
||||
var replies = $(`${topic_id}`);
|
||||
for (var reply of replies.find(".reply-text")) {
|
||||
if (has_common_substring($(reply).text(), input)) {
|
||||
match_in_reply = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Match found in title or replies, then show */
|
||||
if (has_common_substring($(elem).text(), input) || match_in_reply) {
|
||||
$(elem).closest(".sidebar-parent").removeClass("hide")
|
||||
}
|
||||
else {
|
||||
$(elem).closest(".sidebar-parent").addClass("hide");
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
var has_common_substring = (str1, str2) => {
|
||||
var str1_arr = str1.toLowerCase().split(" ");
|
||||
var str2_arr = str2.toLowerCase().split(" ");
|
||||
|
||||
var substring_found = false;
|
||||
for (var first_word of str1_arr) {
|
||||
for (var second_word of str2_arr) {
|
||||
if (first_word.indexOf(second_word) > -1) {
|
||||
substring_found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return substring_found;
|
||||
}
|
||||
|
||||
var 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();
|
||||
|
||||
if (reply) {
|
||||
var doctype = $(e.currentTarget).attr("data-doctype");
|
||||
doctype = doctype ? decodeURIComponent(doctype) : doctype;
|
||||
|
||||
var docname = $(e.currentTarget).attr("data-docname");
|
||||
docname = docname ? decodeURIComponent(docname) : docname;
|
||||
|
||||
frappe.call({
|
||||
method: "community.community.doctype.discussion_topic.discussion_topic.submit_discussion",
|
||||
args: {
|
||||
"doctype": doctype ? doctype : "",
|
||||
"docname": docname ? docname : "",
|
||||
"reply": reply,
|
||||
"title": title,
|
||||
"topic_name": $(e.currentTarget).closest(".discussion-on-page").attr("data-topic")
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
var login_from_discussion = (e) => {
|
||||
var redirect = $(e.currentTarget).attr("data-redirect") || window.location.href;
|
||||
window.location.href = `/login?redirect-to=${redirect}`;
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
<div class="reply-card">
|
||||
{% set member = frappe.get_doc("User", reply.owner) %}
|
||||
<div class="d-flex align-items-center muted-text">
|
||||
{% set member = frappe.get_doc("User", reply.owner) %}
|
||||
{{ widgets.Avatar(member=member, avatar_class="avatar-small")}}
|
||||
<a class="button-links ml-2" href="{{ get_profile_url(member.username) }}">
|
||||
{{ member.full_name }}
|
||||
</a>
|
||||
<div class="ml-2 frappe-timestamp" data-timestamp="{{ reply.creation }}"> just now </div>
|
||||
</div>
|
||||
<div class="card-divider mt-3"></div>
|
||||
<div class="markdown-source reply-text">{{ frappe.utils.md_to_html(reply.reply) }}</div>
|
||||
</div>
|
||||
@@ -1,41 +0,0 @@
|
||||
{% for topic in topics %}
|
||||
{% set replies = frappe.get_all("Discussion Reply", {"topic": topic.name},
|
||||
["reply", "owner", "creation"], order_by="creation desc")%}
|
||||
|
||||
<!-- Hack to reorganize the replies array. So even though we want reverse cronology, the first reply should appear first. -->
|
||||
{% if replies.insert(0, replies.pop()) %}{% endif %}
|
||||
|
||||
{% if replies %}
|
||||
<div class="collapse discussion-on-page" id="t{{ topic.name }}" data-topic="{{ topic.name }}"
|
||||
data-parent="#discussion-group">
|
||||
<div class="course-home-headings p-0">{{ topic.title }}</div>
|
||||
{% for reply in replies %}
|
||||
|
||||
{% if loop.index == 2 %}
|
||||
<div class="card-divider-dark mb-10"></div>
|
||||
{% endif %}
|
||||
|
||||
{% include "community/templates/discussions/reply_card.html" %}
|
||||
|
||||
{% if loop.index == 1 %}
|
||||
|
||||
{% if frappe.session.user == "Guest" or (condition is defined and not condition) %}
|
||||
<div class="d-flex flex-column align-items-center muted-text">
|
||||
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>
|
||||
{% elif not condition %}
|
||||
<div class="button is-primary mt-3 mb-3" id="login-from-discussion" data-redirect="{{ redirect_to }}">{{ button_name }}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% else %}
|
||||
{{ widgets.CommentBox(doctype=doctype, docname=docname) }}
|
||||
{% endif %}
|
||||
|
||||
{% endif %}
|
||||
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
@@ -1,9 +0,0 @@
|
||||
<div class="form-group">
|
||||
<div class="control-input-wrapper">
|
||||
<div class="control-input">
|
||||
<textarea type="text" autocomplete="off" class="input-with-feedback form-control search-field"
|
||||
data-fieldtype="Text" data-fieldname="feedback_comments" placeholder="Search Topics"
|
||||
spellcheck="false"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,20 +0,0 @@
|
||||
<div class="sidebar-parent">
|
||||
<div class="sidebar-topic" data-target="#t{{ topic.name }}" data-toggle="collapse" aria-expanded="false">
|
||||
<div class="discussion-topic-title">{{ topic.title }}</div>
|
||||
<div class="mt-2 mb-3">
|
||||
{% set creator = frappe.get_doc("User", topic.owner) %}
|
||||
{{ widgets.Avatar(member=creator, avatar_class="avatar-small") }}
|
||||
<span class="course-instructor">
|
||||
{{ creator.full_name }}
|
||||
</span>
|
||||
<span class="muted-text pull-right">
|
||||
<span class="mr-2">
|
||||
<img src="/assets/community/icons/message.svg">
|
||||
<span class="reply-count">{{ replies | length }}</span>
|
||||
</span>
|
||||
<span> {{ frappe.utils.format_date(topic.creation, "dd MMM YYYY") }} </span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-divider"></div>
|
||||
</div>
|
||||
@@ -1,15 +0,0 @@
|
||||
<div class="modal fade discussion-modal" id="discussion-modal" tabindex="-1" role="dialog" aria-hidden="true">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<div class="course-home-headings modal-headings">Start a Discussion</div>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
{{ widgets.CommentBox(doctype=doctype, docname=docname) }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,13 +0,0 @@
|
||||
<div class="discussion {% if message.is_author %} is-author {% endif %}">
|
||||
<div class="d-flex justify-content-between">
|
||||
<div class="font-weight-bold">
|
||||
{{ message.author_name }}
|
||||
</div>
|
||||
<div class="text-muted">
|
||||
{{ message.message_time }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-5">
|
||||
{{ message.message }}
|
||||
</div>
|
||||
</div>
|
||||
@@ -3,8 +3,6 @@
|
||||
{% block title %} {{ lesson.title }} - {{ course.title }} {% endblock %}
|
||||
|
||||
{% block head_include %}
|
||||
<link rel="stylesheet" href="/assets/frappe/css/font-awesome.css">
|
||||
<link rel="stylesheet" href="/assets/css/lms.css">
|
||||
<link rel="stylesheet" href="/assets/frappe/css/hljs-night-owl.css">
|
||||
|
||||
{% for ext in page_extensions %}
|
||||
@@ -57,8 +55,10 @@
|
||||
{{ lesson.render_html() }}</div>
|
||||
{% else %}
|
||||
<div class="common-card-style lesson-content-card">
|
||||
<span>This lesson is not available for Preview. Please join the course to access it. <a
|
||||
href="/courses/{{ course.name }}">Checkout Course Details.</a></span>
|
||||
<div class="w-25 text-center" style="margin: 0 auto;">
|
||||
<small>This lesson is not available for preview. Please join the course to access it.</small>
|
||||
<a class="button is-primary ml-auto mr-auto mt-3" href="/courses/{{ course.name }}"> Start Learning </a>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
@@ -110,11 +110,14 @@
|
||||
|
||||
{% macro Discussions() %}
|
||||
{% set is_instructor = frappe.session.user == course.instructor %}
|
||||
{% set title = lesson.title + " - " + course.title %}
|
||||
{% set condition = is_instructor if is_instructor else membership %}
|
||||
{{ widgets.DiscussionMessage(doctype="Course Lesson", docname=lesson.name,
|
||||
condition=condition, button_name="Start Learning",
|
||||
redirect_to="/courses/" + course.name) }}
|
||||
{% set doctype, docname = "Course Lesson", lesson.name %}
|
||||
{% set title = "Questions" %}
|
||||
{% set cta_title = "New Question" %}
|
||||
{% set button_name = "Start Learning" %}
|
||||
{% set redirect_to = "/courses/" + course.name %}
|
||||
|
||||
{% include "frappe/templates/discussions/discussions_section.html" %}
|
||||
{% endmacro %}
|
||||
|
||||
{%- block script %}
|
||||
|
||||
Reference in New Issue
Block a user