[FIX] Corrected tabs.

bzr revid: nicolas.vanhoren@openerp.com-20110330150421-7c7zc2n4mjv44tnh
This commit is contained in:
niv-openerp 2011-03-30 17:04:21 +02:00
parent 0292b18dd1
commit 0519496d0a
3 changed files with 180 additions and 180 deletions

View File

@ -327,7 +327,7 @@ openerp.base.search.FilterGroup = openerp.base.search.Widget.extend({
} }
}); });
openerp.base.search.add_expand_listener = function($root) { openerp.base.search.add_expand_listener = function($root) {
$root.find('a.searchview_group_string').click(function (e) { $root.find('a.searchview_group_string').click(function (e) {
$root.toggleClass('folded expanded'); $root.toggleClass('folded expanded');
e.stopPropagation(); e.stopPropagation();
e.preventDefault(); e.preventDefault();
@ -358,15 +358,15 @@ openerp.base.search.ExtendedSearch = openerp.base.BaseWidget.extend({
template: 'SearchView.extended_search', template: 'SearchView.extended_search',
identifier_prefix: 'extended-search', identifier_prefix: 'extended-search',
init: function (parent, fields) { init: function (parent, fields) {
this._super(parent); this._super(parent);
this.fields = fields; this.fields = fields;
}, },
add_group: function(group) { add_group: function(group) {
var group = new openerp.base.search.ExtendedSearchGroup(this, this.fields); var group = new openerp.base.search.ExtendedSearchGroup(this, this.fields);
var render = group.render({}); var render = group.render({});
this.$element.find('.searchview_extended_groups_list').append(render); this.$element.find('.searchview_extended_groups_list').append(render);
group.start(); group.start();
}, },
start: function () { start: function () {
this._super(); this._super();
var _this = this; var _this = this;
@ -377,146 +377,146 @@ openerp.base.search.ExtendedSearch = openerp.base.BaseWidget.extend({
e.stopPropagation(); e.stopPropagation();
e.preventDefault(); e.preventDefault();
}); });
}, },
get_context: function() { get_context: function() {
return null; return null;
}, },
get_domain: function() { get_domain: function() {
if(this.$element.hasClass("folded")) { if(this.$element.hasClass("folded")) {
return null; return null;
} }
var domain = _.reduce(this.children, var domain = _.reduce(this.children,
function(mem, x) { return mem.concat(x.get_domain());}, []); function(mem, x) { return mem.concat(x.get_domain());}, []);
return domain; return domain;
} }
}); });
openerp.base.search.ExtendedSearchGroup = openerp.base.BaseWidget.extend({ openerp.base.search.ExtendedSearchGroup = openerp.base.BaseWidget.extend({
template: 'SearchView.extended_search.group', template: 'SearchView.extended_search.group',
identifier_prefix: 'extended-search-group', identifier_prefix: 'extended-search-group',
init: function (parent, fields) { init: function (parent, fields) {
this._super(parent); this._super(parent);
this.fields = fields; this.fields = fields;
}, },
add_prop: function() { add_prop: function() {
var prop = new openerp.base.search.ExtendedSearchProposition(this, this.fields); var prop = new openerp.base.search.ExtendedSearchProposition(this, this.fields);
var render = prop.render({}); var render = prop.render({});
this.$element.find('.searchview_extended_propositions_list').append(render); this.$element.find('.searchview_extended_propositions_list').append(render);
prop.start(); prop.start();
}, },
start: function () { start: function () {
this._super(); this._super();
var _this = this; var _this = this;
this.add_prop(); this.add_prop();
this.$element.find('.searchview_extended_add_proposition').click(function (e) { this.$element.find('.searchview_extended_add_proposition').click(function (e) {
_this.add_prop(); _this.add_prop();
e.stopPropagation(); e.stopPropagation();
e.preventDefault(); e.preventDefault();
}); });
var delete_btn = this.$element.find('.searchview_extended_delete_group'); var delete_btn = this.$element.find('.searchview_extended_delete_group');
delete_btn.click(function (e) { delete_btn.click(function (e) {
_this.stop(); _this.stop();
e.stopPropagation(); e.stopPropagation();
e.preventDefault(); e.preventDefault();
}); });
}, },
get_domain: function() { get_domain: function() {
var props = _(this.children).chain().map(function(x) { var props = _(this.children).chain().map(function(x) {
return x.get_proposition(); return x.get_proposition();
}).compact().value(); }).compact().value();
var choice = this.$element.find(".searchview_extended_group_choice").val(); var choice = this.$element.find(".searchview_extended_group_choice").val();
var op = choice == "all" ? "&" : "|"; var op = choice == "all" ? "&" : "|";
var domain = [].concat(choice == "none" ? ['!'] : [], var domain = [].concat(choice == "none" ? ['!'] : [],
_.map(_.range(_.max([0,props.length - 1])), function(x) { return op; }), _.map(_.range(_.max([0,props.length - 1])), function(x) { return op; }),
props); props);
return domain; return domain;
} }
}); });
openerp.base.search.extended_filters_types = { openerp.base.search.extended_filters_types = {
char: { char: {
operators: [ operators: [
{value: "ilike", text: "contains"}, {value: "ilike", text: "contains"},
{value: "not like", text: "doesn't contain"}, {value: "not like", text: "doesn't contain"},
{value: "=", text: "is equal to"}, {value: "=", text: "is equal to"},
{value: "!=", text: "is not equal to"}, {value: "!=", text: "is not equal to"},
{value: ">", text: "greater than"}, {value: ">", text: "greater than"},
{value: "<", text: "less than"}, {value: "<", text: "less than"},
{value: ">=", text: "greater or equal than"}, {value: ">=", text: "greater or equal than"},
{value: "<=", text: "less or equal than"}, {value: "<=", text: "less or equal than"},
], ],
build_component: function(parent) { build_component: function(parent) {
return new openerp.base.search.ExtendedSearchProposition.Char(parent); return new openerp.base.search.ExtendedSearchProposition.Char(parent);
} }
} }
}; };
openerp.base.search.ExtendedSearchProposition = openerp.base.BaseWidget.extend({ openerp.base.search.ExtendedSearchProposition = openerp.base.BaseWidget.extend({
template: 'SearchView.extended_search.proposition', template: 'SearchView.extended_search.proposition',
identifier_prefix: 'extended-search-proposition', identifier_prefix: 'extended-search-proposition',
init: function (parent, fields) { init: function (parent, fields) {
this._super(parent); this._super(parent);
this.fields = _(fields).chain() this.fields = _(fields).chain()
.map(function(val,key) {return {name:key, obj:val};}) .map(function(val,key) {return {name:key, obj:val};})
.sortBy(function(x) {return x.obj.string;}).value(); .sortBy(function(x) {return x.obj.string;}).value();
this.attrs = {_: _, fields: this.fields, selected: null}; this.attrs = {_: _, fields: this.fields, selected: null};
this.value_component = null; this.value_component = null;
}, },
start: function () { start: function () {
this._super(); this._super();
this.set_selected(this.fields.length > 0 ? this.fields[0] : null); this.set_selected(this.fields.length > 0 ? this.fields[0] : null);
var _this = this; var _this = this;
this.$element.find(".searchview_extended_prop_field").change(function(e) { this.$element.find(".searchview_extended_prop_field").change(function(e) {
_this.changed(); _this.changed();
e.stopPropagation();
e.preventDefault();
});
var delete_btn = this.$element.find('.searchview_extended_delete_prop');
delete_btn.click(function (e) {
_this.stop();
e.stopPropagation(); e.stopPropagation();
e.preventDefault(); e.preventDefault();
}); });
}, var delete_btn = this.$element.find('.searchview_extended_delete_prop');
changed: function() { delete_btn.click(function (e) {
var nval = this.$element.find(".searchview_extended_prop_field").val(); _this.stop();
if(this.attrs.selected == null || nval != this.attrs.selected.name) { e.stopPropagation();
this.set_selected(_.detect(this.fields, function(x) {return x.name == nval;})); e.preventDefault();
} });
}, },
set_selected: function(selected) { changed: function() {
var _this = this; var nval = this.$element.find(".searchview_extended_prop_field").val();
if(this.attrs.selected != null) { if(this.attrs.selected == null || nval != this.attrs.selected.name) {
this.value_component.stop(); this.set_selected(_.detect(this.fields, function(x) {return x.name == nval;}));
this.value_component = null; }
this.$element.find('.searchview_extended_prop_op').html(''); },
} set_selected: function(selected) {
this.attrs.selected = selected; var _this = this;
if(selected == null) { if(this.attrs.selected != null) {
return; this.value_component.stop();
} this.value_component = null;
var type = selected.obj.type; this.$element.find('.searchview_extended_prop_op').html('');
var extended_filters_types = openerp.base.search.extended_filters_types; }
type = type in extended_filters_types ? type : "char"; this.attrs.selected = selected;
_.each(extended_filters_types[type].operators, function(operator) { if(selected == null) {
option = jQuery('<option/>'); return;
option.attr('value', operator.value); }
option.text(operator.text); var type = selected.obj.type;
option.appendTo(_this.$element.find('.searchview_extended_prop_op')); var extended_filters_types = openerp.base.search.extended_filters_types;
}); type = type in extended_filters_types ? type : "char";
this.value_component = extended_filters_types[type].build_component(this); _.each(extended_filters_types[type].operators, function(operator) {
var render = this.value_component.render({}); option = jQuery('<option/>');
this.$element.find('.searchview_extended_prop_value').html(render); option.attr('value', operator.value);
this.value_component.start(); option.text(operator.text);
}, option.appendTo(_this.$element.find('.searchview_extended_prop_op'));
get_proposition: function() { });
if ( this.attrs.selected == null) this.value_component = extended_filters_types[type].build_component(this);
return null; var render = this.value_component.render({});
var field = this.attrs.selected.name; this.$element.find('.searchview_extended_prop_value').html(render);
var op = this.$element.find('.searchview_extended_prop_op').val(); this.value_component.start();
var value = this.value_component.get_value(); },
return [field, op, value]; get_proposition: function() {
} if ( this.attrs.selected == null)
return null;
var field = this.attrs.selected.name;
var op = this.$element.find('.searchview_extended_prop_op').val();
var value = this.value_component.get_value();
return [field, op, value];
}
}); });
openerp.base.search.ExtendedSearchProposition.Char = openerp.base.BaseWidget.extend({ openerp.base.search.ExtendedSearchProposition.Char = openerp.base.BaseWidget.extend({
@ -524,9 +524,9 @@ openerp.base.search.ExtendedSearchProposition.Char = openerp.base.BaseWidget.ext
identifier_prefix: 'extended-search-proposition-char', identifier_prefix: 'extended-search-proposition-char',
get_value: function() { get_value: function() {
var val = this.$element.val(); var val = this.$element.val();
return val; return val;
} }
}); });
openerp.base.search.Input = openerp.base.search.Widget.extend({ openerp.base.search.Input = openerp.base.search.Widget.extend({

View File

@ -144,12 +144,12 @@ openerp.base.ViewManagerUsedAsAMany2One = openerp.base.Controller.extend({
* generation, parenting and destruction of the widget. * generation, parenting and destruction of the widget.
*/ */
openerp.base.BaseWidget = openerp.base.Controller.extend({ openerp.base.BaseWidget = openerp.base.Controller.extend({
/** /**
* The name of the QWeb template that will be used for rendering. Must be redifined * The name of the QWeb template that will be used for rendering. Must be redifined
* in subclasses or the render() method can not be used. * in subclasses or the render() method can not be used.
* *
* @type string * @type string
*/ */
template: null, template: null,
/** /**
* The prefix used to generate an id automatically. Should be redifined in subclasses. * The prefix used to generate an id automatically. Should be redifined in subclasses.
@ -164,7 +164,7 @@ openerp.base.BaseWidget = openerp.base.Controller.extend({
* @params {openerp.base.search.BaseWidget} parent The parent widget. * @params {openerp.base.search.BaseWidget} parent The parent widget.
*/ */
init: function (parent) { init: function (parent) {
this.children = []; this.children = [];
this.parent = null; this.parent = null;
this.set_parent(parent); this.set_parent(parent);
this.make_id(this.identifier_prefix); this.make_id(this.identifier_prefix);
@ -194,15 +194,15 @@ openerp.base.BaseWidget = openerp.base.Controller.extend({
* lets the widgets clean up after themselves. * lets the widgets clean up after themselves.
*/ */
stop: function () { stop: function () {
var tmp_children = this.children; var tmp_children = this.children;
this.children = []; this.children = [];
_.each(tmp_children, function(x) { _.each(tmp_children, function(x) {
x.stop(); x.stop();
}); });
if(this.$element != null) { if(this.$element != null) {
this.$element.remove(); this.$element.remove();
} }
this.set_parent(null); this.set_parent(null);
this._super(); this._super();
}, },
/** /**
@ -212,13 +212,13 @@ openerp.base.BaseWidget = openerp.base.Controller.extend({
* @param {openerp.base.BaseWidget} parent The new parent. * @param {openerp.base.BaseWidget} parent The new parent.
*/ */
set_parent: function(parent) { set_parent: function(parent) {
if(this.parent) { if(this.parent) {
this.parent.children = _.without(this.parent.children, this); this.parent.children = _.without(this.parent.children, this);
} }
this.parent = parent; this.parent = parent;
if(this.parent) { if(this.parent) {
parent.children.push(this); parent.children.push(this);
} }
}, },
/** /**
* Render the widget. This.template must be defined. * Render the widget. This.template must be defined.
@ -228,7 +228,7 @@ openerp.base.BaseWidget = openerp.base.Controller.extend({
*/ */
render: function (additional) { render: function (additional) {
return QWeb.render(this.template, _.extend({}, this, return QWeb.render(this.template, _.extend({}, this,
additional != null ? additional : {})); additional != null ? additional : {}));
} }
}); });
openerp.base.CalendarView = openerp.base.Controller.extend({ openerp.base.CalendarView = openerp.base.Controller.extend({

View File

@ -344,7 +344,7 @@
</div> </div>
</t> </t>
<t t-name="SearchView.util.expand"> <t t-name="SearchView.util.expand">
<div t-att-class="'searchview_group ' + (expand == '0' ? 'folded' : 'expanded')" <div t-att-class="'searchview_group ' + (expand == '0' ? 'folded' : 'expanded')"
t-att-id="element_id"> t-att-id="element_id">
<a t-if="label" class="searchview_group_string" href="#"> <a t-if="label" class="searchview_group_string" href="#">
<t t-esc="label"/> <t t-esc="label"/>
@ -355,55 +355,55 @@
</div> </div>
</t> </t>
<t t-name="SearchView.group"> <t t-name="SearchView.group">
<t t-call="SearchView.util.expand"> <t t-call="SearchView.util.expand">
<t t-set="expand" t-value="attrs.expand"/> <t t-set="expand" t-value="attrs.expand"/>
<t t-set="label" t-value="attrs.string"/> <t t-set="label" t-value="attrs.string"/>
<t t-set="content"> <t t-set="content">
<t t-call="SearchView.render_lines"/> <t t-call="SearchView.render_lines"/>
</t> </t>
</t> </t>
</t> </t>
<t t-name="SearchView.extended_search"> <t t-name="SearchView.extended_search">
<t t-call="SearchView.util.expand"> <t t-call="SearchView.util.expand">
<t t-set="expand" t-value="false"/> <t t-set="expand" t-value="false"/>
<t t-set="label" t-value="'Extended Filters'"/> <t t-set="label" t-value="'Extended Filters'"/>
<t t-set="content"> <t t-set="content">
<div class="searchview_extended_groups_list"></div> <div class="searchview_extended_groups_list"></div>
<button class="searchview_extended_add_group">Add group of conditions</button> <button class="searchview_extended_add_group">Add group of conditions</button>
</t> </t>
</t> </t>
</t> </t>
<t t-name="SearchView.extended_search.group"> <t t-name="SearchView.extended_search.group">
<div t-att-id="element_id"> <div t-att-id="element_id">
<select class="searchview_extended_group_choice"> <select class="searchview_extended_group_choice">
<option value="all">All</option> <option value="all">All</option>
<option value="any">Any</option> <option value="any">Any</option>
<option value="none">None</option> <option value="none">None</option>
</select> </select>
<div class="searchview_extended_propositions_list"> <div class="searchview_extended_propositions_list">
</div> </div>
<button class="searchview_extended_add_proposition">Add condition</button> <button class="searchview_extended_add_proposition">Add condition</button>
<button class="searchview_extended_delete_group">Delete this group</button> <button class="searchview_extended_delete_group">Delete this group</button>
</div> </div>
</t> </t>
<t t-name="SearchView.extended_search.proposition"> <t t-name="SearchView.extended_search.proposition">
<div t-att-id="element_id"> <div t-att-id="element_id">
<select class="searchview_extended_prop_field"> <select class="searchview_extended_prop_field">
<t t-foreach="attrs.fields" t-as="field"> <t t-foreach="attrs.fields" t-as="field">
<option t-att="{'selected': field === attrs.selected ? 'selected' : null}" <option t-att="{'selected': field === attrs.selected ? 'selected' : null}"
t-att-value="field.name"> t-att-value="field.name">
<t t-esc="field.obj.string"/> <t t-esc="field.obj.string"/>
</option> </option>
</t> </t>
</select> </select>
<select class="searchview_extended_prop_op"> <select class="searchview_extended_prop_op">
</select> </select>
<span class="searchview_extended_prop_value"> <span class="searchview_extended_prop_value">
</span> </span>
<button class="searchview_extended_delete_prop">Delete this condition</button> <button class="searchview_extended_delete_prop">Delete this condition</button>
</div> </div>
</t> </t>
<t t-name="SearchView.extended_search.proposition.char"> <t t-name="SearchView.extended_search.proposition.char">
<input t-att-id="element_id"></input> <input t-att-id="element_id"></input>
</t> </t>
</templates> </templates>