[help] helpers for youtube videos added in list, form sidebar, modules
This commit is contained in:
parent
b1a463c6c2
commit
b2ee616bb4
16 changed files with 71 additions and 10 deletions
|
|
@ -153,13 +153,13 @@ def pack(target, sources, no_compress, verbose):
|
|||
|
||||
def html_to_js_template(path, content):
|
||||
# remove whitespace to a single space
|
||||
content = re.sub("\s+", " ", content).replace("'", "\'")
|
||||
content = re.sub("\s+", " ", content)
|
||||
|
||||
# strip comments
|
||||
content = re.sub("(<!--.*?-->)", "", content)
|
||||
|
||||
return """frappe.templates["{key}"] = '{content}';\n""".format(\
|
||||
key=path.rsplit("/", 1)[-1][:-5], content=content)
|
||||
key=path.rsplit("/", 1)[-1][:-5], content=content.replace("'", "\'"))
|
||||
|
||||
def files_dirty():
|
||||
for target, sources in get_build_maps().iteritems():
|
||||
|
|
|
|||
|
|
@ -15,3 +15,5 @@ frappe.listview_settings['User'] = {
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
frappe.help.youtube_id["User"] = "fnBoRhBrwR4";
|
||||
|
|
|
|||
|
|
@ -7,6 +7,9 @@ frappe.DataImportTool = Class.extend({
|
|||
title: __("Data Import Tool"),
|
||||
single_column: true
|
||||
});
|
||||
this.page.add_inner_button(__("Help"), function() {
|
||||
frappe.help.show_video("6wiriRKPhmg");
|
||||
});
|
||||
this.make();
|
||||
this.make_upload();
|
||||
},
|
||||
|
|
|
|||
|
|
@ -137,7 +137,8 @@ def apply_permissions(data):
|
|||
|
||||
if ((item.type=="doctype" and item.name in user.can_read)
|
||||
or (item.type=="page" and item.name in allowed_pages)
|
||||
or (item.type=="report" and item.doctype in user.can_get_report)):
|
||||
or (item.type=="report" and item.doctype in user.can_get_report)
|
||||
or item.type=="help"):
|
||||
|
||||
new_items.append(item)
|
||||
|
||||
|
|
|
|||
|
|
@ -19,3 +19,5 @@ frappe.listview_settings["Email Account"] = {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
frappe.help.youtube_id["Email Account"] = "YFYe0DrB95o";
|
||||
|
|
|
|||
|
|
@ -95,6 +95,7 @@
|
|||
"public/js/frappe/misc/tools.js",
|
||||
"public/js/frappe/misc/datetime.js",
|
||||
"public/js/frappe/misc/number_format.js",
|
||||
"public/js/frappe/misc/help.js",
|
||||
|
||||
"public/js/frappe/ui/upload.html",
|
||||
"public/js/frappe/upload.js",
|
||||
|
|
|
|||
|
|
@ -9,6 +9,9 @@
|
|||
<span class="badge n-comments">0</span>
|
||||
</a>
|
||||
</li>
|
||||
{% if(frappe.help.has_help(doctype)) { %}
|
||||
<li><a class="help-link" data-doctype="{{ doctype }}">{{ __("Help") }}</a></li>
|
||||
{% } %}
|
||||
</ul>
|
||||
<ul class="list-unstyled sidebar-menu form-assignments">
|
||||
<li class="divider"></li>
|
||||
|
|
|
|||
|
|
@ -7,6 +7,9 @@
|
|||
<li class="hide calendar-link"><a href="#Calendar/{%= doctype %}">{%= __("Calendar") %}</a></li>
|
||||
<li class="hide gantt-link"><a href="#Gantt/{%= doctype %}">{%= __("Gantt") %}</a></li>
|
||||
<li><a onclick="cur_list.assigned_to_me()">{%= __("Assigned To Me") %}</a></li>
|
||||
{% if(frappe.help.has_help(doctype)) { %}
|
||||
<li><a class="help-link" data-doctype="{{ doctype }}">{{ __("Help") }}</a></li>
|
||||
{% } %}
|
||||
</ul>
|
||||
|
||||
|
||||
|
|
|
|||
31
frappe/public/js/frappe/misc/help.js
Normal file
31
frappe/public/js/frappe/misc/help.js
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
// MIT License. See license.txt
|
||||
|
||||
frappe.provide("frappe.help");
|
||||
|
||||
frappe.help.youtube_id = {};
|
||||
|
||||
frappe.help.has_help = function(doctype) {
|
||||
return frappe.help.youtube_id[doctype];
|
||||
}
|
||||
|
||||
frappe.help.show_link = function() {
|
||||
|
||||
}
|
||||
|
||||
frappe.help.show = function(doctype) {
|
||||
if(frappe.help.youtube_id[doctype]) {
|
||||
frappe.help.show_video(frappe.help.youtube_id[doctype]);
|
||||
}
|
||||
}
|
||||
|
||||
frappe.help.show_video = function(youtube_id, title) {
|
||||
frappe.msgprint('<iframe width="560" height="315" \
|
||||
src="https://www.youtube.com/embed/'+ youtube_id +'" \
|
||||
frameborder="0" allowfullscreen></iframe>', title || __("Help"));
|
||||
}
|
||||
|
||||
$("body").on("click", "a.help-link", function() {
|
||||
var doctype = $(this).attr("data-doctype");
|
||||
doctype && frappe.help.show(doctype);
|
||||
});
|
||||
|
|
@ -132,7 +132,7 @@ $.extend(frappe.user, {
|
|||
var ret = null;
|
||||
switch(type) {
|
||||
case "module":
|
||||
if(frappe.boot.user.allow_modules.indexOf(m)!=-1)
|
||||
if(frappe.boot.user.allow_modules.indexOf(m)!=-1 || frappe.modules[m].is_help)
|
||||
ret = m;
|
||||
break;
|
||||
case "page":
|
||||
|
|
|
|||
|
|
@ -85,7 +85,9 @@ frappe.ui.Page = Class.extend({
|
|||
this.actions_btn_group = this.page_actions.find(".actions-btn-group");
|
||||
|
||||
this.page_form = $('<div class="page-form row hide"></div>').prependTo(this.main);
|
||||
this.inner_toolbar = $('<div class="form-inner-toolbar hide"></div>').prependTo(this.main);
|
||||
this.icon_group = this.page_actions.find(".page-icon-group");
|
||||
|
||||
},
|
||||
|
||||
set_indicator: function(label, color) {
|
||||
|
|
@ -225,6 +227,11 @@ frappe.ui.Page = Class.extend({
|
|||
return $('<li class="divider"></li>').appendTo(this.menu);
|
||||
},
|
||||
|
||||
add_inner_button: function(label, action) {
|
||||
return $('<button class="btn btn-default btn-xs" style="margin-left: 10px;">'+__(label)+'</btn>')
|
||||
.on("click", action).appendTo(this.inner_toolbar.removeClass("hide"))
|
||||
},
|
||||
|
||||
//---//
|
||||
|
||||
clear_user_actions: function() {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
frappe.provide('frappe.pages');
|
||||
frappe.provide('frappe.views');
|
||||
|
||||
var cur_page = null;
|
||||
frappe.views.Container = Class.extend({
|
||||
_intro: "Container contains pages inside `#container` and manages \
|
||||
page creation, switching",
|
||||
|
|
@ -37,6 +38,7 @@ frappe.views.Container = Class.extend({
|
|||
return page;
|
||||
},
|
||||
change_to: function(label) {
|
||||
cur_page = this;
|
||||
if(this.page && this.page.label === label) {
|
||||
$(this.page).trigger('show');
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -91,7 +91,13 @@ frappe.views.moduleview.ModuleView = Class.extend({
|
|||
var doctype = event.target.getAttribute("data-doctype");
|
||||
frappe.route_options = frappe.boot.notification_info.conditions[doctype];
|
||||
}
|
||||
frappe.set_route(me.get_route(data.items[$(mi).attr("data-item-index")]));
|
||||
var item = data.items[$(mi).attr("data-item-index")];
|
||||
if(item.type==="help") {
|
||||
frappe.help.show_video(item.youtube_id);
|
||||
return false;
|
||||
} else {
|
||||
frappe.set_route(me.get_route(item));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -212,7 +212,6 @@ _f.Frm.prototype.watch_model_updates = function() {
|
|||
|
||||
_f.Frm.prototype.setup_std_layout = function() {
|
||||
this.form_wrapper = $('<div></div>').appendTo(this.layout_main);
|
||||
this.inner_toolbar = $('<div class="form-inner-toolbar hide"></div>').appendTo(this.form_wrapper);
|
||||
this.body = $('<div></div>').appendTo(this.form_wrapper);
|
||||
|
||||
// only tray
|
||||
|
|
@ -763,13 +762,11 @@ _f.Frm.prototype.set_footnote = function(txt) {
|
|||
|
||||
|
||||
_f.Frm.prototype.add_custom_button = function(label, fn, icon, toolbar_or_class) {
|
||||
return $('<button class="btn btn-default btn-xs" style="margin-left: 10px;">'+__(label)+'</btn>')
|
||||
.on("click", fn).appendTo(this.inner_toolbar.removeClass("hide"))
|
||||
//return this.page.add_menu_item(label, fn);
|
||||
this.page.add_inner_button(label, fn);
|
||||
}
|
||||
|
||||
_f.Frm.prototype.clear_custom_buttons = function() {
|
||||
this.inner_toolbar.empty().addClass("hide");
|
||||
this.page.inner_toolbar.empty().addClass("hide");
|
||||
this.page.clear_user_actions();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ frappe.template.compile = function(str, name) {
|
|||
|
||||
if(!frappe.template.compiled[key]) {
|
||||
if(str.indexOf("'")!==-1) {
|
||||
str.replace(/'/g, "\\'");
|
||||
console.warn("Warning: Single quotes (') may not work in templates");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,3 +8,5 @@ frappe.listview_settings['Workflow'] = {
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
frappe.help.youtube_id["Workflow"] = "yObJUg9FxFs";
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue