Remove redundant dailog code

This commit is contained in:
Suraj Shetty 2018-10-13 15:09:38 +05:30
parent 0f95d363bd
commit 7e95b1b4d4
2 changed files with 36 additions and 39 deletions

View file

@ -94,8 +94,7 @@ const Post = {
frappe.set_route('social', 'profile/' + user)
},
create_new_reply() {
frappe.social.post_reply_dialog.set_value('reply_to', this.post.name);
frappe.social.post_reply_dialog.show()
frappe.social.post_dialog.open(__('Reply'), __('Reply'), this.post.name);
},
toggle_reply() {
this.show_replies = !this.show_replies

View file

@ -25,48 +25,46 @@ frappe.social.Home = class SocialHome {
}
set_primary_action() {
this.page.set_primary_action(__('Post'), () => {
frappe.social.post_dialog.show();
frappe.social.post_dialog.open();
});
}
};
frappe.social.post_dialog = new frappe.ui.Dialog({
title: __("Create A Post"),
fields: [
{fieldtype: "Text Editor", fieldname: "content", label: __("Content"), reqd: 1},
{fieldtype: "Link", fieldname: "reply_to", label: __("Reply"), hidden: 1}
]
});
frappe.social.post_dialog = {
open(title=__('Create Post'), button_label=__('Post'), reply_to=null) {
const d = new frappe.ui.Dialog({
title,
fields: [
{
fieldtype: "Text Editor",
fieldname: "content",
label: __("Content"),
reqd: 1
},
{
fieldtype: "Link",
fieldname: "reply_to",
label: __("Reply"),
hidden: 1,
default: reply_to
}
],
primary_action_label: title,
primary_action: (values) => {
const post = frappe.model.get_new_doc('Post');
post.content = values.content;
if (values.reply_to) {
post.reply_to = values.reply_to;
}
frappe.db.insert(post).then(() => {
d.hide();
});
}
});
frappe.social.post_dialog.set_primary_action(__('Post'), () => {
const values = frappe.social.post_dialog.get_values();
const post = frappe.model.get_new_doc('Post');
post.content = values.content;
post.reply_to = values.reply_to;
frappe.db.insert(post).then(() => {
frappe.social.post_dialog.clear();
frappe.social.post_dialog.hide();
});
});
frappe.social.post_reply_dialog = new frappe.ui.Dialog({
title: __("Reply"),
fields: [
{fieldtype: "Text Editor", fieldname: "content", label: __("Content"), reqd: 1},
{fieldtype: "Link", fieldname: "reply_to", label: __("Reply"), hidden: 1}
]
});
frappe.social.post_reply_dialog.set_primary_action(__('Reply'), () => {
const values = frappe.social.post_reply_dialog.get_values();
const post = frappe.model.get_new_doc('Post');
post.content = values.content;
post.reply_to = values.reply_to;
frappe.db.insert(post).then(() => {
frappe.social.post_reply_dialog.clear();
frappe.social.post_reply_dialog.hide();
});
});
d.show();
}
};
frappe.social.update_user_image = new frappe.ui.Dialog({
title: __("User Image"),