mirror of
https://github.com/OCA/web.git
synced 2025-02-22 13:21:25 +02:00
[ADD] Module help_online
This module allows the creation of an online help available from the lists and forms in Odoo. When loading a view, the module generates a button allowing access to an help page for the related model if the page exists and the user is member of the group 'Help reader'. If the page doesn't exist and the user is member of the group 'Help writer', the module generate a button allowing the creation an help page. The help pages are created and managed via the website Module.
This commit is contained in:
115
help_online/static/src/js/help_online.js
Normal file
115
help_online/static/src/js/help_online.js
Normal file
@@ -0,0 +1,115 @@
|
||||
openerp.help_online = function (instance) {
|
||||
var QWeb = instance.web.qweb;
|
||||
var _t = instance.web._t;
|
||||
var _lt = instance.web._lt;
|
||||
|
||||
instance.web.ListView.include({
|
||||
load_list: function () {
|
||||
var self = this;
|
||||
var add_button = false;
|
||||
if (!this.$buttons) {
|
||||
add_button = true;
|
||||
}
|
||||
this._super.apply(this, arguments);
|
||||
this.$buttons.on('click', '.oe_list_button_help_online', function() {
|
||||
self.do_action({
|
||||
type: 'ir.actions.act_url',
|
||||
url: '/partner_mobile',
|
||||
target: 'self',
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
openerp.web.TreeView.include({
|
||||
view_loading: function(r) {
|
||||
var ret = this._super(r);
|
||||
if(! _.isUndefined(this.ViewManager.load_help_buttons)){
|
||||
this.ViewManager.load_help_buttons();
|
||||
}
|
||||
return ret
|
||||
},
|
||||
});
|
||||
|
||||
openerp.web.ListView.include({
|
||||
view_loading: function(r) {
|
||||
var ret = this._super(r);
|
||||
if(! _.isUndefined(this.ViewManager.load_help_buttons)){
|
||||
this.ViewManager.load_help_buttons();
|
||||
}
|
||||
return ret
|
||||
},
|
||||
});
|
||||
|
||||
openerp.web.FormView.include({
|
||||
view_loading: function(r) {
|
||||
var ret = this._super(r);
|
||||
if(!_.isUndefined(this.ViewManager.clean_help_buttons)){
|
||||
this.ViewManager.clean_help_buttons();
|
||||
}
|
||||
return ret
|
||||
},
|
||||
|
||||
do_show: function (options){
|
||||
var ret = this._super(options);
|
||||
if(! _.isUndefined(this.ViewManager.load_help_buttons)){
|
||||
this.ViewManager.load_help_buttons();
|
||||
}
|
||||
return ret
|
||||
},
|
||||
});
|
||||
|
||||
openerp.web.ViewManager.include({
|
||||
clean_help_buttons:function() {
|
||||
this.$el.find("div.oe_help_online_buttons").first().remove();
|
||||
},
|
||||
|
||||
load_help_buttons:function() {
|
||||
var self = this;
|
||||
this.rpc('/help_online/build_url', {model: this.dataset.model, view_type: this.active_view}).then(function(result) {
|
||||
self.clean_help_buttons();
|
||||
if (result && ! _.isEmpty(result)) {
|
||||
self.$helpButtonsEl = $(QWeb.render("HelpOnline.Buttons", {'view_manager':self, 'url_info': result}));
|
||||
self.$el.find("ul.oe_view_manager_switch.oe_button_group.oe_right").first().before(self.$helpButtonsEl);
|
||||
self.$helpButtonsEl.find('a.oe_list_button_help_online').tooltip();
|
||||
if (result.exists === false) {
|
||||
self.$helpButtonsEl.find('li').addClass('oe_help_online_not_found')
|
||||
self.$helpButtonsEl.find('a.oe_list_button_help_online').on('click', function (event) {
|
||||
var evt = event;
|
||||
evt.preventDefault();
|
||||
var dialog = new instance.web.Dialog(this, {
|
||||
title: _t('Confirm'),
|
||||
buttons: [
|
||||
{text: _t("Cancel"), click: function() {
|
||||
this.parents('.modal').modal('hide');
|
||||
return false;
|
||||
}
|
||||
},
|
||||
{text: _t("Ok"), click: function() {
|
||||
this.parents('.modal').modal('hide');
|
||||
var form = $("<form></form>");
|
||||
form.attr(
|
||||
{
|
||||
id : "formform",
|
||||
// The location given in the link itself
|
||||
action : evt.target.href,
|
||||
method : "GET",
|
||||
// Open in new window/tab
|
||||
target : evt.target.target
|
||||
});
|
||||
$("body").append(form);
|
||||
$("#formform").submit();
|
||||
$("#formform").remove();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
],
|
||||
}, $('<div/>').text(_t('Page does not exist. Do you want to create?'))).open();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
});
|
||||
}
|
||||
21
help_online/static/src/js/website_help_online.editor.js
Normal file
21
help_online/static/src/js/website_help_online.editor.js
Normal file
@@ -0,0 +1,21 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
var website = openerp.website;
|
||||
var _t = openerp._t;
|
||||
website.RTE.include({
|
||||
_config: function () {
|
||||
// add anchor button
|
||||
var config = this._super();
|
||||
config.plugins = config.plugins.concat(',link');
|
||||
_.each(config.toolbar, function (tb) {
|
||||
if (tb.name === 'span'){
|
||||
tb.items.unshift('Anchor');
|
||||
}
|
||||
});
|
||||
return config;
|
||||
},
|
||||
});
|
||||
})();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user