[FIX] Extend with ViewManager.
bzr revid: vda@tinyerp.com-20110919095730-toavlykgeokcg4d0
This commit is contained in:
parent
a9efd2fdd0
commit
6c17995fb7
|
@ -2,77 +2,69 @@
|
|||
openerp.web_process = function (openerp) {
|
||||
var QWeb = openerp.web.qweb;
|
||||
QWeb.add_template('/web_process/static/src/xml/web_process.xml');
|
||||
openerp.web.ViewManagerAction.include({
|
||||
on_mode_switch: function (view_type) {
|
||||
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;
|
||||
return $.when(
|
||||
this._super(view_type),
|
||||
this.process_check(this.views[view_type])).then(function () {
|
||||
});
|
||||
},
|
||||
process_check: function(view) {
|
||||
var self = this;
|
||||
var grandparent = this.widget_parent && this.widget_parent.widget_parent;
|
||||
// display shortcuts if on the first view for the action
|
||||
var $process_toggle = this.$element.find('.oe-process-toggle');
|
||||
if (!(grandparent instanceof openerp.web.WebClient) ||
|
||||
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_toggle.hide();
|
||||
$process_view.hide();
|
||||
return;
|
||||
}
|
||||
$process_toggle.show();
|
||||
$process_toggle
|
||||
.unbind("click")
|
||||
.click(function(){
|
||||
$.when(self.load_process()).then(self.get_process_id());
|
||||
});
|
||||
},
|
||||
|
||||
load_process: function() {
|
||||
// this.widget_parent.$element.html(QWeb.render("ProcessView",this));
|
||||
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.renderer(res);
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
renderer: function(res) {
|
||||
$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() {
|
||||
self.widget_parent.$element.find('#change_process').click(function(){
|
||||
|
||||
self.p_id = self.widget_parent.$element.find('#select_process').val();
|
||||
$.when(self.load_process()).then(self.render_process_view());
|
||||
|
||||
$.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 {
|
||||
} 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);
|
||||
|
@ -150,7 +142,7 @@ QWeb.add_template('/web_process/static/src/xml/web_process.xml');
|
|||
.push(process_node)
|
||||
.push(process_node_text)
|
||||
.push(process_node_desc);
|
||||
process_node.mousedown(function(){
|
||||
process_node.mousedown(function() {
|
||||
return false;
|
||||
})
|
||||
return process_set;
|
||||
|
@ -189,7 +181,6 @@ QWeb.add_template('/web_process/static/src/xml/web_process.xml');
|
|||
}
|
||||
);
|
||||
}
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -1,73 +1,67 @@
|
|||
<template>
|
||||
<t t-extend="ViewManager" t-name="ViewManagerAction">
|
||||
<t t-jquery=".oe_view_title" t-operation="append">
|
||||
<img class="oe-process-toggle" src="/web/static/src/img/icons/gtk-help.png" title="ProcessView"/>
|
||||
<img class="oe-process-view" src="/web/static/src/img/icons/gtk-help.png" title="ProcessView"/>
|
||||
</t>
|
||||
</t>
|
||||
<!--<t t-extend="SearchView">
|
||||
<t t-jquery="h2" t-operation="append">
|
||||
<img id="ProcessView" src="/web_process/static/src/img/iconset-a-help.gif"/>
|
||||
</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-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>
|
||||
</template>
|
||||
|
|
Loading…
Reference in New Issue