[IMP] code cleaning for get_empty_list_help

bzr revid: chm@openerp.com-20130321134041-o7iz55qlufx33qo4
This commit is contained in:
Christophe Matthieu 2013-03-21 14:40:41 +01:00
commit 6d52a62262
7 changed files with 125 additions and 18 deletions

View File

@ -2108,6 +2108,9 @@
.openerp .oe_form_readonly .oe_edit_only, .openerp .oe_form_readonly .oe_form_field:empty {
display: none !important;
}
.openerp .oe_form_editable .oe_read_only {
display: none !important;
}
.openerp .oe_form_readonly .oe_form .oe_form_field_date {
width: auto;
}
@ -2379,6 +2382,7 @@
background: white;
min-width: 60px;
color: #1f1f1f;
font-family: "Lucida Grande", Helvetica, Verdana, Arial, sans-serif;
}
.openerp .oe_form input[readonly], .openerp .oe_form select[readonly], .openerp .oe_form textarea[readonly], .openerp .oe_form input[disabled], .openerp .oe_form select[disabled] {
background: #e5e5e5 !important;
@ -2393,6 +2397,7 @@
-moz-border-radius: 0px;
-webkit-border-radius: 0px;
border-radius: 0px;
color: #4C4C4C;
}
.openerp .oe_form textarea.oe_inline[disabled] {
border-left: 8px solid #eeeeee;
@ -3262,6 +3267,10 @@ div.ui-widget-overlay {
clear: both;
text-align: center;
}
.openerp .oe_kanban_grouped {
position: relative;
z-index: 1;
}
.openerp_ie.oe_kanban_grouped .oe_kanban_show_more .oe_button {
width: 100%;
padding: 3px 12px;

View File

@ -1607,6 +1607,9 @@ $sheet-padding: 16px
// }}}
.oe_kanban_grouped
position: relative
z-index: 1
// Views Common {{{
.oe_view_nocontent
padding: 15px
@ -1667,6 +1670,8 @@ $sheet-padding: 16px
.oe_form_readonly
.oe_edit_only, .oe_form_field:empty
display: none !important
.oe_read_only
display: none !important
.oe_form .oe_form_field_date
width: auto
// Sheet and padding
@ -1884,6 +1889,7 @@ $sheet-padding: 16px
background: white
min-width: 60px
color: #1f1f1f
font-family: "Lucida Grande", Helvetica, Verdana, Arial, sans-serif
input[readonly], select[readonly], textarea[readonly], input[disabled], select[disabled]
background: #E5E5E5 !important
color: #666
@ -1892,6 +1898,7 @@ $sheet-padding: 16px
padding-left: 8px
@include box-shadow(none)
@include radius(0px)
color: #4C4C4C
textarea.oe_inline[disabled]
border-left: 8px solid #eee
.oe_form_field_url button img

View File

@ -1371,7 +1371,7 @@ instance.web.View = instance.web.Widget.extend({
} else if (action_data.type=="action") {
return this.rpc('/web/action/load', {
action_id: action_data.name,
context: instance.web.pyeval.eval('context', context),
context: _.extend({'active_model': dataset.model, 'active_ids': dataset.ids, 'active_id': record_id}, instance.web.pyeval.eval('context', context)),
do_not_eval: true
}).then(handler);
} else {
@ -1459,7 +1459,7 @@ instance.web.View = instance.web.Widget.extend({
is_action_enabled: function(action) {
var attrs = this.fields_view.arch.attrs;
return (action in attrs) ? JSON.parse(attrs[action]) : true;
}
},
});
/**

View File

@ -101,6 +101,15 @@
overflow: hidden;
text-overflow: ellipsis;
}
.openerp .oe_kanban_view .oe_kanban_group_length {
text-align: center;
display: none;
}
.openerp .oe_kanban_view .oe_kanban_group_length .oe_tag {
position: relative;
top: +8px;
font-weight: bold;
}
.openerp .oe_kanban_view .oe_fold_column .oe_kanban_group_length {
position: absolute;
top: -1px;
@ -108,6 +117,9 @@
float: right;
display: block;
}
.openerp .oe_kanban_view .oe_kanban_header:hover .oe_kanban_group_length {
display: none;
}
.openerp .oe_kanban_view.oe_kanban_grouped .oe_kanban_column, .openerp .oe_kanban_view.oe_kanban_grouped .oe_kanban_group_header {
width: 185px;
min-width: 185px;
@ -147,7 +159,8 @@
.openerp .oe_kanban_view .oe_kanban_group_folded .oe_kanban_group_title, .openerp .oe_kanban_view .oe_kanban_group_folded.oe_kanban_column *, .openerp .oe_kanban_view .oe_kanban_group_folded .oe_kanban_aggregates, .openerp .oe_kanban_view .oe_kanban_group_folded .oe_kanban_add {
display: none;
}
.openerp .oe_kanban_view .oe_kanban_group_folded .oe_kanban_group_title_vertical, .openerp .oe_kanban_view .oe_kanban_group_folded .oe_kanban_group_length {
.openerp .oe_kanban_view .oe_kanban_group_folded .oe_kanban_group_title_vertical,
.openerp .oe_kanban_view .oe_kanban_group_folded .oe_kanban_group_length {
display: block;
}
.openerp .oe_kanban_view .oe_kanban_group_folded .oe_dropdown_kanban {
@ -178,6 +191,7 @@
}
.openerp .oe_kanban_view .oe_kanban_add {
top: -8px;
z-index: 2;
}
.openerp .oe_kanban_view .oe_kanban_header .oe_dropdown_toggle {
top: -2px;
@ -197,6 +211,9 @@
width: 185px;
padding: 10px;
}
.openerp .oe_kanban_view .oe_kanban_quick_create {
z-index: 2;
}
.openerp .oe_kanban_view .oe_kanban_quick_create input {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
@ -614,6 +631,28 @@
background: white;
}
.openerp .oe_kanban_view .oe_view_nocontent {
position: relative;
z-index: 1;
max-width: none;
height: 100%;
}
.openerp .oe_kanban_view .oe_view_nocontent .oe_view_nocontent_content {
margin-left: 90px;
margin-top: 5px;
max-width: 700px;
}
.openerp .oe_kanban_view .oe_view_nocontent .oe_view_nocontent_bg {
background: #eee;
opacity: 0.7;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
z-index: -1;
}
.openerp .oe_popup_form .oe_kanban_buttons .oe_highlight {
color: #404040;
background: none;

View File

@ -51,9 +51,28 @@
//background: url(data:image/pngbase64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAYAAACp8Z5+AAAAKElEQVQIHWP8DwTv379nAAFBQUEGhnfv3oHEwADEZgJLIRGMIClkLQCr3x2Htp/lLwAAAABJRU5ErkJggg==)
background: white
height: inherit
&.oe_kanban_grouped .oe_kanban_dummy_cell
background: url(/web/static/src/img/form_sheetbg.png)
width: 100%
.oe_view_nocontent
position: relative
z-index: 1
max-width: none
height: 100%
.oe_view_nocontent_content
margin-left: 90px
margin-top: 5px
max-width: 700px
.oe_view_nocontent_bg
background: #eee
opacity: 0.7
position: absolute
top: 0
bottom: 0
left: 0
right: 0
z-index: -1
&.oe_kanban_grouped
.oe_kanban_dummy_cell
background: url(/web/static/src/img/form_sheetbg.png)
width: 100%
.oe_kanban_group_length
text-align: center
display: none
@ -195,6 +214,7 @@
position: relative
.oe_kanban_add
top: -8px
z-index: 2
.oe_kanban_header .oe_dropdown_toggle
top: -2px
height: 14px
@ -209,6 +229,8 @@
.oe_kanban_no_group .oe_kanban_quick_create
width: 185px
padding: 10px
.oe_kanban_quick_create
z-index: 2
.oe_kanban_quick_create input
@include box-sizing(border-box)
outline: none

View File

@ -225,7 +225,6 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
},
do_search: function(domain, context, group_by) {
var self = this;
this.$el.find('.oe_view_nocontent').remove();
this.search_domain = domain;
this.search_context = context;
this.search_group_by = group_by;
@ -238,6 +237,7 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
var grouping_fields = self.group_by ? [self.group_by].concat(_.keys(self.aggregates)) : undefined;
var grouping = new instance.web.Model(self.dataset.model, context, domain).query().group_by(grouping_fields);
return self.alive($.when(grouping)).done(function(groups) {
self.remove_no_result();
if (groups) {
self.do_process_groups(groups);
} else {
@ -248,6 +248,7 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
},
do_process_groups: function(groups) {
var self = this;
this.$el.find('table:first').show();
this.$el.removeClass('oe_kanban_ungrouped').addClass('oe_kanban_grouped');
this.add_group_mutex.exec(function() {
self.do_clear_groups();
@ -256,13 +257,15 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
self.no_result();
return false;
}
self.nb_records = 0;
var remaining = groups.length - 1,
groups_array = [];
return $.when.apply(null, _.map(groups, function (group, index) {
var dataset = new instance.web.DataSetSearch(self, self.dataset.model,
new instance.web.CompoundContext(self.dataset.get_context(), group.model.context()), group.model.domain());
return dataset.read_slice(self.fields_keys.concat(['__last_update']), { 'limit': self.limit })
.then(function(records) {
.then(function (records) {
self.nb_records += records.length;
self.dataset.ids.push.apply(self.dataset.ids, dataset.ids);
groups_array[index] = new instance.web_kanban.KanbanGroup(self, records, group, dataset);
if (!remaining--) {
@ -270,11 +273,16 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
return self.do_add_groups(groups_array);
}
});
}));
})).then(function () {
if(!self.nb_records) {
self.no_result();
}
});
});
},
do_process_dataset: function() {
var self = this;
this.$el.find('table:first').show();
this.$el.removeClass('oe_kanban_grouped').addClass('oe_kanban_ungrouped');
this.add_group_mutex.exec(function() {
var def = $.Deferred();
@ -313,6 +321,9 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
var $last_td = self.$el.find('.oe_kanban_groups_headers td:last');
var groups_started = _.map(this.groups, function(group) {
if (!group.is_started) {
group.on("add_record", self, function () {
self.remove_no_result();
});
return group.insertBefore($last_td);
}
});
@ -445,20 +456,22 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
}
},
no_result: function() {
var self = this;
if (this.groups.group_by
|| !this.options.action
|| !this.options.action.help) {
|| (!this.options.action.help && !this.options.action.get_empty_list_help)) {
return;
}
this.$el.find('.oe_view_nocontent').remove();
this.$el.prepend(
$('<div class="oe_view_nocontent">').html(this.options.action.help)
);
var create_nocontent = this.$buttons;
this.$el.find('table:first').css("position", "absolute");
$(QWeb.render('KanbanView.nocontent', { content : this.options.action.get_empty_list_help || this.options.action.help})).insertAfter(this.$('table:first'));
this.$el.find('.oe_view_nocontent').click(function() {
create_nocontent.openerpBounce();
self.$buttons.openerpBounce();
});
},
remove_no_result: function() {
this.$el.find('table:first').css("position", false);
this.$el.find('.oe_view_nocontent').remove();
},
/*
* postprocessing of fields type many2many
@ -573,19 +586,26 @@ instance.web_kanban.KanbanGroup = instance.web.Widget.extend({
});
this.$el.find('.oe_kanban_add').click(function () {
if (self.quick) {
return self.quick.trigger('close');
if (self.view.quick) {
self.view.quick.trigger('close');
}
if (self.quick) {
return false;
}
self.view.$el.find('.oe_view_nocontent').hide();
var ctx = {};
ctx['default_' + self.view.group_by] = self.value;
self.quick = new (get_class(self.view.quick_create_class))(this, self.dataset, ctx, true)
.on('added', self, self.proxy('quick_created'))
.on('close', self, function() {
self.view.$el.find('.oe_view_nocontent').show();
this.quick.destroy();
delete self.view.quick;
delete this.quick;
});
self.quick.appendTo($(".oe_kanban_group_list_header", self.$records));
self.quick.focus();
self.view.quick = self.quick;
});
// Add bounce effect on image '+' of kanban header when click on empty space of kanban grouped column.
this.$records.on('click', '.oe_kanban_show_more', this.do_show_more);
@ -722,6 +742,8 @@ instance.web_kanban.KanbanGroup = instance.web.Widget.extend({
*/
quick_created: function (record) {
var id = record, self = this;
self.view.remove_no_result();
self.trigger("add_record");
this.dataset.read_ids([id], this.view.fields_keys)
.done(function (records) {
self.view.dataset.ids.push(id);

View File

@ -100,4 +100,12 @@
</div>
</t>
</div>
<t t-name="KanbanView.nocontent">
<div class="oe_view_nocontent">
<div class="oe_view_nocontent_bg"></div>
<div class="oe_view_nocontent_content">
<t t-raw="content"/>
</div>
</div>
</t>
</template>