Merge branch 'develop' of https://github.com/frappe/frappe into add-option-to-assign
This commit is contained in:
commit
602968af0b
152 changed files with 1944 additions and 8295 deletions
|
|
@ -147,6 +147,7 @@
|
|||
"context": true,
|
||||
"before": true,
|
||||
"beforeEach": true,
|
||||
"qz": true
|
||||
"qz": true,
|
||||
"localforage": true
|
||||
}
|
||||
}
|
||||
|
|
|
|||
36
cypress/integration/control_select.js
Normal file
36
cypress/integration/control_select.js
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
context('Control Select', () => {
|
||||
before(() => {
|
||||
cy.login();
|
||||
cy.visit('/app/website');
|
||||
});
|
||||
|
||||
function get_dialog_with_select() {
|
||||
return cy.dialog({
|
||||
title: 'Select',
|
||||
fields: [{
|
||||
'fieldname': 'select_control',
|
||||
'fieldtype': 'Select',
|
||||
'placeholder': 'Select an Option',
|
||||
'options': ['', 'Option 1', 'Option 2', 'Option 2'],
|
||||
}]
|
||||
});
|
||||
}
|
||||
|
||||
it('toggles placholder on clicking an option', () => {
|
||||
get_dialog_with_select().as('dialog');
|
||||
|
||||
cy.get('.frappe-control[data-fieldname=select_control] .control-input').as('control');
|
||||
cy.get('.frappe-control[data-fieldname=select_control] .control-input select').as('select');
|
||||
cy.get('@control').get('.select-icon').should('exist');
|
||||
cy.get('@control').get('.placeholder').should('have.css', 'display', 'block');
|
||||
cy.get('@select').select('Option 1');
|
||||
cy.get('@control').get('.placeholder').should('have.css', 'display', 'none');
|
||||
cy.get('@select').invoke('val', '');
|
||||
cy.get('@control').get('.placeholder').should('have.css', 'display', 'block');
|
||||
|
||||
|
||||
cy.get('@dialog').then(dialog => {
|
||||
dialog.hide();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -8,7 +8,7 @@ context('Table MultiSelect', () => {
|
|||
it('select value from multiselect dropdown', () => {
|
||||
cy.new_form('Assignment Rule');
|
||||
cy.fill_field('__newname', name);
|
||||
cy.fill_field('document_type', 'ToDo');
|
||||
cy.fill_field('document_type', 'Blog Post');
|
||||
cy.fill_field('assign_condition', 'status=="Open"', 'Code');
|
||||
cy.get('input[data-fieldname="users"]').focus().as('input');
|
||||
cy.get('input[data-fieldname="users"] + ul').should('be.visible');
|
||||
|
|
|
|||
|
|
@ -312,7 +312,6 @@ Cypress.Commands.add('add_filter', () => {
|
|||
cy.get('.filter-section .filter-button').click();
|
||||
cy.wait(300);
|
||||
cy.get('.filter-popover').should('exist');
|
||||
cy.get('.filter-popover').find('.add-filter').click();
|
||||
});
|
||||
|
||||
Cypress.Commands.add('clear_filters', () => {
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ from werkzeug.local import Local, release_local
|
|||
import os, sys, importlib, inspect, json
|
||||
from past.builtins import cmp
|
||||
import click
|
||||
from faker import Faker
|
||||
|
||||
# public
|
||||
from .exceptions import *
|
||||
|
|
@ -196,17 +195,20 @@ def init(site, sites_path=None, new_site=False):
|
|||
|
||||
local.initialised = True
|
||||
|
||||
def connect(site=None, db_name=None):
|
||||
def connect(site=None, db_name=None, set_admin_as_user=True):
|
||||
"""Connect to site database instance.
|
||||
|
||||
:param site: If site is given, calls `frappe.init`.
|
||||
:param db_name: Optional. Will use from `site_config.json`."""
|
||||
:param db_name: Optional. Will use from `site_config.json`.
|
||||
:param set_admin_as_user: Set Administrator as current user.
|
||||
"""
|
||||
from frappe.database import get_db
|
||||
if site:
|
||||
init(site)
|
||||
|
||||
local.db = get_db(user=db_name or local.conf.db_name)
|
||||
set_user("Administrator")
|
||||
if set_admin_as_user:
|
||||
set_user("Administrator")
|
||||
|
||||
def connect_replica():
|
||||
from frappe.database import get_db
|
||||
|
|
@ -468,8 +470,8 @@ def get_request_header(key, default=None):
|
|||
|
||||
def sendmail(recipients=[], sender="", subject="No Subject", message="No Message",
|
||||
as_markdown=False, delayed=True, reference_doctype=None, reference_name=None,
|
||||
unsubscribe_method=None, unsubscribe_params=None, unsubscribe_message=None,
|
||||
attachments=None, content=None, doctype=None, name=None, reply_to=None,
|
||||
unsubscribe_method=None, unsubscribe_params=None, unsubscribe_message=None, add_unsubscribe_link=1,
|
||||
attachments=None, content=None, doctype=None, name=None, reply_to=None, queue_separately=False,
|
||||
cc=[], bcc=[], message_id=None, in_reply_to=None, send_after=None, expose_recipients=None,
|
||||
send_priority=1, communication=None, retry=1, now=None, read_receipt=None, is_notification=False,
|
||||
inline_images=None, template=None, args=None, header=None, print_letterhead=False, with_container=False):
|
||||
|
|
@ -516,10 +518,10 @@ def sendmail(recipients=[], sender="", subject="No Subject", message="No Message
|
|||
from frappe.email import queue
|
||||
queue.send(recipients=recipients, sender=sender,
|
||||
subject=subject, message=message, text_content=text_content,
|
||||
reference_doctype = doctype or reference_doctype, reference_name = name or reference_name,
|
||||
reference_doctype = doctype or reference_doctype, reference_name = name or reference_name, add_unsubscribe_link=add_unsubscribe_link,
|
||||
unsubscribe_method=unsubscribe_method, unsubscribe_params=unsubscribe_params, unsubscribe_message=unsubscribe_message,
|
||||
attachments=attachments, reply_to=reply_to, cc=cc, bcc=bcc, message_id=message_id, in_reply_to=in_reply_to,
|
||||
send_after=send_after, expose_recipients=expose_recipients, send_priority=send_priority,
|
||||
send_after=send_after, expose_recipients=expose_recipients, send_priority=send_priority, queue_separately=queue_separately,
|
||||
communication=communication, now=now, read_receipt=read_receipt, is_notification=is_notification,
|
||||
inline_images=inline_images, header=header, print_letterhead=print_letterhead, with_container=with_container)
|
||||
|
||||
|
|
@ -1747,6 +1749,8 @@ def parse_json(val):
|
|||
return parse_json(val)
|
||||
|
||||
def mock(type, size=1, locale='en'):
|
||||
from faker import Faker
|
||||
|
||||
results = []
|
||||
faker = Faker(locale)
|
||||
if not type in dir(faker):
|
||||
|
|
|
|||
|
|
@ -128,6 +128,8 @@ def init_request(request):
|
|||
if frappe.local.conf.get('maintenance_mode'):
|
||||
frappe.connect()
|
||||
raise frappe.SessionStopped('Session Stopped')
|
||||
else:
|
||||
frappe.connect(set_admin_as_user=False)
|
||||
|
||||
make_form_dict(request)
|
||||
|
||||
|
|
@ -152,10 +154,10 @@ def process_response(response):
|
|||
|
||||
def set_cors_headers(response):
|
||||
origin = frappe.request.headers.get('Origin')
|
||||
if not origin:
|
||||
allow_cors = frappe.conf.allow_cors
|
||||
if not (origin and allow_cors):
|
||||
return
|
||||
|
||||
allow_cors = frappe.conf.allow_cors
|
||||
if allow_cors != "*":
|
||||
if not isinstance(allow_cors, list):
|
||||
allow_cors = [allow_cors]
|
||||
|
|
@ -181,6 +183,9 @@ def make_form_dict(request):
|
|||
else:
|
||||
args = request.form or request.args
|
||||
|
||||
if not isinstance(args, dict):
|
||||
frappe.throw("Invalid request arguments")
|
||||
|
||||
try:
|
||||
frappe.local.form_dict = frappe._dict({ k:v[0] if isinstance(v, (list, tuple)) else v \
|
||||
for k, v in iteritems(args) })
|
||||
|
|
|
|||
175
frappe/auth.py
175
frappe/auth.py
|
|
@ -207,23 +207,44 @@ class LoginManager:
|
|||
if frappe.session.user != "Guest":
|
||||
clear_sessions(frappe.session.user, keep_current=True)
|
||||
|
||||
def authenticate(self, user=None, pwd=None):
|
||||
def authenticate(self, user: str = None, pwd: str = None):
|
||||
from frappe.core.doctype.user.user import User
|
||||
|
||||
if not (user and pwd):
|
||||
user, pwd = frappe.form_dict.get('usr'), frappe.form_dict.get('pwd')
|
||||
if not (user and pwd):
|
||||
self.fail(_('Incomplete login details'), user=user)
|
||||
|
||||
if cint(frappe.db.get_value("System Settings", "System Settings", "allow_login_using_mobile_number")):
|
||||
user = frappe.db.get_value("User", filters={"mobile_no": user}, fieldname="name") or user
|
||||
# Ignore password check if tmp_id is set, 2FA takes care of authentication.
|
||||
validate_password = not bool(frappe.form_dict.get('tmp_id'))
|
||||
user = User.find_by_credentials(user, pwd, validate_password=validate_password)
|
||||
|
||||
if cint(frappe.db.get_value("System Settings", "System Settings", "allow_login_using_user_name")):
|
||||
user = frappe.db.get_value("User", filters={"username": user}, fieldname="name") or user
|
||||
if not user:
|
||||
self.fail('Invalid login credentials')
|
||||
|
||||
self.check_if_enabled(user)
|
||||
if not frappe.form_dict.get('tmp_id'):
|
||||
self.user = self.check_password(user, pwd)
|
||||
sys_settings = frappe.get_doc("System Settings")
|
||||
track_login_attempts = (sys_settings.allow_consecutive_login_attempts >0)
|
||||
|
||||
tracker_kwargs = {}
|
||||
if track_login_attempts:
|
||||
tracker_kwargs['lock_interval'] = sys_settings.allow_login_after_fail
|
||||
tracker_kwargs['max_consecutive_login_attempts'] = sys_settings.allow_consecutive_login_attempts
|
||||
|
||||
tracker = LoginAttemptTracker(user.name, **tracker_kwargs)
|
||||
|
||||
if track_login_attempts and not tracker.is_user_allowed():
|
||||
frappe.throw(_("Your account has been locked and will resume after {0} seconds")
|
||||
.format(sys_settings.allow_login_after_fail), frappe.SecurityException)
|
||||
|
||||
if not user.is_authenticated:
|
||||
tracker.add_failure_attempt()
|
||||
self.fail('Invalid login credentials', user=user.name)
|
||||
elif not (user.name == 'Administrator' or user.enabled):
|
||||
tracker.add_failure_attempt()
|
||||
self.fail('User disabled or missing', user=user.name)
|
||||
else:
|
||||
self.user = user
|
||||
tracker.add_success_attempt()
|
||||
self.user = user.name
|
||||
|
||||
def force_user_to_reset_password(self):
|
||||
if not self.user:
|
||||
|
|
@ -245,23 +266,12 @@ class LoginManager:
|
|||
if last_pwd_reset_days > reset_pwd_after_days:
|
||||
return True
|
||||
|
||||
def check_if_enabled(self, user):
|
||||
"""raise exception if user not enabled"""
|
||||
doc = frappe.get_doc("System Settings")
|
||||
if cint(doc.allow_consecutive_login_attempts) > 0:
|
||||
check_consecutive_login_attempts(user, doc)
|
||||
|
||||
if user=='Administrator': return
|
||||
if not cint(frappe.db.get_value('User', user, 'enabled')):
|
||||
self.fail('User disabled or missing', user=user)
|
||||
|
||||
def check_password(self, user, pwd):
|
||||
"""check password"""
|
||||
try:
|
||||
# returns user in correct case
|
||||
return check_password(user, pwd)
|
||||
except frappe.AuthenticationError:
|
||||
self.update_invalid_login(user)
|
||||
self.fail('Incorrect password', user=user)
|
||||
|
||||
def fail(self, message, user=None):
|
||||
|
|
@ -272,15 +282,6 @@ class LoginManager:
|
|||
frappe.db.commit()
|
||||
raise frappe.AuthenticationError
|
||||
|
||||
def update_invalid_login(self, user):
|
||||
last_login_tried = get_last_tried_login_data(user)
|
||||
|
||||
failed_count = 0
|
||||
if last_login_tried > get_datetime():
|
||||
failed_count = get_login_failed_count(user)
|
||||
|
||||
frappe.cache().hset('login_failed_count', user, failed_count + 1)
|
||||
|
||||
def run_trigger(self, event='on_login'):
|
||||
for method in frappe.get_hooks().get(event, []):
|
||||
frappe.call(frappe.get_attr(method), login_manager=self)
|
||||
|
|
@ -383,38 +384,6 @@ def clear_cookies():
|
|||
frappe.session.sid = ""
|
||||
frappe.local.cookie_manager.delete_cookie(["full_name", "user_id", "sid", "user_image", "system_user"])
|
||||
|
||||
def get_last_tried_login_data(user, get_last_login=False):
|
||||
locked_account_time = frappe.cache().hget('locked_account_time', user)
|
||||
if get_last_login and locked_account_time:
|
||||
return locked_account_time
|
||||
|
||||
last_login_tried = frappe.cache().hget('last_login_tried', user)
|
||||
if not last_login_tried or last_login_tried < get_datetime():
|
||||
last_login_tried = get_datetime() + datetime.timedelta(seconds=60)
|
||||
|
||||
frappe.cache().hset('last_login_tried', user, last_login_tried)
|
||||
|
||||
return last_login_tried
|
||||
|
||||
def get_login_failed_count(user):
|
||||
return cint(frappe.cache().hget('login_failed_count', user)) or 0
|
||||
|
||||
def check_consecutive_login_attempts(user, doc):
|
||||
login_failed_count = get_login_failed_count(user)
|
||||
last_login_tried = (get_last_tried_login_data(user, True)
|
||||
+ datetime.timedelta(seconds=doc.allow_login_after_fail))
|
||||
|
||||
if login_failed_count >= cint(doc.allow_consecutive_login_attempts):
|
||||
locked_account_time = frappe.cache().hget('locked_account_time', user)
|
||||
if not locked_account_time:
|
||||
frappe.cache().hset('locked_account_time', user, get_datetime())
|
||||
|
||||
if last_login_tried > get_datetime():
|
||||
frappe.throw(_("Your account has been locked and will resume after {0} seconds")
|
||||
.format(doc.allow_login_after_fail), frappe.SecurityException)
|
||||
else:
|
||||
delete_login_failed_cache(user)
|
||||
|
||||
def validate_ip_address(user):
|
||||
"""check if IP Address is valid"""
|
||||
user = frappe.get_cached_doc("User", user) if not frappe.flags.in_test else frappe.get_doc("User", user)
|
||||
|
|
@ -436,3 +405,87 @@ def validate_ip_address(user):
|
|||
return
|
||||
|
||||
frappe.throw(_("Access not allowed from this IP Address"), frappe.AuthenticationError)
|
||||
|
||||
|
||||
class LoginAttemptTracker(object):
|
||||
"""Track login attemts of a user.
|
||||
|
||||
Lock the account for s number of seconds if there have been n consecutive unsuccessful attempts to log in.
|
||||
"""
|
||||
def __init__(self, user_name: str, max_consecutive_login_attempts: int=3, lock_interval:int = 5*60):
|
||||
""" Initialize the tracker.
|
||||
|
||||
:param user_name: Name of the loggedin user
|
||||
:param max_consecutive_login_attempts: Maximum allowed consecutive failed login attempts
|
||||
:param lock_interval: Locking interval incase of maximum failed attempts
|
||||
"""
|
||||
self.user_name = user_name
|
||||
self.lock_interval = datetime.timedelta(seconds=lock_interval)
|
||||
self.max_failed_logins = max_consecutive_login_attempts
|
||||
|
||||
@property
|
||||
def login_failed_count(self):
|
||||
return frappe.cache().hget('login_failed_count', self.user_name)
|
||||
|
||||
@login_failed_count.setter
|
||||
def login_failed_count(self, count):
|
||||
frappe.cache().hset('login_failed_count', self.user_name, count)
|
||||
|
||||
@login_failed_count.deleter
|
||||
def login_failed_count(self):
|
||||
frappe.cache().hdel('login_failed_count', self.user_name)
|
||||
|
||||
@property
|
||||
def login_failed_time(self):
|
||||
"""First failed login attempt time within lock interval.
|
||||
|
||||
For every user we track only First failed login attempt time within lock interval of time.
|
||||
"""
|
||||
return frappe.cache().hget('login_failed_time', self.user_name)
|
||||
|
||||
@login_failed_time.setter
|
||||
def login_failed_time(self, timestamp):
|
||||
frappe.cache().hset('login_failed_time', self.user_name, timestamp)
|
||||
|
||||
@login_failed_time.deleter
|
||||
def login_failed_time(self):
|
||||
frappe.cache().hdel('login_failed_time', self.user_name)
|
||||
|
||||
def add_failure_attempt(self):
|
||||
""" Log user failure attempts into the system.
|
||||
|
||||
Increase the failure count if new failure is with in current lock interval time period, if not reset the login failure count.
|
||||
"""
|
||||
login_failed_time = self.login_failed_time
|
||||
login_failed_count = self.login_failed_count # Consecutive login failure count
|
||||
current_time = get_datetime()
|
||||
|
||||
if not (login_failed_time and login_failed_count):
|
||||
login_failed_time, login_failed_count = current_time, 0
|
||||
|
||||
if login_failed_time + self.lock_interval > current_time:
|
||||
login_failed_count += 1
|
||||
else:
|
||||
login_failed_time, login_failed_count = current_time, 1
|
||||
|
||||
self.login_failed_time = login_failed_time
|
||||
self.login_failed_count = login_failed_count
|
||||
|
||||
def add_success_attempt(self):
|
||||
"""Reset login failures.
|
||||
"""
|
||||
del self.login_failed_count
|
||||
del self.login_failed_time
|
||||
|
||||
def is_user_allowed(self) -> bool:
|
||||
"""Is user allowed to login
|
||||
|
||||
User is not allowed to login if login failures are greater than threshold within in lock interval from first login failure.
|
||||
"""
|
||||
login_failed_time = self.login_failed_time
|
||||
login_failed_count = self.login_failed_count or 0
|
||||
current_time = get_datetime()
|
||||
|
||||
if login_failed_time and login_failed_time + self.lock_interval > current_time and login_failed_count > self.max_failed_logins:
|
||||
return False
|
||||
return True
|
||||
|
|
|
|||
|
|
@ -9,6 +9,16 @@ frappe.ui.form.on('Assignment Rule', {
|
|||
frm.events.rule(frm);
|
||||
},
|
||||
|
||||
setup: function(frm) {
|
||||
frm.set_query("document_type", () => {
|
||||
return {
|
||||
filters: {
|
||||
name: ["!=", "ToDo"]
|
||||
}
|
||||
};
|
||||
});
|
||||
},
|
||||
|
||||
document_type: function(frm) {
|
||||
frm.trigger('set_options');
|
||||
},
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@ class AssignmentRule(Document):
|
|||
if not len(set(assignment_days)) == len(assignment_days):
|
||||
repeated_days = get_repeated(assignment_days)
|
||||
frappe.throw(_("Assignment Day {0} has been repeated.").format(frappe.bold(repeated_days)))
|
||||
if self.document_type == 'ToDo':
|
||||
frappe.throw(_('Assignment Rule is not allowed on {0} document type').format(frappe.bold("ToDo")))
|
||||
|
||||
def on_update(self):
|
||||
clear_assignment_rule_cache(self)
|
||||
|
|
@ -298,4 +300,4 @@ def get_repeated(values):
|
|||
|
||||
def clear_assignment_rule_cache(rule):
|
||||
frappe.cache_manager.clear_doctype_map('Assignment Rule', rule.document_type)
|
||||
frappe.cache_manager.clear_doctype_map('Assignment Rule', 'due_date_rules_for_' + rule.document_type)
|
||||
frappe.cache_manager.clear_doctype_map('Assignment Rule', 'due_date_rules_for_' + rule.document_type)
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ import frappe
|
|||
from frappe.utils.minify import JavascriptMinify
|
||||
|
||||
import click
|
||||
from requests import get
|
||||
from six import iteritems, text_type
|
||||
from six.moves.urllib.parse import urlparse
|
||||
|
||||
|
|
@ -26,6 +25,8 @@ sites_path = os.path.abspath(os.getcwd())
|
|||
|
||||
|
||||
def download_file(url, prefix):
|
||||
from requests import get
|
||||
|
||||
filename = urlparse(url).path.split("/")[-1]
|
||||
local_filename = os.path.join(prefix, filename)
|
||||
with get(url, stream=True, allow_redirects=True) as r:
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ import click
|
|||
import frappe
|
||||
from frappe.commands import get_site, pass_context
|
||||
from frappe.exceptions import SiteNotSpecifiedError
|
||||
from frappe.installer import _new_site
|
||||
|
||||
|
||||
@click.command('new-site')
|
||||
|
|
@ -31,6 +30,8 @@ def new_site(site, mariadb_root_username=None, mariadb_root_password=None, admin
|
|||
verbose=False, install_apps=None, source_sql=None, force=None, no_mariadb_socket=False,
|
||||
install_app=None, db_name=None, db_password=None, db_type=None, db_host=None, db_port=None):
|
||||
"Create a new site"
|
||||
from frappe.installer import _new_site
|
||||
|
||||
frappe.init(site=site, new_site=True)
|
||||
|
||||
_new_site(db_name, site, mariadb_root_username=mariadb_root_username,
|
||||
|
|
@ -57,6 +58,7 @@ def new_site(site, mariadb_root_username=None, mariadb_root_password=None, admin
|
|||
def restore(context, sql_file_path, mariadb_root_username=None, mariadb_root_password=None, db_name=None, verbose=None, install_app=None, admin_password=None, force=None, with_public_files=None, with_private_files=None):
|
||||
"Restore site database from an sql file"
|
||||
from frappe.installer import (
|
||||
_new_site,
|
||||
extract_sql_from_archive,
|
||||
extract_files,
|
||||
is_downgrade,
|
||||
|
|
@ -145,6 +147,8 @@ def reinstall(context, admin_password=None, mariadb_root_username=None, mariadb_
|
|||
_reinstall(site, admin_password, mariadb_root_username, mariadb_root_password, yes, verbose=context.verbose)
|
||||
|
||||
def _reinstall(site, admin_password=None, mariadb_root_username=None, mariadb_root_password=None, yes=False, verbose=False):
|
||||
from frappe.installer import _new_site
|
||||
|
||||
if not yes:
|
||||
click.confirm('This will wipe your database. Are you sure you want to reinstall?', abort=True)
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -77,6 +77,10 @@ class TestActivityLog(unittest.TestCase):
|
|||
self.assertRaises(frappe.AuthenticationError, LoginManager)
|
||||
self.assertRaises(frappe.AuthenticationError, LoginManager)
|
||||
self.assertRaises(frappe.AuthenticationError, LoginManager)
|
||||
|
||||
# REMOVE ME: current logic allows allow_consecutive_login_attempts+1 attempts
|
||||
# before raising security exception, remove below line when that is fixed.
|
||||
self.assertRaises(frappe.AuthenticationError, LoginManager)
|
||||
self.assertRaises(frappe.SecurityException, LoginManager)
|
||||
time.sleep(5)
|
||||
self.assertRaises(frappe.AuthenticationError, LoginManager)
|
||||
|
|
|
|||
|
|
@ -555,7 +555,7 @@
|
|||
},
|
||||
{
|
||||
"group": "Customization",
|
||||
"link_doctype": "Custom Script",
|
||||
"link_doctype": "Client Script",
|
||||
"link_fieldname": "dt"
|
||||
},
|
||||
{
|
||||
|
|
@ -609,7 +609,7 @@
|
|||
"link_fieldname": "reference_doctype"
|
||||
}
|
||||
],
|
||||
"modified": "2020-12-10 15:10:09.227205",
|
||||
"modified": "2021-02-04 15:10:09.227205",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Core",
|
||||
"name": "DocType",
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
# For license information, please see license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
from typing import Dict, List
|
||||
|
||||
import frappe, json
|
||||
from frappe.model.document import Document
|
||||
|
|
@ -11,12 +12,13 @@ from datetime import datetime
|
|||
from croniter import croniter
|
||||
from frappe.utils.background_jobs import enqueue, get_jobs
|
||||
|
||||
|
||||
class ScheduledJobType(Document):
|
||||
def autoname(self):
|
||||
self.name = '.'.join(self.method.split('.')[-2:])
|
||||
self.name = ".".join(self.method.split(".")[-2:])
|
||||
|
||||
def validate(self):
|
||||
if self.frequency != 'All':
|
||||
if self.frequency != "All":
|
||||
# force logging for all events other than continuous ones (ALL)
|
||||
self.create_log = 1
|
||||
|
||||
|
|
@ -69,7 +71,7 @@ class ScheduledJobType(Document):
|
|||
def execute(self):
|
||||
self.scheduler_log = None
|
||||
try:
|
||||
self.log_status('Start')
|
||||
self.log_status('Started')
|
||||
if self.server_script:
|
||||
script_name = frappe.db.get_value("Server Script", self.server_script)
|
||||
if script_name:
|
||||
|
|
@ -84,7 +86,7 @@ class ScheduledJobType(Document):
|
|||
|
||||
def log_status(self, status):
|
||||
# log file
|
||||
frappe.logger("scheduler").info('Scheduled Job {0}: {1} for {2}'.format(status, self.method, frappe.local.site))
|
||||
frappe.logger("scheduler").info(f"Scheduled Job {status}: {self.method} for {frappe.local.site}")
|
||||
self.update_scheduler_log(status)
|
||||
|
||||
def update_scheduler_log(self, status):
|
||||
|
|
@ -111,28 +113,29 @@ class ScheduledJobType(Document):
|
|||
|
||||
|
||||
@frappe.whitelist()
|
||||
def execute_event(doc):
|
||||
frappe.only_for('System Manager')
|
||||
def execute_event(doc: str):
|
||||
frappe.only_for("System Manager")
|
||||
doc = json.loads(doc)
|
||||
frappe.get_doc('Scheduled Job Type', doc.get('name')).enqueue(force=True)
|
||||
frappe.get_doc("Scheduled Job Type", doc.get("name")).enqueue(force=True)
|
||||
return doc
|
||||
|
||||
|
||||
def run_scheduled_job(job_type):
|
||||
'''This is a wrapper function that runs a hooks.scheduler_events method'''
|
||||
def run_scheduled_job(job_type: str):
|
||||
"""This is a wrapper function that runs a hooks.scheduler_events method"""
|
||||
try:
|
||||
frappe.get_doc('Scheduled Job Type', dict(method=job_type)).execute()
|
||||
frappe.get_doc("Scheduled Job Type", dict(method=job_type)).execute()
|
||||
except Exception:
|
||||
print(frappe.get_traceback())
|
||||
|
||||
|
||||
def sync_jobs(hooks=None):
|
||||
def sync_jobs(hooks: Dict = None):
|
||||
frappe.reload_doc("core", "doctype", "scheduled_job_type")
|
||||
scheduler_events = hooks or frappe.get_hooks("scheduler_events")
|
||||
all_events = insert_events(scheduler_events)
|
||||
clear_events(all_events)
|
||||
|
||||
|
||||
def insert_events(scheduler_events):
|
||||
def insert_events(scheduler_events: Dict) -> List:
|
||||
cron_jobs, event_jobs = [], []
|
||||
for event_type in scheduler_events:
|
||||
events = scheduler_events.get(event_type)
|
||||
|
|
@ -144,7 +147,7 @@ def insert_events(scheduler_events):
|
|||
return cron_jobs + event_jobs
|
||||
|
||||
|
||||
def insert_cron_jobs(events):
|
||||
def insert_cron_jobs(events: Dict) -> List:
|
||||
cron_jobs = []
|
||||
for cron_format in events:
|
||||
for event in events.get(cron_format):
|
||||
|
|
@ -153,25 +156,29 @@ def insert_cron_jobs(events):
|
|||
return cron_jobs
|
||||
|
||||
|
||||
def insert_event_jobs(events, event_type):
|
||||
def insert_event_jobs(events: List, event_type: str) -> List:
|
||||
event_jobs = []
|
||||
for event in events:
|
||||
event_jobs.append(event)
|
||||
frequency = event_type.replace('_', ' ').title()
|
||||
frequency = event_type.replace("_", " ").title()
|
||||
insert_single_event(frequency, event)
|
||||
return event_jobs
|
||||
|
||||
|
||||
def insert_single_event(frequency, event, cron_format=None):
|
||||
def insert_single_event(frequency: str, event: str, cron_format: str = None):
|
||||
cron_expr = {"cron_format": cron_format} if cron_format else {}
|
||||
doc = frappe.get_doc({
|
||||
"doctype": "Scheduled Job Type",
|
||||
"method": event,
|
||||
"cron_format": cron_format,
|
||||
"frequency": frequency
|
||||
})
|
||||
doc = frappe.get_doc(
|
||||
{
|
||||
"doctype": "Scheduled Job Type",
|
||||
"method": event,
|
||||
"cron_format": cron_format,
|
||||
"frequency": frequency,
|
||||
}
|
||||
)
|
||||
|
||||
if not frappe.db.exists("Scheduled Job Type", {"method": event, "frequency": frequency, **cron_expr }):
|
||||
if not frappe.db.exists(
|
||||
"Scheduled Job Type", {"method": event, "frequency": frequency, **cron_expr}
|
||||
):
|
||||
try:
|
||||
doc.insert()
|
||||
except frappe.DuplicateEntryError:
|
||||
|
|
@ -179,7 +186,12 @@ def insert_single_event(frequency, event, cron_format=None):
|
|||
doc.insert()
|
||||
|
||||
|
||||
def clear_events(all_events):
|
||||
for event in frappe.get_all("Scheduled Job Type", ("name", "method")):
|
||||
if event.method not in all_events:
|
||||
def clear_events(all_events: List):
|
||||
for event in frappe.get_all(
|
||||
"Scheduled Job Type", fields=["name", "method", "server_script"]
|
||||
):
|
||||
is_server_script = event.server_script
|
||||
is_defined_in_hooks = event.method in all_events
|
||||
|
||||
if not (is_defined_in_hooks or is_server_script):
|
||||
frappe.delete_doc("Scheduled Job Type", event.name)
|
||||
|
|
|
|||
|
|
@ -6,46 +6,11 @@ frappe.ui.form.on('Server Script', {
|
|||
frm.trigger('setup_help');
|
||||
},
|
||||
refresh: function(frm) {
|
||||
if (frm.doc.script_type === 'Scheduler Event' && !frm.doc.disabled) {
|
||||
frm.add_custom_button('Schedule Script', function() {
|
||||
var d = new frappe.ui.Dialog({
|
||||
title: "Schedule Script Execution",
|
||||
fields: [
|
||||
{
|
||||
fieldname: "event_type",
|
||||
label: __('Select Event Type'),
|
||||
fieldtype: "Select",
|
||||
options: "All\nHourly\nDaily\nWeekly\nMonthly\nYearly\nHourly Long\nDaily Long\nWeekly Long\nMonthly Long"
|
||||
},
|
||||
],
|
||||
primary_action_label: __('Schedule Script'),
|
||||
primary_action: () => {
|
||||
d.get_primary_btn().attr('disabled', true);
|
||||
var data = d.get_values();
|
||||
d.hide();
|
||||
if(data) {
|
||||
frm.events.schedule_script(frm, data);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
d.show();
|
||||
|
||||
});
|
||||
if (frm.doc.script_type != 'Scheduler Event') {
|
||||
frm.dashboard.hide();
|
||||
}
|
||||
},
|
||||
|
||||
schedule_script(frm, data) {
|
||||
frm.call({
|
||||
method: "frappe.core.doctype.server_script.server_script.setup_scheduler_events",
|
||||
args: {
|
||||
'script_name': frm.doc.name,
|
||||
'frequency': data.event_type
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
setup_help(frm) {
|
||||
frm.get_field('help_html').html(`
|
||||
<h4>DocType Event</h4>
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
"field_order": [
|
||||
"script_type",
|
||||
"reference_doctype",
|
||||
"event_frequency",
|
||||
"doctype_event",
|
||||
"api_method",
|
||||
"allow_guest",
|
||||
|
|
@ -84,11 +85,24 @@
|
|||
{
|
||||
"fieldname": "help_html",
|
||||
"fieldtype": "HTML"
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:doc.script_type == \"Scheduler Event\"",
|
||||
"fieldname": "event_frequency",
|
||||
"fieldtype": "Select",
|
||||
"label": "Event Frequency",
|
||||
"mandatory_depends_on": "eval:doc.script_type == \"Scheduler Event\"",
|
||||
"options": "All\nHourly\nDaily\nWeekly\nMonthly\nYearly\nHourly Long\nDaily Long\nWeekly Long\nMonthly Long"
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2021-01-03 18:50:14.767595",
|
||||
"links": [
|
||||
{
|
||||
"link_doctype": "Scheduled Job Type",
|
||||
"link_fieldname": "server_script"
|
||||
}
|
||||
],
|
||||
"modified": "2021-02-18 12:36:19.803425",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Core",
|
||||
"name": "Server Script",
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
import ast
|
||||
from typing import Dict, List
|
||||
|
||||
import frappe
|
||||
from frappe.model.document import Document
|
||||
|
|
@ -14,67 +15,146 @@ from frappe import _
|
|||
|
||||
class ServerScript(Document):
|
||||
def validate(self):
|
||||
frappe.only_for('Script Manager', True)
|
||||
frappe.only_for("Script Manager", True)
|
||||
self.validate_script()
|
||||
self.sync_scheduled_jobs()
|
||||
self.clear_scheduled_events()
|
||||
|
||||
def on_update(self):
|
||||
frappe.cache().delete_value("server_script_map")
|
||||
self.sync_scheduler_events()
|
||||
|
||||
def on_trash(self):
|
||||
if self.script_type == "Scheduler Event":
|
||||
for job in self.scheduled_jobs:
|
||||
frappe.delete_doc("Scheduled Job Type", job.name)
|
||||
|
||||
@property
|
||||
def scheduled_jobs(self) -> List[Dict[str, str]]:
|
||||
return frappe.get_all(
|
||||
"Scheduled Job Type",
|
||||
filters={"server_script": self.name},
|
||||
fields=["name", "stopped"],
|
||||
)
|
||||
|
||||
def validate_script(self):
|
||||
"""Utilizes the ast module to check for syntax errors
|
||||
"""
|
||||
ast.parse(self.script)
|
||||
|
||||
@staticmethod
|
||||
def on_update():
|
||||
frappe.cache().delete_value('server_script_map')
|
||||
def sync_scheduled_jobs(self):
|
||||
"""Sync Scheduled Job Type statuses if Server Script's disabled status is changed
|
||||
"""
|
||||
if self.script_type != "Scheduler Event" or not self.has_value_changed("disabled"):
|
||||
return
|
||||
|
||||
def execute_method(self):
|
||||
if self.script_type == 'API':
|
||||
# validate if guest is allowed
|
||||
if frappe.session.user == 'Guest' and not self.allow_guest:
|
||||
raise frappe.PermissionError
|
||||
_globals, _locals = safe_exec(self.script)
|
||||
return _globals.frappe.flags # output can be stored in flags
|
||||
else:
|
||||
# wrong report type!
|
||||
for scheduled_job in self.scheduled_jobs:
|
||||
if bool(scheduled_job.stopped) != bool(self.disabled):
|
||||
job = frappe.get_doc("Scheduled Job Type", scheduled_job.name)
|
||||
job.stopped = self.disabled
|
||||
job.save()
|
||||
|
||||
def sync_scheduler_events(self):
|
||||
"""Create or update Scheduled Job Type documents for Scheduler Event Server Scripts
|
||||
"""
|
||||
if not self.disabled and self.event_frequency and self.script_type == "Scheduler Event":
|
||||
setup_scheduler_events(script_name=self.name, frequency=self.event_frequency)
|
||||
|
||||
def clear_scheduled_events(self):
|
||||
"""Deletes existing scheduled jobs by Server Script if self.event_frequency has changed
|
||||
"""
|
||||
if self.script_type == "Scheduler Event" and self.has_value_changed("event_frequency"):
|
||||
for scheduled_job in self.scheduled_jobs:
|
||||
frappe.delete_doc("Scheduled Job Type", scheduled_job.name)
|
||||
|
||||
def execute_method(self) -> Dict:
|
||||
"""Specific to API endpoint Server Scripts
|
||||
|
||||
Raises:
|
||||
frappe.DoesNotExistError: If self.script_type is not API
|
||||
frappe.PermissionError: If self.allow_guest is unset for API accessed by Guest user
|
||||
|
||||
Returns:
|
||||
dict: Evaluates self.script with frappe.utils.safe_exec.safe_exec and returns the flags set in it's safe globals
|
||||
"""
|
||||
# wrong report type!
|
||||
if self.script_type != "API":
|
||||
raise frappe.DoesNotExistError
|
||||
|
||||
def execute_doc(self, doc):
|
||||
# execute event
|
||||
safe_exec(self.script, None, dict(doc = doc))
|
||||
# validate if guest is allowed
|
||||
if frappe.session.user == "Guest" and not self.allow_guest:
|
||||
raise frappe.PermissionError
|
||||
|
||||
# output can be stored in flags
|
||||
_globals, _locals = safe_exec(self.script)
|
||||
return _globals.frappe.flags
|
||||
|
||||
def execute_doc(self, doc: Document):
|
||||
"""Specific to Document Event triggered Server Scripts
|
||||
|
||||
Args:
|
||||
doc (Document): Executes script with for a certain document's events
|
||||
"""
|
||||
safe_exec(self.script, _locals={"doc": doc})
|
||||
|
||||
def execute_scheduled_method(self):
|
||||
if self.script_type == 'Scheduler Event':
|
||||
safe_exec(self.script)
|
||||
else:
|
||||
# wrong report type!
|
||||
"""Specific to Scheduled Jobs via Server Scripts
|
||||
|
||||
Raises:
|
||||
frappe.DoesNotExistError: If script type is not a scheduler event
|
||||
"""
|
||||
if self.script_type != "Scheduler Event":
|
||||
raise frappe.DoesNotExistError
|
||||
|
||||
def get_permission_query_conditions(self, user):
|
||||
safe_exec(self.script)
|
||||
|
||||
def get_permission_query_conditions(self, user: str) -> List[str]:
|
||||
"""Specific to Permission Query Server Scripts
|
||||
|
||||
Args:
|
||||
user (str): Takes user email to execute script and return list of conditions
|
||||
|
||||
Returns:
|
||||
list: Returns list of conditions defined by rules in self.script
|
||||
"""
|
||||
locals = {"user": user, "conditions": ""}
|
||||
safe_exec(self.script, None, locals)
|
||||
if locals["conditions"]:
|
||||
return locals["conditions"]
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def setup_scheduler_events(script_name, frequency):
|
||||
method = frappe.scrub('{0}-{1}'.format(script_name, frequency))
|
||||
scheduled_script = frappe.db.get_value('Scheduled Job Type',
|
||||
dict(method=method))
|
||||
"""Creates or Updates Scheduled Job Type documents based on the specified script name and frequency
|
||||
|
||||
Args:
|
||||
script_name (str): Name of the Server Script document
|
||||
frequency (str): Event label compatible with the Frappe scheduler
|
||||
"""
|
||||
method = frappe.scrub(f"{script_name}-{frequency}")
|
||||
scheduled_script = frappe.db.get_value("Scheduled Job Type", {"method": method})
|
||||
|
||||
if not scheduled_script:
|
||||
doc = frappe.get_doc(dict(
|
||||
doctype = 'Scheduled Job Type',
|
||||
method = method,
|
||||
frequency = frequency,
|
||||
server_script = script_name
|
||||
))
|
||||
frappe.get_doc(
|
||||
{
|
||||
"doctype": "Scheduled Job Type",
|
||||
"method": method,
|
||||
"frequency": frequency,
|
||||
"server_script": script_name,
|
||||
}
|
||||
).insert()
|
||||
|
||||
doc.insert()
|
||||
|
||||
frappe.msgprint(_('Enabled scheduled execution for script {0}').format(script_name))
|
||||
frappe.msgprint(_("Enabled scheduled execution for script {0}").format(script_name))
|
||||
|
||||
else:
|
||||
doc = frappe.get_doc('Scheduled Job Type', scheduled_script)
|
||||
doc.update(dict(
|
||||
doctype = 'Scheduled Job Type',
|
||||
method = method,
|
||||
frequency = frequency,
|
||||
server_script = script_name
|
||||
))
|
||||
doc = frappe.get_doc("Scheduled Job Type", scheduled_script)
|
||||
|
||||
if doc.frequency == frequency:
|
||||
return
|
||||
|
||||
doc.frequency = frequency
|
||||
doc.save()
|
||||
|
||||
frappe.msgprint(_('Scheduled execution for script {0} has updated').format(script_name))
|
||||
frappe.msgprint(
|
||||
_("Scheduled execution for script {0} has updated").format(script_name)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import frappe
|
|||
from frappe.model.document import Document
|
||||
from frappe.utils import cint, flt, has_gravatar, escape_html, format_datetime, now_datetime, get_formatted_email, today
|
||||
from frappe import throw, msgprint, _
|
||||
from frappe.utils.password import update_password as _update_password
|
||||
from frappe.utils.password import update_password as _update_password, check_password
|
||||
from frappe.desk.notifications import clear_notifications
|
||||
from frappe.desk.doctype.notification_settings.notification_settings import create_notification_settings
|
||||
from frappe.utils.user import get_system_managers
|
||||
|
|
@ -527,6 +527,27 @@ class User(Document):
|
|||
|
||||
return [i.strip() for i in self.restrict_ip.split(",")]
|
||||
|
||||
@classmethod
|
||||
def find_by_credentials(cls, user_name: str, password: str, validate_password: bool = True):
|
||||
"""Find the user by credentials.
|
||||
"""
|
||||
login_with_mobile = cint(frappe.db.get_value("System Settings", "System Settings", "allow_login_using_mobile_number"))
|
||||
filter = {"mobile_no": user_name} if login_with_mobile else {"name": user_name}
|
||||
|
||||
user = frappe.db.get_value("User", filters=filter, fieldname=['name', 'enabled'], as_dict=True) or {}
|
||||
if not user:
|
||||
return
|
||||
|
||||
user['is_authenticated'] = True
|
||||
if validate_password:
|
||||
try:
|
||||
check_password(user_name, password)
|
||||
except frappe.AuthenticationError:
|
||||
user['is_authenticated'] = False
|
||||
|
||||
return user
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_timezones():
|
||||
import pytz
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
"hide_custom": 0,
|
||||
"icon": "tool",
|
||||
"idx": 0,
|
||||
"is_default": 0,
|
||||
"is_standard": 1,
|
||||
"label": "Build",
|
||||
"links": [
|
||||
|
|
@ -163,8 +164,8 @@
|
|||
{
|
||||
"hidden": 0,
|
||||
"is_query_report": 0,
|
||||
"label": "Custom Script",
|
||||
"link_to": "Custom Script",
|
||||
"label": "Client Script",
|
||||
"link_to": "Client Script",
|
||||
"link_type": "DocType",
|
||||
"onboard": 0,
|
||||
"only_for": "",
|
||||
|
|
@ -181,7 +182,7 @@
|
|||
"type": "Link"
|
||||
}
|
||||
],
|
||||
"modified": "2021-01-02 14:03:15.029699",
|
||||
"modified": "2021-02-04 13:48:48.493146",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Core",
|
||||
"name": "Build",
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (c) 2016, Frappe Technologies and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on('Custom Script', {
|
||||
frappe.ui.form.on('Client Script', {
|
||||
refresh(frm) {
|
||||
if (frm.doc.dt && frm.doc.script) {
|
||||
frm.add_custom_button(__('Go to {0}', [frm.doc.dt]),
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
"actions": [],
|
||||
"allow_import": 1,
|
||||
"creation": "2013-01-10 16:34:01",
|
||||
"description": "Adds a client custom script to a DocType",
|
||||
"description": "Adds a custom client script to a DocType",
|
||||
"doctype": "DocType",
|
||||
"document_type": "Document",
|
||||
"engine": "InnoDB",
|
||||
|
|
@ -22,9 +22,7 @@
|
|||
"oldfieldname": "dt",
|
||||
"oldfieldtype": "Link",
|
||||
"options": "DocType",
|
||||
"reqd": 1,
|
||||
"show_days": 1,
|
||||
"show_seconds": 1
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "script",
|
||||
|
|
@ -32,35 +30,29 @@
|
|||
"label": "Script",
|
||||
"oldfieldname": "script",
|
||||
"oldfieldtype": "Code",
|
||||
"options": "JS",
|
||||
"show_days": 1,
|
||||
"show_seconds": 1
|
||||
"options": "JS"
|
||||
},
|
||||
{
|
||||
"fieldname": "sample",
|
||||
"fieldtype": "HTML",
|
||||
"label": "Sample",
|
||||
"options": "<h3>Custom Script Help</h3>\n<p>Custom Scripts are executed only on the client-side (i.e. in Forms). Here are some examples to get you started</p>\n<pre><code>\n\n// fetch local_tax_no on selection of customer \n// cur_frm.add_fetch(link_field, source_fieldname, target_fieldname); \ncur_frm.add_fetch('customer', 'local_tax_no', 'local_tax_no');\n\n// additional validation on dates \nfrappe.ui.form.on('Task', 'validate', function(frm) {\n if (frm.doc.from_date < get_today()) {\n msgprint('You can not select past date in From Date');\n validated = false;\n } \n});\n\n// make a field read-only after saving \nfrappe.ui.form.on('Task', {\n refresh: function(frm) {\n // use the __islocal value of doc, to check if the doc is saved or not\n frm.set_df_property('myfield', 'read_only', frm.doc.__islocal ? 0 : 1);\n } \n});\n\n// additional permission check\nfrappe.ui.form.on('Task', {\n validate: function(frm) {\n if(user=='user1@example.com' && frm.doc.purpose!='Material Receipt') {\n msgprint('You are only allowed Material Receipt');\n validated = false;\n }\n } \n});\n\n// calculate sales incentive\nfrappe.ui.form.on('Sales Invoice', {\n validate: function(frm) {\n // calculate incentives for each person on the deal\n total_incentive = 0\n $.each(frm.doc.sales_team, function(i, d) {\n // calculate incentive\n var incentive_percent = 2;\n if(frm.doc.base_grand_total > 400) incentive_percent = 4;\n // actual incentive\n d.incentives = flt(frm.doc.base_grand_total) * incentive_percent / 100;\n total_incentive += flt(d.incentives)\n });\n frm.doc.total_incentive = total_incentive;\n } \n})\n\n</code></pre>",
|
||||
"show_days": 1,
|
||||
"show_seconds": 1
|
||||
"options": "<h3>Client Script Help</h3>\n<p>Client Scripts are executed only on the client-side (i.e. in Forms). Here are some examples to get you started</p>\n<pre><code>\n\n// fetch local_tax_no on selection of customer \n// cur_frm.add_fetch(link_field, source_fieldname, target_fieldname); \ncur_frm.add_fetch('customer', 'local_tax_no', 'local_tax_no');\n\n// additional validation on dates \nfrappe.ui.form.on('Task', 'validate', function(frm) {\n if (frm.doc.from_date < get_today()) {\n msgprint('You can not select past date in From Date');\n validated = false;\n } \n});\n\n// make a field read-only after saving \nfrappe.ui.form.on('Task', {\n refresh: function(frm) {\n // use the __islocal value of doc, to check if the doc is saved or not\n frm.set_df_property('myfield', 'read_only', frm.doc.__islocal ? 0 : 1);\n } \n});\n\n// additional permission check\nfrappe.ui.form.on('Task', {\n validate: function(frm) {\n if(user=='user1@example.com' && frm.doc.purpose!='Material Receipt') {\n msgprint('You are only allowed Material Receipt');\n validated = false;\n }\n } \n});\n\n// calculate sales incentive\nfrappe.ui.form.on('Sales Invoice', {\n validate: function(frm) {\n // calculate incentives for each person on the deal\n total_incentive = 0\n $.each(frm.doc.sales_team, function(i, d) {\n // calculate incentive\n var incentive_percent = 2;\n if(frm.doc.base_grand_total > 400) incentive_percent = 4;\n // actual incentive\n d.incentives = flt(frm.doc.base_grand_total) * incentive_percent / 100;\n total_incentive += flt(d.incentives)\n });\n frm.doc.total_incentive = total_incentive;\n } \n})\n\n</code></pre>"
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"fieldname": "enabled",
|
||||
"fieldtype": "Check",
|
||||
"label": "Enabled",
|
||||
"show_days": 1,
|
||||
"show_seconds": 1
|
||||
"label": "Enabled"
|
||||
}
|
||||
],
|
||||
"icon": "fa fa-glass",
|
||||
"idx": 1,
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2020-08-24 21:56:07.719579",
|
||||
"modified": "2021-02-04 13:57:56.509437",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Custom",
|
||||
"name": "Custom Script",
|
||||
"name": "Client Script",
|
||||
"owner": "Administrator",
|
||||
"permissions": [
|
||||
{
|
||||
|
|
@ -86,6 +78,7 @@
|
|||
"write": 1
|
||||
}
|
||||
],
|
||||
"sort_field": "modified",
|
||||
"sort_order": "ASC",
|
||||
"track_changes": 1
|
||||
}
|
||||
|
|
@ -5,9 +5,9 @@ import frappe
|
|||
|
||||
from frappe.model.document import Document
|
||||
|
||||
class CustomScript(Document):
|
||||
class ClientScript(Document):
|
||||
def autoname(self):
|
||||
self.name = self.dt + "-Client"
|
||||
self.name = self.dt
|
||||
|
||||
def on_update(self):
|
||||
frappe.clear_cache(doctype=self.dt)
|
||||
|
|
@ -6,7 +6,7 @@ from __future__ import unicode_literals
|
|||
import frappe
|
||||
import unittest
|
||||
|
||||
# test_records = frappe.get_test_records('Custom Script')
|
||||
# test_records = frappe.get_test_records('Client Script')
|
||||
|
||||
class TestCustomScript(unittest.TestCase):
|
||||
class TestClientScript(unittest.TestCase):
|
||||
pass
|
||||
|
|
@ -10,6 +10,7 @@
|
|||
"hide_custom": 0,
|
||||
"icon": "customization",
|
||||
"idx": 0,
|
||||
"is_default": 0,
|
||||
"is_standard": 1,
|
||||
"label": "Customization",
|
||||
"links": [
|
||||
|
|
@ -81,8 +82,8 @@
|
|||
"dependencies": "",
|
||||
"hidden": 0,
|
||||
"is_query_report": 0,
|
||||
"label": "Custom Script",
|
||||
"link_to": "Custom Script",
|
||||
"label": "Client Script",
|
||||
"link_to": "Client Script",
|
||||
"link_type": "DocType",
|
||||
"onboard": 0,
|
||||
"type": "Link"
|
||||
|
|
@ -115,7 +116,7 @@
|
|||
"type": "Link"
|
||||
}
|
||||
],
|
||||
"modified": "2020-12-01 13:38:39.843773",
|
||||
"modified": "2021-02-04 13:50:35.750463",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Custom",
|
||||
"name": "Customization",
|
||||
|
|
@ -134,8 +135,14 @@
|
|||
"type": "DocType"
|
||||
},
|
||||
{
|
||||
"label": "Custom Script",
|
||||
"link_to": "Custom Script",
|
||||
"label": "Client Script",
|
||||
"link_to": "Client Script",
|
||||
"type": "DocType"
|
||||
},
|
||||
{
|
||||
"doc_view": "",
|
||||
"label": "Server Script",
|
||||
"link_to": "Server Script",
|
||||
"type": "DocType"
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ import frappe.model.meta
|
|||
from frappe import _
|
||||
from time import time
|
||||
from frappe.utils import now, getdate, cast_fieldtype, get_datetime
|
||||
from frappe.utils.background_jobs import execute_job, get_queue
|
||||
from frappe.model.utils.link_count import flush_local_link_count
|
||||
from frappe.utils import cint
|
||||
|
||||
|
|
@ -1032,6 +1031,8 @@ class Database(object):
|
|||
insert_list = []
|
||||
|
||||
def enqueue_jobs_after_commit():
|
||||
from frappe.utils.background_jobs import execute_job, get_queue
|
||||
|
||||
if frappe.flags.enqueue_after_commit and len(frappe.flags.enqueue_after_commit) > 0:
|
||||
for job in frappe.flags.enqueue_after_commit:
|
||||
q = get_queue(job.get("queue"), is_async=job.get("is_async"))
|
||||
|
|
|
|||
|
|
@ -8,8 +8,7 @@ from pymysql.times import TimeDelta
|
|||
from pymysql.constants import ER, FIELD_TYPE
|
||||
from pymysql.converters import conversions
|
||||
|
||||
from frappe.utils import get_datetime, cstr
|
||||
from markdown2 import UnicodeWithAttrs
|
||||
from frappe.utils import get_datetime, cstr, UnicodeWithAttrs
|
||||
from frappe.database.database import Database
|
||||
from six import PY2, binary_type, text_type, string_types
|
||||
from frappe.database.mariadb.schema import MariaDBTable
|
||||
|
|
|
|||
|
|
@ -601,8 +601,8 @@ def merge_cards_based_on_label(cards):
|
|||
for card in cards:
|
||||
label = card.get('label')
|
||||
if label in cards_dict:
|
||||
links = loads(cards_dict[label].links) + loads(card.links)
|
||||
cards_dict[label].update(dict(links=dumps(links)))
|
||||
links = cards_dict[label].links + card.links
|
||||
cards_dict[label].update(dict(links=links))
|
||||
cards_dict[label] = cards_dict.pop(label)
|
||||
else:
|
||||
cards_dict[label] = card
|
||||
|
|
|
|||
|
|
@ -17,6 +17,10 @@ class KanbanBoard(Document):
|
|||
def on_update(self):
|
||||
frappe.clear_cache(doctype=self.reference_doctype)
|
||||
|
||||
def before_insert(self):
|
||||
for column in self.columns:
|
||||
column.order = get_order_for_column(self, column.column_name)
|
||||
|
||||
def validate_column_name(self):
|
||||
for column in self.columns:
|
||||
if not column.column_name:
|
||||
|
|
@ -125,6 +129,53 @@ def update_order(board_name, order):
|
|||
board.save()
|
||||
return board, updated_cards
|
||||
|
||||
@frappe.whitelist()
|
||||
def update_order_for_single_card(board_name, docname, from_colname, to_colname, old_index, new_index):
|
||||
'''Save the order of cards in columns'''
|
||||
board = frappe.get_doc('Kanban Board', board_name)
|
||||
doctype = board.reference_doctype
|
||||
fieldname = board.field_name
|
||||
old_index = frappe.parse_json(old_index)
|
||||
new_index = frappe.parse_json(new_index)
|
||||
|
||||
# save current order and index of columns to be updated
|
||||
from_col_order, from_col_idx = get_kanban_column_order_and_index(board, from_colname)
|
||||
to_col_order, to_col_idx = get_kanban_column_order_and_index(board, to_colname)
|
||||
|
||||
if from_colname == to_colname:
|
||||
from_col_order = to_col_order
|
||||
|
||||
to_col_order.insert(new_index, from_col_order.pop((old_index)))
|
||||
|
||||
# save updated order
|
||||
board.columns[from_col_idx].order = frappe.as_json(from_col_order)
|
||||
board.columns[to_col_idx].order = frappe.as_json(to_col_order)
|
||||
board.save()
|
||||
|
||||
# update changed value in doc
|
||||
frappe.set_value(doctype, docname, fieldname, to_colname)
|
||||
|
||||
return board
|
||||
|
||||
def get_kanban_column_order_and_index(board, colname):
|
||||
for i, col in enumerate(board.columns):
|
||||
if col.column_name == colname:
|
||||
col_order = frappe.parse_json(col.order)
|
||||
col_idx = i
|
||||
|
||||
return col_order, col_idx
|
||||
|
||||
@frappe.whitelist()
|
||||
def add_card(board_name, docname, colname):
|
||||
board = frappe.get_doc('Kanban Board', board_name)
|
||||
|
||||
col_order, col_idx = get_kanban_column_order_and_index(board, colname)
|
||||
col_order.insert(0, docname)
|
||||
|
||||
board.columns[col_idx].order = frappe.as_json(col_order)
|
||||
|
||||
board.save()
|
||||
return board
|
||||
|
||||
@frappe.whitelist()
|
||||
def quick_kanban_board(doctype, board_name, field_name, project=None):
|
||||
|
|
@ -133,6 +184,13 @@ def quick_kanban_board(doctype, board_name, field_name, project=None):
|
|||
doc = frappe.new_doc('Kanban Board')
|
||||
meta = frappe.get_meta(doctype)
|
||||
|
||||
doc.kanban_board_name = board_name
|
||||
doc.reference_doctype = doctype
|
||||
doc.field_name = field_name
|
||||
|
||||
if project:
|
||||
doc.filters = '[["Task","project","=","{0}"]]'.format(project)
|
||||
|
||||
options = ''
|
||||
for field in meta.fields:
|
||||
if field.fieldname == field_name:
|
||||
|
|
@ -149,12 +207,6 @@ def quick_kanban_board(doctype, board_name, field_name, project=None):
|
|||
column_name=column
|
||||
))
|
||||
|
||||
doc.kanban_board_name = board_name
|
||||
doc.reference_doctype = doctype
|
||||
doc.field_name = field_name
|
||||
|
||||
if project:
|
||||
doc.filters = '[["Task","project","=","{0}"]]'.format(project)
|
||||
|
||||
if doctype in ['Note', 'ToDo']:
|
||||
doc.private = 1
|
||||
|
|
@ -162,6 +214,12 @@ def quick_kanban_board(doctype, board_name, field_name, project=None):
|
|||
doc.save()
|
||||
return doc
|
||||
|
||||
def get_order_for_column(board, colname):
|
||||
filters = [[board.reference_doctype, board.field_name, '=', colname]]
|
||||
if board.filters:
|
||||
filters.append(frappe.parse_json(board.filters)[0])
|
||||
|
||||
return frappe.as_json(frappe.get_list(board.reference_doctype, filters=filters, pluck='name'))
|
||||
|
||||
@frappe.whitelist()
|
||||
def update_column_order(board_name, order):
|
||||
|
|
|
|||
|
|
@ -147,6 +147,8 @@ def get_version(doctype, doc_name, frequency, user):
|
|||
return timeline
|
||||
|
||||
def get_comments(doctype, doc_name, frequency, user):
|
||||
from html2text import html2text
|
||||
|
||||
timeline = []
|
||||
filters = get_filters("reference_name", doc_name, frequency, user)
|
||||
comments = frappe.get_all("Comment",
|
||||
|
|
@ -166,7 +168,7 @@ def get_comments(doctype, doc_name, frequency, user):
|
|||
"time": comment.modified,
|
||||
"data": {
|
||||
"time": time,
|
||||
"comment": frappe.utils.html2text(str(comment.content)),
|
||||
"comment": html2text(str(comment.content)),
|
||||
"by": by
|
||||
},
|
||||
"doctype": doctype,
|
||||
|
|
@ -197,6 +199,8 @@ def get_follow_users(doctype, doc_name):
|
|||
)
|
||||
|
||||
def get_row_changed(row_changed, time, doctype, doc_name, v):
|
||||
from html2text import html2text
|
||||
|
||||
items = []
|
||||
for d in row_changed:
|
||||
d[2] = d[2] if d[2] else ' '
|
||||
|
|
@ -209,8 +213,8 @@ def get_row_changed(row_changed, time, doctype, doc_name, v):
|
|||
"table_field": d[0],
|
||||
"row": str(d[1]),
|
||||
"field": d[3][0][0],
|
||||
"from": frappe.utils.html2text(str(d[3][0][1])),
|
||||
"to": frappe.utils.html2text(str(d[3][0][2]))
|
||||
"from": html2text(str(d[3][0][1])),
|
||||
"to": html2text(str(d[3][0][2]))
|
||||
},
|
||||
"doctype": doctype,
|
||||
"doc_name": doc_name,
|
||||
|
|
@ -236,6 +240,8 @@ def get_added_row(added, time, doctype, doc_name, v):
|
|||
return items
|
||||
|
||||
def get_field_changed(changed, time, doctype, doc_name, v):
|
||||
from html2text import html2text
|
||||
|
||||
items = []
|
||||
for d in changed:
|
||||
d[1] = d[1] if d[1] else ' '
|
||||
|
|
@ -246,8 +252,8 @@ def get_field_changed(changed, time, doctype, doc_name, v):
|
|||
"data": {
|
||||
"time": time,
|
||||
"field": d[0],
|
||||
"from": frappe.utils.html2text(str(d[1])),
|
||||
"to": frappe.utils.html2text(str(d[2]))
|
||||
"from": html2text(str(d[1])),
|
||||
"to": html2text(str(d[2]))
|
||||
},
|
||||
"doctype": doctype,
|
||||
"doc_name": doc_name,
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ class FormMeta(Meta):
|
|||
def add_custom_script(self):
|
||||
"""embed all require files"""
|
||||
# custom script
|
||||
custom = frappe.db.get_value("Custom Script", {"dt": self.name, "enabled": 1}, "script") or ""
|
||||
custom = frappe.db.get_value("Client Script", {"dt": self.name, "enabled": 1}, "script") or ""
|
||||
|
||||
self.set("__custom_js", custom)
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ def validate_link():
|
|||
except Exception as e:
|
||||
error_message = str(e).split("Unknown column '")
|
||||
fieldname = None if len(error_message)<=1 else error_message[1].split("'")[0]
|
||||
frappe.msgprint(_("Wrong fieldname <b>{0}</b> in add_fetch configuration of custom script").format(fieldname))
|
||||
frappe.msgprint(_("Wrong fieldname <b>{0}</b> in add_fetch configuration of custom client script").format(fieldname))
|
||||
frappe.errprint(frappe.get_traceback())
|
||||
|
||||
if fetch_value:
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ class Leaderboard {
|
|||
}
|
||||
|
||||
create_date_range_field() {
|
||||
let timespan_field = $(this.parent).find(`.frappe-control[data-original-title='Timespan']`);
|
||||
let timespan_field = $(this.parent).find(`.frappe-control[data-original-title=${__('Timespan')}]`);
|
||||
this.date_range_field = $(`<div class="from-date-field"></div>`).insertAfter(timespan_field).hide();
|
||||
|
||||
let date_field = frappe.ui.form.make_control({
|
||||
|
|
|
|||
|
|
@ -80,13 +80,15 @@ def search_widget(doctype, txt, query=None, searchfield=None, start=0,
|
|||
is_whitelisted(frappe.get_attr(query))
|
||||
frappe.response["values"] = frappe.call(query, doctype, txt,
|
||||
searchfield, start, page_length, filters, as_dict=as_dict)
|
||||
except Exception as e:
|
||||
except frappe.exceptions.PermissionError as e:
|
||||
if frappe.local.conf.developer_mode:
|
||||
raise e
|
||||
else:
|
||||
frappe.respond_as_web_page(title='Invalid Method', html='Method not found',
|
||||
indicator_color='red', http_status_code=404)
|
||||
return
|
||||
except Exception as e:
|
||||
raise e
|
||||
elif not query and doctype in standard_queries:
|
||||
# from standard queries
|
||||
search_widget(doctype, txt, standard_queries[doctype][0],
|
||||
|
|
|
|||
|
|
@ -90,6 +90,29 @@ class EmailAccount(Document):
|
|||
if self.append_to not in valid_doctypes:
|
||||
frappe.throw(_("Append To can be one of {0}").format(comma_or(valid_doctypes)))
|
||||
|
||||
def before_save(self):
|
||||
messages = []
|
||||
as_list = 1
|
||||
if not self.enable_incoming and self.default_incoming:
|
||||
self.default_incoming = False
|
||||
messages.append(_("{} has been disabled. It can only be enabled if {} is checked.")
|
||||
.format(
|
||||
frappe.bold(_('Default Incoming')),
|
||||
frappe.bold(_('Enable Incoming'))
|
||||
)
|
||||
)
|
||||
if not self.enable_outgoing and self.default_outgoing:
|
||||
self.default_outgoing = False
|
||||
messages.append(_("{} has been disabled. It can only be enabled if {} is checked.")
|
||||
.format(
|
||||
frappe.bold(_('Default Outgoing')),
|
||||
frappe.bold(_('Enable Outgoing'))
|
||||
)
|
||||
)
|
||||
if messages:
|
||||
if len(messages) == 1: (as_list, messages) = (0, messages[0])
|
||||
frappe.msgprint(messages, as_list= as_list, indicator='orange', title=_("Defaults Updated"))
|
||||
|
||||
def on_update(self):
|
||||
"""Check there is only one default of each type."""
|
||||
from frappe.core.doctype.user.user import setup_user_email_inbox
|
||||
|
|
|
|||
|
|
@ -19,9 +19,12 @@
|
|||
"message",
|
||||
"message_md",
|
||||
"message_html",
|
||||
"section_break_13",
|
||||
"send_unsubscribe_link",
|
||||
"send_attachments",
|
||||
"column_break_9",
|
||||
"published",
|
||||
"send_webview_link",
|
||||
"route",
|
||||
"test_the_newsletter",
|
||||
"test_email_id",
|
||||
|
|
@ -160,6 +163,21 @@
|
|||
"fieldtype": "Check",
|
||||
"label": "Schedule Sending",
|
||||
"read_only_depends_on": "eval: doc.email_sent"
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_9",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"depends_on": "published",
|
||||
"fieldname": "send_webview_link",
|
||||
"fieldtype": "Check",
|
||||
"label": "Send Web View Link"
|
||||
},
|
||||
{
|
||||
"fieldname": "section_break_13",
|
||||
"fieldtype": "Section Break"
|
||||
}
|
||||
],
|
||||
"has_web_view": 1,
|
||||
|
|
@ -169,7 +187,7 @@
|
|||
"is_published_field": "published",
|
||||
"links": [],
|
||||
"max_attachments": 3,
|
||||
"modified": "2020-08-24 19:59:37.262500",
|
||||
"modified": "2021-02-22 14:33:56.095380",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Email",
|
||||
"name": "Newsletter",
|
||||
|
|
|
|||
|
|
@ -68,13 +68,17 @@ class Newsletter(WebsiteGenerator):
|
|||
except IOError:
|
||||
frappe.throw(_("Unable to find attachment {0}").format(file.name))
|
||||
|
||||
send(recipients=self.recipients, sender=sender,
|
||||
subject=self.subject, message=self.get_message(),
|
||||
args = {
|
||||
"message": self.get_message(),
|
||||
"name": self.name
|
||||
}
|
||||
frappe.sendmail(recipients=self.recipients, sender=sender,
|
||||
subject=self.subject, message=self.get_message(), template="newsletter",
|
||||
reference_doctype=self.doctype, reference_name=self.name,
|
||||
add_unsubscribe_link=self.send_unsubscribe_link, attachments=attachments,
|
||||
unsubscribe_method="/unsubscribe",
|
||||
unsubscribe_params={"name": self.name},
|
||||
send_priority=0, queue_separately=True)
|
||||
send_priority=0, queue_separately=True, args=args)
|
||||
|
||||
if not frappe.flags.in_test:
|
||||
frappe.db.auto_commit_on_many_writes = False
|
||||
|
|
|
|||
|
|
@ -108,13 +108,8 @@ class TestConnectedApp(unittest.TestCase):
|
|||
|
||||
session = requests.Session()
|
||||
|
||||
# first login of a new user on a new site fails with "401 UNAUTHORIZED"
|
||||
# when anybody fixes that, the two lines below can be removed
|
||||
first_login = login()
|
||||
self.assertEqual(first_login.status_code, 401)
|
||||
|
||||
second_login = login()
|
||||
self.assertEqual(second_login.status_code, 200)
|
||||
self.assertEqual(first_login.status_code, 200)
|
||||
|
||||
authorization_url = self.connected_app.initiate_web_application_flow(user=self.user_name)
|
||||
|
||||
|
|
|
|||
|
|
@ -163,10 +163,13 @@ def openid_profile(*args, **kwargs):
|
|||
first_name, last_name, avatar, name = frappe.db.get_value("User", frappe.session.user, ["first_name", "last_name", "user_image", "name"])
|
||||
frappe_userid = frappe.db.get_value("User Social Login", {"parent":frappe.session.user, "provider": "frappe"}, "userid")
|
||||
request_url = urlparse(frappe.request.url)
|
||||
base_url = frappe.db.get_value("Social Login Key", "frappe", "base_url") or None
|
||||
|
||||
if avatar:
|
||||
if validate_url(avatar):
|
||||
picture = avatar
|
||||
elif base_url:
|
||||
picture = base_url + '/' + avatar
|
||||
else:
|
||||
picture = request_url.scheme + "://" + request_url.netloc + avatar
|
||||
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ core_doctypes_list = (
|
|||
'Customize Form Field',
|
||||
'Property Setter',
|
||||
'Custom Field',
|
||||
'Custom Script'
|
||||
'Client Script'
|
||||
)
|
||||
|
||||
log_types = (
|
||||
|
|
|
|||
|
|
@ -12,11 +12,9 @@ from frappe.model.naming import set_new_name
|
|||
from frappe.model.utils.link_count import notify_link_count
|
||||
from frappe.modules import load_doctype_module
|
||||
from frappe.model import display_fieldtypes
|
||||
from frappe.utils.password import get_decrypted_password, set_encrypted_password
|
||||
from frappe.utils import (cint, flt, now, cstr, strip_html,
|
||||
sanitize_html, sanitize_email, cast_fieldtype)
|
||||
from frappe.utils.html_utils import unescape_html
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
max_positive_value = {
|
||||
'smallint': 2 ** 15,
|
||||
|
|
@ -69,13 +67,13 @@ def get_controller(doctype):
|
|||
|
||||
if frappe.local.dev_server:
|
||||
return _get_controller()
|
||||
|
||||
|
||||
site_controllers = frappe.controllers.setdefault(frappe.local.site, {})
|
||||
if doctype not in site_controllers:
|
||||
site_controllers[doctype] = _get_controller()
|
||||
|
||||
|
||||
return site_controllers[doctype]
|
||||
|
||||
|
||||
class BaseDocument(object):
|
||||
ignore_in_getter = ("doctype", "_meta", "meta", "_table_fields", "_valid_columns")
|
||||
|
||||
|
|
@ -94,6 +92,14 @@ class BaseDocument(object):
|
|||
return self._meta
|
||||
|
||||
def update(self, d):
|
||||
""" Update multiple fields of a doctype using a dictionary of key-value pairs.
|
||||
|
||||
Example:
|
||||
doc.update({
|
||||
"user": "admin",
|
||||
"balance": 42000
|
||||
})
|
||||
"""
|
||||
if "doctype" in d:
|
||||
self.set("doctype", d.get("doctype"))
|
||||
|
||||
|
|
@ -159,6 +165,15 @@ class BaseDocument(object):
|
|||
del self.__dict__[key]
|
||||
|
||||
def append(self, key, value=None):
|
||||
""" Append an item to a child table.
|
||||
|
||||
Example:
|
||||
doc.append("childtable", {
|
||||
"child_table_field": "value",
|
||||
"child_table_int_field": 0,
|
||||
...
|
||||
})
|
||||
"""
|
||||
if value==None:
|
||||
value={}
|
||||
if isinstance(value, (dict, BaseDocument)):
|
||||
|
|
@ -402,25 +417,60 @@ class BaseDocument(object):
|
|||
doc.db_update()
|
||||
|
||||
def show_unique_validation_message(self, e):
|
||||
# TODO: Find a better way to extract fieldname
|
||||
if frappe.db.db_type != 'postgres':
|
||||
fieldname = str(e).split("'")[-2]
|
||||
label = None
|
||||
|
||||
# unique_first_fieldname_second_fieldname is the constraint name
|
||||
# created using frappe.db.add_unique
|
||||
if "unique_" in fieldname:
|
||||
fieldname = fieldname.split("_", 1)[1]
|
||||
# MariaDB gives key_name in error. Extracting fieldname from key name
|
||||
try:
|
||||
fieldname = self.get_field_name_by_key_name(fieldname)
|
||||
except IndexError:
|
||||
pass
|
||||
|
||||
df = self.meta.get_field(fieldname)
|
||||
if df:
|
||||
label = df.label
|
||||
label = self.get_label_from_fieldname(fieldname)
|
||||
|
||||
frappe.msgprint(_("{0} must be unique").format(label or fieldname))
|
||||
|
||||
# this is used to preserve traceback
|
||||
raise frappe.UniqueValidationError(self.doctype, self.name, e)
|
||||
|
||||
def get_field_name_by_key_name(self, key_name):
|
||||
"""MariaDB stores a mapping between `key_name` and `column_name`.
|
||||
This function returns the `column_name` associated with the `key_name` passed
|
||||
|
||||
Args:
|
||||
key_name (str): The name of the database index.
|
||||
|
||||
Raises:
|
||||
IndexError: If the key is not found in the table.
|
||||
|
||||
Returns:
|
||||
str: The column name associated with the key.
|
||||
"""
|
||||
return frappe.db.sql(f"""
|
||||
SHOW
|
||||
INDEX
|
||||
FROM
|
||||
`tab{self.doctype}`
|
||||
WHERE
|
||||
key_name=%s
|
||||
AND
|
||||
Non_unique=0
|
||||
""", key_name, as_dict=True)[0].get("Column_name")
|
||||
|
||||
def get_label_from_fieldname(self, fieldname):
|
||||
"""Returns the associated label for fieldname
|
||||
|
||||
Args:
|
||||
fieldname (str): The fieldname in the DocType to use to pull the label.
|
||||
|
||||
Returns:
|
||||
str: The label associated with the fieldname, if found, otherwise `None`.
|
||||
"""
|
||||
df = self.meta.get_field(fieldname)
|
||||
if df:
|
||||
return df.label
|
||||
|
||||
def update_modified(self):
|
||||
"""Update modified timestamp"""
|
||||
self.set("modified", now())
|
||||
|
|
@ -704,6 +754,8 @@ class BaseDocument(object):
|
|||
|
||||
- Ignore if 'Ignore XSS Filter' is checked or fieldtype is 'Code'
|
||||
"""
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
if frappe.flags.in_install:
|
||||
return
|
||||
|
||||
|
|
@ -740,6 +792,8 @@ class BaseDocument(object):
|
|||
|
||||
def _save_passwords(self):
|
||||
"""Save password field values in __Auth table"""
|
||||
from frappe.utils.password import set_encrypted_password
|
||||
|
||||
if self.flags.ignore_save_passwords is True:
|
||||
return
|
||||
|
||||
|
|
@ -754,6 +808,8 @@ class BaseDocument(object):
|
|||
self.set(df.fieldname, '*'*len(new_password))
|
||||
|
||||
def get_password(self, fieldname='password', raise_exception=True):
|
||||
from frappe.utils.password import get_decrypted_password
|
||||
|
||||
if self.get(fieldname) and not self.is_dummy_password(self.get(fieldname)):
|
||||
return self.get(fieldname)
|
||||
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ def delete_doc(doctype=None, name=None, force=0, ignore_doctypes=None, for_reloa
|
|||
check_permission_and_not_submitted(doc)
|
||||
|
||||
frappe.db.sql("delete from `tabCustom Field` where dt = %s", name)
|
||||
frappe.db.sql("delete from `tabCustom Script` where dt = %s", name)
|
||||
frappe.db.sql("delete from `tabClient Script` where dt = %s", name)
|
||||
frappe.db.sql("delete from `tabProperty Setter` where doc_type = %s", name)
|
||||
frappe.db.sql("delete from `tabReport` where ref_doctype=%s", name)
|
||||
frappe.db.sql("delete from `tabCustom DocPerm` where parent=%s", name)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import frappe
|
|||
import time
|
||||
from frappe import _, msgprint
|
||||
from frappe.utils import flt, cstr, now, get_datetime_str, file_lock, date_diff
|
||||
from frappe.utils.background_jobs import enqueue
|
||||
from frappe.model.base_document import BaseDocument, get_controller
|
||||
from frappe.model.naming import set_new_name
|
||||
from six import iteritems, string_types
|
||||
|
|
@ -1015,6 +1014,8 @@ class Document(BaseDocument):
|
|||
|
||||
def notify_update(self):
|
||||
"""Publish realtime that the current document is modified"""
|
||||
if frappe.flags.in_patch: return
|
||||
|
||||
frappe.publish_realtime("doc_update", {"modified": self.modified, "doctype": self.doctype, "name": self.name},
|
||||
doctype=self.doctype, docname=self.name, after_commit=True)
|
||||
|
||||
|
|
@ -1267,6 +1268,8 @@ class Document(BaseDocument):
|
|||
# call _submit instead of submit, so you can override submit to call
|
||||
# run_delayed based on some action
|
||||
# See: Stock Reconciliation
|
||||
from frappe.utils.background_jobs import enqueue
|
||||
|
||||
if hasattr(self, '_' + action):
|
||||
action = '_' + action
|
||||
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ frappe.patches.v11_0.change_email_signature_fieldtype
|
|||
execute:frappe.reload_doc('core', 'doctype', 'activity_log')
|
||||
execute:frappe.reload_doc('core', 'doctype', 'deleted_document')
|
||||
execute:frappe.reload_doc('core', 'doctype', 'domain_settings')
|
||||
frappe.patches.v13_0.rename_custom_client_script
|
||||
frappe.patches.v8_0.rename_page_role_to_has_role #2017-03-16
|
||||
frappe.patches.v7_2.setup_custom_perms #2017-01-19
|
||||
frappe.patches.v8_0.set_user_permission_for_page_and_report #2017-03-20
|
||||
|
|
@ -329,3 +330,4 @@ frappe.core.doctype.page.patches.drop_unused_pages
|
|||
execute:frappe.get_doc('Role', 'Guest').save() # remove desk access
|
||||
frappe.patches.v13_0.rename_desk_page_to_workspace # 02.02.2021
|
||||
frappe.patches.v13_0.delete_package_publish_tool
|
||||
frappe.patches.v13_0.rename_list_view_setting_to_list_view_settings
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import frappe
|
||||
|
||||
def execute():
|
||||
frappe.reload_doc('core', 'doctype', 'user')
|
||||
frappe.db.sql('''
|
||||
UPDATE `tabUser`
|
||||
SET `home_settings` = ''
|
||||
|
|
|
|||
|
|
@ -5,9 +5,8 @@ from __future__ import unicode_literals
|
|||
import frappe
|
||||
|
||||
def execute():
|
||||
"""Enable all the existing custom script"""
|
||||
frappe.reload_doc("Custom", "doctype", "Custom Script")
|
||||
"""Enable all the existing Client script"""
|
||||
|
||||
frappe.db.sql("""
|
||||
UPDATE `tabCustom Script` SET enabled=1
|
||||
UPDATE `tabClient Script` SET enabled=1
|
||||
""")
|
||||
9
frappe/patches/v13_0/rename_custom_client_script.py
Normal file
9
frappe/patches/v13_0/rename_custom_client_script.py
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
if frappe.db.exists("DocType", "Client Script"):
|
||||
return
|
||||
|
||||
frappe.rename_doc("DocType", "Custom Script", "Client Script")
|
||||
frappe.reload_doctype("Client Script", force=True)
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
# MIT License. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
if frappe.db.table_exists('List View Setting'):
|
||||
existing_list_view_settings = frappe.get_all('List View Settings', as_list=True)
|
||||
for list_view_setting in frappe.get_all('List View Setting', fields = ['disable_count', 'disable_sidebar_stats', 'disable_auto_refresh', 'name']):
|
||||
name = list_view_setting.pop('name')
|
||||
if name not in [x[0] for x in existing_list_view_settings]:
|
||||
list_view_setting['doctype'] = 'List View Settings'
|
||||
list_view_settings = frappe.get_doc(list_view_setting)
|
||||
# setting name here is necessary because autoname is set as prompt
|
||||
list_view_settings.name = name
|
||||
list_view_settings.insert()
|
||||
frappe.delete_doc("DocType", "List View Setting", force=True)
|
||||
frappe.db.commit()
|
||||
|
|
@ -75,7 +75,6 @@
|
|||
"public/css/octicons/octicons.css",
|
||||
"public/less/desk.less",
|
||||
"public/less/module.less",
|
||||
"public/less/link_preview.less",
|
||||
"public/less/mobile.less",
|
||||
"public/less/controls.less",
|
||||
"public/less/chat.less",
|
||||
|
|
@ -94,14 +93,14 @@
|
|||
"public/scss/print.scss"
|
||||
],
|
||||
"concat:js/libs.min.js": [
|
||||
"public/js/lib/awesomplete/awesomplete.min.js",
|
||||
"public/js/lib/Sortable.min.js",
|
||||
"public/js/lib/jquery/jquery.hotkeys.js",
|
||||
"node_modules/bootstrap/dist/js/bootstrap.bundle.min.js",
|
||||
"node_modules/vue/dist/vue.min.js",
|
||||
"node_modules/moment/min/moment-with-locales.min.js",
|
||||
"node_modules/moment-timezone/builds/moment-timezone-with-data.min.js",
|
||||
"public/js/lib/socket.io.min.js",
|
||||
"node_modules/socket.io-client/dist/socket.io.slim.js",
|
||||
"node_modules/localforage/dist/localforage.min.js",
|
||||
"public/js/lib/jSignature.min.js",
|
||||
"public/js/lib/leaflet/leaflet.js",
|
||||
"public/js/lib/leaflet/leaflet.draw.js",
|
||||
|
|
@ -224,7 +223,6 @@
|
|||
"public/js/frappe/form/form.js",
|
||||
"public/js/frappe/meta_tag.js"
|
||||
],
|
||||
"css/list.min.css": "public/less/gantt.less",
|
||||
"js/list.min.js": [
|
||||
"public/js/frappe/ui/listing.html",
|
||||
|
||||
|
|
@ -291,7 +289,7 @@
|
|||
"css/web_form.css": [
|
||||
"website/css/web_form.css",
|
||||
"public/css/octicons/octicons.css",
|
||||
"public/less/controls.less",
|
||||
"public/scss/controls.scss",
|
||||
"node_modules/frappe-datatable/dist/frappe-datatable.css"
|
||||
],
|
||||
"css/email.css": "public/scss/email.scss",
|
||||
|
|
|
|||
|
|
@ -1,253 +0,0 @@
|
|||
/* the element that this class is applied to, should have a max width for this to work*/
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
|
||||
}
|
||||
a {
|
||||
cursor: pointer;
|
||||
}
|
||||
a,
|
||||
a:hover,
|
||||
a:active,
|
||||
a:focus,
|
||||
.btn,
|
||||
.btn:hover,
|
||||
.btn:active,
|
||||
.btn:focus {
|
||||
outline: 0;
|
||||
}
|
||||
img {
|
||||
max-width: 100%;
|
||||
}
|
||||
p {
|
||||
margin: 10px 0px;
|
||||
}
|
||||
.text-color {
|
||||
color: #36414C !important;
|
||||
}
|
||||
.text-muted {
|
||||
color: #8D99A6 !important;
|
||||
}
|
||||
.text-extra-muted {
|
||||
color: #d1d8dd !important;
|
||||
}
|
||||
a,
|
||||
.badge {
|
||||
-webkit-transition: 0.2s;
|
||||
-o-transition: 0.2s;
|
||||
transition: 0.2s;
|
||||
}
|
||||
.btn {
|
||||
-webkit-transition: background-color 0.2s;
|
||||
-o-transition: background-color 0.2s;
|
||||
transition: background-color 0.2s;
|
||||
}
|
||||
a.disabled,
|
||||
a.disabled:hover {
|
||||
color: #888;
|
||||
cursor: default;
|
||||
text-decoration: none;
|
||||
}
|
||||
a.grey,
|
||||
.sidebar-section a,
|
||||
.control-value a,
|
||||
.data-row a {
|
||||
text-decoration: none;
|
||||
}
|
||||
a.grey:hover,
|
||||
.sidebar-section a:hover,
|
||||
.control-value a:hover,
|
||||
.data-row a:hover,
|
||||
a.grey:focus,
|
||||
.sidebar-section a:focus,
|
||||
.control-value a:focus,
|
||||
.data-row a:focus {
|
||||
text-decoration: underline;
|
||||
}
|
||||
a.text-muted,
|
||||
a.text-extra-muted {
|
||||
text-decoration: none;
|
||||
}
|
||||
.underline {
|
||||
text-decoration: underline;
|
||||
}
|
||||
.inline-block {
|
||||
display: inline-block;
|
||||
}
|
||||
.bold,
|
||||
.strong {
|
||||
font-weight: bold;
|
||||
}
|
||||
kbd {
|
||||
color: inherit;
|
||||
background-color: #F0F4F7;
|
||||
}
|
||||
.btn [class^="fa fa-"],
|
||||
.nav [class^="fa fa-"],
|
||||
.btn [class*="fa fa-"],
|
||||
.nav [class*="fa fa-"] {
|
||||
display: inline-block;
|
||||
}
|
||||
.dropdown-menu > li > a {
|
||||
padding: 14px;
|
||||
white-space: normal;
|
||||
}
|
||||
.dropdown-menu {
|
||||
min-width: 200px;
|
||||
padding: 0px;
|
||||
font-size: 12px;
|
||||
max-height: 400px;
|
||||
overflow: auto;
|
||||
border-radius: 0px 0px 4px 4px;
|
||||
}
|
||||
.dropdown-menu .dropdown-header {
|
||||
padding: 3px 14px;
|
||||
font-size: 11px;
|
||||
font-weight: 200;
|
||||
padding-top: 12px;
|
||||
}
|
||||
.dropdown-menu .divider {
|
||||
margin: 0px;
|
||||
}
|
||||
a.badge-hover:hover .badge,
|
||||
a.badge-hover:focus .badge,
|
||||
a.badge-hover:active .badge {
|
||||
background-color: #D8DFE5;
|
||||
}
|
||||
.msgprint {
|
||||
word-wrap: break-word;
|
||||
}
|
||||
.msgprint pre {
|
||||
text-align: left;
|
||||
}
|
||||
.centered {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
-webkit-transform: translate(-50%, -50%);
|
||||
}
|
||||
.border-top {
|
||||
border-top: 1px solid #d1d8dd;
|
||||
}
|
||||
.border-bottom {
|
||||
border-bottom: 1px solid #d1d8dd;
|
||||
}
|
||||
.border-left {
|
||||
border-left: 1px solid #d1d8dd;
|
||||
}
|
||||
.border-right {
|
||||
border-right: 1px solid #d1d8dd;
|
||||
}
|
||||
.border {
|
||||
border: 1px solid #d1d8dd;
|
||||
}
|
||||
.close-inline {
|
||||
font-size: 120%;
|
||||
font-weight: bold;
|
||||
line-height: 1;
|
||||
cursor: pointer;
|
||||
color: inherit;
|
||||
display: inline-block;
|
||||
}
|
||||
.close-inline:hover,
|
||||
.close-inline:focus {
|
||||
text-decoration: none;
|
||||
}
|
||||
.middle {
|
||||
vertical-align: middle;
|
||||
}
|
||||
.full-center-container {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
}
|
||||
.full-center {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
width: 100%;
|
||||
transform: translate(-50%, -50%);
|
||||
-webkit-transform: translate(-50%, -50%);
|
||||
}
|
||||
#freeze {
|
||||
z-index: 1020;
|
||||
bottom: 0px;
|
||||
opacity: 0;
|
||||
background-color: #fafbfc;
|
||||
}
|
||||
#freeze .freeze-message-container {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
}
|
||||
#freeze .freeze-message {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
width: 100%;
|
||||
transform: translate(-50%, -50%);
|
||||
-webkit-transform: translate(-50%, -50%);
|
||||
text-align: center;
|
||||
color: #36414C !important;
|
||||
}
|
||||
#freeze.dark {
|
||||
background-color: #334143;
|
||||
}
|
||||
#freeze.in {
|
||||
opacity: 0.5;
|
||||
}
|
||||
a.no-decoration {
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
}
|
||||
a.no-decoration:hover,
|
||||
a.no-decoration:focus,
|
||||
a.no-decoration:active {
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
}
|
||||
.padding {
|
||||
padding: 15px;
|
||||
}
|
||||
.margin {
|
||||
margin: 15px;
|
||||
}
|
||||
.margin-top {
|
||||
margin-top: 15px;
|
||||
}
|
||||
.margin-bottom {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
.margin-left {
|
||||
margin-left: 15px;
|
||||
}
|
||||
.margin-right {
|
||||
margin-right: 15px;
|
||||
}
|
||||
@media (max-width: 767px) {
|
||||
.text-center-xs {
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
.grayscale {
|
||||
-webkit-filter: grayscale(100%);
|
||||
filter: grayscale(100%);
|
||||
}
|
||||
.uppercase {
|
||||
padding-bottom: 4px;
|
||||
text-transform: uppercase;
|
||||
font-size: 12px;
|
||||
letter-spacing: 0.4px;
|
||||
color: #8D99A6;
|
||||
}
|
||||
.ellipsis {
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
max-width: 100%;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
|
@ -1,604 +0,0 @@
|
|||
/* the element that this class is applied to, should have a max width for this to work*/
|
||||
.navbar .dropdown-toggle {
|
||||
padding-top: 8px;
|
||||
padding-bottom: 8px;
|
||||
}
|
||||
.navbar-fixed-top {
|
||||
left: 0px;
|
||||
right: 0px;
|
||||
}
|
||||
.navbar a {
|
||||
font-size: 12px;
|
||||
font-weight: bold;
|
||||
}
|
||||
.navbar-icon-home {
|
||||
vertical-align: middle;
|
||||
}
|
||||
.navbar-icon-home:hover,
|
||||
.navbar-icon-home:focus,
|
||||
.navbar-icon-home:active,
|
||||
.navbar-icon-home-hover {
|
||||
opacity: 1;
|
||||
Filter: alpha(opacity=100);
|
||||
/* For IE8 and earlier */
|
||||
}
|
||||
.navbar-user-image {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
margin-right: 3px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
@media (max-width: 991px) {
|
||||
.navbar-desk {
|
||||
width: 35% !important;
|
||||
}
|
||||
.navbar-desk ~ ul > li {
|
||||
float: left;
|
||||
}
|
||||
.navbar-desk ~ ul > li a {
|
||||
padding-left: 10px !important;
|
||||
padding-right: 10px !important;
|
||||
}
|
||||
.navbar-desk ~ ul > li a .avatar {
|
||||
margin-right: 0;
|
||||
}
|
||||
.dropdown-navbar-new-comments > a {
|
||||
padding: 8px 0 !important;
|
||||
margin-left: 0 !important;
|
||||
}
|
||||
}
|
||||
@media (max-width: 767px) {
|
||||
.navbar-desk {
|
||||
width: 50% !important;
|
||||
}
|
||||
}
|
||||
#search-modal .modal-dialog,
|
||||
#search-modal .modal-content {
|
||||
background: transparent;
|
||||
}
|
||||
#search-modal .modal-header {
|
||||
background: #fff;
|
||||
width: 100%;
|
||||
}
|
||||
#search-modal .modal-header form {
|
||||
vertical-align: middle;
|
||||
}
|
||||
#search-modal .modal-header button {
|
||||
line-height: 0;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 0;
|
||||
z-index: 9;
|
||||
padding: 9px;
|
||||
}
|
||||
.dropdown-navbar-new-comments > a {
|
||||
border: 0;
|
||||
}
|
||||
.dropdown-navbar-new-comments .dropdown-menu {
|
||||
margin-top: 0;
|
||||
}
|
||||
.dropdown-help .dropdown-menu {
|
||||
width: 350px !important;
|
||||
max-height: 440px;
|
||||
overflow: auto;
|
||||
}
|
||||
.dropdown-help .dropdown-menu .input-group {
|
||||
width: 100%;
|
||||
background-color: #f5f7fa;
|
||||
padding: 8px 12px;
|
||||
}
|
||||
.dropdown-help .dropdown-menu input {
|
||||
width: 100%;
|
||||
padding: 5px 10px;
|
||||
outline: none;
|
||||
border-radius: 3px 0 0 3px;
|
||||
border: 1px solid #d1d8dd;
|
||||
opacity: 0.9;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.dropdown-help .dropdown-menu button {
|
||||
border: 1px solid #d1d8dd;
|
||||
}
|
||||
@media (max-width: 767px) {
|
||||
.dropdown-help .dropdown-menu {
|
||||
position: fixed !important;
|
||||
top: 40px;
|
||||
width: 100% !important;
|
||||
}
|
||||
}
|
||||
@media (max-width: 767px) {
|
||||
.dropdown-mobile.open .dropdown-menu {
|
||||
position: absolute;
|
||||
border-top: 1px solid rgba(0, 0, 0, 0.14902);
|
||||
box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
|
||||
background-color: #fff;
|
||||
right: 0;
|
||||
left: auto;
|
||||
}
|
||||
.dropdown-mobile.open .dropdown-menu > li > a {
|
||||
padding: 12px;
|
||||
}
|
||||
.dropdown-help {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
.navbar-new-comments {
|
||||
display: inline-block;
|
||||
min-width: 24px;
|
||||
height: 24px;
|
||||
border-radius: 4px;
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
padding: 2px 5px;
|
||||
background-color: #b8c2cc;
|
||||
}
|
||||
.navbar-new-comments-true {
|
||||
background-color: #ff5858;
|
||||
}
|
||||
.navbar-form .awesomplete {
|
||||
margin-left: -15px;
|
||||
width: 300px;
|
||||
}
|
||||
@media (max-width: 1199px) {
|
||||
.navbar-form .awesomplete {
|
||||
width: 280px;
|
||||
}
|
||||
}
|
||||
@media (max-width: 991px) {
|
||||
.navbar-form .awesomplete {
|
||||
width: 250px;
|
||||
}
|
||||
}
|
||||
#navbar-search {
|
||||
width: 100%;
|
||||
background-color: rgba(255, 255, 255, 0.9);
|
||||
}
|
||||
.navbar .navbar-search-icon {
|
||||
color: #6C7680;
|
||||
font-size: inherit;
|
||||
position: relative;
|
||||
right: 24px;
|
||||
top: 1px;
|
||||
}
|
||||
.navbar .badge {
|
||||
font-weight: normal;
|
||||
}
|
||||
#navbar-search-results {
|
||||
left: auto;
|
||||
right: inherit;
|
||||
margin-top: -1px;
|
||||
max-height: 300px;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
.navbar-center {
|
||||
float: left;
|
||||
color: #6C7680;
|
||||
}
|
||||
#navbar-breadcrumbs > li > a:before {
|
||||
font-family: FontAwesome;
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
text-decoration: inherit;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
*margin-right: 0.3em;
|
||||
display: inline-block;
|
||||
speak: none;
|
||||
font-size: 24px;
|
||||
transition: 0.2s;
|
||||
position: relative;
|
||||
top: 3px;
|
||||
content: "\f105";
|
||||
margin-right: 10px;
|
||||
color: #C0C9D2;
|
||||
}
|
||||
#navbar-breadcrumbs > li > a:hover:before,
|
||||
#navbar-breadcrumbs > li > a:focus:before,
|
||||
#navbar-breadcrumbs > li > a:active:before {
|
||||
color: #36414C;
|
||||
}
|
||||
#navbar-breadcrumbs > li > a {
|
||||
padding: 6px 15px 10px 0px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
max-width: 170px;
|
||||
}
|
||||
@media (min-width: 991px) and (max-width: 1199px) {
|
||||
#navbar-breadcrumbs > li > a {
|
||||
max-width: 120px;
|
||||
}
|
||||
}
|
||||
.toolbar-user-fullname {
|
||||
max-width: 150px;
|
||||
display: inline-block;
|
||||
}
|
||||
.navbar-brand > img {
|
||||
display: inline-block;
|
||||
}
|
||||
.toggle-sidebar {
|
||||
margin-right: 10px;
|
||||
}
|
||||
.navbar-default .navbar-nav > li > a,
|
||||
.navbar-default .navbar-brand {
|
||||
color: #8D99A6;
|
||||
}
|
||||
body {
|
||||
font-size: 16px;
|
||||
line-height: 1.65em;
|
||||
color: #454e57;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
|
||||
}
|
||||
.container {
|
||||
max-width: 870px;
|
||||
}
|
||||
img {
|
||||
max-width: 100%;
|
||||
}
|
||||
.splash {
|
||||
border-bottom: 1px solid #d1d8dd;
|
||||
}
|
||||
.splash .jumbotron {
|
||||
background-color: transparent;
|
||||
padding: 40px 0 60px 0;
|
||||
text-align: center;
|
||||
}
|
||||
.splash .jumbotron h1 {
|
||||
font-size: 48px;
|
||||
font-weight: 400;
|
||||
opacity: 0.9;
|
||||
color: #2E3338;
|
||||
}
|
||||
.splash .jumbotron p {
|
||||
font-size: 24px;
|
||||
font-color: #8D99A6 !important;
|
||||
letter-spacing: 0px;
|
||||
opacity: 0.7;
|
||||
margin-bottom: 90px;
|
||||
font-weight: 300;
|
||||
line-height: 1.4em;
|
||||
}
|
||||
.splash .section {
|
||||
padding: 30px 0 0 0;
|
||||
}
|
||||
.page-container {
|
||||
padding-top: 38px;
|
||||
margin: 0 auto;
|
||||
max-width: 870px;
|
||||
}
|
||||
.page-container .webpage-content ol > li,
|
||||
.page-container .webpage-content ul > li {
|
||||
margin: 13px auto;
|
||||
}
|
||||
.page-container .webpage-content ol > li li,
|
||||
.page-container .webpage-content ul > li li {
|
||||
margin: 4px auto;
|
||||
}
|
||||
.page-container .webpage-content ol li ol {
|
||||
list-style-type: disc;
|
||||
}
|
||||
.page-container .webpage-content ul,
|
||||
.page-container .webpage-content ol {
|
||||
margin-bottom: 32px;
|
||||
}
|
||||
@media (min-width: 768px) {
|
||||
.page-container .page-content {
|
||||
width: 83%;
|
||||
margin: 0 auto;
|
||||
}
|
||||
}
|
||||
#page-index {
|
||||
padding-top: 0;
|
||||
width: 100%;
|
||||
margin: 0;
|
||||
}
|
||||
#page-index .page-content {
|
||||
width: 100%;
|
||||
margin: 0;
|
||||
}
|
||||
body[data-path="index"] .navbar .toggle-sidebar i {
|
||||
color: #fff;
|
||||
}
|
||||
code {
|
||||
color: #e66a12;
|
||||
background: #fff6df;
|
||||
}
|
||||
pre {
|
||||
background: #fafbfc;
|
||||
border: 1px solid #e1e9f0;
|
||||
border-radius: 2px;
|
||||
}
|
||||
.hljs {
|
||||
background: transparent;
|
||||
border: none;
|
||||
padding: 1.2em 1.5em 1.5em;
|
||||
color: #454e57;
|
||||
}
|
||||
.hljs-keyword,
|
||||
.hljs-tag,
|
||||
.css .hljs-class,
|
||||
.css .hljs-id,
|
||||
.lisp .hljs-title,
|
||||
.nginx .hljs-title,
|
||||
.hljs-request,
|
||||
.hljs-status,
|
||||
.clojure .hljs-attribute {
|
||||
color: #e66a12;
|
||||
}
|
||||
.diff .hljs-deletion,
|
||||
.hljs-string,
|
||||
.hljs-tag .hljs-value,
|
||||
.hljs-preprocessor,
|
||||
.hljs-pragma,
|
||||
.hljs-built_in,
|
||||
.hljs-javadoc,
|
||||
.smalltalk .hljs-class,
|
||||
.smalltalk .hljs-localvars,
|
||||
.smalltalk .hljs-array,
|
||||
.css .hljs-rules .hljs-value,
|
||||
.hljs-attr_selector,
|
||||
.hljs-pseudo,
|
||||
.apache .hljs-cbracket,
|
||||
.tex .hljs-formula,
|
||||
.coffeescript .hljs-attribute {
|
||||
color: #dd4a68;
|
||||
}
|
||||
.hljs-number,
|
||||
.hljs-date,
|
||||
.hljs-regexp,
|
||||
.hljs-literal,
|
||||
.hljs-hexcolor,
|
||||
.smalltalk .hljs-symbol,
|
||||
.smalltalk .hljs-char,
|
||||
.go .hljs-constant,
|
||||
.hljs-change,
|
||||
.lasso .hljs-variable,
|
||||
.makefile .hljs-variable,
|
||||
.asciidoc .hljs-bullet,
|
||||
.markdown .hljs-bullet,
|
||||
.asciidoc .hljs-link_url,
|
||||
.markdown .hljs-link_url {
|
||||
color: #7575ff;
|
||||
}
|
||||
.hljs-shebang,
|
||||
.diff .hljs-addition,
|
||||
.hljs-comment,
|
||||
.hljs-annotation,
|
||||
.hljs-template_comment,
|
||||
.hljs-pi,
|
||||
.hljs-doctype {
|
||||
color: #6a906a;
|
||||
}
|
||||
.dos .hljs-keyword,
|
||||
.hljs-decorator,
|
||||
.hljs-title,
|
||||
.hljs-type,
|
||||
.diff .hljs-header,
|
||||
.ruby .hljs-class .hljs-parent,
|
||||
.apache .hljs-tag,
|
||||
.nginx .hljs-built_in,
|
||||
.tex .hljs-command,
|
||||
.hljs-prompt {
|
||||
color: #4f4fa4;
|
||||
}
|
||||
.navbar {
|
||||
background-color: #36414C !important;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
.navbar .container {
|
||||
max-width: 870px;
|
||||
}
|
||||
.navbar .brand-logo {
|
||||
width: 30px;
|
||||
margin-top: -4px;
|
||||
margin-right: 7px;
|
||||
}
|
||||
.navbar a {
|
||||
font-size: 16px;
|
||||
font-weight: normal;
|
||||
color: #fff !important;
|
||||
}
|
||||
.navbar a.navbar-brand {
|
||||
font-weight: bold;
|
||||
}
|
||||
.navbar a.toggle-sidebar {
|
||||
margin-top: 8px;
|
||||
}
|
||||
.sidebar a {
|
||||
font-size: 14px;
|
||||
padding-top: 14px !important;
|
||||
padding-bottom: 14px !important;
|
||||
}
|
||||
.breadcrumb {
|
||||
line-height: 1em;
|
||||
color: #8D99A6;
|
||||
background-color: transparent;
|
||||
margin-bottom: 32px;
|
||||
padding: 0px;
|
||||
padding-left: 20px;
|
||||
background: url('/assets/img/up.png') 0% 30% no-repeat;
|
||||
}
|
||||
.breadcrumb .icon {
|
||||
display: none;
|
||||
}
|
||||
.breadcrumb a,
|
||||
.breadcrumb a:hover,
|
||||
.breadcrumb a:focus,
|
||||
.breadcrumb a:visited {
|
||||
color: #7575ff;
|
||||
font-size: 16px;
|
||||
}
|
||||
.hero-and-content a,
|
||||
.hero-and-content a:hover,
|
||||
.hero-and-content a:focus,
|
||||
.hero-and-content a:visited {
|
||||
color: #5E64FF;
|
||||
}
|
||||
.hero-and-content a.btn {
|
||||
color: inherit;
|
||||
}
|
||||
a.btn-primary {
|
||||
color: #7575ff;
|
||||
}
|
||||
a.btn-primary:hover,
|
||||
a.btn-primary:focus,
|
||||
a.btn-primary:visited {
|
||||
color: #7575ff;
|
||||
}
|
||||
.btn-next-wrapper {
|
||||
margin-top: 32px;
|
||||
text-align: right;
|
||||
}
|
||||
h2 {
|
||||
margin-top: 48px;
|
||||
font-size: 24px;
|
||||
}
|
||||
h3,
|
||||
h4 {
|
||||
margin-top: 48px;
|
||||
}
|
||||
p {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.hero-and-content > p {
|
||||
max-width: 723px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
.navbar {
|
||||
background-color: transparent;
|
||||
border: none;
|
||||
padding: 15px 0px;
|
||||
border-radius: 0px;
|
||||
border-bottom: 1px solid #d1d8dd;
|
||||
}
|
||||
.section {
|
||||
padding: 64px 0 0 0;
|
||||
}
|
||||
.dev-header {
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
.docs-footer {
|
||||
padding: 30px 0px 60px 0px;
|
||||
border-top: 1px solid #d1d8dd;
|
||||
max-width: 870px;
|
||||
margin: 0 auto;
|
||||
margin-top: 80px;
|
||||
font-size: 14px;
|
||||
}
|
||||
.docs-footer h3 {
|
||||
margin-top: 24px;
|
||||
font-size: 16px;
|
||||
}
|
||||
.docs-footer img.frappe-bird {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
background: #fff;
|
||||
margin-bottom: 10px;
|
||||
padding: 5px;
|
||||
}
|
||||
.docs-footer a {
|
||||
color: #8D99A6;
|
||||
}
|
||||
.docs-footer li {
|
||||
display: inline-block;
|
||||
margin: 0 10px;
|
||||
}
|
||||
.docs-footer .built-with-frappe {
|
||||
margin-top: -50px;
|
||||
}
|
||||
.browser-image {
|
||||
min-height: 200px;
|
||||
border: 1px solid #d1d8dd;
|
||||
border-bottom: 0px;
|
||||
}
|
||||
.fake-browser-frame {
|
||||
position: relative;
|
||||
margin: 24px auto 0px;
|
||||
box-shadow: 0px -6px 100px 1px rgba(0, 0, 0, 0.1), 0px -6px 50px 1px rgba(0, 0, 0, 0.4);
|
||||
}
|
||||
.fake-browser-frame::before {
|
||||
content: "";
|
||||
height: 24px;
|
||||
position: absolute;
|
||||
top: -24px;
|
||||
left: 0px;
|
||||
right: 0px;
|
||||
border: 1px solid #d1d8dd;
|
||||
background: #f5f7fa;
|
||||
border-bottom: none;
|
||||
border-top-left-radius: 4px;
|
||||
border-top-right-radius: 4px;
|
||||
}
|
||||
.fake-browser-frame::after {
|
||||
content: '\f111 \00a0\00a0 \f111 \00a0\00a0 \f111';
|
||||
position: absolute;
|
||||
color: #d1d8dd;
|
||||
top: -15px;
|
||||
left: 8px;
|
||||
/* octicon */
|
||||
font: normal normal;
|
||||
font-size: 8px;
|
||||
font-family: 'FontAwesome';
|
||||
line-height: 1;
|
||||
display: inline-block;
|
||||
text-decoration: none;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
.fake-iphone-frame {
|
||||
position: relative;
|
||||
padding: 40px 8px;
|
||||
border: 1px solid #d1d8dd;
|
||||
border-radius: 15px;
|
||||
}
|
||||
.fake-ipad-frame {
|
||||
position: relative;
|
||||
padding: 8px 40px;
|
||||
border: 1px solid #d1d8dd;
|
||||
border-radius: 15px;
|
||||
}
|
||||
hr {
|
||||
margin: 48px 0px 30px;
|
||||
}
|
||||
.edit {
|
||||
color: #8d99a6;
|
||||
}
|
||||
a.edit,
|
||||
a.edit:hover,
|
||||
a.edit:focus,
|
||||
a.edit:visited,
|
||||
.edit-container .icon {
|
||||
color: #8d99a6;
|
||||
}
|
||||
.btn-next {
|
||||
margin-top: 30px;
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
.btn-next:after {
|
||||
content: " \2192";
|
||||
}
|
||||
#current td {
|
||||
font-weight: bold;
|
||||
}
|
||||
#current td code {
|
||||
font-weight: normal;
|
||||
background: transparent;
|
||||
font-family: "Helvetica Neue", Helvetica, Arial, "Open Sans", sans-serif;
|
||||
color: #454e57;
|
||||
font-size: 16px;
|
||||
}
|
||||
.hero-and-content [data-html-block="hero"] {
|
||||
overflow-y: hidden;
|
||||
}
|
||||
.page-content-wrapper > .row .col-sm-8 {
|
||||
width: 100%;
|
||||
}
|
||||
.page-content-wrapper > .row .col-sm-4 {
|
||||
display: none;
|
||||
}
|
||||
|
|
@ -1,411 +0,0 @@
|
|||
/* the element that this class is applied to, should have a max width for this to work*/
|
||||
html {
|
||||
min-height: 100%;
|
||||
}
|
||||
body {
|
||||
height: 100%;
|
||||
margin: 0px;
|
||||
padding: 0px !important;
|
||||
}
|
||||
html,
|
||||
body {
|
||||
overflow-x: hidden;
|
||||
overflow-y: overlay;
|
||||
}
|
||||
@media (max-width: 991px) {
|
||||
.intro-area,
|
||||
.footnote-area {
|
||||
padding: 15px;
|
||||
}
|
||||
.grid-row-open {
|
||||
top: 0;
|
||||
}
|
||||
.layout-main {
|
||||
position: relative;
|
||||
}
|
||||
body[data-route^="Form"] .page-title h1 {
|
||||
margin-top: 12px;
|
||||
}
|
||||
body[data-route^="Form"] .page-title h1.editable-title {
|
||||
padding-right: 80px;
|
||||
}
|
||||
body[data-route^="Form"] .page-title .indicator {
|
||||
display: inline-block;
|
||||
margin-top: 12px;
|
||||
}
|
||||
body[data-route^="Form"] .page-actions {
|
||||
padding-top: 20px !important;
|
||||
padding-bottom: 0px !important;
|
||||
padding-left: 0px !important;
|
||||
}
|
||||
body[data-route^="Form"] .page-head .sub-heading {
|
||||
font-weight: normal;
|
||||
font-size: 10px;
|
||||
display: block;
|
||||
position: absolute;
|
||||
right: 140px;
|
||||
min-width: 200px;
|
||||
}
|
||||
body[data-route^="Form"] .title-text {
|
||||
margin-top: 10px;
|
||||
}
|
||||
.toggle-navbar-new-comments {
|
||||
padding: 8px 0px !important;
|
||||
}
|
||||
.navbar > .container > .navbar-header {
|
||||
float: left;
|
||||
width: 80%;
|
||||
}
|
||||
.navbar > .container > .navbar-right {
|
||||
float: right;
|
||||
}
|
||||
.module-item {
|
||||
padding: 7px 0px !important;
|
||||
}
|
||||
.module-item h4 {
|
||||
font-weight: normal;
|
||||
}
|
||||
#navbar-breadcrumbs {
|
||||
margin: 0px;
|
||||
display: inline-block;
|
||||
max-width: 150px;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
#navbar-breadcrumbs > li,
|
||||
#navbar-breadcrumbs > li > a {
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
}
|
||||
#navbar-breadcrumbs > li > a:before {
|
||||
content: "\f104";
|
||||
margin-right: 10px;
|
||||
color: #6C7680;
|
||||
}
|
||||
#navbar-breadcrumbs li:not(:nth-last-child(-n+1)) {
|
||||
display: none;
|
||||
}
|
||||
.navbar-nav {
|
||||
margin: 0px;
|
||||
margin-right: -15px;
|
||||
}
|
||||
.sidebar .form-group {
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
#sidebar-search {
|
||||
height: 27px;
|
||||
}
|
||||
.sidebar .navbar-search-icon {
|
||||
float: right;
|
||||
color: #6C7680;
|
||||
font-size: inherit;
|
||||
position: relative;
|
||||
right: 7px;
|
||||
top: -20px;
|
||||
height: 0;
|
||||
}
|
||||
.sidebar form {
|
||||
padding: 7px;
|
||||
}
|
||||
.sidebar .main-menu {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
top: 0;
|
||||
bottom: 41px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
.sidebar .user-menu {
|
||||
padding: 9px 14px;
|
||||
background-color: #f5f7fa;
|
||||
position: absolute;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
}
|
||||
.sidebar .user-menu,
|
||||
.sidebar .user-menu .octicon {
|
||||
color: #6C7680;
|
||||
}
|
||||
.sidebar .user-menu img {
|
||||
margin-top: -1px;
|
||||
}
|
||||
body[data-route^="Module"] .navbar-center {
|
||||
display: block !important;
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
left: 25%;
|
||||
right: 25%;
|
||||
text-align: center;
|
||||
}
|
||||
body.no-breadcrumbs .navbar .navbar-home {
|
||||
display: inline-block !important;
|
||||
padding-left: 0px;
|
||||
margin-left: 0px;
|
||||
padding-top: 6px;
|
||||
}
|
||||
body.no-breadcrumbs .navbar .navbar-home:before {
|
||||
font-family: FontAwesome;
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
text-decoration: inherit;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
*margin-right: 0.3em;
|
||||
display: inline-block;
|
||||
speak: none;
|
||||
font-size: 24px;
|
||||
transition: 0.2s;
|
||||
position: relative;
|
||||
top: 3px;
|
||||
content: "\f104";
|
||||
margin-right: 10px;
|
||||
color: #6C7680;
|
||||
}
|
||||
body.no-breadcrumbs .navbar .navbar-home:hover:before,
|
||||
body.no-breadcrumbs .navbar .navbar-home:focus:before,
|
||||
body.no-breadcrumbs .navbar .navbar-home:active:before {
|
||||
color: #36414C !important;
|
||||
}
|
||||
body[data-route=""] .navbar .navbar-home,
|
||||
body[data-route="desktop"] .navbar .navbar-home {
|
||||
padding: 8px 10px;
|
||||
}
|
||||
body[data-route=""] .navbar .navbar-home:before,
|
||||
body[data-route="desktop"] .navbar .navbar-home:before {
|
||||
display: none;
|
||||
}
|
||||
body[data-route=""] .navbar .navbar-home img,
|
||||
body[data-route="desktop"] .navbar .navbar-home img {
|
||||
margin-top: 0;
|
||||
}
|
||||
body[data-route=""] .toggle-sidebar,
|
||||
body[data-route="desktop"] .toggle-sidebar {
|
||||
display: none !important;
|
||||
}
|
||||
body[data-sidebar="0"] .toggle-sidebar {
|
||||
display: none !important;
|
||||
}
|
||||
body[data-sidebar="0"] #navbar-breadcrumbs,
|
||||
body[data-sidebar="0"] .navbar-home {
|
||||
margin-left: 15px !important;
|
||||
}
|
||||
}
|
||||
@media (max-width: 991px) and (max-width: 480px) {
|
||||
#navbar-breadcrumbs li > a {
|
||||
width: 100px;
|
||||
}
|
||||
}
|
||||
@media (max-width: 767px) {
|
||||
.toggle-sidebar {
|
||||
margin-right: 0;
|
||||
}
|
||||
body[data-route^="Form"] .page-title .title-text {
|
||||
font-size: 16px;
|
||||
width: calc(100% - 90px);
|
||||
}
|
||||
body[data-route^="Form"] .page-title .indicator {
|
||||
float: left;
|
||||
margin-top: 10px;
|
||||
margin-right: 5px;
|
||||
}
|
||||
.modal .modal-dialog {
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
width: 100%;
|
||||
background-color: #fff;
|
||||
}
|
||||
.modal .modal-content {
|
||||
border-radius: 0px;
|
||||
border: none;
|
||||
height: 100%;
|
||||
}
|
||||
.modal .modal-body .form-layout {
|
||||
margin: -15px;
|
||||
}
|
||||
.modal .file-upload .input-upload {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
}
|
||||
.modal .file-upload .input-upload .btn-browse {
|
||||
width: 100%;
|
||||
}
|
||||
.modal .file-upload .web-link-wrapper {
|
||||
display: block;
|
||||
width: 100% !important;
|
||||
text-align: center;
|
||||
}
|
||||
.modal .file-upload .web-link-wrapper .file-upload-or {
|
||||
display: block;
|
||||
margin: 15px 24px;
|
||||
}
|
||||
.modal .file-upload .web-link-wrapper .input-link {
|
||||
width: 100% !important;
|
||||
}
|
||||
.layout-main-section-wrapper {
|
||||
padding: 0px;
|
||||
}
|
||||
.layout-main-section {
|
||||
border-left-color: transparent !important;
|
||||
border-right-color: transparent !important;
|
||||
}
|
||||
.list-row {
|
||||
padding: 13px 15px !important;
|
||||
}
|
||||
.doclist-row {
|
||||
position: relative;
|
||||
padding-right: 10px;
|
||||
}
|
||||
.doclist-row .list-id {
|
||||
font-weight: normal;
|
||||
}
|
||||
.doclist-row .list-row-id {
|
||||
left: 18px;
|
||||
text-align: left;
|
||||
margin-top: 3px;
|
||||
}
|
||||
.doclist-row.has-checkbox .list-row-id {
|
||||
left: 40px;
|
||||
}
|
||||
.doclist-row .list-row-indicator {
|
||||
position: absolute;
|
||||
right: 0px;
|
||||
top: -20px;
|
||||
}
|
||||
.doclist-row .list-row-modified {
|
||||
margin-right: -10px;
|
||||
}
|
||||
.doclist-row .list-row-left {
|
||||
z-index: 1;
|
||||
}
|
||||
.doclist-row .list-row-right {
|
||||
float: right;
|
||||
}
|
||||
.doclist-row .list-row-right .list-row-indicator {
|
||||
top: 4px;
|
||||
}
|
||||
.doclist-row .list-row-right .list-row-indicator .indicator::before,
|
||||
.doclist-row .list-row-right .list-row-indicator .indicator::after {
|
||||
height: 12px;
|
||||
width: 12px;
|
||||
border-radius: 12px;
|
||||
}
|
||||
.doclist-row .list-row-right.no-right-column {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 10px;
|
||||
left: -10px;
|
||||
width: 100%;
|
||||
}
|
||||
body[data-route^="chat"] .navbar-center {
|
||||
display: block !important;
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
left: 25%;
|
||||
right: 25%;
|
||||
text-align: center;
|
||||
}
|
||||
#page-chat .layout-side-section {
|
||||
position: relative;
|
||||
left: 0px;
|
||||
border-right: 1px solid #d1d8dd;
|
||||
padding-left: 0px;
|
||||
float: left;
|
||||
width: 76px;
|
||||
}
|
||||
#page-chat .layout-main-section-wrapper {
|
||||
position: absolute;
|
||||
left: 75px;
|
||||
right: 0px;
|
||||
border-left: 1px solid #d1d8dd;
|
||||
float: left;
|
||||
}
|
||||
#page-chat .module-sidebar-item {
|
||||
margin: 0px;
|
||||
}
|
||||
#page-chat .module-sidebar-item .chat-sidebar-link {
|
||||
padding: 15px;
|
||||
}
|
||||
#page-chat .timeline-head {
|
||||
padding: 15px 15px 7px;
|
||||
}
|
||||
#page-chat .list-row {
|
||||
padding: 7px 0px;
|
||||
}
|
||||
#page-chat .message-row-right {
|
||||
margin-top: 10px;
|
||||
text-align: left;
|
||||
}
|
||||
body[data-route^="Form"] .page-head .sub-heading {
|
||||
right: 90px;
|
||||
}
|
||||
.timeline::before {
|
||||
content: none;
|
||||
}
|
||||
.timeline .timeline-new-email {
|
||||
margin: 20px 0;
|
||||
padding-left: 15px;
|
||||
}
|
||||
.timeline .timeline-new-email::before {
|
||||
content: none;
|
||||
}
|
||||
.timeline .timeline-item.user-content {
|
||||
margin: 20px 15px;
|
||||
}
|
||||
.timeline .timeline-item.user-content .media-body {
|
||||
margin-left: 0;
|
||||
max-width: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
.timeline .timeline-item.user-content .media-body:before {
|
||||
content: none;
|
||||
}
|
||||
.timeline .timeline-item.user-content .action-btns {
|
||||
padding: 7px 10px 2px 5px;
|
||||
}
|
||||
.timeline .timeline-item.user-content .action-btns .edit-btn-container {
|
||||
margin-right: 0;
|
||||
}
|
||||
.timeline .timeline-item.user-content .comment-header {
|
||||
padding: 7px 10px;
|
||||
}
|
||||
.timeline .timeline-item.user-content .comment-header .links-active {
|
||||
padding-right: 10px;
|
||||
}
|
||||
.timeline .timeline-item.user-content .comment-header .reply-link {
|
||||
margin-left: 0;
|
||||
}
|
||||
.timeline .timeline-item.user-content .comment-header .asset-details {
|
||||
width: calc(100% - 30px);
|
||||
}
|
||||
.timeline .timeline-item.user-content .avatar-medium {
|
||||
margin-right: 10px;
|
||||
}
|
||||
.timeline .timeline-item.user-content .reply {
|
||||
padding: 10px;
|
||||
}
|
||||
.timeline .timeline-item.user-content .commented-on-small {
|
||||
display: inline-block;
|
||||
}
|
||||
.timeline .timeline-item.user-content .commented-on-small {
|
||||
display: inline-block;
|
||||
}
|
||||
.timeline .timeline-item.notification-content {
|
||||
padding-left: 15px;
|
||||
margin: 20px 0;
|
||||
}
|
||||
.timeline .timeline-item.notification-content::before {
|
||||
content: none;
|
||||
}
|
||||
.timeline .timeline-item.notification-content .small {
|
||||
padding-left: 0;
|
||||
}
|
||||
.timeline .timeline-item .delivery-status-indicator {
|
||||
float: left;
|
||||
margin: 0 5px 0 0;
|
||||
}
|
||||
.timeline .asset-details {
|
||||
line-height: 24px;
|
||||
/*Height of avtar image -36px to align text center vertically*/
|
||||
}
|
||||
}
|
||||
|
|
@ -138,7 +138,10 @@
|
|||
<path fill-rule="evenodd" clip-rule="evenodd" d="M3.25 6C3.25 5.72386 3.47386 5.5 3.75 5.5H20.2474C20.5236 5.5 20.7474 5.72386 20.7474 6C20.7474 6.27614 20.5236 6.5 20.2474 6.5H3.75C3.47386 6.5 3.25 6.27614 3.25 6ZM3.25 12C3.25 11.7239 3.47386 11.5 3.75 11.5H20.2474C20.5236 11.5 20.7474 11.7239 20.7474 12C20.7474 12.2761 20.5236 12.5 20.2474 12.5H3.75C3.47386 12.5 3.25 12.2761 3.25 12ZM3.75 17.5C3.47386 17.5 3.25 17.7239 3.25 18C3.25 18.2761 3.47386 18.5 3.75 18.5H20.2474C20.5236 18.5 20.7474 18.2761 20.7474 18C20.7474 17.7239 20.5236 17.5 20.2474 17.5H3.75Z" fill="var(--icon-stroke)"/>
|
||||
</symbol>
|
||||
<symbol fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" id="icon-lock">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M8.077 1.45h-.055a3.356 3.356 0 00-3.387 3.322v.35H3.75a2 2 0 00-2 2v5.391a2 2 0 002 2h8.539a2 2 0 002-2V7.122a2 2 0 00-2-2h-.885v-.285A3.356 3.356 0 008.082 1.45h-.005zm2.327 3.672V4.83a2.356 2.356 0 00-2.33-2.38h-.06a2.356 2.356 0 00-2.38 2.33v.342h4.77zm-6.654 1a1 1 0 00-1 1v5.391a1 1 0 001 1h8.539a1 1 0 001-1V7.122a1 1 0 00-1-1H3.75zm4.27 4.269a.573.573 0 100-1.147.573.573 0 000 1.147zm1.573-.574a1.573 1.573 0 11-3.147 0 1.573 1.573 0 013.147 0z"></path>
|
||||
<path stroke="none" fill-rule="evenodd" clip-rule="evenodd" d="M8.077 1.45h-.055a3.356 3.356 0 00-3.387 3.322v.35H3.75a2 2 0 00-2 2v5.391a2 2 0 002 2h8.539a2 2 0 002-2V7.122a2 2 0 00-2-2h-.885v-.285A3.356 3.356 0 008.082 1.45h-.005zm2.327 3.672V4.83a2.356 2.356 0 00-2.33-2.38h-.06a2.356 2.356 0 00-2.38 2.33v.342h4.77zm-6.654 1a1 1 0 00-1 1v5.391a1 1 0 001 1h8.539a1 1 0 001-1V7.122a1 1 0 00-1-1H3.75zm4.27 4.269a.573.573 0 100-1.147.573.573 0 000 1.147zm1.573-.574a1.573 1.573 0 11-3.147 0 1.573 1.573 0 013.147 0z" fill="#1F272E"></path>
|
||||
</symbol>
|
||||
<symbol width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" id="icon-unlock">
|
||||
<path stroke="none" fill-rule="evenodd" clip-rule="evenodd" d="M8.07685 1.45034H8.02155C7.13255 1.44218 6.2766 1.78707 5.64159 2.40938C5.00596 3.03229 4.64377 3.88215 4.63464 4.77206L4.63462 4.77206V4.77719V5.12175H3.75C2.64543 5.12175 1.75 6.01719 1.75 7.12175V12.5134C1.75 13.6179 2.64543 14.5134 3.75 14.5134H12.2885C13.393 14.5134 14.2885 13.6179 14.2885 12.5134V7.12175C14.2885 6.01718 13.393 5.12175 12.2885 5.12175H5.63462V4.77988C5.64166 4.156 5.89586 3.56033 6.34152 3.12359C6.78776 2.68627 7.38942 2.4441 8.01419 2.45031L8.01418 2.45034H8.01916H8.07417C8.69805 2.45738 9.29371 2.71158 9.73045 3.15724C9.92373 3.35446 10.2403 3.35766 10.4375 3.16438C10.6347 2.9711 10.6379 2.65453 10.4447 2.45731C9.82175 1.82169 8.97189 1.45949 8.08198 1.45036L8.08198 1.45034H8.07685ZM3.75 6.12175C3.19772 6.12175 2.75 6.56947 2.75 7.12175V12.5134C2.75 13.0656 3.19772 13.5134 3.75 13.5134H12.2885C12.8407 13.5134 13.2885 13.0656 13.2885 12.5134V7.12175C13.2885 6.56947 12.8407 6.12175 12.2885 6.12175H3.75ZM8.01936 10.3909C8.33605 10.3909 8.59279 10.1342 8.59279 9.81752C8.59279 9.50083 8.33605 9.24409 8.01936 9.24409C7.70266 9.24409 7.44593 9.50083 7.44593 9.81752C7.44593 10.1342 7.70266 10.3909 8.01936 10.3909ZM9.59279 9.81752C9.59279 10.6865 8.88834 11.3909 8.01936 11.3909C7.15038 11.3909 6.44593 10.6865 6.44593 9.81752C6.44593 8.94854 7.15038 8.24409 8.01936 8.24409C8.88834 8.24409 9.59279 8.94854 9.59279 9.81752Z" fill="#1F272E"/>
|
||||
</symbol>
|
||||
<symbol viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" id="icon-list_alt">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M2.5 3.722c0-.454.316-.722.59-.722h9.82c.274 0 .59.268.59.722v8.556c0 .454-.316.722-.59.722H3.09c-.274 0-.59-.268-.59-.722V3.722zM3.09 2c-.93 0-1.59.826-1.59 1.722v8.556c0 .896.66 1.722 1.59 1.722h9.82c.93 0 1.59-.826 1.59-1.722V3.722C14.5 2.826 13.84 2 12.91 2H3.09zM5 4.5a.5.5 0 0 0 0 1h4.002a.5.5 0 1 0 0-1H5zM5 7a.5.5 0 0 0 0 1h5.002a.5.5 0 1 0 0-1H5zm-.5 3a.5.5 0 0 1 .5-.5h2.27a.5.5 0 0 1 0 1H5a.5.5 0 0 1-.5-.5z"
|
||||
|
|
@ -265,7 +268,7 @@
|
|||
<path d="M16.127 13.077l3.194 3.194a2.588 2.588 0 0 1 0 3.66 2.589 2.589 0 0 1-3.66 0l-2.902-2.902" stroke="var(--icon-stroke)" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"></path>
|
||||
<path d="M11.315 10.095l-4.96-4.96a1.294 1.294 0 1 0-1.83 1.83l4.877 4.877" stroke="var(--icon-stroke)" stroke-miterlimit="10"></path>
|
||||
<path d="M18.56 11.949l-.353.353a.5.5 0 0 0 .707 0l-.354-.353zM21 9.509l.354.353a.5.5 0 0 0 0-.705L21 9.509zm-5.47-5.51l.354-.352-.004-.004-.35.357zm-4.9.02l-.353-.353a.5.5 0 0 0 0 .707l.353-.354zm8.284 8.283l2.44-2.44-.707-.707-2.44 2.44.707.707zm2.44-3.145l-5.47-5.51-.71.705 5.471 5.51.71-.705zM15.88 3.643A3.977 3.977 0 0 0 13.074 2.5l.004 1a2.977 2.977 0 0 1 2.1.856l.702-.713zM13.074 2.5a3.977 3.977 0 0 0-2.797 1.166l.707.706a2.977 2.977 0 0 1 2.094-.872l-.004-1zm-2.797 1.873l7.93 7.93.707-.708-7.93-7.93-.707.708z"
|
||||
fill="#4C5A67" stroke="none"></path>
|
||||
fill="var(--icon-stroke)" stroke="none"></path>
|
||||
<path d="M14.133 7.522L3.398 17.325a1.219 1.219 0 0 0-.04 1.764L4.6 20.331a1.22 1.22 0 0 0 1.764-.04l9.789-10.75" stroke="var(--icon-stroke)" stroke-miterlimit="10"></path>
|
||||
</symbol>
|
||||
<symbol viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" id="icon-support">
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 89 KiB After Width: | Height: | Size: 91 KiB |
|
|
@ -1,52 +0,0 @@
|
|||
// used in documenation site built via document generator
|
||||
|
||||
$(function() {
|
||||
if(window.hljs) {
|
||||
$('pre code').each(function(i, block) {
|
||||
hljs.highlightBlock(block);
|
||||
});
|
||||
}
|
||||
|
||||
// search
|
||||
$('.sidebar-navbar-items .octicon-search, .navbar .octicon-search').parent().on("click", function() {
|
||||
var modal = frappe.get_modal("Search",
|
||||
'<p><input class="search-input form-control" type="text" placeholder="Search text..." tabindex="1"></p>\
|
||||
<p><a class="btn btn-sm btn-default btn-search" href="#" target="_blank" tabindex="2">Search via Google</a></p>');
|
||||
modal.find(".search-input").on("keyup", function(e) {
|
||||
if(e.which===13) {
|
||||
modal.find(".btn-search").trigger("click");
|
||||
}
|
||||
if(e.which===9) {
|
||||
e.preventDefault();
|
||||
modal.find(".btn-search").focus();
|
||||
return false;
|
||||
}
|
||||
var text = $(this).val();
|
||||
modal.find(".btn-search").attr("href", "https://google.com/search?q="
|
||||
+ text + "+site:" + (window.docs_base_url || ""));
|
||||
});
|
||||
modal.modal("show");
|
||||
return false;
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
frappe = {
|
||||
get_modal: function(title, body_html) {
|
||||
var modal = $('<div class="modal" style="overflow: auto;" tabindex="-1">\
|
||||
<div class="modal-dialog">\
|
||||
<div class="modal-content">\
|
||||
<div class="modal-header">\
|
||||
<a type="button" class="close"\
|
||||
data-dismiss="modal" aria-hidden="true">×</a>\
|
||||
<h4 class="modal-title">'+title+'</h4>\
|
||||
</div>\
|
||||
<div class="modal-body ui-front">'+body_html+'\
|
||||
</div>\
|
||||
</div>\
|
||||
</div>\
|
||||
</div>').appendTo(document.body);
|
||||
|
||||
return modal;
|
||||
},
|
||||
};
|
||||
|
|
@ -128,7 +128,7 @@ frappe.Application = Class.extend({
|
|||
}
|
||||
|
||||
// REDESIGN-TODO: Fix preview popovers
|
||||
//this.link_preview = new frappe.ui.LinkPreview();
|
||||
this.link_preview = new frappe.ui.LinkPreview();
|
||||
|
||||
if (!frappe.boot.developer_mode) {
|
||||
setInterval(function() {
|
||||
|
|
|
|||
|
|
@ -11,17 +11,18 @@
|
|||
</div>
|
||||
<div>
|
||||
<div>
|
||||
<a :href="file.doc.file_url" v-if="file.doc" target="_blank">
|
||||
<a class="flex" :href="file.doc.file_url" v-if="file.doc" target="_blank">
|
||||
<span class="file-name">{{ file.name | file_name }}</span>
|
||||
<i v-html="frappe.utils.icon(file.doc.is_private ? 'lock' : 'unlock')"></i>
|
||||
<div class="ml-2" v-html="private_icon"></div>
|
||||
</a>
|
||||
<span class="flex" v-else>
|
||||
<span class="file-name">{{ file.name | file_name }}</span>
|
||||
<span class="cursor-pointer" @click="$emit('toggle_private')" :title="__('Toggle Public/Private')">
|
||||
<i v-html="frappe.utils.icon(file.is_private ? 'lock' : 'unlock')"></i>
|
||||
</span>
|
||||
<button class="ml-2 btn-reset" @click="$emit('toggle_private')" :title="__('Toggle Public/Private')">
|
||||
<div v-html="private_icon"></div>
|
||||
</button>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<span class="file-size">
|
||||
{{ file.file_obj.size | file_size }}
|
||||
|
|
@ -30,7 +31,7 @@
|
|||
</div>
|
||||
<div class="file-actions">
|
||||
<ProgressRing
|
||||
v-show="file.uploading"
|
||||
v-show="file.uploading && !uploaded"
|
||||
primary="var(--primary-color)"
|
||||
secondary="var(--gray-200)"
|
||||
radius="24"
|
||||
|
|
@ -76,6 +77,12 @@ export default {
|
|||
}
|
||||
},
|
||||
computed: {
|
||||
private_icon() {
|
||||
return frappe.utils.icon(this.is_private ? 'lock' : 'unlock');
|
||||
},
|
||||
is_private() {
|
||||
return this.file.doc ? this.file.doc.is_private : this.file.private;
|
||||
},
|
||||
uploaded() {
|
||||
return this.file.total && this.file.total === this.file.progress && !this.file.failed;
|
||||
},
|
||||
|
|
@ -156,9 +163,10 @@ export default {
|
|||
}
|
||||
|
||||
.file-actions {
|
||||
width: 2.5rem;
|
||||
width: 3rem;
|
||||
flex-shrink: 0;
|
||||
margin-left: auto;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.file-actions .btn {
|
||||
|
|
|
|||
|
|
@ -73,21 +73,13 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="file-preview-area" v-show="files.length && !show_file_browser && !show_web_link">
|
||||
<!-- <div class="margin-bottom" v-if="!upload_complete">
|
||||
<label>
|
||||
<input type="checkbox" class="input-with-feedback" @change="e => toggle_all_private(e.target.checked)">
|
||||
<span class="text-medium" style="font-weight: normal;">
|
||||
{{ __('Make all attachments private') }}
|
||||
</span>
|
||||
</label>
|
||||
</div> -->
|
||||
<div class="file-preview-container">
|
||||
<FilePreview
|
||||
v-for="(file, i) in files"
|
||||
:key="file.name"
|
||||
:file="file"
|
||||
@remove="remove_file(i)"
|
||||
@toggle_private="toggle_private(i)"
|
||||
@remove="remove_file(file)"
|
||||
@toggle_private="file.private = !file.private"
|
||||
/>
|
||||
</div>
|
||||
<div class="flex align-center" v-if="show_upload_button && currently_uploading === -1">
|
||||
|
|
@ -217,15 +209,19 @@ export default {
|
|||
on_file_input(e) {
|
||||
this.add_files(this.$refs.file_input.files);
|
||||
},
|
||||
remove_file(i) {
|
||||
this.files = this.files.filter((file, j) => i !== j);
|
||||
remove_file(file) {
|
||||
this.files = this.files.filter(f => f !== file);
|
||||
},
|
||||
toggle_private(i) {
|
||||
this.files[i].private = !this.files[i].private;
|
||||
},
|
||||
toggle_all_private(flag) {
|
||||
if (flag == null) {
|
||||
flag = this.files.every(file => file.private);
|
||||
toggle_all_private() {
|
||||
let flag;
|
||||
let private_values = this.files.filter(file => file.private);
|
||||
if (private_values.length < this.files.length) {
|
||||
// there are some private and some public
|
||||
// set all to private
|
||||
flag = true;
|
||||
} else {
|
||||
// all are private, set all to public
|
||||
flag = false;
|
||||
}
|
||||
this.files = this.files.map(file => {
|
||||
file.private = flag;
|
||||
|
|
|
|||
|
|
@ -48,6 +48,13 @@ export default class FileUploader {
|
|||
|
||||
this.uploader = this.$fileuploader.$children[0];
|
||||
|
||||
this.uploader.$watch('files', (files) => {
|
||||
let all_private = files.every(file => file.private);
|
||||
if (this.dialog) {
|
||||
this.dialog.set_secondary_action_label(all_private ? __('Set all public') : __('Set all private'));
|
||||
}
|
||||
}, { deep: true });
|
||||
|
||||
if (files && files.length) {
|
||||
this.uploader.add_files(files);
|
||||
}
|
||||
|
|
@ -66,8 +73,10 @@ export default class FileUploader {
|
|||
title: __('Upload'),
|
||||
primary_action_label: __('Upload'),
|
||||
primary_action: () => this.upload_files(),
|
||||
secondary_action_label: __('Toggle Private'),
|
||||
secondary_action: () => this.uploader.toggle_all_private()
|
||||
secondary_action_label: __('Set all private'),
|
||||
secondary_action: () => {
|
||||
this.uploader.toggle_all_private();
|
||||
}
|
||||
});
|
||||
|
||||
this.wrapper = this.dialog.body;
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ frappe.ui.form.Control = Class.extend({
|
|||
frappe.model.get_doc(this.doctype, this.docname), this.perm || (this.frm && this.frm.perm), explain);
|
||||
|
||||
// Match parent grid controls read only status
|
||||
if (status === 'Write' && (this.grid || (this.layout && this.layout.grid))) {
|
||||
if (status === 'Write' && (this.grid || (this.layout && this.layout.grid) && !cint(this.df.allow_on_submit))) {
|
||||
var grid = this.grid || this.layout.grid;
|
||||
if (grid.display_status == 'Read') {
|
||||
status = 'Read';
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
frappe.ui.form.ControlInt = frappe.ui.form.ControlData.extend({
|
||||
trigger_change_on_input_event: false,
|
||||
make: function () {
|
||||
this._super();
|
||||
// $(this.label_area).addClass('pull-right');
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ frappe.ui.form.ControlLink = frappe.ui.form.ControlData.extend({
|
|||
return $('<li></li>')
|
||||
.data('item.autocomplete', d)
|
||||
.prop('aria-selected', 'false')
|
||||
.html('<a><p>' + html + '</p></a>')
|
||||
.html(`<a><p class="ellipsis" title="${_label}">${html}</p></a>`)
|
||||
.get(0);
|
||||
},
|
||||
sort: function() {
|
||||
|
|
|
|||
|
|
@ -84,12 +84,12 @@ frappe.ui.form.ControlMultiSelectPills = frappe.ui.form.ControlAutocomplete.exte
|
|||
|
||||
get_pill_html(value) {
|
||||
const encoded_value = encodeURIComponent(value);
|
||||
return `<div class="btn-group tb-selected-value" data-value="${encoded_value}">
|
||||
<button class="btn btn-default btn-xs btn-link-to-form">${__(value)}</button>
|
||||
<button class="btn btn-default btn-xs btn-remove">
|
||||
${frappe.utils.icon('close')}
|
||||
return `
|
||||
<button class="data-pill btn tb-selected-value" data-value="${encoded_value}">
|
||||
<span class="btn-link-to-form">${__(value)}</span>
|
||||
<span class="btn-remove">${frappe.utils.icon('close')}</span>
|
||||
</button>
|
||||
</div>`;
|
||||
`;
|
||||
},
|
||||
|
||||
get_awesomplete_settings() {
|
||||
|
|
|
|||
|
|
@ -2,11 +2,41 @@ frappe.ui.form.ControlSelect = frappe.ui.form.ControlData.extend({
|
|||
html_element: 'select',
|
||||
make_input: function() {
|
||||
this._super();
|
||||
this.$wrapper.find('.control-input')
|
||||
.addClass('flex align-center')
|
||||
.append(frappe.utils.icon('select'));
|
||||
|
||||
const is_xs_input = this.df.input_class
|
||||
&& this.df.input_class.includes('input-xs');
|
||||
this.set_icon(is_xs_input);
|
||||
this.df.placeholder && this.set_placeholder(is_xs_input);
|
||||
|
||||
this.$input.addClass('ellipsis');
|
||||
this.set_options();
|
||||
},
|
||||
set_icon: function(is_xs_input) {
|
||||
const select_icon_html =
|
||||
`<div class="select-icon ${is_xs_input ? 'xs' : ''}">
|
||||
${frappe.utils.icon('select', is_xs_input ? 'xs' : 'sm')}
|
||||
</div>`;
|
||||
if (this.only_input) {
|
||||
this.$wrapper.append(select_icon_html);
|
||||
} else {
|
||||
this.$wrapper.find('.control-input')
|
||||
.addClass('flex align-center')
|
||||
.append(select_icon_html);
|
||||
}
|
||||
},
|
||||
set_placeholder: function(is_xs_input) {
|
||||
const placeholder_html =
|
||||
`<div class="placeholder ellipsis text-extra-muted ${is_xs_input ? 'xs' : ''}">
|
||||
<span>${this.df.placeholder}</span>
|
||||
</div>`;
|
||||
if (this.only_input) {
|
||||
this.$wrapper.append(placeholder_html);
|
||||
} else {
|
||||
this.$wrapper.find('.control-input').append(placeholder_html);
|
||||
}
|
||||
this.toggle_placeholder();
|
||||
this.$input && this.$input.on('select-change', () => this.toggle_placeholder());
|
||||
},
|
||||
set_formatted_input: function(value) {
|
||||
// refresh options first - (new ones??)
|
||||
if(value==null) value = '';
|
||||
|
|
@ -64,6 +94,10 @@ frappe.ui.form.ControlSelect = frappe.ui.form.ControlData.extend({
|
|||
this.set_description(__("Please attach a file first."));
|
||||
return [""];
|
||||
}
|
||||
},
|
||||
toggle_placeholder: function() {
|
||||
const input_set = Boolean(this.$input.val());
|
||||
this.$wrapper.find('.placeholder').toggle(!input_set);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -103,4 +137,11 @@ frappe.ui.form.ControlSelect = frappe.ui.form.ControlData.extend({
|
|||
$.fn.done_working = function() {
|
||||
this.prop('disabled', false);
|
||||
};
|
||||
|
||||
let original_val = $.fn.val;
|
||||
$.fn.val = function() {
|
||||
let result = original_val.apply(this, arguments);
|
||||
if (arguments.length > 0) $(this).trigger('select-change');
|
||||
return result;
|
||||
};
|
||||
})(jQuery);
|
||||
|
|
|
|||
|
|
@ -123,12 +123,12 @@ frappe.ui.form.ControlTableMultiSelect = frappe.ui.form.ControlLink.extend({
|
|||
},
|
||||
get_pill_html(value) {
|
||||
const encoded_value = encodeURIComponent(value);
|
||||
return `<div class="btn-group tb-selected-value" data-value="${encoded_value}">
|
||||
<button class="btn btn-default btn-xs btn-link-to-form">${__(value)}</button>
|
||||
<button class="btn btn-default btn-xs btn-remove">
|
||||
${frappe.utils.icon('close')}
|
||||
return `
|
||||
<button class="data-pill btn tb-selected-value" data-value="${encoded_value}">
|
||||
<span class="btn-link-to-form">${__(value)}</span>
|
||||
<span class="btn-remove">${frappe.utils.icon('close')}</span>
|
||||
</button>
|
||||
</div>`;
|
||||
`;
|
||||
},
|
||||
get_options() {
|
||||
return (this.get_link_field() || {}).options;
|
||||
|
|
|
|||
|
|
@ -358,10 +358,11 @@ class FormTimeline extends BaseTimeline {
|
|||
const args = {
|
||||
doc: this.frm.doc,
|
||||
frm: this.frm,
|
||||
recipients: communication_doc ? communication_doc.sender : this.get_recipient(),
|
||||
recipients: communication_doc && communication_doc.sender != frappe.session.user_email ? communication_doc.sender : this.get_recipient(),
|
||||
is_a_reply: Boolean(communication_doc),
|
||||
title: communication_doc ? __('Reply') : null,
|
||||
last_email: communication_doc
|
||||
last_email: communication_doc,
|
||||
subject: communication_doc && communication_doc.subject
|
||||
};
|
||||
|
||||
if (communication_doc && reply_all) {
|
||||
|
|
|
|||
|
|
@ -334,7 +334,7 @@ frappe.ui.form.Form = class FrappeForm {
|
|||
}
|
||||
}
|
||||
if (action.action_type==='Server Action') {
|
||||
frappe.xcall(action.action, {doc: this.doc}).then((doc) => {
|
||||
frappe.xcall(action.action, {'doc': this.doc}).then((doc) => {
|
||||
if (doc.doctype) {
|
||||
// document is returned by the method,
|
||||
// apply the changes locally and refresh
|
||||
|
|
@ -1498,7 +1498,7 @@ frappe.ui.form.Form = class FrappeForm {
|
|||
|
||||
const escaped_name = encodeURIComponent(value);
|
||||
|
||||
return `<a class="indicator ${get_color(doc || {})}" href="/app/${frappe.router.slug(df.options)}/${escaped_name}" data-doctype="${doctype}" data-name="${value}">${label}</a>'`;
|
||||
return `<a class="indicator ${get_color(doc || {})}" href="/app/${frappe.router.slug(df.options)}/${escaped_name}" data-doctype="${doctype}" data-name="${value}">${label}</a>`;
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -229,7 +229,7 @@ export default class GridRow {
|
|||
this.open_form_button = $(`
|
||||
<div class="btn-open-row">
|
||||
<a>${frappe.utils.icon('edit', 'xs')}</a>
|
||||
<div class="hidden-xs edit-grid-row">Edit</div>
|
||||
<div class="hidden-xs edit-grid-row">${ __("Edit") }</div>
|
||||
</div>
|
||||
`)
|
||||
.appendTo($('<div class="col col-xs-1"></div>').appendTo(this.row))
|
||||
|
|
|
|||
|
|
@ -176,7 +176,7 @@ frappe.ui.form.ScriptManager = Class.extend({
|
|||
eval(doctype.__custom_js);
|
||||
} catch(e) {
|
||||
frappe.msgprint({
|
||||
title: __('Error in Custom Script'),
|
||||
title: __('Error in Client Script'),
|
||||
indicator: 'orange',
|
||||
message: '<pre class="small"><code>' + e.stack + '</code></pre>'
|
||||
});
|
||||
|
|
|
|||
|
|
@ -210,7 +210,7 @@ frappe.ui.form.Sidebar = class {
|
|||
if (follow == null) {
|
||||
follow = this.frm.get_docinfo().is_document_followed;
|
||||
}
|
||||
this.follow_button.text(follow ? "Unfollow" : "Follow");
|
||||
this.follow_button.text(follow ? __("Unfollow") : __("Follow"));
|
||||
}
|
||||
|
||||
refresh_like() {
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@
|
|||
</a>
|
||||
<ul class="dropdown-menu list-stats-dropdown" role="menu">
|
||||
<div class="dropdown-search">
|
||||
<input type="text" placeholder="Search" data-element="search" class="form-control input-xs">
|
||||
<input type="text" placeholder={{__("Search") }} data-element="search" class="form-control input-xs">
|
||||
</div>
|
||||
<div class="stat-result">
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList {
|
|||
const match_rules_list = frappe.perm.get_match_rules(this.doctype);
|
||||
if (match_rules_list.length) {
|
||||
this.restricted_list = $(
|
||||
`<button class="btn btn-default btn-xs restricted-button flex align-center">
|
||||
`<button class="btn btn-xs restricted-button flex align-center">
|
||||
${frappe.utils.icon('restriction', 'xs')}
|
||||
</button>`
|
||||
).click(() => this.show_restrictions(match_rules_list)).appendTo(this.page.page_form);
|
||||
|
|
@ -676,7 +676,7 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList {
|
|||
|
||||
if (col.type === "Tag") {
|
||||
const tags_display_class = !this.tags_shown ? 'hide' : '';
|
||||
let tags_html = doc._user_tags ? this.get_tags_html(doc._user_tags) : '<div class="tags-empty">-</div>';
|
||||
let tags_html = doc._user_tags ? this.get_tags_html(doc._user_tags, 2) : '<div class="tags-empty">-</div>';
|
||||
return `
|
||||
<div class="list-row-col tag-col ${tags_display_class} hidden-xs ellipsis">
|
||||
${tags_html}
|
||||
|
|
@ -790,13 +790,19 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList {
|
|||
`;
|
||||
}
|
||||
|
||||
get_tags_html(user_tags) {
|
||||
get_tags_html(user_tags, limit, colored=false) {
|
||||
let get_tag_html = tag => {
|
||||
let color = '', style = '';
|
||||
if (tag) {
|
||||
return `<div class="tag-pill ellipsis" title="${tag}">${tag}</div>`;
|
||||
if (colored) {
|
||||
color = frappe.get_palette(tag);
|
||||
style = `background-color: var(${color[0]}); color: var(${color[1]})`;
|
||||
}
|
||||
|
||||
return `<div class="tag-pill ellipsis" title="${tag}" style="${style}">${tag}</div>`;
|
||||
}
|
||||
};
|
||||
return user_tags.split(',').slice(1, 3).map(get_tag_html).join('');
|
||||
return user_tags.split(',').slice(1, limit + 1).map(get_tag_html).join('');
|
||||
}
|
||||
|
||||
get_meta_html(doc) {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ frappe.views.ListViewSelect = class ListViewSelect {
|
|||
add_view_to_menu(view, action) {
|
||||
let $el = this.page.add_custom_menu_item(
|
||||
this.parent,
|
||||
view,
|
||||
__(view),
|
||||
action,
|
||||
true,
|
||||
null,
|
||||
|
|
@ -51,10 +51,15 @@ frappe.views.ListViewSelect = class ListViewSelect {
|
|||
action: () => this.set_route("report"),
|
||||
current_view_handler: () => {
|
||||
const reports = this.get_reports();
|
||||
this.setup_dropdown_in_sidebar("Report", reports, {
|
||||
label: __("Report Builder"),
|
||||
action: () => this.set_route("report")
|
||||
});
|
||||
let default_action = {};
|
||||
// Only add action if current route is not report builder
|
||||
if (frappe.get_route().length > 3) {
|
||||
default_action = {
|
||||
label: __("Report Builder"),
|
||||
action: () => this.set_route("report")
|
||||
};
|
||||
}
|
||||
this.setup_dropdown_in_sidebar("Report", reports, default_action);
|
||||
}
|
||||
},
|
||||
Dashboard: {
|
||||
|
|
@ -147,8 +152,9 @@ frappe.views.ListViewSelect = class ListViewSelect {
|
|||
${__("No {} Found", [view])}
|
||||
</div>`;
|
||||
} else {
|
||||
const page_name = this.get_page_name();
|
||||
items.map(item => {
|
||||
if (item.name == this.get_page_name()) {
|
||||
if (item.name.toLowerCase() == page_name.toLowerCase()) {
|
||||
placeholder = item.name;
|
||||
}
|
||||
html += `<li><a class="dropdown-item" href="${item.route}">${
|
||||
|
|
@ -212,7 +218,7 @@ frappe.views.ListViewSelect = class ListViewSelect {
|
|||
const report_type =
|
||||
r.report_type === "Report Builder"
|
||||
? `/app/list/${r.ref_doctype}/report`
|
||||
: "query-report";
|
||||
: "/app/query-report";
|
||||
|
||||
const route =
|
||||
r.route || report_type + "/" + (r.title || r.name);
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ $.extend(frappe.model, {
|
|||
|
||||
core_doctypes_list: ['DocType', 'DocField', 'DocPerm', 'User', 'Role', 'Has Role',
|
||||
'Page', 'Module Def', 'Print Format', 'Report', 'Customize Form',
|
||||
'Customize Form Field', 'Property Setter', 'Custom Field', 'Custom Script'],
|
||||
'Customize Form Field', 'Property Setter', 'Custom Field', 'Client Script'],
|
||||
|
||||
std_fields: [
|
||||
{fieldname:'name', fieldtype:'Link', label:__('ID')},
|
||||
|
|
|
|||
|
|
@ -492,7 +492,7 @@ frappe.request.report_error = function(xhr, request_opts) {
|
|||
|
||||
if (!frappe.error_dialog) {
|
||||
frappe.error_dialog = new frappe.ui.Dialog({
|
||||
title: 'Server Error',
|
||||
title: __('Server Error'),
|
||||
primary_action_label: __('Report'),
|
||||
primary_action: () => {
|
||||
if (error_report_email) {
|
||||
|
|
|
|||
|
|
@ -35,6 +35,8 @@ frappe.ui.Dialog = class Dialog extends frappe.ui.FieldGroup {
|
|||
$(this.wrapper).addClass("modal-sm");
|
||||
else if (this.size == "large" )
|
||||
$(this.wrapper).addClass("modal-lg");
|
||||
else if (this.size == "extra-large" )
|
||||
$(this.wrapper).addClass("modal-xl");
|
||||
|
||||
this.make_head();
|
||||
this.modal_body = this.$wrapper.find(".modal-body");
|
||||
|
|
|
|||
|
|
@ -214,6 +214,7 @@ frappe.ui.Filter = class {
|
|||
df.read_only = 0;
|
||||
df.hidden = 0;
|
||||
df.is_filter = true;
|
||||
delete df.hidden_due_to_dependency;
|
||||
|
||||
let c = condition ? condition : this.utils.get_default_condition(df);
|
||||
this.set_condition(c);
|
||||
|
|
|
|||
|
|
@ -74,8 +74,8 @@ frappe.ui.FilterGroup = class {
|
|||
}
|
||||
this.set_filter_events();
|
||||
}
|
||||
|
||||
hide_empty_filters && this.toggle_empty_filters(false);
|
||||
this.toggle_empty_filters(false);
|
||||
!hide_empty_filters && this.add_filter(this.doctype, 'name');
|
||||
});
|
||||
|
||||
this.filter_button.on('hidden.bs.popover', () => {
|
||||
|
|
@ -286,7 +286,9 @@ frappe.ui.FilterGroup = class {
|
|||
return $(`
|
||||
<div class="filter-area">
|
||||
<div class="filter-edit-area">
|
||||
<div class="text-muted empty-filters text-center">${__('No filters selected')}</div>
|
||||
<div class="text-muted empty-filters text-center">
|
||||
${__('No filters selected')}
|
||||
</div>
|
||||
</div>
|
||||
<hr class="divider"></hr>
|
||||
<div class="filter-action-buttons">
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ frappe.ui.LinkPreview = class {
|
|||
}
|
||||
});
|
||||
this.handle_popover_hide();
|
||||
|
||||
}
|
||||
|
||||
identify_doc() {
|
||||
|
|
@ -122,7 +121,7 @@ frappe.ui.LinkPreview = class {
|
|||
}
|
||||
});
|
||||
|
||||
$(window).on('hashchange', () => {
|
||||
frappe.router.on('change', () => {
|
||||
this.clear_all_popovers();
|
||||
});
|
||||
}
|
||||
|
|
@ -142,18 +141,22 @@ frappe.ui.LinkPreview = class {
|
|||
let popover_content = this.get_popover_html(preview_data);
|
||||
this.element.popover({
|
||||
container: 'body',
|
||||
template: `
|
||||
<div class="link-preview-popover popover">
|
||||
<div class="arrow"></div>
|
||||
<div class="popover-body popover-content">
|
||||
</div>
|
||||
</div>
|
||||
`,
|
||||
html: true,
|
||||
sanitizeFn: (content) => content,
|
||||
content: popover_content,
|
||||
trigger: 'manual',
|
||||
placement: 'top auto',
|
||||
animation: false,
|
||||
placement: 'top',
|
||||
});
|
||||
|
||||
const $popover = this.element.data('bs.popover').tip();
|
||||
|
||||
$popover.addClass('link-preview-popover');
|
||||
const $popover = $(this.element.data('bs.popover').tip);
|
||||
$popover.toggleClass('control-field-popover', this.is_link);
|
||||
|
||||
this.popovers_list.push(this.element.data('bs.popover'));
|
||||
|
||||
}
|
||||
|
|
@ -167,53 +170,63 @@ frappe.ui.LinkPreview = class {
|
|||
this.href = this.href.replace(new RegExp(' ', 'g'), '%20');
|
||||
}
|
||||
|
||||
let image_html = '';
|
||||
let id_html = '';
|
||||
let content_html = '';
|
||||
|
||||
if (preview_data.preview_image) {
|
||||
let image_url = encodeURI(preview_data.preview_image);
|
||||
image_html = `
|
||||
let popover_content =`
|
||||
<div class="preview-popover-header">
|
||||
<div class="preview-header">
|
||||
<img src="${image_url}" onerror="this.src='/assets/frappe/images/fallback-thumbnail.jpg'" class="preview-image"></img>
|
||||
${this.get_image_html(preview_data)}
|
||||
<div class="preview-name">
|
||||
<a href=${this.href}>${__(preview_data.preview_title)}</a>
|
||||
</div>
|
||||
<div class="text-muted preview-title">${this.get_id_html(preview_data)}</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
</div>
|
||||
<hr>
|
||||
<div class="popover-body">
|
||||
${this.get_content_html(preview_data)}
|
||||
</div>
|
||||
`;
|
||||
|
||||
if (preview_data.preview_title != preview_data.name) {
|
||||
return popover_content;
|
||||
}
|
||||
|
||||
get_id_html(preview_data) {
|
||||
let id_html = '';
|
||||
if (preview_data.preview_title !== preview_data.name) {
|
||||
id_html = `<a class="text-muted" href=${this.href}>${preview_data.name}</a>`;
|
||||
}
|
||||
|
||||
return id_html;
|
||||
}
|
||||
|
||||
get_image_html(preview_data) {
|
||||
let avatar_html = frappe.get_avatar(
|
||||
"avatar-medium",
|
||||
preview_data.preview_title,
|
||||
preview_data.preview_image
|
||||
);
|
||||
|
||||
return `<div class="preview-image">
|
||||
${avatar_html}
|
||||
</div>`;
|
||||
}
|
||||
|
||||
get_content_html(preview_data) {
|
||||
let content_html = '';
|
||||
|
||||
Object.keys(preview_data).forEach(key => {
|
||||
if (!['preview_image', 'preview_title', 'name'].includes(key)) {
|
||||
let value = frappe.ellipsis(preview_data[key], 280);
|
||||
let label = key;
|
||||
content_html += `
|
||||
<div class="preview-field">
|
||||
<div class='small preview-label text-muted bold'>${__(label)}</div>
|
||||
<div class="small preview-value">${value}</div>
|
||||
<div class="preview-label text-muted">${__(label)}</div>
|
||||
<div class="preview-value">${value}</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
});
|
||||
content_html = `<div class="preview-table">${content_html}</div>`;
|
||||
|
||||
let popover_content =`
|
||||
<div class="preview-popover-header">${image_html}
|
||||
<div class="preview-header">
|
||||
<div class="preview-main">
|
||||
<a class="preview-name bold" href=${this.href}>${__(preview_data.preview_title)}</a>
|
||||
<span class="text-muted small">${__(this.doctype)} ${id_html}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="popover-body">
|
||||
${content_html}
|
||||
</div>
|
||||
`;
|
||||
|
||||
return popover_content;
|
||||
return `<div class="preview-table">${content_html}</div>`;
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
|||
|
|
@ -114,6 +114,7 @@ frappe.ui.Page = Class.extend({
|
|||
this.get_main_icon(this.icon);
|
||||
|
||||
this.body = this.main = this.wrapper.find(".layout-main-section");
|
||||
this.container = this.wrapper.find(".page-body");
|
||||
this.sidebar = this.wrapper.find(".layout-side-section");
|
||||
this.footer = this.wrapper.find(".layout-footer");
|
||||
this.indicator = this.wrapper.find(".indicator-pill");
|
||||
|
|
@ -770,6 +771,8 @@ frappe.ui.Page = Class.extend({
|
|||
df.placeholder = df.label;
|
||||
}
|
||||
|
||||
df.input_class = 'input-xs';
|
||||
|
||||
var f = frappe.ui.form.make_control({
|
||||
df: df,
|
||||
parent: parent || this.page_form,
|
||||
|
|
@ -791,7 +794,7 @@ frappe.ui.Page = Class.extend({
|
|||
// hidden fields dont have $input
|
||||
if (!f.$input) f.make_input();
|
||||
|
||||
f.$input.addClass("input-xs").attr("placeholder", __(df.label));
|
||||
f.$input.attr("placeholder", __(df.label));
|
||||
|
||||
if(df.fieldtype==="Check") {
|
||||
$(f.wrapper).find(":first-child")
|
||||
|
|
|
|||
|
|
@ -303,7 +303,7 @@ frappe.search.SearchDialog = class {
|
|||
|
||||
let $results_list = $(`<div class="results-summary">
|
||||
<div class="result-section full-list ${type}-section col-sm-12">
|
||||
<div class="result-title">${type}</div>
|
||||
<div class="result-title"> ${ __(type) }</div>
|
||||
<div class="result-body">
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -340,7 +340,7 @@ frappe.search.SearchDialog = class {
|
|||
}
|
||||
|
||||
let $result_section = $(`<div class="col-sm-12 result-section" data-type="${type}">
|
||||
<div class="result-title">${type}</div>
|
||||
<div class="result-title">${__(type)}</div>
|
||||
<div class="result-body">
|
||||
${more_html}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -126,6 +126,12 @@ frappe.ui.toolbar.Toolbar = class {
|
|||
if (frappe.boot.desk_settings.search_bar) {
|
||||
let awesome_bar = new frappe.search.AwesomeBar();
|
||||
awesome_bar.setup("#navbar-search");
|
||||
|
||||
// TODO: Remove this in v14
|
||||
frappe.search.utils.make_function_searchable(function() {
|
||||
frappe.set_route("List", "Client Script");
|
||||
}, __("Custom Script List"));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,27 +20,25 @@ frappe.avatar = function (user, css_class, title, image_url=null, remove_color=f
|
|||
title = user_info.fullname;
|
||||
}
|
||||
|
||||
return frappe.get_avatar(
|
||||
user, css_class, title, image_url || user_info.image, remove_color, filterable
|
||||
);
|
||||
};
|
||||
|
||||
frappe.get_avatar = function(user, css_class, title, image_url=null, remove_color, filterable) {
|
||||
let data_attr = '';
|
||||
|
||||
if (!css_class) {
|
||||
css_class = "avatar-small";
|
||||
}
|
||||
|
||||
if (filterable) {
|
||||
css_class += " filterable";
|
||||
data_attr = `data-filter="_assign,like,%${user}%"`;
|
||||
}
|
||||
|
||||
return frappe.get_avatar(
|
||||
css_class, title, image_url || user_info.image, remove_color, data_attr
|
||||
);
|
||||
};
|
||||
|
||||
frappe.get_avatar = function(css_class, title, image_url=null, remove_color, data_attributes) {
|
||||
if (!css_class) {
|
||||
css_class = "avatar-small";
|
||||
}
|
||||
|
||||
if (image_url) {
|
||||
const image = (window.cordova && image_url.indexOf('http') === -1) ? frappe.base_url + image_url : image_url;
|
||||
|
||||
return `<span class="avatar ${css_class}" title="${title}" ${data_attr}>
|
||||
return `<span class="avatar ${css_class}" title="${title}" ${data_attributes}>
|
||||
<span class="avatar-frame" style='background-image: url("${image}")'
|
||||
title="${title}"></span>
|
||||
</span>`;
|
||||
|
|
@ -55,7 +53,8 @@ frappe.get_avatar = function(user, css_class, title, image_url=null, remove_colo
|
|||
if (css_class === 'avatar-small' || css_class == 'avatar-xs') {
|
||||
abbr = abbr.substr(0, 1);
|
||||
}
|
||||
return `<span class="avatar ${css_class}" title="${title}" ${data_attr}>
|
||||
|
||||
return `<span class="avatar ${css_class}" title="${title}" ${data_attributes}>
|
||||
<div class="avatar-frame standard-image"
|
||||
style="${style}">
|
||||
${abbr}
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ frappe.breadcrumbs = {
|
|||
} else {
|
||||
route = doctype_route;
|
||||
}
|
||||
$(`<li><a href="/app/${route}">${doctype}</a></li>`)
|
||||
$(`<li><a href="/app/${route}">${__(doctype)}</a></li>`)
|
||||
.appendTo(this.$breadcrumbs);
|
||||
}
|
||||
},
|
||||
|
|
@ -147,7 +147,7 @@ frappe.breadcrumbs = {
|
|||
const doctype = breadcrumbs.doctype;
|
||||
const docname = frappe.get_route()[2];
|
||||
let form_route = `/app/${frappe.router.slug(doctype)}/${docname}`;
|
||||
$(`<li><a href="${form_route}">${docname}</a></li>`)
|
||||
$(`<li><a href="${form_route}">${__(docname)}</a></li>`)
|
||||
.appendTo(this.$breadcrumbs);
|
||||
|
||||
if (view === "form") {
|
||||
|
|
|
|||
|
|
@ -386,21 +386,18 @@ frappe.views.CommunicationComposer = Class.extend({
|
|||
},
|
||||
|
||||
setup_print_language: function() {
|
||||
var me = this;
|
||||
var doc = this.doc || cur_frm.doc;
|
||||
var fields = this.dialog.fields_dict;
|
||||
|
||||
//Load default print language from doctype
|
||||
this.lang_code = doc.language
|
||||
|
||||
if (this.get_print_format().default_print_language) {
|
||||
var default_print_language_code = this.get_print_format().default_print_language;
|
||||
me.lang_code = default_print_language_code;
|
||||
} else {
|
||||
var default_print_language_code = null;
|
||||
if (!this.lang_code && this.get_print_format().default_print_language) {
|
||||
this.lang_code = this.get_print_format().default_print_language;
|
||||
}
|
||||
|
||||
//On selection of language retrieve language code
|
||||
var me = this;
|
||||
$(fields.language_sel.input).change(function(){
|
||||
me.lang_code = this.value
|
||||
})
|
||||
|
|
@ -410,10 +407,8 @@ frappe.views.CommunicationComposer = Class.extend({
|
|||
.empty()
|
||||
.add_options(frappe.get_languages());
|
||||
|
||||
if (default_print_language_code) {
|
||||
$(fields.language_sel.input).val(default_print_language_code);
|
||||
} else {
|
||||
$(fields.language_sel.input).val(doc.language);
|
||||
if (this.lang_code) {
|
||||
$(fields.language_sel.input).val(this.lang_code);
|
||||
}
|
||||
},
|
||||
|
||||
|
|
@ -440,6 +435,7 @@ frappe.views.CommunicationComposer = Class.extend({
|
|||
}
|
||||
|
||||
},
|
||||
|
||||
setup_attach: function() {
|
||||
var fields = this.dialog.fields_dict;
|
||||
var attach = $(fields.select_attachments.wrapper);
|
||||
|
|
@ -591,26 +587,28 @@ frappe.views.CommunicationComposer = Class.extend({
|
|||
|
||||
save_as_draft: function() {
|
||||
if (this.dialog && this.frm) {
|
||||
try {
|
||||
let message = this.dialog.get_value('content');
|
||||
message = message.split(frappe.separator_element)[0];
|
||||
localStorage.setItem(this.frm.doctype + this.frm.docname, message);
|
||||
} catch (e) {
|
||||
// silently fail
|
||||
console.log(e);
|
||||
console.warn('[Communication] localStorage is full. Cannot save message as draft');
|
||||
}
|
||||
let message = this.dialog.get_value('content');
|
||||
message = message.split(frappe.separator_element)[0];
|
||||
localforage.setItem(this.frm.doctype + this.frm.docname, message).catch(e => {
|
||||
if (e) {
|
||||
// silently fail
|
||||
console.log(e); // eslint-disable-line
|
||||
console.warn('[Communication] localStorage is full. Cannot save message as draft'); // eslint-disable-line
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
delete_saved_draft() {
|
||||
if (this.dialog) {
|
||||
try {
|
||||
localStorage.removeItem(this.frm.doctype + this.frm.docname);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
console.warn('[Communication] Cannot delete localStorage item'); // eslint-disable-line
|
||||
}
|
||||
localforage.removeItem(this.frm.doctype + this.frm.docname).catch(e => {
|
||||
if (e) {
|
||||
// silently fail
|
||||
console.log(e); // eslint-disable-line
|
||||
console.warn('[Communication] localStorage is full. Cannot save message as draft'); // eslint-disable-line
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
|
|
@ -721,7 +719,7 @@ frappe.views.CommunicationComposer = Class.extend({
|
|||
signature = res.message.signature;
|
||||
}
|
||||
|
||||
if(!frappe.utils.is_html(signature)) {
|
||||
if (signature && !frappe.utils.is_html(signature)) {
|
||||
signature = signature.replace(/\n/g, "<br>");
|
||||
}
|
||||
|
||||
|
|
@ -731,7 +729,7 @@ frappe.views.CommunicationComposer = Class.extend({
|
|||
// saved draft in localStorage
|
||||
const { doctype, docname } = this.frm || {};
|
||||
if (doctype && docname) {
|
||||
this.message = localStorage.getItem(doctype + docname) || '';
|
||||
this.message = await localforage.getItem(doctype + docname) || '';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -124,7 +124,12 @@ frappe.provide("frappe.views");
|
|||
const new_cards = state.cards.slice();
|
||||
new_cards[index] = card;
|
||||
updater.set({ cards: new_cards });
|
||||
fluxify.doAction('update_order');
|
||||
const args = {
|
||||
new: 1,
|
||||
name: card.name,
|
||||
colname: updated_doc[state.board.field_name],
|
||||
};
|
||||
fluxify.doAction('update_order_for_single_card', args);
|
||||
});
|
||||
} else {
|
||||
frappe.new_doc(this.doctype, doc);
|
||||
|
|
@ -155,6 +160,53 @@ frappe.provide("frappe.views");
|
|||
fluxify.doAction('update_card', updated_card);
|
||||
});
|
||||
},
|
||||
update_order_for_single_card: function(updater, card) {
|
||||
// cache original order
|
||||
const _cards = this.cards.slice();
|
||||
const _columns = this.columns.slice();
|
||||
let args = {};
|
||||
let method_name = "";
|
||||
|
||||
if (card.new) {
|
||||
method_name = "add_card";
|
||||
args = {
|
||||
board_name: this.board.name,
|
||||
docname: card.name,
|
||||
colname: card.colname,
|
||||
};
|
||||
} else {
|
||||
method_name = "update_order_for_single_card";
|
||||
args = {
|
||||
board_name: this.board.name,
|
||||
docname: unescape(card.name),
|
||||
from_colname: card.from_colname,
|
||||
to_colname: card.to_colname,
|
||||
old_index: card.old_index,
|
||||
new_index: card.new_index,
|
||||
};
|
||||
}
|
||||
|
||||
frappe.call({
|
||||
method: method_prefix + method_name,
|
||||
args: args,
|
||||
callback: (r) => {
|
||||
let board = r.message;
|
||||
let updated_cards = [{'name': card.name, 'column': card.to_colname || card.colname}];
|
||||
let cards = update_cards_column(updated_cards);
|
||||
let columns = prepare_columns(board.columns);
|
||||
updater.set({
|
||||
cards: cards,
|
||||
columns: columns
|
||||
});
|
||||
}
|
||||
}).fail(function() {
|
||||
// revert original order
|
||||
updater.set({
|
||||
cards: _cards,
|
||||
columns: _columns
|
||||
});
|
||||
});
|
||||
},
|
||||
update_order: function(updater) {
|
||||
// cache original order
|
||||
const _cards = this.cards.slice();
|
||||
|
|
@ -446,16 +498,24 @@ frappe.provide("frappe.views");
|
|||
group: "cards",
|
||||
animation: 150,
|
||||
dataIdAttr: 'data-name',
|
||||
forceFallback: true,
|
||||
onStart: function() {
|
||||
wrapper.find('.kanban-card.add-card').fadeOut(200, function() {
|
||||
wrapper.find('.kanban-cards').height('100vh');
|
||||
});
|
||||
},
|
||||
onEnd: function() {
|
||||
onEnd: function(e) {
|
||||
wrapper.find('.kanban-card.add-card').fadeIn(100);
|
||||
wrapper.find('.kanban-cards').height('auto');
|
||||
// update order
|
||||
fluxify.doAction('update_order');
|
||||
const args = {
|
||||
name: $(e.item).attr('data-name'),
|
||||
from_colname: $(e.from).parents('.kanban-column').attr('data-column-value'),
|
||||
to_colname: $(e.to).parents('.kanban-column').attr('data-column-value'),
|
||||
old_index: e.oldIndex,
|
||||
new_index: e.newIndex,
|
||||
};
|
||||
fluxify.doAction('update_order_for_single_card', args);
|
||||
},
|
||||
onAdd: function() {
|
||||
},
|
||||
|
|
@ -546,14 +606,24 @@ frappe.provide("frappe.views");
|
|||
var opts = {
|
||||
name: card.name,
|
||||
title: remove_img_tags(card.title),
|
||||
disable_click: card._disable_click ? 'disable-click' : ''
|
||||
disable_click: card._disable_click ? 'disable-click' : '',
|
||||
creation: card.creation,
|
||||
};
|
||||
self.$card = $(frappe.render_template('kanban_card', opts))
|
||||
.appendTo(wrapper);
|
||||
}
|
||||
|
||||
function get_tags_html(card) {
|
||||
return card.tags
|
||||
? `<div class="kanban-tags">
|
||||
${cur_list.get_tags_html(card.tags, 3, true)}
|
||||
</div>`
|
||||
: '';
|
||||
}
|
||||
|
||||
function render_card_meta() {
|
||||
var html = "";
|
||||
let html = get_tags_html(card);
|
||||
|
||||
if (card.comment_count > 0)
|
||||
html +=
|
||||
`<span class="list-comment-count small text-muted ">
|
||||
|
|
@ -563,7 +633,10 @@ frappe.provide("frappe.views");
|
|||
|
||||
const $assignees_group = get_assignees_group();
|
||||
|
||||
html += `<span class="kanban-assignments"></span>`;
|
||||
html += `
|
||||
<span class="kanban-assignments"></span>
|
||||
${cur_list.get_like_html(card)}
|
||||
`;
|
||||
|
||||
if (card.color && frappe.ui.color.validate_hex(card.color)) {
|
||||
const $div = $('<div>');
|
||||
|
|
@ -630,6 +703,9 @@ frappe.provide("frappe.views");
|
|||
doctype: state.doctype,
|
||||
name: card.name,
|
||||
title: card[state.card_meta.title_field.fieldname],
|
||||
creation: moment(card.creation).format('MMM DD, YYYY'),
|
||||
_liked_by: card._liked_by,
|
||||
tags: card._user_tags,
|
||||
column: card[state.board.field_name],
|
||||
assigned_list: card.assigned_list || assigned_list,
|
||||
comment_count: card.comment_count || comment_count,
|
||||
|
|
|
|||
|
|
@ -2,9 +2,12 @@
|
|||
<a class="kanban-card-redirect" href="#">
|
||||
<div class="kanban-card content">
|
||||
<div class="kanban-title-area">
|
||||
<div class="kanban-card-title ellipsis" title="{{title}}">
|
||||
<div class="kanban-card-title" title="{{title}}">
|
||||
{{ title }}
|
||||
</div>
|
||||
<div class="kanban-card-creation">
|
||||
{{ creation }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="kanban-card-meta">
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -73,7 +73,11 @@ frappe.views.KanbanView = class KanbanView extends frappe.views.ListView {
|
|||
}
|
||||
|
||||
setup_view() {
|
||||
if (this.board.columns.length > 5) {
|
||||
this.page.container.addClass('full-width');
|
||||
}
|
||||
this.setup_realtime_updates();
|
||||
this.setup_like();
|
||||
}
|
||||
|
||||
set_fields() {
|
||||
|
|
|
|||
|
|
@ -172,6 +172,23 @@ frappe.views.TreeView = Class.extend({
|
|||
this.post_render();
|
||||
},
|
||||
|
||||
rebuild_tree: function() {
|
||||
let me = this;
|
||||
|
||||
frappe.call({
|
||||
"method": "frappe.utils.nestedset.rebuild_tree",
|
||||
"args": {
|
||||
'doctype': me.doctype,
|
||||
'parent_field': "parent_"+me.doctype.toLowerCase().replace(/ /g, '_'),
|
||||
},
|
||||
"callback": function(r) {
|
||||
if (!r.exc) {
|
||||
me.make_tree();
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
post_render: function() {
|
||||
var me = this;
|
||||
me.opts.post_render && me.opts.post_render(me);
|
||||
|
|
@ -368,7 +385,7 @@ frappe.views.TreeView = Class.extend({
|
|||
}, "add");
|
||||
}
|
||||
},
|
||||
set_menu_item: function(){
|
||||
set_menu_item: function() {
|
||||
var me = this;
|
||||
|
||||
this.menu_items = [
|
||||
|
|
@ -393,6 +410,17 @@ frappe.views.TreeView = Class.extend({
|
|||
},
|
||||
];
|
||||
|
||||
if (frappe.user.has_role('System Manager')) {
|
||||
this.menu_items.push(
|
||||
{
|
||||
label: __('Rebuild Tree'),
|
||||
action: function() {
|
||||
me.rebuild_tree();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if (me.opts.menu_items) {
|
||||
me.menu_items.push.apply(me.menu_items, me.opts.menu_items)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,23 +0,0 @@
|
|||
# 3rd party libraries
|
||||
|
||||
Import / Upgrade Guide
|
||||
|
||||
## JQuery UI
|
||||
|
||||
Download modules
|
||||
|
||||
- core
|
||||
- interactions
|
||||
- autocomplete
|
||||
- datepicker
|
||||
|
||||
## JQuery UI Bootstrap theme
|
||||
|
||||
Changes images urls
|
||||
|
||||
- from: url(images
|
||||
- to: url(../lib/js/lib/jquery/bootstrap_theme/images
|
||||
|
||||
## JQuery Gantt
|
||||
|
||||
Not a very mature project. Please check css / js after updating
|
||||
|
|
@ -1,104 +0,0 @@
|
|||
.awesomplete [hidden] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.awesomplete .visually-hidden {
|
||||
position: absolute;
|
||||
clip: rect(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
.awesomplete {
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.awesomplete > input {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.awesomplete > ul {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
z-index: 1;
|
||||
min-width: 100%;
|
||||
box-sizing: border-box;
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.awesomplete > ul:empty {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.awesomplete > ul {
|
||||
border-radius: .3em;
|
||||
margin: .2em 0 0;
|
||||
background: hsla(0,0%,100%,.9);
|
||||
background: linear-gradient(to bottom right, white, hsla(0,0%,100%,.8));
|
||||
border: 1px solid rgba(0,0,0,.3);
|
||||
box-shadow: .05em .2em .6em rgba(0,0,0,.2);
|
||||
text-shadow: none;
|
||||
}
|
||||
|
||||
@supports (transform: scale(0)) {
|
||||
.awesomplete > ul {
|
||||
transition: .3s cubic-bezier(.4,.2,.5,1.4);
|
||||
transform-origin: 1.43em -.43em;
|
||||
}
|
||||
|
||||
.awesomplete > ul[hidden],
|
||||
.awesomplete > ul:empty {
|
||||
opacity: 0;
|
||||
transform: scale(0);
|
||||
display: block;
|
||||
transition-timing-function: ease;
|
||||
}
|
||||
}
|
||||
|
||||
/* Pointer */
|
||||
.awesomplete > ul:before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: -.43em;
|
||||
left: 1em;
|
||||
width: 0; height: 0;
|
||||
padding: .4em;
|
||||
background: white;
|
||||
border: inherit;
|
||||
border-right: 0;
|
||||
border-bottom: 0;
|
||||
-webkit-transform: rotate(45deg);
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
|
||||
.awesomplete > ul > li {
|
||||
position: relative;
|
||||
padding: .2em .5em;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.awesomplete > ul > li:hover {
|
||||
background: hsl(200, 40%, 80%);
|
||||
color: black;
|
||||
}
|
||||
|
||||
.awesomplete > ul > li[aria-selected="true"] {
|
||||
background: hsl(205, 40%, 40%);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.awesomplete mark {
|
||||
background: hsl(65, 100%, 50%);
|
||||
}
|
||||
|
||||
.awesomplete li:hover mark {
|
||||
background: hsl(68, 100%, 41%);
|
||||
}
|
||||
|
||||
.awesomplete li[aria-selected="true"] mark {
|
||||
background: hsl(86, 100%, 21%);
|
||||
color: inherit;
|
||||
}
|
||||
/*# sourceMappingURL=awesomplete.css.map */
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load diff
|
|
@ -1,208 +0,0 @@
|
|||
/*!
|
||||
* FullCalendar v3.4.0 Print Stylesheet
|
||||
* Docs & License: https://fullcalendar.io/
|
||||
* (c) 2017 Adam Shaw
|
||||
*/
|
||||
|
||||
/*
|
||||
* Include this stylesheet on your page to get a more printer-friendly calendar.
|
||||
* When including this stylesheet, use the media='print' attribute of the <link> tag.
|
||||
* Make sure to include this stylesheet IN ADDITION to the regular fullcalendar.css.
|
||||
*/
|
||||
|
||||
.fc {
|
||||
max-width: 100% !important;
|
||||
}
|
||||
|
||||
|
||||
/* Global Event Restyling
|
||||
--------------------------------------------------------------------------------------------------*/
|
||||
|
||||
.fc-event {
|
||||
background: #fff !important;
|
||||
color: #000 !important;
|
||||
page-break-inside: avoid;
|
||||
}
|
||||
|
||||
.fc-event .fc-resizer {
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
||||
/* Table & Day-Row Restyling
|
||||
--------------------------------------------------------------------------------------------------*/
|
||||
|
||||
.fc th,
|
||||
.fc td,
|
||||
.fc hr,
|
||||
.fc thead,
|
||||
.fc tbody,
|
||||
.fc-row {
|
||||
border-color: #ccc !important;
|
||||
background: #fff !important;
|
||||
}
|
||||
|
||||
/* kill the overlaid, absolutely-positioned components */
|
||||
/* common... */
|
||||
.fc-bg,
|
||||
.fc-bgevent-skeleton,
|
||||
.fc-highlight-skeleton,
|
||||
.fc-helper-skeleton,
|
||||
/* for timegrid. within cells within table skeletons... */
|
||||
.fc-bgevent-container,
|
||||
.fc-business-container,
|
||||
.fc-highlight-container,
|
||||
.fc-helper-container {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* don't force a min-height on rows (for DayGrid) */
|
||||
.fc tbody .fc-row {
|
||||
height: auto !important; /* undo height that JS set in distributeHeight */
|
||||
min-height: 0 !important; /* undo the min-height from each view's specific stylesheet */
|
||||
}
|
||||
|
||||
.fc tbody .fc-row .fc-content-skeleton {
|
||||
position: static; /* undo .fc-rigid */
|
||||
padding-bottom: 0 !important; /* use a more border-friendly method for this... */
|
||||
}
|
||||
|
||||
.fc tbody .fc-row .fc-content-skeleton tbody tr:last-child td { /* only works in newer browsers */
|
||||
padding-bottom: 1em; /* ...gives space within the skeleton. also ensures min height in a way */
|
||||
}
|
||||
|
||||
.fc tbody .fc-row .fc-content-skeleton table {
|
||||
/* provides a min-height for the row, but only effective for IE, which exaggerates this value,
|
||||
making it look more like 3em. for other browers, it will already be this tall */
|
||||
height: 1em;
|
||||
}
|
||||
|
||||
|
||||
/* Undo month-view event limiting. Display all events and hide the "more" links
|
||||
--------------------------------------------------------------------------------------------------*/
|
||||
|
||||
.fc-more-cell,
|
||||
.fc-more {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.fc tr.fc-limited {
|
||||
display: table-row !important;
|
||||
}
|
||||
|
||||
.fc td.fc-limited {
|
||||
display: table-cell !important;
|
||||
}
|
||||
|
||||
.fc-popover {
|
||||
display: none; /* never display the "more.." popover in print mode */
|
||||
}
|
||||
|
||||
|
||||
/* TimeGrid Restyling
|
||||
--------------------------------------------------------------------------------------------------*/
|
||||
|
||||
/* undo the min-height 100% trick used to fill the container's height */
|
||||
.fc-time-grid {
|
||||
min-height: 0 !important;
|
||||
}
|
||||
|
||||
/* don't display the side axis at all ("all-day" and time cells) */
|
||||
.fc-agenda-view .fc-axis {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* don't display the horizontal lines */
|
||||
.fc-slats,
|
||||
.fc-time-grid hr { /* this hr is used when height is underused and needs to be filled */
|
||||
display: none !important; /* important overrides inline declaration */
|
||||
}
|
||||
|
||||
/* let the container that holds the events be naturally positioned and create real height */
|
||||
.fc-time-grid .fc-content-skeleton {
|
||||
position: static;
|
||||
}
|
||||
|
||||
/* in case there are no events, we still want some height */
|
||||
.fc-time-grid .fc-content-skeleton table {
|
||||
height: 4em;
|
||||
}
|
||||
|
||||
/* kill the horizontal spacing made by the event container. event margins will be done below */
|
||||
.fc-time-grid .fc-event-container {
|
||||
margin: 0 !important;
|
||||
}
|
||||
|
||||
|
||||
/* TimeGrid *Event* Restyling
|
||||
--------------------------------------------------------------------------------------------------*/
|
||||
|
||||
/* naturally position events, vertically stacking them */
|
||||
.fc-time-grid .fc-event {
|
||||
position: static !important;
|
||||
margin: 3px 2px !important;
|
||||
}
|
||||
|
||||
/* for events that continue to a future day, give the bottom border back */
|
||||
.fc-time-grid .fc-event.fc-not-end {
|
||||
border-bottom-width: 1px !important;
|
||||
}
|
||||
|
||||
/* indicate the event continues via "..." text */
|
||||
.fc-time-grid .fc-event.fc-not-end:after {
|
||||
content: "...";
|
||||
}
|
||||
|
||||
/* for events that are continuations from previous days, give the top border back */
|
||||
.fc-time-grid .fc-event.fc-not-start {
|
||||
border-top-width: 1px !important;
|
||||
}
|
||||
|
||||
/* indicate the event is a continuation via "..." text */
|
||||
.fc-time-grid .fc-event.fc-not-start:before {
|
||||
content: "...";
|
||||
}
|
||||
|
||||
/* time */
|
||||
|
||||
/* undo a previous declaration and let the time text span to a second line */
|
||||
.fc-time-grid .fc-event .fc-time {
|
||||
white-space: normal !important;
|
||||
}
|
||||
|
||||
/* hide the the time that is normally displayed... */
|
||||
.fc-time-grid .fc-event .fc-time span {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* ...replace it with a more verbose version (includes AM/PM) stored in an html attribute */
|
||||
.fc-time-grid .fc-event .fc-time:after {
|
||||
content: attr(data-full);
|
||||
}
|
||||
|
||||
|
||||
/* Vertical Scroller & Containers
|
||||
--------------------------------------------------------------------------------------------------*/
|
||||
|
||||
/* kill the scrollbars and allow natural height */
|
||||
.fc-scroller,
|
||||
.fc-day-grid-container, /* these divs might be assigned height, which we need to cleared */
|
||||
.fc-time-grid-container { /* */
|
||||
overflow: visible !important;
|
||||
height: auto !important;
|
||||
}
|
||||
|
||||
/* kill the horizontal border/padding used to compensate for scrollbars */
|
||||
.fc-row {
|
||||
border: 0 !important;
|
||||
margin: 0 !important;
|
||||
}
|
||||
|
||||
|
||||
/* Button Controls
|
||||
--------------------------------------------------------------------------------------------------*/
|
||||
|
||||
.fc-button-group,
|
||||
.fc button {
|
||||
display: none; /* don't display any button-related controls */
|
||||
}
|
||||
|
|
@ -1,181 +0,0 @@
|
|||
/*!
|
||||
* FullCalendar v3.4.0 Google Calendar Plugin
|
||||
* Docs & License: https://fullcalendar.io/
|
||||
* (c) 2017 Adam Shaw
|
||||
*/
|
||||
|
||||
|
||||
(function(factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define([ 'jquery' ], factory);
|
||||
}
|
||||
else if (typeof exports === 'object') { // Node/CommonJS
|
||||
module.exports = factory(require('jquery'));
|
||||
}
|
||||
else {
|
||||
factory(jQuery);
|
||||
}
|
||||
})(function($) {
|
||||
|
||||
|
||||
var API_BASE = 'https://www.googleapis.com/calendar/v3/calendars';
|
||||
var FC = $.fullCalendar;
|
||||
var applyAll = FC.applyAll;
|
||||
|
||||
|
||||
FC.sourceNormalizers.push(function(sourceOptions) {
|
||||
var googleCalendarId = sourceOptions.googleCalendarId;
|
||||
var url = sourceOptions.url;
|
||||
var match;
|
||||
|
||||
// if the Google Calendar ID hasn't been explicitly defined
|
||||
if (!googleCalendarId && url) {
|
||||
|
||||
// detect if the ID was specified as a single string.
|
||||
// will match calendars like "asdf1234@calendar.google.com" in addition to person email calendars.
|
||||
if (/^[^\/]+@([^\/\.]+\.)*(google|googlemail|gmail)\.com$/.test(url)) {
|
||||
googleCalendarId = url;
|
||||
}
|
||||
// try to scrape it out of a V1 or V3 API feed URL
|
||||
else if (
|
||||
(match = /^https:\/\/www.googleapis.com\/calendar\/v3\/calendars\/([^\/]*)/.exec(url)) ||
|
||||
(match = /^https?:\/\/www.google.com\/calendar\/feeds\/([^\/]*)/.exec(url))
|
||||
) {
|
||||
googleCalendarId = decodeURIComponent(match[1]);
|
||||
}
|
||||
|
||||
if (googleCalendarId) {
|
||||
sourceOptions.googleCalendarId = googleCalendarId;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (googleCalendarId) { // is this a Google Calendar?
|
||||
|
||||
// make each Google Calendar source uneditable by default
|
||||
if (sourceOptions.editable == null) {
|
||||
sourceOptions.editable = false;
|
||||
}
|
||||
|
||||
// We want removeEventSource to work, but it won't know about the googleCalendarId primitive.
|
||||
// Shoehorn it into the url, which will function as the unique primitive. Won't cause side effects.
|
||||
// This hack is obsolete since 2.2.3, but keep it so this plugin file is compatible with old versions.
|
||||
sourceOptions.url = googleCalendarId;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
FC.sourceFetchers.push(function(sourceOptions, start, end, timezone) {
|
||||
if (sourceOptions.googleCalendarId) {
|
||||
return transformOptions(sourceOptions, start, end, timezone, this); // `this` is the calendar
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
function transformOptions(sourceOptions, start, end, timezone, calendar) {
|
||||
var url = API_BASE + '/' + encodeURIComponent(sourceOptions.googleCalendarId) + '/events?callback=?'; // jsonp
|
||||
var apiKey = sourceOptions.googleCalendarApiKey || calendar.opt('googleCalendarApiKey');
|
||||
var success = sourceOptions.success;
|
||||
var data;
|
||||
var timezoneArg; // populated when a specific timezone. escaped to Google's liking
|
||||
|
||||
function reportError(message, apiErrorObjs) {
|
||||
var errorObjs = apiErrorObjs || [ { message: message } ]; // to be passed into error handlers
|
||||
|
||||
// call error handlers
|
||||
(sourceOptions.googleCalendarError || $.noop).apply(calendar, errorObjs);
|
||||
(calendar.opt('googleCalendarError') || $.noop).apply(calendar, errorObjs);
|
||||
|
||||
// print error to debug console
|
||||
FC.warn.apply(null, [ message ].concat(apiErrorObjs || []));
|
||||
}
|
||||
|
||||
if (!apiKey) {
|
||||
reportError("Specify a googleCalendarApiKey. See http://fullcalendar.io/docs/google_calendar/");
|
||||
return {}; // an empty source to use instead. won't fetch anything.
|
||||
}
|
||||
|
||||
// The API expects an ISO8601 datetime with a time and timezone part.
|
||||
// Since the calendar's timezone offset isn't always known, request the date in UTC and pad it by a day on each
|
||||
// side, guaranteeing we will receive all events in the desired range, albeit a superset.
|
||||
// .utc() will set a zone and give it a 00:00:00 time.
|
||||
if (!start.hasZone()) {
|
||||
start = start.clone().utc().add(-1, 'day');
|
||||
}
|
||||
if (!end.hasZone()) {
|
||||
end = end.clone().utc().add(1, 'day');
|
||||
}
|
||||
|
||||
// when sending timezone names to Google, only accepts underscores, not spaces
|
||||
if (timezone && timezone != 'local') {
|
||||
timezoneArg = timezone.replace(' ', '_');
|
||||
}
|
||||
|
||||
data = $.extend({}, sourceOptions.data || {}, {
|
||||
key: apiKey,
|
||||
timeMin: start.format(),
|
||||
timeMax: end.format(),
|
||||
timeZone: timezoneArg,
|
||||
singleEvents: true,
|
||||
maxResults: 9999
|
||||
});
|
||||
|
||||
return $.extend({}, sourceOptions, {
|
||||
googleCalendarId: null, // prevents source-normalizing from happening again
|
||||
url: url,
|
||||
data: data,
|
||||
startParam: false, // `false` omits this parameter. we already included it above
|
||||
endParam: false, // same
|
||||
timezoneParam: false, // same
|
||||
success: function(data) {
|
||||
var events = [];
|
||||
var successArgs;
|
||||
var successRes;
|
||||
|
||||
if (data.error) {
|
||||
reportError('Google Calendar API: ' + data.error.message, data.error.errors);
|
||||
}
|
||||
else if (data.items) {
|
||||
$.each(data.items, function(i, entry) {
|
||||
var url = entry.htmlLink || null;
|
||||
|
||||
// make the URLs for each event show times in the correct timezone
|
||||
if (timezoneArg && url !== null) {
|
||||
url = injectQsComponent(url, 'ctz=' + timezoneArg);
|
||||
}
|
||||
|
||||
events.push({
|
||||
id: entry.id,
|
||||
title: entry.summary,
|
||||
start: entry.start.dateTime || entry.start.date, // try timed. will fall back to all-day
|
||||
end: entry.end.dateTime || entry.end.date, // same
|
||||
url: url,
|
||||
location: entry.location,
|
||||
description: entry.description
|
||||
});
|
||||
});
|
||||
|
||||
// call the success handler(s) and allow it to return a new events array
|
||||
successArgs = [ events ].concat(Array.prototype.slice.call(arguments, 1)); // forward other jq args
|
||||
successRes = applyAll(success, this, successArgs);
|
||||
if ($.isArray(successRes)) {
|
||||
return successRes;
|
||||
}
|
||||
}
|
||||
|
||||
return events;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// Injects a string like "arg=value" into the querystring of a URL
|
||||
function injectQsComponent(url, component) {
|
||||
// inject it after the querystring but before the fragment
|
||||
return url.replace(/(\?.*?)?(#|$)/, function(whole, qs, hash) {
|
||||
return (qs ? qs + '&' : '?') + component + hash;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
1
frappe/public/js/lib/fuse.min.js
vendored
1
frappe/public/js/lib/fuse.min.js
vendored
File diff suppressed because one or more lines are too long
|
|
@ -1,480 +0,0 @@
|
|||
/*
|
||||
http://www.JSON.org/json2.js
|
||||
2011-02-23
|
||||
|
||||
Public Domain.
|
||||
|
||||
NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
|
||||
|
||||
See http://www.JSON.org/js.html
|
||||
|
||||
|
||||
This code should be minified before deployment.
|
||||
See http://javascript.crockford.com/jsmin.html
|
||||
|
||||
USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
|
||||
NOT CONTROL.
|
||||
|
||||
|
||||
This file creates a global JSON object containing two methods: stringify
|
||||
and parse.
|
||||
|
||||
JSON.stringify(value, replacer, space)
|
||||
value any JavaScript value, usually an object or array.
|
||||
|
||||
replacer an optional parameter that determines how object
|
||||
values are stringified for objects. It can be a
|
||||
function or an array of strings.
|
||||
|
||||
space an optional parameter that specifies the indentation
|
||||
of nested structures. If it is omitted, the text will
|
||||
be packed without extra whitespace. If it is a number,
|
||||
it will specify the number of spaces to indent at each
|
||||
level. If it is a string (such as '\t' or ' '),
|
||||
it contains the characters used to indent at each level.
|
||||
|
||||
This method produces a JSON text from a JavaScript value.
|
||||
|
||||
When an object value is found, if the object contains a toJSON
|
||||
method, its toJSON method will be called and the result will be
|
||||
stringified. A toJSON method does not serialize: it returns the
|
||||
value represented by the name/value pair that should be serialized,
|
||||
or undefined if nothing should be serialized. The toJSON method
|
||||
will be passed the key associated with the value, and this will be
|
||||
bound to the value
|
||||
|
||||
For example, this would serialize Dates as ISO strings.
|
||||
|
||||
Date.prototype.toJSON = function (key) {
|
||||
function f(n) {
|
||||
// Format integers to have at least two digits.
|
||||
return n < 10 ? '0' + n : n;
|
||||
}
|
||||
|
||||
return this.getUTCFullYear() + '-' +
|
||||
f(this.getUTCMonth() + 1) + '-' +
|
||||
f(this.getUTCDate()) + 'T' +
|
||||
f(this.getUTCHours()) + ':' +
|
||||
f(this.getUTCMinutes()) + ':' +
|
||||
f(this.getUTCSeconds()) + 'Z';
|
||||
};
|
||||
|
||||
You can provide an optional replacer method. It will be passed the
|
||||
key and value of each member, with this bound to the containing
|
||||
object. The value that is returned from your method will be
|
||||
serialized. If your method returns undefined, then the member will
|
||||
be excluded from the serialization.
|
||||
|
||||
If the replacer parameter is an array of strings, then it will be
|
||||
used to select the members to be serialized. It filters the results
|
||||
such that only members with keys listed in the replacer array are
|
||||
stringified.
|
||||
|
||||
Values that do not have JSON representations, such as undefined or
|
||||
functions, will not be serialized. Such values in objects will be
|
||||
dropped; in arrays they will be replaced with null. You can use
|
||||
a replacer function to replace those with JSON values.
|
||||
JSON.stringify(undefined) returns undefined.
|
||||
|
||||
The optional space parameter produces a stringification of the
|
||||
value that is filled with line breaks and indentation to make it
|
||||
easier to read.
|
||||
|
||||
If the space parameter is a non-empty string, then that string will
|
||||
be used for indentation. If the space parameter is a number, then
|
||||
the indentation will be that many spaces.
|
||||
|
||||
Example:
|
||||
|
||||
text = JSON.stringify(['e', {pluribus: 'unum'}]);
|
||||
// text is '["e",{"pluribus":"unum"}]'
|
||||
|
||||
|
||||
text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
|
||||
// text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'
|
||||
|
||||
text = JSON.stringify([new Date()], function (key, value) {
|
||||
return this[key] instanceof Date ?
|
||||
'Date(' + this[key] + ')' : value;
|
||||
});
|
||||
// text is '["Date(---current time---)"]'
|
||||
|
||||
|
||||
JSON.parse(text, reviver)
|
||||
This method parses a JSON text to produce an object or array.
|
||||
It can throw a SyntaxError exception.
|
||||
|
||||
The optional reviver parameter is a function that can filter and
|
||||
transform the results. It receives each of the keys and values,
|
||||
and its return value is used instead of the original value.
|
||||
If it returns what it received, then the structure is not modified.
|
||||
If it returns undefined then the member is deleted.
|
||||
|
||||
Example:
|
||||
|
||||
// Parse the text. Values that look like ISO date strings will
|
||||
// be converted to Date objects.
|
||||
|
||||
myData = JSON.parse(text, function (key, value) {
|
||||
var a;
|
||||
if (typeof value === 'string') {
|
||||
a =
|
||||
/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
|
||||
if (a) {
|
||||
return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
|
||||
+a[5], +a[6]));
|
||||
}
|
||||
}
|
||||
return value;
|
||||
});
|
||||
|
||||
myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
|
||||
var d;
|
||||
if (typeof value === 'string' &&
|
||||
value.slice(0, 5) === 'Date(' &&
|
||||
value.slice(-1) === ')') {
|
||||
d = new Date(value.slice(5, -1));
|
||||
if (d) {
|
||||
return d;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
});
|
||||
|
||||
|
||||
This is a reference implementation. You are free to copy, modify, or
|
||||
redistribute.
|
||||
*/
|
||||
|
||||
/*jslint evil: true, strict: false, regexp: false */
|
||||
|
||||
/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
|
||||
call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
|
||||
getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
|
||||
lastIndex, length, parse, prototype, push, replace, slice, stringify,
|
||||
test, toJSON, toString, valueOf
|
||||
*/
|
||||
|
||||
|
||||
// Create a JSON object only if one does not already exist. We create the
|
||||
// methods in a closure to avoid creating global variables.
|
||||
|
||||
var JSON;
|
||||
if (!JSON) {
|
||||
JSON = {};
|
||||
}
|
||||
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
function f(n) {
|
||||
// Format integers to have at least two digits.
|
||||
return n < 10 ? '0' + n : n;
|
||||
}
|
||||
|
||||
if (typeof Date.prototype.toJSON !== 'function') {
|
||||
|
||||
Date.prototype.toJSON = function (key) {
|
||||
|
||||
return isFinite(this.valueOf()) ?
|
||||
this.getUTCFullYear() + '-' +
|
||||
f(this.getUTCMonth() + 1) + '-' +
|
||||
f(this.getUTCDate()) + 'T' +
|
||||
f(this.getUTCHours()) + ':' +
|
||||
f(this.getUTCMinutes()) + ':' +
|
||||
f(this.getUTCSeconds()) + 'Z' : null;
|
||||
};
|
||||
|
||||
String.prototype.toJSON =
|
||||
Number.prototype.toJSON =
|
||||
Boolean.prototype.toJSON = function (key) {
|
||||
return this.valueOf();
|
||||
};
|
||||
}
|
||||
|
||||
var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
|
||||
escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
|
||||
gap,
|
||||
indent,
|
||||
meta = { // table of character substitutions
|
||||
'\b': '\\b',
|
||||
'\t': '\\t',
|
||||
'\n': '\\n',
|
||||
'\f': '\\f',
|
||||
'\r': '\\r',
|
||||
'"' : '\\"',
|
||||
'\\': '\\\\'
|
||||
},
|
||||
rep;
|
||||
|
||||
|
||||
function quote(string) {
|
||||
|
||||
// If the string contains no control characters, no quote characters, and no
|
||||
// backslash characters, then we can safely slap some quotes around it.
|
||||
// Otherwise we must also replace the offending characters with safe escape
|
||||
// sequences.
|
||||
|
||||
escapable.lastIndex = 0;
|
||||
return escapable.test(string) ? '"' + string.replace(escapable, function (a) {
|
||||
var c = meta[a];
|
||||
return typeof c === 'string' ? c :
|
||||
'\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
|
||||
}) + '"' : '"' + string + '"';
|
||||
}
|
||||
|
||||
|
||||
function str(key, holder) {
|
||||
|
||||
// Produce a string from holder[key].
|
||||
|
||||
var i, // The loop counter.
|
||||
k, // The member key.
|
||||
v, // The member value.
|
||||
length,
|
||||
mind = gap,
|
||||
partial,
|
||||
value = holder[key];
|
||||
|
||||
// If the value has a toJSON method, call it to obtain a replacement value.
|
||||
|
||||
if (value && typeof value === 'object' &&
|
||||
typeof value.toJSON === 'function') {
|
||||
value = value.toJSON(key);
|
||||
}
|
||||
|
||||
// If we were called with a replacer function, then call the replacer to
|
||||
// obtain a replacement value.
|
||||
|
||||
if (typeof rep === 'function') {
|
||||
value = rep.call(holder, key, value);
|
||||
}
|
||||
|
||||
// What happens next depends on the value's type.
|
||||
|
||||
switch (typeof value) {
|
||||
case 'string':
|
||||
return quote(value);
|
||||
|
||||
case 'number':
|
||||
|
||||
// JSON numbers must be finite. Encode non-finite numbers as null.
|
||||
|
||||
return isFinite(value) ? String(value) : 'null';
|
||||
|
||||
case 'boolean':
|
||||
case 'null':
|
||||
|
||||
// If the value is a boolean or null, convert it to a string. Note:
|
||||
// typeof null does not produce 'null'. The case is included here in
|
||||
// the remote chance that this gets fixed someday.
|
||||
|
||||
return String(value);
|
||||
|
||||
// If the type is 'object', we might be dealing with an object or an array or
|
||||
// null.
|
||||
|
||||
case 'object':
|
||||
|
||||
// Due to a specification blunder in ECMAScript, typeof null is 'object',
|
||||
// so watch out for that case.
|
||||
|
||||
if (!value) {
|
||||
return 'null';
|
||||
}
|
||||
|
||||
// Make an array to hold the partial results of stringifying this object value.
|
||||
|
||||
gap += indent;
|
||||
partial = [];
|
||||
|
||||
// Is the value an array?
|
||||
|
||||
if (Object.prototype.toString.apply(value) === '[object Array]') {
|
||||
|
||||
// The value is an array. Stringify every element. Use null as a placeholder
|
||||
// for non-JSON values.
|
||||
|
||||
length = value.length;
|
||||
for (i = 0; i < length; i += 1) {
|
||||
partial[i] = str(i, value) || 'null';
|
||||
}
|
||||
|
||||
// Join all of the elements together, separated with commas, and wrap them in
|
||||
// brackets.
|
||||
|
||||
v = partial.length === 0 ? '[]' : gap ?
|
||||
'[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']' :
|
||||
'[' + partial.join(',') + ']';
|
||||
gap = mind;
|
||||
return v;
|
||||
}
|
||||
|
||||
// If the replacer is an array, use it to select the members to be stringified.
|
||||
|
||||
if (rep && typeof rep === 'object') {
|
||||
length = rep.length;
|
||||
for (i = 0; i < length; i += 1) {
|
||||
if (typeof rep[i] === 'string') {
|
||||
k = rep[i];
|
||||
v = str(k, value);
|
||||
if (v) {
|
||||
partial.push(quote(k) + (gap ? ': ' : ':') + v);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
// Otherwise, iterate through all of the keys in the object.
|
||||
|
||||
for (k in value) {
|
||||
if (Object.prototype.hasOwnProperty.call(value, k)) {
|
||||
v = str(k, value);
|
||||
if (v) {
|
||||
partial.push(quote(k) + (gap ? ': ' : ':') + v);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Join all of the member texts together, separated with commas,
|
||||
// and wrap them in braces.
|
||||
|
||||
v = partial.length === 0 ? '{}' : gap ?
|
||||
'{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' :
|
||||
'{' + partial.join(',') + '}';
|
||||
gap = mind;
|
||||
return v;
|
||||
}
|
||||
}
|
||||
|
||||
// If the JSON object does not yet have a stringify method, give it one.
|
||||
|
||||
if (typeof JSON.stringify !== 'function') {
|
||||
JSON.stringify = function (value, replacer, space) {
|
||||
|
||||
// The stringify method takes a value and an optional replacer, and an optional
|
||||
// space parameter, and returns a JSON text. The replacer can be a function
|
||||
// that can replace values, or an array of strings that will select the keys.
|
||||
// A default replacer method can be provided. Use of the space parameter can
|
||||
// produce text that is more easily readable.
|
||||
|
||||
var i;
|
||||
gap = '';
|
||||
indent = '';
|
||||
|
||||
// If the space parameter is a number, make an indent string containing that
|
||||
// many spaces.
|
||||
|
||||
if (typeof space === 'number') {
|
||||
for (i = 0; i < space; i += 1) {
|
||||
indent += ' ';
|
||||
}
|
||||
|
||||
// If the space parameter is a string, it will be used as the indent string.
|
||||
|
||||
} else if (typeof space === 'string') {
|
||||
indent = space;
|
||||
}
|
||||
|
||||
// If there is a replacer, it must be a function or an array.
|
||||
// Otherwise, throw an error.
|
||||
|
||||
rep = replacer;
|
||||
if (replacer && typeof replacer !== 'function' &&
|
||||
(typeof replacer !== 'object' ||
|
||||
typeof replacer.length !== 'number')) {
|
||||
throw new Error('JSON.stringify');
|
||||
}
|
||||
|
||||
// Make a fake root object containing our value under the key of ''.
|
||||
// Return the result of stringifying the value.
|
||||
|
||||
return str('', {'': value});
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// If the JSON object does not yet have a parse method, give it one.
|
||||
|
||||
if (typeof JSON.parse !== 'function') {
|
||||
JSON.parse = function (text, reviver) {
|
||||
|
||||
// The parse method takes a text and an optional reviver function, and returns
|
||||
// a JavaScript value if the text is a valid JSON text.
|
||||
|
||||
var j;
|
||||
|
||||
function walk(holder, key) {
|
||||
|
||||
// The walk method is used to recursively walk the resulting structure so
|
||||
// that modifications can be made.
|
||||
|
||||
var k, v, value = holder[key];
|
||||
if (value && typeof value === 'object') {
|
||||
for (k in value) {
|
||||
if (Object.prototype.hasOwnProperty.call(value, k)) {
|
||||
v = walk(value, k);
|
||||
if (v !== undefined) {
|
||||
value[k] = v;
|
||||
} else {
|
||||
delete value[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return reviver.call(holder, key, value);
|
||||
}
|
||||
|
||||
|
||||
// Parsing happens in four stages. In the first stage, we replace certain
|
||||
// Unicode characters with escape sequences. JavaScript handles many characters
|
||||
// incorrectly, either silently deleting them, or treating them as line endings.
|
||||
|
||||
text = String(text);
|
||||
cx.lastIndex = 0;
|
||||
if (cx.test(text)) {
|
||||
text = text.replace(cx, function (a) {
|
||||
return '\\u' +
|
||||
('0000' + a.charCodeAt(0).toString(16)).slice(-4);
|
||||
});
|
||||
}
|
||||
|
||||
// In the second stage, we run the text against regular expressions that look
|
||||
// for non-JSON patterns. We are especially concerned with '()' and 'new'
|
||||
// because they can cause invocation, and '=' because it can cause mutation.
|
||||
// But just to be safe, we want to reject all unexpected forms.
|
||||
|
||||
// We split the second stage into 4 regexp operations in order to work around
|
||||
// crippling inefficiencies in IE's and Safari's regexp engines. First we
|
||||
// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
|
||||
// replace all simple value tokens with ']' characters. Third, we delete all
|
||||
// open brackets that follow a colon or comma or that begin the text. Finally,
|
||||
// we look to see that the remaining characters are only whitespace or ']' or
|
||||
// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
|
||||
|
||||
if (/^[\],:{}\s]*$/
|
||||
.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@')
|
||||
.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']')
|
||||
.replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
|
||||
|
||||
// In the third stage we use the eval function to compile the text into a
|
||||
// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
|
||||
// in JavaScript: it can begin a block or an object literal. We wrap the text
|
||||
// in parens to eliminate the ambiguity.
|
||||
|
||||
j = eval('(' + text + ')');
|
||||
|
||||
// In the optional fourth stage, we recursively walk the new structure, passing
|
||||
// each name/value pair to a reviver function for possible transformation.
|
||||
|
||||
return typeof reviver === 'function' ?
|
||||
walk({'': j}, '') : j;
|
||||
}
|
||||
|
||||
// If the text is not JSON parseable, then a SyntaxError is thrown.
|
||||
|
||||
throw new SyntaxError('JSON.parse');
|
||||
};
|
||||
}
|
||||
}());
|
||||
File diff suppressed because one or more lines are too long
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue