From 0b632ee37bd87923d690ce5f9be037c0d0a5d6ce Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Thu, 6 Dec 2018 11:26:45 +0530 Subject: [PATCH 01/35] Remove avatar user avatar from wall - since it seems useless --- .../js/frappe/social/components/PostSidebar.vue | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/frappe/public/js/frappe/social/components/PostSidebar.vue b/frappe/public/js/frappe/social/components/PostSidebar.vue index 30527f4a58..b14d2fff8a 100644 --- a/frappe/public/js/frappe/social/components/PostSidebar.vue +++ b/frappe/public/js/frappe/social/components/PostSidebar.vue @@ -1,9 +1,5 @@ @@ -40,6 +49,9 @@ export default { }, go_to_profile_page() { frappe.set_route('social', 'profile', frappe.session.user) + }, + go_to_user_list() { + frappe.set_route('social', 'users') } } } diff --git a/frappe/public/js/frappe/social/pages/UserList.vue b/frappe/public/js/frappe/social/pages/UserList.vue new file mode 100644 index 0000000000..6f2c6bbed7 --- /dev/null +++ b/frappe/public/js/frappe/social/pages/UserList.vue @@ -0,0 +1,60 @@ + + + + From e5f5d01b71965418dc275b86ef3a2aa6cbd25419 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Wed, 23 Jan 2019 10:36:28 +0530 Subject: [PATCH 07/35] Move all user link to the top --- .../js/frappe/social/components/PostSidebar.vue | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/frappe/public/js/frappe/social/components/PostSidebar.vue b/frappe/public/js/frappe/social/components/PostSidebar.vue index b0aaefba4a..108e83e734 100644 --- a/frappe/public/js/frappe/social/components/PostSidebar.vue +++ b/frappe/public/js/frappe/social/components/PostSidebar.vue @@ -1,5 +1,9 @@ From 59b55d4df065ba5fe582658e4113e9fb347fbb51 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Mon, 4 Feb 2019 10:06:14 +0530 Subject: [PATCH 08/35] Use comment control for post comment --- .../frappe/social/components/PostComment.vue | 80 +++++++++++++------ 1 file changed, 56 insertions(+), 24 deletions(-) diff --git a/frappe/public/js/frappe/social/components/PostComment.vue b/frappe/public/js/frappe/social/components/PostComment.vue index 2d41a0a839..d993eb2f7b 100644 --- a/frappe/public/js/frappe/social/components/PostComment.vue +++ b/frappe/public/js/frappe/social/components/PostComment.vue @@ -2,26 +2,25 @@
{{ __('Add a comment') }}
- +
-
+
- - - {{ comment.content }} + + +
@@ -29,10 +28,15 @@ + + From 076985156cfad634c6d757a5d020a48686ff33d1 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Mon, 11 Mar 2019 11:44:33 +0530 Subject: [PATCH 14/35] Limit bio text on user list to 100 characters --- frappe/public/js/frappe/social/pages/UserList.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frappe/public/js/frappe/social/pages/UserList.vue b/frappe/public/js/frappe/social/pages/UserList.vue index b257223572..dbd4ec5e6f 100644 --- a/frappe/public/js/frappe/social/pages/UserList.vue +++ b/frappe/public/js/frappe/social/pages/UserList.vue @@ -12,7 +12,7 @@
{{ user.fullname }} -
{{ user.bio || 'No Bio'}}
+
{{ frappe.ellipsis(user.bio, 100) || 'No Bio'}}
  • {{__('No user found')}}
  • From e67567a13df9a9808271534b840483d1c3b2b0e6 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Mon, 11 Mar 2019 14:01:35 +0530 Subject: [PATCH 15/35] Show post button only on home page --- frappe/public/js/frappe/social/Home.vue | 12 ++++++++++++ frappe/public/js/frappe/social/social_home.js | 11 ++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/frappe/public/js/frappe/social/Home.vue b/frappe/public/js/frappe/social/Home.vue index dd508ff7af..55397de76b 100644 --- a/frappe/public/js/frappe/social/Home.vue +++ b/frappe/public/js/frappe/social/Home.vue @@ -63,11 +63,14 @@ export default { frappe.app_updates.on('user_image_updated', () => { this.$root.$emit('user_image_updated') }) + + this.update_primary_action(frappe.get_route()[1]) }, mounted() { frappe.route.on('change', () => { if (frappe.get_route()[0] === 'social') { this.set_current_page(); + this.update_primary_action(frappe.get_route()[1]) frappe.utils.scroll_to(0); $("body").attr("data-route", frappe.get_route_str()); } @@ -78,6 +81,15 @@ export default { set_current_page() { this.current_page = this.get_current_page(); }, + update_primary_action(current_route) { + if (current_route === 'home') { + this.$root.page.set_primary_action(__('Post'), () => { + frappe.social.post_dialog.show(); + }); + } else { + this.$root.page.clear_primary_action() + } + }, get_current_page() { const route_map = get_route_map(); const route = frappe.get_route_str(); diff --git a/frappe/public/js/frappe/social/social_home.js b/frappe/public/js/frappe/social/social_home.js index 38dee6727e..26e4542d88 100644 --- a/frappe/public/js/frappe/social/social_home.js +++ b/frappe/public/js/frappe/social/social_home.js @@ -8,23 +8,20 @@ frappe.social.Home = class SocialHome { this.page = parent.page; this.setup_header(); this.make_body(); - this.set_primary_action(); } make_body() { this.$social_container = this.$parent.find('.layout-main'); new Vue({ el: this.$social_container[0], - render: h => h(Home) + render: h => h(Home), + data: { + 'page': this.page + } }); } setup_header() { this.page.set_title(__('Social')); } - set_primary_action() { - this.page.set_primary_action(__('Post'), () => { - frappe.social.post_dialog.show(); - }); - } }; frappe.social.post_dialog = new frappe.ui.Dialog({ From 2d194959235e8e021b80701914292a9c6d05985c Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Mon, 11 Mar 2019 14:02:33 +0530 Subject: [PATCH 16/35] Init social unseen count --- frappe/core/notifications.py | 3 +++ frappe/social/doctype/post/post.py | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/frappe/core/notifications.py b/frappe/core/notifications.py index 0f932d9f67..26e2049273 100644 --- a/frappe/core/notifications.py +++ b/frappe/core/notifications.py @@ -17,6 +17,9 @@ def get_notification_config(): "for_other": { "Likes": "frappe.core.notifications.get_unseen_likes", "Email": "frappe.core.notifications.get_unread_emails", + }, + "for_module": { + "Social": "frappe.social.doctype.post.post.get_unseen_post_count" } } diff --git a/frappe/social/doctype/post/post.py b/frappe/social/doctype/post/post.py index c5ee3bf854..fd69c9c61c 100644 --- a/frappe/social/doctype/post/post.py +++ b/frappe/social/doctype/post/post.py @@ -69,4 +69,7 @@ def get_link_info(url): def delete_post(post_name): post = frappe.get_doc('Post', post_name) post.delete() - frappe.publish_realtime('delete_post' + post_name, after_commit=True) \ No newline at end of file + frappe.publish_realtime('delete_post' + post_name, after_commit=True) + +def get_unseen_post_count(): + return 10 \ No newline at end of file From fbf67b78b1c38aca6a06e0ae22eedccaf989b512 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Mon, 11 Mar 2019 19:41:50 +0530 Subject: [PATCH 17/35] Move get_safe_filters to frappe.utils --- frappe/client.py | 16 ++-------------- frappe/utils/__init__.py | 13 +++++++++++++ 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/frappe/client.py b/frappe/client.py index 39f0fd8516..fb2d47925b 100644 --- a/frappe/client.py +++ b/frappe/client.py @@ -7,6 +7,7 @@ from frappe import _ import frappe.model import frappe.utils import json, os +from frappe.utils import get_safe_filters from six import iteritems, string_types, integer_types @@ -370,17 +371,4 @@ def check_parent_permission(parent, child_doctype): if frappe.permissions.has_permission(parent): return # Either parent not passed or the user doesn't have permission on parent doctype of child table! - raise frappe.PermissionError - -def get_safe_filters(filters): - try: - filters = json.loads(filters) - - if isinstance(filters, (integer_types, float)): - filters = frappe.as_unicode(filters) - - except (TypeError, ValueError): - # filters are not passesd, not json - pass - - return filters + raise frappe.PermissionError \ No newline at end of file diff --git a/frappe/utils/__init__.py b/frappe/utils/__init__.py index a995d89bd4..de3a071698 100644 --- a/frappe/utils/__init__.py +++ b/frappe/utils/__init__.py @@ -642,3 +642,16 @@ def gzip_decompress(data): """ with GzipFile(fileobj=io.BytesIO(data)) as f: return f.read() + +def get_safe_filters(filters): + try: + filters = json.loads(filters) + + if isinstance(filters, (integer_types, float)): + filters = frappe.as_unicode(filters) + + except (TypeError, ValueError): + # filters are not passed, not json + pass + + return filters \ No newline at end of file From c941b5e1041cd5739a27dd8a8c56c762c11df2de Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Mon, 11 Mar 2019 21:32:32 +0530 Subject: [PATCH 18/35] Add posts seen indicator --- frappe/model/document.py | 2 +- frappe/public/js/frappe/dom.js | 10 +- .../js/frappe/social/components/Post.vue | 20 + .../frappe/social/components/PostLoader.vue | 25 +- .../js/frappe/social/pages/UserList.vue | 8 +- frappe/social/doctype/post/post.json | 621 +++++++++--------- frappe/social/doctype/post/post.py | 39 +- 7 files changed, 400 insertions(+), 325 deletions(-) diff --git a/frappe/model/document.py b/frappe/model/document.py index 4542cb03cb..697278f4bd 100644 --- a/frappe/model/document.py +++ b/frappe/model/document.py @@ -1154,7 +1154,7 @@ class Document(BaseDocument): frappe.local.flags.commit = True def add_viewed(self, user=None): - '''add log to communication when a user viewes a document''' + '''add log to communication when a user views a document''' if not user: user = frappe.session.user diff --git a/frappe/public/js/frappe/dom.js b/frappe/public/js/frappe/dom.js index 39e576ebf8..830ed0a5ce 100644 --- a/frappe/public/js/frappe/dom.js +++ b/frappe/public/js/frappe/dom.js @@ -68,7 +68,7 @@ frappe.dom = { return txt; } }, - is_element_in_viewport: function (el) { + is_element_in_viewport: function (el, tolerance=0) { //special bonus for those using jQuery if (typeof jQuery === "function" && el instanceof jQuery) { @@ -78,10 +78,10 @@ frappe.dom = { var rect = el.getBoundingClientRect(); return ( - rect.top >= 0 - && rect.left >= 0 - // && rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && /*or $(window).height() */ - // && rect.right <= (window.innerWidth || document.documentElement.clientWidth) /*or $(window).width() */ + rect.top + tolerance >= 0 + && rect.left + tolerance >= 0 + && rect.bottom - tolerance <= $(window).height() + && rect.right - tolerance <= $(window).width() ); }, diff --git a/frappe/public/js/frappe/social/components/Post.vue b/frappe/public/js/frappe/social/components/Post.vue index 71afccfa1f..297ffa702f 100644 --- a/frappe/public/js/frappe/social/components/Post.vue +++ b/frappe/public/js/frappe/social/components/Post.vue @@ -12,6 +12,12 @@ v-if="options.length" :options="options" /> + + + +
    {{ user_name }} @@ -170,6 +176,11 @@ export default { }).then(frappe.dom.unfreeze) }) }, + update_seen() { + frappe.xcall('frappe.social.doctype.post.post.set_seen', { + post_name: this.post.name + }).then(() => this.post.seen = true) + }, generate_preview(link_element) { // TODO: move the code to separate component frappe.xcall('frappe.social.doctype.post.post.get_link_info', { @@ -203,5 +214,14 @@ export default { padding-top: 0px; background: #F6F6F6; } +.indicator { + margin-left: 15px; +} +.fade-enter-active, .fade-leave-active { + transition: opacity .8s; +} +.fade-enter, .fade-leave-to { + opacity: 0; +} diff --git a/frappe/public/js/frappe/social/components/PostLoader.vue b/frappe/public/js/frappe/social/components/PostLoader.vue index b99528ff26..e8c05e769f 100644 --- a/frappe/public/js/frappe/social/components/PostLoader.vue +++ b/frappe/public/js/frappe/social/components/PostLoader.vue @@ -1,8 +1,10 @@