[FIX] Indentation.Show help.
bzr revid: vda@tinyerp.com-20110928084739-cd0tnajmulohp0k8
This commit is contained in:
parent
a7a2564542
commit
78eb1e13e5
|
@ -1,195 +1,208 @@
|
|||
|
||||
openerp.web_process = function (openerp) {
|
||||
var QWeb = openerp.web.qweb;
|
||||
QWeb.add_template('/web_process/static/src/xml/web_process.xml');
|
||||
openerp.web.ViewManager.include({
|
||||
start: function() {
|
||||
this._super();
|
||||
var self = this;
|
||||
|
||||
this.process_check();
|
||||
},
|
||||
process_check: function() {
|
||||
var self = this,
|
||||
grandparent = this.widget_parent && this.widget_parent.widget_parent,
|
||||
view = this.views[this.views_src[0].view_type],
|
||||
$process_view = this.$element.find('.oe-process-view');
|
||||
|
||||
this.process_model = this.model;
|
||||
if (!(grandparent instanceof openerp.web.WebClient) ||
|
||||
var QWeb = openerp.web.qweb;
|
||||
QWeb.add_template('/web_process/static/src/xml/web_process.xml');
|
||||
openerp.web.ViewManager.include({
|
||||
start: function() {
|
||||
this._super();
|
||||
var self = this;
|
||||
this.process_check();
|
||||
this.process_help = this.action.help || 'Help: Not Defined';
|
||||
},
|
||||
process_check: function() {
|
||||
var self = this,
|
||||
grandparent = this.widget_parent && this.widget_parent.widget_parent,
|
||||
view = this.views[this.views_src[0].view_type],
|
||||
$process_view = this.$element.find('.oe-process-view');
|
||||
|
||||
this.process_model = this.model;
|
||||
if (!(grandparent instanceof openerp.web.WebClient) ||
|
||||
!(view.view_type === this.views_src[0].view_type
|
||||
&& view.view_id === this.views_src[0].view_id)) {
|
||||
$process_view.hide();
|
||||
return;
|
||||
$process_view.hide();
|
||||
return;
|
||||
}
|
||||
$process_view.click(function() {
|
||||
$.when(self.load_process()).then(self.get_process_id());
|
||||
});
|
||||
},
|
||||
|
||||
load_process: function() {
|
||||
this.$element.html(QWeb.render("ProcessView",this));
|
||||
},
|
||||
|
||||
get_process_id: function() {
|
||||
var self = this;
|
||||
this.process_dataset = new openerp.web.DataSetStatic(this, "process.process", this.session.context);
|
||||
this.process_dataset
|
||||
.call(
|
||||
"search_by_model",
|
||||
[self.process_model,self.session.context],
|
||||
function(res) {self.process_renderer(res)}
|
||||
);
|
||||
},
|
||||
|
||||
process_renderer: function(res) {
|
||||
var self = this;
|
||||
if(!res.length) {
|
||||
this.process_model = false;
|
||||
this.get_process_id();
|
||||
} else {
|
||||
if(res.length > 1) {
|
||||
this.selection = res;
|
||||
$.when(this.load_process())
|
||||
.then(function(){
|
||||
var $parent = self.widget_parent.$element;
|
||||
$parent.find('#change_process').click(function() {
|
||||
self.selection = false;
|
||||
self.p_id = $parent.find('#select_process').val();
|
||||
$.when(self.load_process()).then(self.render_process_view());
|
||||
});
|
||||
});
|
||||
} else {
|
||||
this.p_id = res[0][0];
|
||||
$.when(this.load_process()).then(this.render_process_view());
|
||||
}
|
||||
}
|
||||
},
|
||||
render_process_view: function() {
|
||||
var self = this;
|
||||
this.p_id = parseInt(this.p_id, 10);
|
||||
this.process_dataset
|
||||
.call(
|
||||
"graph_get",
|
||||
[self.p_id, self.model, false, [80,80,150,100]],
|
||||
function(res) {
|
||||
res['title'] = res.resource ? res.resource : res.name;
|
||||
self.process_dataset.call("search_by_model",[self.model,self.session.context],function(r){
|
||||
res['related'] = r;
|
||||
});
|
||||
self.draw_process_graph(res);
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
draw_process_graph: function(res) {
|
||||
var self = this;
|
||||
var process_graph = new Graph();
|
||||
|
||||
var process_renderer = function(r, n) {
|
||||
var process_node,
|
||||
process_node_text,
|
||||
process_node_desc,
|
||||
process_set;
|
||||
|
||||
var node_button,
|
||||
node_menu,
|
||||
img_src;
|
||||
|
||||
var bg = "node";
|
||||
var clip_rect = "".concat(n.node.x,",",n.node.y,",150,100");
|
||||
var text_position_x = n.node.kind == "subflow" ? n.node.x+88 : n.node.x+75;
|
||||
|
||||
//Image part
|
||||
bg = n.node.kind == "subflow" ? "node-subflow" : "node";
|
||||
bg = n.node.gray ? bg + "-gray" : bg;
|
||||
img_src = '/web_process/static/src/img/'+ bg + '.png';
|
||||
|
||||
r['image'](img_src, n.node.x, n.node.y,150, 100)
|
||||
.attr({"clip-rect": clip_rect})
|
||||
.mousedown(function(){
|
||||
return false;
|
||||
});
|
||||
|
||||
//Node
|
||||
process_node = r['rect'](n.node.x, n.node.y, 150, 100).attr({stroke: "none"});
|
||||
|
||||
// Node text
|
||||
process_node_text = r.text(text_position_x, n.node.y+10, (n.node.name))
|
||||
.attr({"fill": "#fff", "font-weight": "bold", "cursor": "pointer"});
|
||||
|
||||
if(n.node.subflow) {
|
||||
process_node_text.click(function() {
|
||||
self.p_id = n.node.subflow[0];
|
||||
$.when(self.load_process()).then(self.render_process_view());
|
||||
});
|
||||
}
|
||||
|
||||
//Node Description
|
||||
process_node_desc = r.text(n.node.x+75, n.node.y+50, (n.node.notes));
|
||||
|
||||
r['image']('/web/static/src/img/icons/gtk-info.png', n.node.x+20, n.node.y+70, 16, 16)
|
||||
.attr({"cursor": "pointer", "title": "Help"})
|
||||
.click(function(){
|
||||
window.open(n.node.url || "http://doc.openerp.com/v6.0/index.php?model=" + n.node.model);
|
||||
});
|
||||
|
||||
if(n.node.menu) {
|
||||
r['image']('/web/static/src/img/icons/gtk-jump-to.png', n.node.x+115, n.node.y+70, 16, 16)
|
||||
.attr({"cursor": "pointer", "title": n.node.menu.name})
|
||||
.click(function() {
|
||||
self.jump_to_view(n.node.res_model, n.node.menu.id);
|
||||
});
|
||||
}
|
||||
|
||||
process_set = r.set()
|
||||
.push(process_node)
|
||||
$process_view.click(function() {
|
||||
$.when(self.load_process()).then(self.get_process_id());
|
||||
});
|
||||
},
|
||||
|
||||
process_subflow : function() {
|
||||
var self = this;
|
||||
new openerp.web.DataSetSearch(this,
|
||||
"ir.actions.act_window",this.session.context,[])
|
||||
.read_slice(['help'],
|
||||
{ domain:
|
||||
[
|
||||
['res_model','=',this.process_action_model],
|
||||
['name','ilike', this.process_action_name]
|
||||
]
|
||||
},
|
||||
function(res) {
|
||||
if (res.length) {
|
||||
self.process_help = res[0]['help'] || 'Help: Not Defined';
|
||||
}
|
||||
$.when(self.load_process()).then(self.render_process_view());
|
||||
|
||||
});
|
||||
},
|
||||
|
||||
load_process: function() {
|
||||
this.$element.html(QWeb.render("ProcessView", this));
|
||||
},
|
||||
|
||||
get_process_id: function() {
|
||||
var self = this;
|
||||
this.process_dataset = new openerp.web.DataSetStatic(this, "process.process", this.session.context);
|
||||
this.process_dataset.call("search_by_model",
|
||||
[self.process_model,self.session.context],
|
||||
function(res) {self.process_renderer(res)});
|
||||
},
|
||||
process_renderer: function(res) {
|
||||
var self = this;
|
||||
if(!res.length) {
|
||||
this.process_model = false;
|
||||
this.get_process_id();
|
||||
} else {
|
||||
if(res.length > 1) {
|
||||
this.selection = res;
|
||||
$.when(this.load_process()).then(function() {
|
||||
var $parent = self.widget_parent.$element;
|
||||
$parent.find('#change_process').click(function() {
|
||||
self.selection = false;
|
||||
self.p_id = $parent.find('#select_process').val();
|
||||
$.when(self.load_process()).then(self.render_process_view());
|
||||
});
|
||||
});
|
||||
} else {
|
||||
this.p_id = res[0][0];
|
||||
$.when(this.load_process()).then(this.render_process_view());
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
render_process_view: function() {
|
||||
var self = this;
|
||||
this.p_id = parseInt(this.p_id, 10);
|
||||
this.process_dataset.call("graph_get",
|
||||
[self.p_id, self.model, false, [80,80,150,100]],
|
||||
function(res) {
|
||||
res['title'] = res.resource ? res.resource : res.name;
|
||||
self.process_dataset.call("search_by_model",
|
||||
[self.model,self.session.context],
|
||||
function(r) {
|
||||
res['related'] = r;
|
||||
});
|
||||
self.draw_process_graph(res);
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
draw_process_graph: function(res) {
|
||||
var self = this;
|
||||
var process_graph = new Graph();
|
||||
|
||||
var process_renderer = function(r, n) {
|
||||
var process_node,
|
||||
process_node_text,
|
||||
process_node_desc,
|
||||
process_set;
|
||||
|
||||
var node_button,
|
||||
node_menu,
|
||||
img_src;
|
||||
|
||||
var bg = "node",
|
||||
clip_rect = "".concat(n.node.x,",",n.node.y,",150,100"),
|
||||
// text_position_x = n.node.x + (n.node.y/2)
|
||||
|
||||
//Image part
|
||||
bg = n.node.kind == "subflow" ? "node-subflow" : "node";
|
||||
bg = n.node.gray ? bg + "-gray" : bg;
|
||||
img_src = '/web_process/static/src/img/'+ bg + '.png';
|
||||
|
||||
r['image'](img_src, n.node.x, n.node.y,150, 100)
|
||||
.attr({"clip-rect": clip_rect})
|
||||
.mousedown(function(){
|
||||
return false;
|
||||
});
|
||||
|
||||
//Node
|
||||
process_node = r['rect'](n.node.x, n.node.y, 150, 100).attr({stroke: "none"});
|
||||
// Node text
|
||||
process_node_text = r.text(n.node.x, n.node.y, (n.node.name))
|
||||
.attr({"fill": "#fff", "font-weight": "bold", "cursor": "pointer"});
|
||||
process_node_text.translate(n.node.x / 2, 10)
|
||||
if(n.node.subflow) {
|
||||
process_node_text.click(function() {
|
||||
self.p_id = n.node.subflow[0];
|
||||
self.process_action_model = n.node.model;
|
||||
self.process_action_name = n.node.name;
|
||||
self.process_subflow();
|
||||
});
|
||||
}
|
||||
|
||||
//Node Description
|
||||
process_node_desc = r.text(n.node.x+75, n.node.y+50, (n.node.notes));
|
||||
|
||||
r['image']('/web/static/src/img/icons/gtk-info.png', n.node.x+20, n.node.y+70, 16, 16)
|
||||
.attr({"cursor": "pointer", "title": "Help"})
|
||||
.click(function() {
|
||||
window.open(n.node.url || "http://doc.openerp.com/v6.0/index.php?model=" + n.node.model);
|
||||
});
|
||||
|
||||
if(n.node.menu) {
|
||||
r['image']('/web/static/src/img/icons/gtk-jump-to.png', n.node.x+115, n.node.y+70, 16, 16)
|
||||
.attr({"cursor": "pointer", "title": n.node.menu.name})
|
||||
.click(function() {
|
||||
self.jump_to_view(n.node.res_model, n.node.menu.id);
|
||||
});
|
||||
}
|
||||
|
||||
process_set = r.set().push(process_node);
|
||||
process_set.mousedown(function() {
|
||||
return false;
|
||||
});
|
||||
return process_set;
|
||||
};
|
||||
|
||||
_.each(res['nodes'],function(node, node_id) {
|
||||
node['res_model'] = self.model,
|
||||
node['res_id'] = false,
|
||||
node['id'] = node_id;
|
||||
process_graph.addNode(node['name'], {node: node,render: process_renderer});
|
||||
});
|
||||
|
||||
_.each(res['transitions'], function(transitions) {
|
||||
|
||||
var src = res['nodes'][transitions['source']];
|
||||
var dst = res['nodes'][transitions['target']];
|
||||
// make active
|
||||
transitions['active'] = src.active && !dst.gray;
|
||||
process_graph.addEdge(src['name'], dst['name'], {directed : true, label: transitions['name']})
|
||||
});
|
||||
var layouter = new Graph.Layout.Ordered(process_graph);
|
||||
var render_process_graph = new Graph.Renderer.Raphael('process_canvas', process_graph, $('#process_canvas').width(), $('#process_canvas').height());
|
||||
},
|
||||
|
||||
jump_to_view: function(model, id) {
|
||||
var self = this;
|
||||
var dataset = new openerp.web.DataSetStatic(this, 'ir.values', this.session.context);
|
||||
dataset
|
||||
.call('get',
|
||||
['action', 'tree_but_open',[['ir.ui.menu', id]], dataset.context],
|
||||
function(res) {
|
||||
self.$element.empty();
|
||||
var action = res[0][res[0].length - 1];
|
||||
self.rpc("/web/action/load", {
|
||||
action_id: action.id,
|
||||
context: dataset.context
|
||||
}, function(result) {
|
||||
var action_manager = new openerp.web.ActionManager(self);
|
||||
action_manager.appendTo(self.widget_parent.$element);
|
||||
action_manager.do_action(result.result);
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
return process_set;
|
||||
};
|
||||
|
||||
_.each(res['nodes'],function(node, node_id) {
|
||||
node['res_model'] = self.model,
|
||||
node['res_id'] = false,
|
||||
node['id'] = node_id;
|
||||
process_graph.addNode(node['name'], {node: node,render: process_renderer});
|
||||
});
|
||||
|
||||
_.each(res['transitions'], function(transitions) {
|
||||
var src = res['nodes'][transitions['source']];
|
||||
var dst = res['nodes'][transitions['target']];
|
||||
// make active
|
||||
transitions['active'] = src.active && !dst.gray;
|
||||
process_graph.addEdge(src['name'], dst['name'], {directed : true});
|
||||
});
|
||||
|
||||
var layouter = new Graph.Layout.Ordered(process_graph);
|
||||
var render_process_graph = new Graph.Renderer.Raphael('process_canvas', process_graph, $('#process_canvas').width(), $('#process_canvas').height());
|
||||
},
|
||||
|
||||
jump_to_view: function(model, id) {
|
||||
var self = this;
|
||||
var dataset = new openerp.web.DataSetStatic(this, 'ir.values', this.session.context);
|
||||
dataset.call('get',
|
||||
['action', 'tree_but_open',[['ir.ui.menu', id]], dataset.context],
|
||||
function(res) {
|
||||
self.$element.empty();
|
||||
var action = res[0][res[0].length - 1];
|
||||
self.rpc("/web/action/load", {
|
||||
action_id: action.id,
|
||||
context: dataset.context
|
||||
}, function(result) {
|
||||
var action_manager = new openerp.web.ActionManager(self);
|
||||
action_manager.appendTo(self.widget_parent.$element);
|
||||
action_manager.do_action(result.result);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1,67 +1,71 @@
|
|||
<template>
|
||||
<t t-extend="ViewManager" t-name="ViewManagerAction">
|
||||
<t t-jquery=".oe_view_title" t-operation="append">
|
||||
<img class="oe-process-view" src="/web/static/src/img/icons/gtk-help.png" title="ProcessView"/>
|
||||
</t>
|
||||
</t>
|
||||
<t t-name="ProcessView">
|
||||
<table class="view" border="0" width="100%" height="100%" cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<td width="75%" valign="top" class="fields collapsed" style="padding-top:10px;">
|
||||
<h1 class="process_h1">
|
||||
<t t-esc="action.name"/> (<t t-esc="model"/>)
|
||||
</h1>
|
||||
<p class="process-links">
|
||||
<a class="cta-a" target="_blank" href="#">
|
||||
<span>
|
||||
<strong>Documentation</strong>
|
||||
Read Documentation Online
|
||||
</span>
|
||||
|
||||
</a>
|
||||
<a class="cta-a" target="_blank" href="http://www.openerp.com/forum/">
|
||||
<span>
|
||||
<strong>Forum</strong>
|
||||
Community Discussion
|
||||
</span>
|
||||
</a>
|
||||
<a class="cta-a" target="_blank" href="http://www.openerp.com/services/books">
|
||||
<span>
|
||||
<strong>Books</strong>
|
||||
Get the book on Amazon
|
||||
</span>
|
||||
</a>
|
||||
<a class="cta-a" target="_blank" href="http://www.openerp.com/services/subscribe-onsite">
|
||||
<span>
|
||||
<strong>Support / Publisher Warranty</strong>
|
||||
Get the OpenERP Warranty
|
||||
</span>
|
||||
</a>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr t-if="selection">
|
||||
<td>
|
||||
<fieldset>
|
||||
<legend>
|
||||
Select Process
|
||||
</legend>
|
||||
<select id="select_process">
|
||||
<t t-foreach="selection" t-as="prc">
|
||||
<option t-att-value="prc[0]">
|
||||
<t t-esc="prc[1]"/>
|
||||
</option>
|
||||
</t>
|
||||
</select>
|
||||
<button id="change_process">Select</button>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>
|
||||
<tr t-if="p_id">
|
||||
<td>
|
||||
<div id="process_canvas" style="overflow: auto;"></div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</t>
|
||||
<t t-extend="ViewManager" t-name="ViewManagerAction">
|
||||
<t t-jquery=".oe_view_title" t-operation="append">
|
||||
<img class="oe-process-view" src="/web/static/src/img/icons/gtk-help.png" title="ProcessView"/>
|
||||
</t>
|
||||
</t>
|
||||
<t t-name="ProcessView">
|
||||
<table class="view" border="0" width="100%" height="100%" cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<td width="75%" valign="top" class="fields collapsed" style="padding-top:10px;">
|
||||
<h1 class="process_h1">
|
||||
<t t-esc="action.name"/> (<t t-esc="model"/>)
|
||||
</h1>
|
||||
<p class="process-links">
|
||||
<a class="cta-a" target="_blank" href="#">
|
||||
<span>
|
||||
<strong>Documentation</strong>
|
||||
Read Documentation Online
|
||||
</span>
|
||||
</a>
|
||||
<a class="cta-a" target="_blank" href="http://www.openerp.com/forum/">
|
||||
<span>
|
||||
<strong>Forum</strong>
|
||||
Community Discussion
|
||||
</span>
|
||||
</a>
|
||||
<a class="cta-a" target="_blank" href="http://www.openerp.com/services/books">
|
||||
<span>
|
||||
<strong>Books</strong>
|
||||
Get the book on Amazon
|
||||
</span>
|
||||
</a>
|
||||
<a class="cta-a" target="_blank" href="http://www.openerp.com/services/subscribe-onsite">
|
||||
<span>
|
||||
<strong>Support / Publisher Warranty</strong>
|
||||
Get the OpenERP Warranty
|
||||
</span>
|
||||
</a>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p><t t-esc="process_help"/></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr t-if="selection">
|
||||
<td>
|
||||
<fieldset>
|
||||
<legend>
|
||||
Select Process
|
||||
</legend>
|
||||
<select id="select_process">
|
||||
<t t-foreach="selection" t-as="prc">
|
||||
<option t-att-value="prc[0]">
|
||||
<t t-esc="prc[1]"/>
|
||||
</option>
|
||||
</t>
|
||||
</select>
|
||||
<button id="change_process">Select</button>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>
|
||||
<tr t-if="p_id">
|
||||
<td>
|
||||
<div id="process_canvas" style="overflow: auto;"></div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</t>
|
||||
</template>
|
||||
|
|
Loading…
Reference in New Issue