Merge branch 'develop' into kanban-access-w-perms

This commit is contained in:
Marica 2022-12-29 23:17:20 +05:30 committed by GitHub
commit 182c535067
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 52 additions and 20 deletions

View file

@ -77,8 +77,6 @@ frappe.ui.form.on("DocType", {
istable: (frm) => {
if (frm.doc.istable && frm.is_new()) {
frm.set_value("autoname", "autoincrement");
frm.set_value("allow_rename", 0);
frm.set_value("default_view", null);
} else if (!frm.doc.istable && !frm.is_new()) {
frm.events.set_default_permission(frm);

View file

@ -33,6 +33,8 @@ ALLOWED_MIMETYPES = (
"application/vnd.oasis.opendocument.text",
"application/vnd.oasis.opendocument.spreadsheet",
"text/plain",
"video/quicktime",
"video/mp4",
)

View file

@ -193,7 +193,7 @@ class Document(BaseDocument):
self.load_from_db()
def get_latest(self):
if not hasattr(self, "_doc_before_save"):
if not getattr(self, "_doc_before_save", None):
self.load_doc_before_save()
return self._doc_before_save

View file

@ -2,12 +2,6 @@ frappe.ui.form.Control = class BaseControl {
constructor(opts) {
$.extend(this, opts);
this.make();
// if developer_mode=1, show fieldname as tooltip
if (frappe.boot.user && frappe.boot.developer_mode === 1 && this.$wrapper) {
this.$wrapper.attr("title", __(this.df.fieldname));
}
if (this.render_input) {
this.refresh();
}
@ -19,6 +13,7 @@ frappe.ui.form.Control = class BaseControl {
.attr("data-fieldname", this.df.fieldname);
this.wrapper = this.$wrapper.get(0);
this.wrapper.fieldobj = this; // reference for event handlers
this.$wrapper.append(`<span class="tooltip-content">${__(this.df.fieldname)}</span>`);
}
make_wrapper() {

View file

@ -35,6 +35,7 @@ frappe.ui.form.Layout = class Layout {
}
this.setup_tab_events();
this.setup_tooltip_events();
this.render();
}
@ -529,6 +530,19 @@ frappe.ui.form.Layout = class Layout {
});
}
setup_tooltip_events() {
$(document).on("keydown", (e) => {
if (e.metaKey || e.ctrlKey) {
this.wrapper.addClass("show-tooltip");
}
});
$(document).on("keyup", (e) => {
if (!e.metaKey || !e.ctrlKey) {
this.wrapper.removeClass("show-tooltip");
}
});
}
handle_tab(doctype, fieldname, shift) {
let grid_row = null,
prev = null,

View file

@ -1321,7 +1321,7 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList {
if (this.list_view_settings && this.list_view_settings.disable_auto_refresh) {
return;
}
frappe.socketio.list_subscribe(this.doctype);
frappe.socketio.doctype_subscribe(this.doctype);
frappe.realtime.on("list_update", (data) => {
if (!frappe.get_doc(data?.doctype, data?.name)?.__unsaved) {
frappe.model.remove_from_locals(data.doctype, data.name);

View file

@ -129,8 +129,8 @@ frappe.socketio = {
task_unsubscribe: function (task_id) {
frappe.socketio.socket.emit("task_unsubscribe", task_id);
},
list_subscribe: function (doctype) {
frappe.socketio.socket.emit("list_update", doctype);
doctype_subscribe: function (doctype) {
frappe.socketio.socket.emit("doctype_subscribe", doctype);
},
doc_subscribe: function (doctype, docname) {
if (frappe.flags.doc_subscribe) {

View file

@ -56,7 +56,7 @@ frappe.views.ReportView = class ReportView extends frappe.views.ListView {
if (this.list_view_settings?.disable_auto_refresh) {
return;
}
frappe.socketio.list_subscribe(this.doctype);
frappe.socketio.doctype_subscribe(this.doctype);
frappe.realtime.on("list_update", (data) => this.on_update(data));
}

View file

@ -1,6 +1,29 @@
@import "../common/form.scss";
@import '~cropperjs/dist/cropper.min';
.tooltip-content {
position: absolute;
bottom: 104%;
left: 0;
z-index: 9999;
padding: 2px 6px;
border-radius: var(--border-radius-sm);
background: var(--gray-dark);
color: var(--text-dark);
font-size: var(--text-xs);
opacity: 0;
cursor: default;
transition: opacity 0.3s, transform 3s;
pointer-events: none;
}
.show-tooltip .frappe-control:hover .tooltip-content {
opacity: 1;
transform: translate3d(0,0,0);
pointer-events: auto;
}
.std-form-layout > .form-layout > .form-page {
border-radius: var(--border-radius-md);
box-shadow: var(--card-shadow);

View file

@ -115,7 +115,7 @@ def can_subscribe_doc(doctype: str, docname: str) -> bool:
@frappe.whitelist(allow_guest=True)
def can_subscribe_list(doctype: str) -> bool:
def can_subscribe_doctype(doctype: str) -> bool:
from frappe.exceptions import PermissionError
if not frappe.has_permission(user=frappe.session.user, doctype=doctype, ptype="read"):

View file

@ -9,7 +9,7 @@ import frappe
def remote_login():
try:
login_url = frappe.conf.subscription["login_url"]
if frappe.conf.subscription["expiry"] and login_url:
if login_url:
resp = requests.post(login_url)
if resp.status_code != 200:

View file

@ -58,8 +58,8 @@ io.on("connection", function (socket) {
socket.join(get_site_room(socket));
}
socket.on("list_update", function (doctype) {
can_subscribe_list({
socket.on("doctype_subscribe", function (doctype) {
can_subscribe_doctype({
socket,
doctype,
callback: () => {
@ -286,11 +286,11 @@ function can_subscribe_doc(args) {
});
}
function can_subscribe_list(args) {
function can_subscribe_doctype(args) {
if (!args) return;
if (!args.doctype) return;
request
.get(get_url(args.socket, "/api/method/frappe.realtime.can_subscribe_list"))
.get(get_url(args.socket, "/api/method/frappe.realtime.can_subscribe_doctype"))
.type("form")
.query({
sid: args.socket.sid,
@ -306,7 +306,7 @@ function can_subscribe_list(args) {
args.callback && args.callback(err, res);
return true;
}
log("ERROR (can_subscribe_list): ", err, res);
log("ERROR (can_subscribe_doctype): ", err, res);
});
}