[MERGE] from trunk
bzr revid: fva@openerp.com-20120919091522-20yc9992q5zfzwgb
This commit is contained in:
@@ -79,6 +79,9 @@ instance.web.Dialog = instance.web.Widget.extend({
|
||||
}
|
||||
}
|
||||
if (options) {
|
||||
if (options.buttons) {
|
||||
this.params_buttons = true;
|
||||
}
|
||||
_.extend(this.dialog_options, options);
|
||||
}
|
||||
},
|
||||
@@ -123,7 +126,13 @@ instance.web.Dialog = instance.web.Widget.extend({
|
||||
if (! this.dialog_inited)
|
||||
this.init_dialog();
|
||||
var o = this.get_options(options);
|
||||
if (! this.params_buttons) {
|
||||
this.$buttons.appendTo($("body"));
|
||||
}
|
||||
instance.web.dialog(this.$el, o).dialog('open');
|
||||
if (! this.params_buttons) {
|
||||
this.$buttons.appendTo(this.$el.dialog("widget"));
|
||||
}
|
||||
if (o.height === 'auto' && o.max_height) {
|
||||
this.$el.css({ 'max-height': o.max_height, 'overflow-y': 'auto' });
|
||||
}
|
||||
@@ -133,6 +142,10 @@ instance.web.Dialog = instance.web.Widget.extend({
|
||||
this.renderElement();
|
||||
var o = this.get_options(options);
|
||||
instance.web.dialog(this.$el, o);
|
||||
if (! this.params_buttons) {
|
||||
this.$buttons = $('<div class="ui-dialog-buttonpane ui-widget-content ui-helper-clearfix" />');
|
||||
this.$el.dialog("widget").append(this.$buttons);
|
||||
}
|
||||
var res = this.start();
|
||||
this.dialog_inited = true;
|
||||
return res;
|
||||
|
||||
@@ -2616,6 +2616,7 @@ instance.web.form.CompletionFieldMixin = {
|
||||
|
||||
var dataset = new instance.web.DataSet(this, this.field.relation, self.build_context());
|
||||
var blacklist = this.get_search_blacklist();
|
||||
this.last_query = search_val;
|
||||
|
||||
return this.orderer.add(dataset.name_search(
|
||||
search_val, new instance.web.CompoundDomain(self.build_domain(), [["id", "not in", blacklist]]),
|
||||
@@ -2723,6 +2724,32 @@ instance.web.form.CompletionFieldMixin = {
|
||||
},
|
||||
};
|
||||
|
||||
instance.web.form.M2ODialog = instance.web.Dialog.extend({
|
||||
template: "M2ODialog",
|
||||
init: function(parent) {
|
||||
this._super(parent, {
|
||||
title: _.str.sprintf(_t("Add %s"), parent.string),
|
||||
width: 312,
|
||||
});
|
||||
},
|
||||
start: function() {
|
||||
var self = this;
|
||||
this.$buttons.html(QWeb.render("M2ODialog.buttons"));
|
||||
this.$("input").val(this.getParent().last_query);
|
||||
this.$buttons.find(".oe_form_m2o_qc_button").click(function(){
|
||||
self.getParent()._quick_create(self.$("input").val());
|
||||
self.destroy();
|
||||
});
|
||||
this.$buttons.find(".oe_form_m2o_sc_button").click(function(){
|
||||
self.getParent()._search_create_popup("form", undefined, self.getParent()._create_context(self.$("input").val()));
|
||||
self.destroy();
|
||||
});
|
||||
this.$buttons.find(".oe_form_m2o_cancel_button").click(function(){
|
||||
self.destroy();
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instance.web.form.CompletionFieldMixin, instance.web.form.ReinitializeFieldMixin, {
|
||||
template: "FieldMany2One",
|
||||
init: function(field_manager, node) {
|
||||
@@ -2754,25 +2781,13 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instanc
|
||||
this.render_value();
|
||||
},
|
||||
init_error_displayer: function() {
|
||||
this.$input.tipsy({
|
||||
title: function() {
|
||||
return QWeb.render('Tipsy.alert', {
|
||||
message: "No element was selected, you should create or select one from the dropdown list."
|
||||
});
|
||||
},
|
||||
trigger:'manual',
|
||||
fade: true,
|
||||
gravity: 's',
|
||||
html: true,
|
||||
opacity: 1,
|
||||
offset: 4,
|
||||
});
|
||||
// nothing
|
||||
},
|
||||
hide_error_displayer: function() {
|
||||
this.$input.tipsy("hide");
|
||||
// doesn't work
|
||||
},
|
||||
show_error_displayer: function() {
|
||||
this.$input.tipsy("show");
|
||||
new instance.web.form.M2ODialog(this).open();
|
||||
},
|
||||
render_editable: function() {
|
||||
var self = this;
|
||||
|
||||
@@ -919,6 +919,7 @@
|
||||
t-att-tabindex="widget.node.attrs.tabindex"
|
||||
t-att-autofocus="widget.node.attrs.autofocus"
|
||||
t-att-placeholder="widget.node.attrs.placeholder"
|
||||
t-att-maxlength="widget.field.size"
|
||||
/><img class="oe_field_translate oe_input_icon" t-if="widget.field.translate" t-att-src='_s + "/web/static/src/img/icons/terp-translate.png"' width="16" height="16" border="0"/>
|
||||
</t>
|
||||
</span>
|
||||
@@ -933,6 +934,7 @@
|
||||
t-att-tabindex="widget.node.attrs.tabindex"
|
||||
t-att-autofocus="widget.node.attrs.autofocus"
|
||||
t-att-placeholder="widget.node.attrs.placeholder"
|
||||
t-att-maxlength="widget.field.size"
|
||||
/>
|
||||
</div>
|
||||
</t>
|
||||
@@ -951,6 +953,7 @@
|
||||
t-att-tabindex="widget.node.attrs.tabindex"
|
||||
t-att-autofocus="widget.node.attrs.autofocus"
|
||||
t-att-placeholder="! widget.get('effective_readonly') ? widget.node.attrs.placeholder : ''"
|
||||
t-att-maxlength="widget.field.size"
|
||||
></textarea><img class="oe_field_translate oe_input_icon"
|
||||
t-if="widget.field.translate and !widget.get('effective_readonly')"
|
||||
t-att-src='_s + "/web/static/src/img/icons/terp-translate.png"' width="16" height="16" border="0"
|
||||
@@ -1700,4 +1703,14 @@
|
||||
<div class="oe_throbber_message" style="color:white"></div>
|
||||
</div>
|
||||
</t>
|
||||
<t t-name="M2ODialog">
|
||||
<div>
|
||||
Name: <input class="oe_form_m2o_input_name" type="text"/>
|
||||
</div>
|
||||
</t>
|
||||
<t t-name="M2ODialog.buttons">
|
||||
<button class="oe_form_m2o_qc_button oe_button oe_highlight">Quick Add</button>
|
||||
<button class="oe_form_m2o_sc_button oe_button">Add All Info...</button>
|
||||
<button class="oe_form_m2o_cancel_button oe_button">Cancel</button>
|
||||
</t>
|
||||
</templates>
|
||||
|
||||
@@ -143,6 +143,10 @@
|
||||
position: relative;
|
||||
top: -8px;
|
||||
}
|
||||
.openerp .oe_kanban_view .oe_kanban_add, .openerp .oe_kanban_view .oe_kanban_card .oe_dropdown_toggle {
|
||||
cursor: pointer;
|
||||
display:inline-block;
|
||||
}
|
||||
.openerp .oe_kanban_view .oe_kanban_add {
|
||||
float: right;
|
||||
}
|
||||
|
||||
@@ -154,6 +154,9 @@
|
||||
cursor: pointer
|
||||
position: relative
|
||||
top: -8px
|
||||
.oe_kanban_card, .oe_dropdown_toggle
|
||||
cursor: pointer
|
||||
display:inline-block
|
||||
.oe_kanban_add
|
||||
float: right
|
||||
|
||||
|
||||
@@ -71,6 +71,7 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
|
||||
this.fields_keys = _.keys(this.fields_view.fields);
|
||||
this.add_qweb_template();
|
||||
this.has_been_loaded.resolve();
|
||||
this._super.apply(this, arguments);
|
||||
return $.when();
|
||||
},
|
||||
_is_quick_create_enabled: function() {
|
||||
@@ -85,6 +86,9 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
|
||||
return false;
|
||||
return this._super(action);
|
||||
},
|
||||
/* add_qweb_template
|
||||
* select the nodes into the xml and send to extract_aggregates the nodes with TagName="field"
|
||||
*/
|
||||
add_qweb_template: function() {
|
||||
for (var i=0, ii=this.fields_view.arch.children.length; i < ii; i++) {
|
||||
var child = this.fields_view.arch.children[i];
|
||||
@@ -97,6 +101,9 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
|
||||
}
|
||||
}
|
||||
},
|
||||
/* extract_aggregates
|
||||
* extract the agggregates from the nodes (TagName="field")
|
||||
*/
|
||||
extract_aggregates: function(node) {
|
||||
for (var j = 0, jj = this.group_operators.length; j < jj; j++) {
|
||||
if (node.attrs[this.group_operators[j]]) {
|
||||
@@ -121,9 +128,15 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
|
||||
}
|
||||
switch (node.tag) {
|
||||
case 'field':
|
||||
node.tag = QWeb.prefix;
|
||||
node.attrs[QWeb.prefix + '-esc'] = 'record.' + node.attrs['name'] + '.value';
|
||||
this.extract_aggregates(node);
|
||||
if(this.fields_view.fields[ node.attrs['name'] ].type == 'many2many'){
|
||||
node.tag = 'div';
|
||||
node.attrs['class'] = 'oe_kanban_many2many_tags';
|
||||
node.attrs['model'] = this.fields_view.fields[node.attrs['name']].relation;
|
||||
node.attrs['t-att-data'] = 'record.' + node.attrs['name'] + '.raw_value';
|
||||
}else {
|
||||
node.tag = QWeb.prefix;
|
||||
node.attrs[QWeb.prefix + '-esc'] = 'record.' + node.attrs['name'] + '.value';
|
||||
}
|
||||
break;
|
||||
case 'button':
|
||||
case 'a':
|
||||
@@ -163,6 +176,37 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
|
||||
}
|
||||
}
|
||||
},
|
||||
/* widget for list of tags/categories...
|
||||
*/
|
||||
transform_widget_many2many: function(){
|
||||
var self=this,
|
||||
arg={};
|
||||
// select all widget
|
||||
self.$el.find(".oe_kanban_many2many_tags").each(function(){
|
||||
var model = $(this).attr("model");
|
||||
var data = $(this).attr("data");
|
||||
var list = data.split(",");
|
||||
//select all id (per model)
|
||||
if(!arg[model]) arg[model]=[];
|
||||
for(var t=0;t<list.length;t++) if(list[t]!="") arg[model].push( list[t] );
|
||||
});
|
||||
|
||||
// only one request by model
|
||||
for(var model in arg){
|
||||
if(arg[model].length>0){
|
||||
var dataset = new instance.web.DataSetSearch(self, model, self.session.context);
|
||||
dataset.name_get(_.uniq( arg[model] )).then(
|
||||
function(result) {
|
||||
for(var t=0;t<result.length;t++){
|
||||
self.$el.find(".oe_kanban_many2many_tags[model='" + model + "']")
|
||||
.filter(function(){ return this.getAttribute("data").match(new RegExp('(^|,)'+result[t][0]+'(,|$)')); })
|
||||
.append('<span class="oe_tag" data-list_id="' + result[t][0] +'"">'+result[t][1]+'</span>');
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
do_add_record: function() {
|
||||
this.dataset.index = null;
|
||||
this.do_switch_view('form');
|
||||
@@ -350,6 +394,7 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
|
||||
} else {
|
||||
this.$el.find('.oe_kanban_draghandle').removeClass('oe_kanban_draghandle');
|
||||
}
|
||||
this.transform_widget_many2many();
|
||||
},
|
||||
on_record_moved : function(record, old_group, old_index, new_group, new_index) {
|
||||
var self = this;
|
||||
@@ -762,7 +807,7 @@ instance.web_kanban.KanbanRecord = instance.web.Widget.extend({
|
||||
}
|
||||
});
|
||||
|
||||
if (this.$el.find('.oe_kanban_global_click').length) {
|
||||
if (this.$el.find('.oe_kanban_global_click,.oe_kanban_global_click_edit').length) {
|
||||
this.$el.on('click', function(ev) {
|
||||
if (!ev.isTrigger && !$(ev.target).data('events')) {
|
||||
var trigger = true;
|
||||
@@ -803,8 +848,15 @@ instance.web_kanban.KanbanRecord = instance.web.Widget.extend({
|
||||
});
|
||||
}
|
||||
},
|
||||
/* actions when user click on the block with a specific class
|
||||
* open on normal view : oe_kanban_global_click
|
||||
* open on form/edit view : oe_kanban_global_click_edit
|
||||
*/
|
||||
on_card_clicked: function(ev) {
|
||||
this.view.open_record(this.id);
|
||||
if(this.$el.find('.oe_kanban_global_click_edit').size()>0)
|
||||
this.do_action_edit();
|
||||
else
|
||||
this.do_action_open();
|
||||
},
|
||||
setup_color_picker: function() {
|
||||
var self = this;
|
||||
|
||||
Reference in New Issue
Block a user