bzr revid: nicolas.vanhoren@openerp.com-20110812095515-wpi5e3rsznaterk6
This commit is contained in:
niv-openerp 2011-08-12 11:55:15 +02:00
commit dfaf0bd84e
4 changed files with 80 additions and 65 deletions

View File

@ -923,7 +923,7 @@ label.error {
height: 15px;
}
.openerp td.required input, .openerp td.required select {
background-color: #D2D2FF;
background-color: #D2D2FF !important;
}
.openerp td.invalid input, .openerp td.invalid select, .openerp td.invalid textarea {
background-color: #F66 !important;

View File

@ -362,7 +362,8 @@ openerp.base.search.fields = new openerp.base.Registry({
'datetime': 'openerp.base.search.DateTimeField',
'date': 'openerp.base.search.DateField',
'many2one': 'openerp.base.search.ManyToOneField',
'many2many': 'openerp.base.search.ManyToManyField'
'many2many': 'openerp.base.search.CharField',
'one2many': 'openerp.base.search.CharField'
});
openerp.base.search.Invalid = openerp.base.Class.extend( /** @lends openerp.base.search.Invalid# */{
/**
@ -723,11 +724,8 @@ openerp.base.search.DateField = openerp.base.search.Field.extend( /** @lends ope
}
});
openerp.base.search.DateTimeField = openerp.base.search.DateField.extend({
// TODO: time?
});
openerp.base.search.ManyToOneField = openerp.base.search.CharField.extend({
// TODO: @widget
// TODO: .selection, .context, .domain
init: function (view_section, field, view) {
this._super(view_section, field, view);
var self = this;
@ -795,12 +793,6 @@ openerp.base.search.ManyToOneField = openerp.base.search.CharField.extend({
return this._super();
}
});
/**
* m2m search field behaves pretty much exactly like a char field
*
* @class
*/
openerp.base.search.ManyToManyField = openerp.base.search.CharField.extend({});
openerp.base.search.ExtendedSearch = openerp.base.OldWidget.extend({
template: 'SearchView.extended_search',
@ -883,11 +875,10 @@ openerp.base.search.ExtendedSearchGroup = openerp.base.OldWidget.extend({
this._super();
var _this = this;
this.add_prop();
this.$element.find('.searchview_extended_add_proposition').click(function (e) {
this.$element.find('.searchview_extended_add_proposition').click(function () {
_this.add_prop();
});
var delete_btn = this.$element.find('.searchview_extended_delete_group');
delete_btn.click(function (e) {
this.$element.find('.searchview_extended_delete_group').click(function () {
_this.stop();
});
},
@ -897,7 +888,7 @@ openerp.base.search.ExtendedSearchGroup = openerp.base.OldWidget.extend({
}).compact().value();
var choice = this.$element.find(".searchview_extended_group_choice").val();
var op = choice == "all" ? "&" : "|";
return [].concat(choice == "none" ? ['!'] : [],
return choice == "none" ? ['!'] : [].concat(
_.map(_.range(_.max([0,props.length - 1])), function() { return op; }),
props);
},
@ -909,10 +900,7 @@ openerp.base.search.ExtendedSearchGroup = openerp.base.OldWidget.extend({
parent.check_last_element();
},
set_last_group: function(is_last) {
if(is_last)
this.$element.addClass("last_group");
else
this.$element.removeClass("last_group");
this.$element.toggleClass('last_group', is_last);
}
});
@ -935,8 +923,7 @@ openerp.base.search.ExtendedSearchProposition = openerp.base.OldWidget.extend({
this.$element.find(".searchview_extended_prop_field").change(function() {
_this.changed();
});
var delete_btn = this.$element.find('.searchview_extended_delete_prop');
delete_btn.click(function (e) {
this.$element.find('.searchview_extended_delete_prop').click(function () {
_this.stop();
});
},

View File

@ -17,10 +17,15 @@ openerp.base_calendar.CalendarView = openerp.base.View.extend({
this.context = this.dataset.context || {};
this.has_been_loaded = $.Deferred();
this.creating_event_id = null;
this.dataset_events = [];
if (this.options.action_views_ids.form) {
this.form_dialog = new openerp.base_calendar.CalendarFormDialog(this, {}, this.options.action_views_ids.form, dataset);
this.form_dialog.start();
}
this.COLOR_PALETTE = ['#f57900', '#cc0000', '#d400a8', '#75507b', '#3465a4', '#73d216', '#c17d11', '#edd400',
'#fcaf3e', '#ef2929', '#ff00c9', '#ad7fa8', '#729fcf', '#8ae234', '#e9b96e', '#fce94f',
'#ff8e00', '#ff0000', '#b0008c', '#9000ff', '#0078ff', '#00ff00', '#e6ff00', '#ffff00',
'#905000', '#9b0000', '#840067', '#510090', '#0000c9', '#009b00', '#9abe00', '#ffc900' ];
},
start: function() {
this.rpc("/base_calendar/calendarview/load", {"model": this.model, "view_id": this.view_id, 'toolbar': true}, this.on_loaded);
@ -111,6 +116,7 @@ openerp.base_calendar.CalendarView = openerp.base.View.extend({
scheduler.attachEvent('onEventDeleted', this.do_delete_event);
scheduler.attachEvent('onEventChanged', this.do_save_event);
scheduler.attachEvent('onDblClick', this.do_edit_event);
scheduler.attachEvent('onBeforeLightbox', this.do_edit_event);
this.mini_calendar = scheduler.renderCalendar({
container: this.sidebar.navigator.element_id,
@ -130,25 +136,11 @@ openerp.base_calendar.CalendarView = openerp.base.View.extend({
reload_event: function(id) {
this.dataset.read_ids([id], _.keys(this.fields), this.on_events_loaded);
},
load_scheduler: function() {
var self = this;
this.dataset.read_slice({
fields: _.keys(self.fields_view.fields)
}, function(events) {
if (self.session.locale_code) {
// TODO: replace $LAB
$LAB.setOptions({AlwaysPreserveOrder: true}).script([
'/base_calendar/static/lib/dhtmlxScheduler/sources/locale_' + self.session.locale_code + '.js',
'/base_calendar/static/lib/dhtmlxScheduler/sources/locale_recurring_' + self.session.locale_code + '.js'
]).wait(function() {
self.on_events_loaded(events);
});
} else {
self.on_events_loaded(events);
}
});
get_color: function(index) {
index = index % this.COLOR_PALETTE.length;
return this.COLOR_PALETTE[index];
},
on_events_loaded: function(events) {
on_events_loaded: function(events, fn_filter, no_filter_reload) {
var self = this;
//To parse Events we have to convert date Format
@ -162,32 +154,42 @@ openerp.base_calendar.CalendarView = openerp.base.View.extend({
break;
}
if (this.color_field) {
var filter = evt[this.color_field];
if (filter) {
var filter_item = {
value: (typeof filter === 'object') ? filter[0] : filter,
label: (typeof filter === 'object') ? filter[1] : filter
}
if (typeof(fn_filter) === 'function' && !fn_filter(filter_item.value)) {
continue;
}
var filter_index = _.indexOf(sidebar_ids, filter_item.value);
if (filter_index === -1) {
evt.color = filter_item.color = this.get_color(sidebar_ids.length);
sidebar_items.push(filter_item);
sidebar_ids.push(filter_item.value);
} else {
evt.color = this.get_color(filter_index);
}
evt.textColor = '#ffffff';
}
}
if (this.fields[this.date_start]['type'] == 'date') {
evt[this.date_start] = openerp.base.parse_date(evt[this.date_start]).set({hour: 9}).toString('yyyy-MM-dd HH:mm:ss');
}
if (this.date_stop && evt[this.date_stop] && this.fields[this.date_stop]['type'] == 'date') {
evt[this.date_stop] = openerp.base.parse_date(evt[this.date_stop]).set({hour: 17}).toString('yyyy-MM-dd HH:mm:ss');
}
if (this.color_field) {
var user = evt[this.color_field];
if (user) {
if (_.indexOf(sidebar_ids, user[0]) === -1) {
sidebar_items.push({
id: user[0],
name: user[1],
// TODO: use color table
color: '#dddddd'
});
sidebar_ids.push(user[0]);
}
}
}
res_events.push(this.convert_event(evt));
}
scheduler.parse(res_events, 'json');
this.refresh_scheduler();
this.refresh_minical();
this.sidebar.responsible.on_events_loaded(sidebar_items);
if (!no_filter_reload) {
this.sidebar.responsible.on_events_loaded(sidebar_items);
}
},
convert_event: function(evt) {
var date_start = openerp.base.parse_datetime(evt[this.date_start]),
@ -213,13 +215,20 @@ openerp.base_calendar.CalendarView = openerp.base.View.extend({
if (!date_stop && date_delay) {
date_stop = date_start.clone().addHours(date_delay);
}
return {
var r = {
'start_date': date_start.toString('yyyy-MM-dd HH:mm:ss'),
'end_date': date_stop.toString('yyyy-MM-dd HH:mm:ss'),
'text': res_text,
'id': evt.id,
'title': res_description.join()
}
if (evt.color) {
r.color = evt.color;
}
if (evt.textColor) {
r.textColor = evt.textColor;
}
return r;
},
do_create_event: function(event_id, event_obj) {
var self = this,
@ -260,9 +269,9 @@ openerp.base_calendar.CalendarView = openerp.base.View.extend({
this.dataset.index = index;
this.form_dialog.form.do_show();
this.form_dialog.open();
} else {
this.notification.warn("Edit event", "Could not find event #" + event_id);
return false;
}
return true;
},
get_event_data: function(event_obj) {
var data = {
@ -280,6 +289,7 @@ openerp.base_calendar.CalendarView = openerp.base.View.extend({
},
do_search: function(domains, contexts, groupbys) {
var self = this;
scheduler.clearAll();
$.when(this.has_been_loaded).then(function() {
self.rpc('/base/session/eval_domain_and_context', {
domains: domains,
@ -293,7 +303,11 @@ openerp.base_calendar.CalendarView = openerp.base.View.extend({
fields: _.keys(self.fields),
offset:0,
limit: self.limit
}, self.on_events_loaded);
}, function(events) {
self.dataset_events = events;
self.on_events_loaded(events);
}
);
});
});
},
@ -352,10 +366,25 @@ openerp.base_calendar.SidebarResponsible = openerp.base.Widget.extend({
init: function(parent, element_id, view) {
this._super(parent, element_id);
this.view = view;
this.$element.delegate('input:checkbox', 'change', this.on_filter_click);
},
on_events_loaded: function(users) {
this.$element.html(QWeb.render('CalendarView.sidebar.responsible', { users : users }));
// TODO: bind checkboxes reload sheduler
on_events_loaded: function(filters) {
this.$element.html(QWeb.render('CalendarView.sidebar.responsible', { filters: filters }));
},
on_filter_click: function(e) {
var responsibles = [],
$e = $(e.target);
this.$element.find('div.oe_calendar_responsible input:checked').each(function() {
responsibles.push($(this).val());
});
scheduler.clearAll();
if (responsibles.length) {
this.view.on_events_loaded(this.view.dataset_events, function(filter_value) {
return _.indexOf(responsibles, filter_value.toString()) > -1;
}, true);
} else {
this.view.on_events_loaded(this.view.dataset_events, false, true);
}
}
});
@ -367,7 +396,6 @@ openerp.base_calendar.SidebarNavigator = openerp.base.Widget.extend({
on_events_loaded: function(events) {
}
});
};
// DEBUG_RPC:rpc.request:('execute', 'addons-dsh-l10n_us', 1, '*', ('ir.filters', 'get_filters', u'res.partner'))

View File

@ -18,9 +18,9 @@
</div>
</t>
<t t-name="CalendarView.sidebar.responsible">
<div t-foreach="users" t-as="user" class="oe_calendar_responsible" t-attf-style="background: #{user.color}">
<input type="checkbox" name="selection" t-att-value="user.id"/>
<span><t t-esc="user.name"/></span>
<div t-foreach="filters" t-as="filter" class="oe_calendar_responsible" t-attf-style="background: #{filter.color}">
<input type="checkbox" name="selection" t-att-value="filter.value"/>
<span><t t-esc="filter.label"/></span>
</div>
</t>
</template>