[MERGE] [ADD] kanban_state_selection widget, allowing to manage kanban_state-like selection fields using bullet + dropdown; priority widget allowing to manage priorities using stars.
bzr revid: tde@openerp.com-20140508160156-b2jekyiajkjp7bse
This commit is contained in:
commit
b4aa0eb76f
|
@ -1,4 +1,4 @@
|
|||
@charset "UTF-8";
|
||||
@charset "utf-8";
|
||||
@font-face {
|
||||
font-family: "mnmliconsRegular";
|
||||
src: url("/web/static/src/font/mnmliconsv21-webfont.eot") format("eot");
|
||||
|
@ -426,7 +426,7 @@
|
|||
text-shadow: 0 0 2px black;
|
||||
vertical-align: top;
|
||||
position: relative;
|
||||
top: -5px;
|
||||
top: -8px;
|
||||
}
|
||||
.openerp .oe_webclient .oe_star_on:hover, .openerp .oe_webclient .oe_star_off:hover {
|
||||
text-decoration: none;
|
||||
|
@ -449,6 +449,51 @@
|
|||
border-style: inset;
|
||||
border-width: 1px;
|
||||
}
|
||||
.openerp .oe_kanban_status {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
height: 12px;
|
||||
width: 12px;
|
||||
-moz-border-radius: 6px;
|
||||
-webkit-border-radius: 6px;
|
||||
border-radius: 6px;
|
||||
background-position: center center;
|
||||
background-image: -webkit-radial-gradient(circle, #eeeeee 0%, #cccccc 40%, #bbbbbb 100%);
|
||||
background-image: -moz-radial-gradient(#eeeeee 0%, #cccccc 40%, #bbbbbb 100%);
|
||||
background-image: -ms-radial-gradient(#eeeeee 0%, #cccccc 40%, #bbbbbb 100%);
|
||||
background-image: radial-gradient(#eeeeee 0%, #cccccc 40%, #bbbbbb 100%);
|
||||
}
|
||||
.openerp .oe_kanban_status_green {
|
||||
background: green;
|
||||
background-position: center center;
|
||||
background-image: -webkit-radial-gradient(circle, #55dd55 0%, #44aa44 40%, #339933 100%);
|
||||
background-image: -moz-radial-gradient(#55dd55 0%, #44aa44 40%, #339933 100%);
|
||||
background-image: -ms-radial-gradient(#55dd55 0%, #44aa44 40%, #339933 100%);
|
||||
background-image: radial-gradient(#55dd55 0%, #44aa44 40%, #339933 100%);
|
||||
}
|
||||
.openerp .oe_kanban_status_red {
|
||||
background: red;
|
||||
background-position: center center;
|
||||
background-image: -webkit-radial-gradient(circle, #ee7777 0%, #cc3333 40%, #bb0808 100%);
|
||||
background-image: -moz-radial-gradient(#ee7777 0%, #cc3333 40%, #bb0808 100%);
|
||||
background-image: -ms-radial-gradient(#ee7777 0%, #cc3333 40%, #bb0808 100%);
|
||||
background-image: radial-gradient(#ee7777 0%, #cc3333 40%, #bb0808 100%);
|
||||
}
|
||||
.openerp .btn-group.kanban_state {
|
||||
padding-top: 8px;
|
||||
margin-right: 4px !important;
|
||||
}
|
||||
.openerp .btn-group.kanban_state .dropdown-menu {
|
||||
min-width: 100%;
|
||||
padding-right: 10px !important;
|
||||
}
|
||||
.openerp .btn-group.kanban_state .dropdown-menu li a, .openerp .btn-group.kanban_state .dropdown-menu li a:hover, .openerp .btn-group.kanban_state .dropdown-menu li a:focus {
|
||||
padding-left: 5px;
|
||||
padding-right: 0px;
|
||||
}
|
||||
.openerp .btn-group.kanban_state a {
|
||||
color: #333333;
|
||||
}
|
||||
.openerp .oe_tag {
|
||||
border: 1px solid #afafb6;
|
||||
font-size: 11px;
|
||||
|
@ -777,7 +822,7 @@
|
|||
background-image: -moz-linear-gradient(top, #fc8787, maroon);
|
||||
background-image: -ms-linear-gradient(top, #fc8787, maroon);
|
||||
background-image: -o-linear-gradient(top, #fc8787, maroon);
|
||||
background-image: linear-gradient(to bottom, #fc8787, #800000);
|
||||
background-image: linear-gradient(to bottom, #fc8787, maroon);
|
||||
}
|
||||
.openerp .navbar .oe_topbar_anonymous_login a {
|
||||
display: block;
|
||||
|
|
|
@ -404,7 +404,7 @@ $sheet-padding: 16px
|
|||
text-shadow: 0 0 2px black
|
||||
vertical-align: top
|
||||
position: relative
|
||||
top: -5px
|
||||
top: -8px
|
||||
.oe_star_on:hover, .oe_star_off:hover
|
||||
text-decoration: none
|
||||
.oe_star_on
|
||||
|
@ -424,7 +424,33 @@ $sheet-padding: 16px
|
|||
border-style: inset
|
||||
border-width: 1px
|
||||
// }}}
|
||||
|
||||
// Kanban state (used in form and kanban) {{{
|
||||
.oe_kanban_status
|
||||
position: relative
|
||||
display: inline-block
|
||||
height: 12px
|
||||
width: 12px
|
||||
@include radius(6px)
|
||||
@include radial-gradient((#eee 0%, #ccc 40%, #bbb 100%))
|
||||
// +background-image(radial-gradient(45px 45px, #0ff 10px, #1e90ff 30px))
|
||||
.oe_kanban_status_green
|
||||
background: green
|
||||
@include radial-gradient((#55dd55 0%, #44aa44 40%, #339933 100%))
|
||||
.oe_kanban_status_red
|
||||
background: red
|
||||
@include radial-gradient((#ee7777 0%, #cc3333 40%, #bb0808 100%))
|
||||
.btn-group.kanban_state
|
||||
padding-top: 8px
|
||||
margin-right: 4px !important
|
||||
.dropdown-menu
|
||||
min-width: 100%
|
||||
padding-right: 10px !important
|
||||
.dropdown-menu li a, .dropdown-menu li a:hover, .dropdown-menu li a:focus
|
||||
padding-left: 5px
|
||||
padding-right: 0px
|
||||
a
|
||||
color: #333333
|
||||
// }}}
|
||||
// Tags (for many2many tags, among others) {{{
|
||||
.oe_tag
|
||||
border: 1px solid $tag-border
|
||||
|
@ -2752,5 +2778,6 @@ input[type="radio"], input[type="checkbox"]
|
|||
background-color: black
|
||||
opacity: 0.6000000238418579
|
||||
|
||||
|
||||
// au BufWritePost,FileWritePost *.sass :!sass --style expanded --line-numbers <afile> > "%:p:r.css"
|
||||
// vim:tabstop=4:shiftwidth=4:softtabstop=4:fdm=marker:
|
||||
|
|
|
@ -2365,6 +2365,106 @@ instance.web.form.FieldChar = instance.web.form.AbstractField.extend(instance.we
|
|||
}
|
||||
});
|
||||
|
||||
instance.web.form.KanbanSelection = instance.web.form.FieldChar.extend({
|
||||
init: function (field_manager, node) {
|
||||
this._super(field_manager, node);
|
||||
},
|
||||
prepare_dropdown_selection: function() {
|
||||
var self = this;
|
||||
var data = [];
|
||||
var selection = self.field.selection || [];
|
||||
_.map(selection, function(res) {
|
||||
var value = {
|
||||
'name': res[0],
|
||||
'tooltip': res[1],
|
||||
'state_name': res[1],
|
||||
}
|
||||
if (res[0] == 'normal') { value['state_class'] = 'oe_kanban_status'; }
|
||||
else if (res[0] == 'done') { value['state_class'] = 'oe_kanban_status oe_kanban_status_green'; }
|
||||
else { value['state_class'] = 'oe_kanban_status oe_kanban_status_red'; }
|
||||
data.push(value);
|
||||
});
|
||||
return data;
|
||||
},
|
||||
render_value: function() {
|
||||
var self = this;
|
||||
this.record_id = self.view.datarecord.id;
|
||||
this.states = self.prepare_dropdown_selection();;
|
||||
this.$el.html(QWeb.render("KanbanSelection", {'widget': self}));
|
||||
this.$el.find('.oe_legend').click(self.do_action.bind(self));
|
||||
},
|
||||
do_action: function(e) {
|
||||
var self = this;
|
||||
var li = $(e.target).closest( "li" );
|
||||
if (li.length) {
|
||||
var value = {};
|
||||
value[self.name] = String(li.data('value'));
|
||||
if (self.record_id) {
|
||||
return self.view.dataset._model.call('write', [[self.record_id], value, self.view.dataset.get_context()]).done(self.reload_record.bind(self));
|
||||
} else {
|
||||
return self.view.on_button_save().done(function(result) {
|
||||
if (result) {
|
||||
self.view.dataset._model.call('write', [[result], value, self.view.dataset.get_context()]).done(self.reload_record.bind(self));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
reload_record: function() {
|
||||
this.view.reload();
|
||||
},
|
||||
});
|
||||
|
||||
instance.web.form.Priority = instance.web.form.FieldChar.extend({
|
||||
init: function (field_manager, node) {
|
||||
this._super(field_manager, node);
|
||||
},
|
||||
prepare_priority: function() {
|
||||
var self = this;
|
||||
var selection = this.field.selection || [];
|
||||
var init_value = selection && selection[0][0] || 0;
|
||||
var data = _.map(selection.slice(1), function(element, index) {
|
||||
var value = {
|
||||
'value': element[0],
|
||||
'name': element[1],
|
||||
'click_value': element[0],
|
||||
}
|
||||
if (index == 0 && self.get('value') == element[0]) {
|
||||
value['click_value'] = init_value;
|
||||
}
|
||||
return value;
|
||||
});
|
||||
return data;
|
||||
},
|
||||
render_value: function() {
|
||||
var self = this;
|
||||
this.record_id = self.view.datarecord.id;
|
||||
this.priorities = self.prepare_priority();
|
||||
this.$el.html(QWeb.render("Priority", {'widget': this}));
|
||||
this.$el.find('.oe_legend').click(self.do_action.bind(self));
|
||||
},
|
||||
do_action: function(e) {
|
||||
var self = this;
|
||||
var li = $(e.target).closest( "li" );
|
||||
if (li.length) {
|
||||
var value = {};
|
||||
value[self.name] = String(li.data('value'));
|
||||
if (self.record_id) {
|
||||
return self.view.dataset._model.call('write', [[self.record_id], value, self.view.dataset.get_context()]).done(self.reload_record.bind(self));
|
||||
} else {
|
||||
return self.view.on_button_save().done(function(result) {
|
||||
if (result) {
|
||||
self.view.dataset._model.call('write', [[result], value, self.view.dataset.get_context()]).done(self.reload_record.bind(self));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
reload_record: function() {
|
||||
this.view.reload();
|
||||
},
|
||||
});
|
||||
|
||||
instance.web.form.FieldID = instance.web.form.FieldChar.extend({
|
||||
process_modifiers: function () {
|
||||
this._super();
|
||||
|
@ -6115,6 +6215,8 @@ instance.web.form.widgets = new instance.web.Registry({
|
|||
'monetary': 'instance.web.form.FieldMonetary',
|
||||
'many2many_checkboxes': 'instance.web.form.FieldMany2ManyCheckBoxes',
|
||||
'x2many_counter': 'instance.web.form.X2ManyCounter',
|
||||
'priority':'instance.web.form.Priority',
|
||||
'kanban_state_selection':'instance.web.form.KanbanSelection',
|
||||
'statinfo': 'instance.web.form.StatInfo',
|
||||
});
|
||||
|
||||
|
|
|
@ -1029,6 +1029,39 @@
|
|||
</t>
|
||||
</span>
|
||||
</t>
|
||||
<t t-name="KanbanSelection">
|
||||
<div class="btn-group kanban_state">
|
||||
<t t-foreach="widget.states" t-as="rec">
|
||||
<a t-if="widget.get('value') === rec.name">
|
||||
<a class="oe_legend dropdown-toggle" data-toggle="dropdown">
|
||||
<span t-att-class="rec.state_class" t-if="widget.get('value') === rec.name" t-att-title="rec.tooltip"/>
|
||||
<span class="sr-only">Toggle Dropdown</span>
|
||||
</a>
|
||||
</a>
|
||||
</t>
|
||||
<ul class="dropdown-menu state" role="menu">
|
||||
<t t-foreach="widget.states" t-as="rec">
|
||||
<t t-if="widget.get('value') !== rec.name">
|
||||
<li class="oe_legend" t-att-data-value="rec.name" ><a href="#">
|
||||
<span t-att-class="rec.state_class" t-att-title="rec.tooltip"/>
|
||||
<t t-raw="rec.state_name" /></a>
|
||||
</li>
|
||||
</t>
|
||||
</t>
|
||||
</ul>
|
||||
</div>
|
||||
</t>
|
||||
<t t-name="Priority">
|
||||
<ul style="list-style: none; padding-left: 2px; display: inline-block;">
|
||||
<t t-foreach="widget.priorities" t-as="rec" >
|
||||
<li t-att-data-value="rec.click_value" class="oe_legend" style="display: inline-block;">
|
||||
<a href="#" t-att-title="rec.name">
|
||||
<span t-att-class="widget.get('value') gte rec.value and 'oe_e oe_star_on' or 'oe_e oe_star_off'">7</span>
|
||||
</a>
|
||||
</li>
|
||||
</t>
|
||||
</ul>
|
||||
</t>
|
||||
<t t-name="FieldEmail">
|
||||
<span class="oe_form_field oe_form_field_email" t-att-style="widget.node.attrs.style">
|
||||
<a t-if="widget.get('effective_readonly')" href="#" class="oe_form_uri" target="_blank"/>
|
||||
|
|
|
@ -9,8 +9,6 @@
|
|||
.openerp .oe_kanban_view .oe_view_nocontent {
|
||||
position: relative;
|
||||
max-width: none;
|
||||
z-index: 1;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
.openerp .oe_kanban_view .oe_view_nocontent .oe_view_nocontent_content {
|
||||
|
@ -77,7 +75,7 @@
|
|||
text-shadow: 0 0 2px black;
|
||||
vertical-align: top;
|
||||
position: relative;
|
||||
top: -5px;
|
||||
top: -8px;
|
||||
}
|
||||
.openerp .oe_kanban_view .oe_kanban_content .oe_star_on:hover, .openerp .oe_kanban_view .oe_kanban_content .oe_star_off:hover {
|
||||
text-decoration: none;
|
||||
|
@ -165,9 +163,6 @@
|
|||
.openerp .oe_kanban_view .oe_kanban_column, .openerp .oe_kanban_view .oe_kanban_column_cards {
|
||||
height: 100%;
|
||||
}
|
||||
.openerp .oe_kanban_view .oe_kanban_column, .openerp .oe_kanban_view .oe_kanban_column_cards {
|
||||
height: 100%;
|
||||
}
|
||||
.openerp .oe_kanban_view .oe_kanban_aggregates {
|
||||
padding: 0;
|
||||
margin: 0px;
|
||||
|
@ -522,37 +517,6 @@
|
|||
position: relative;
|
||||
top: 2px;
|
||||
}
|
||||
.openerp .oe_kanban_view .oe_kanban_status {
|
||||
position: relative;
|
||||
top: 4px;
|
||||
display: inline-block;
|
||||
height: 12px;
|
||||
width: 12px;
|
||||
-moz-border-radius: 6px;
|
||||
-webkit-border-radius: 6px;
|
||||
border-radius: 6px;
|
||||
background-position: center center;
|
||||
background-image: -webkit-radial-gradient(circle, #eeeeee 0%, #cccccc 40%, #bbbbbb 100%);
|
||||
background-image: -moz-radial-gradient(#eeeeee 0%, #cccccc 40%, #bbbbbb 100%);
|
||||
background-image: -ms-radial-gradient(#eeeeee 0%, #cccccc 40%, #bbbbbb 100%);
|
||||
background-image: radial-gradient(#eeeeee 0%, #cccccc 40%, #bbbbbb 100%);
|
||||
}
|
||||
.openerp .oe_kanban_view .oe_kanban_status_green {
|
||||
background: green;
|
||||
background-position: center center;
|
||||
background-image: -webkit-radial-gradient(circle, #55dd55 0%, #44aa44 40%, #339933 100%);
|
||||
background-image: -moz-radial-gradient(#55dd55 0%, #44aa44 40%, #339933 100%);
|
||||
background-image: -ms-radial-gradient(#55dd55 0%, #44aa44 40%, #339933 100%);
|
||||
background-image: radial-gradient(#55dd55 0%, #44aa44 40%, #339933 100%);
|
||||
}
|
||||
.openerp .oe_kanban_view .oe_kanban_status_red {
|
||||
background: red;
|
||||
background-position: center center;
|
||||
background-image: -webkit-radial-gradient(circle, #ee7777 0%, #cc3333 40%, #bb0808 100%);
|
||||
background-image: -moz-radial-gradient(#ee7777 0%, #cc3333 40%, #bb0808 100%);
|
||||
background-image: -ms-radial-gradient(#ee7777 0%, #cc3333 40%, #bb0808 100%);
|
||||
background-image: radial-gradient(#ee7777 0%, #cc3333 40%, #bb0808 100%);
|
||||
}
|
||||
.openerp .oe_kanban_view .oe_kanban_text_red {
|
||||
color: #a61300;
|
||||
font-weight: bold;
|
||||
|
|
|
@ -105,7 +105,7 @@
|
|||
text-shadow: 0 0 2px black
|
||||
vertical-align: top
|
||||
position: relative
|
||||
top: -5px
|
||||
top: -8px
|
||||
&:hover
|
||||
text-decoration: none
|
||||
.oe_star_on
|
||||
|
@ -454,20 +454,6 @@
|
|||
position: relative
|
||||
top: 2px
|
||||
|
||||
.oe_kanban_status
|
||||
position: relative
|
||||
top: 4px
|
||||
display: inline-block
|
||||
height: 12px
|
||||
width: 12px
|
||||
@include radius(6px)
|
||||
@include radial-gradient((#eee 0%, #ccc 40%, #bbb 100%))
|
||||
.oe_kanban_status_green
|
||||
background: green
|
||||
@include radial-gradient((#55dd55 0%, #44aa44 40%, #339933 100%))
|
||||
.oe_kanban_status_red
|
||||
background: red
|
||||
@include radial-gradient((#ee7777 0%, #cc3333 40%, #bb0808 100%))
|
||||
.oe_kanban_text_red
|
||||
color: #A61300
|
||||
font-weight: bold
|
||||
|
|
|
@ -1259,7 +1259,95 @@ instance.web_kanban.AbstractField = instance.web.Widget.extend(instance.web_kanb
|
|||
},
|
||||
});
|
||||
|
||||
instance.web_kanban.Priority = instance.web_kanban.AbstractField.extend({
|
||||
init: function(parent, field, $node) {
|
||||
this._super.apply(this, arguments);
|
||||
this.name = $node.attr('name')
|
||||
this.parent = parent;
|
||||
},
|
||||
prepare_priority: function() {
|
||||
var self = this;
|
||||
var selection = this.field.selection || [];
|
||||
var init_value = selection && selection[0][0] || 0;
|
||||
var data = _.map(selection.slice(1), function(element, index) {
|
||||
var value = {
|
||||
'value': element[0],
|
||||
'name': element[1],
|
||||
'click_value': element[0],
|
||||
}
|
||||
if (index == 0 && self.get('value') == element[0]) {
|
||||
value['click_value'] = init_value;
|
||||
}
|
||||
return value;
|
||||
});
|
||||
return data;
|
||||
},
|
||||
renderElement: function() {
|
||||
var self = this;
|
||||
this.record_id = self.parent.id;
|
||||
this.priorities = self.prepare_priority();
|
||||
this.$el = $(QWeb.render("Priority", {'widget': this}));
|
||||
this.$el.find('.oe_legend').click(self.do_action.bind(self));
|
||||
},
|
||||
do_action: function(e) {
|
||||
var self = this;
|
||||
var li = $(e.target).closest( "li" );
|
||||
if (li.length) {
|
||||
var value = {};
|
||||
value[self.name] = String(li.data('value'));
|
||||
return self.parent.view.dataset._model.call('write', [[self.record_id], value, self.parent.view.dataset.get_context()]).done(self.reload_record.bind(self.parent));
|
||||
}
|
||||
},
|
||||
reload_record: function() {
|
||||
this.do_reload();
|
||||
},
|
||||
});
|
||||
|
||||
instance.web_kanban.KanbanSelection = instance.web_kanban.AbstractField.extend({
|
||||
init: function(parent, field, $node) {
|
||||
this._super.apply(this, arguments);
|
||||
this.name = $node.attr('name')
|
||||
this.parent = parent;
|
||||
},
|
||||
prepare_dropdown_selection: function() {
|
||||
var data = [];
|
||||
_.map(this.field.selection || [], function(res) {
|
||||
var value = {
|
||||
'name': res[0],
|
||||
'tooltip': res[1],
|
||||
'state_name': res[1],
|
||||
}
|
||||
if (res[0] == 'normal') { value['state_class'] = 'oe_kanban_status'; }
|
||||
else if (res[0] == 'done') { value['state_class'] = 'oe_kanban_status oe_kanban_status_green'; }
|
||||
else { value['state_class'] = 'oe_kanban_status oe_kanban_status_red'; }
|
||||
data.push(value);
|
||||
});
|
||||
return data;
|
||||
},
|
||||
renderElement: function() {
|
||||
var self = this;
|
||||
this.record_id = self.parent.id;
|
||||
this.states = self.prepare_dropdown_selection();;
|
||||
this.$el = $(QWeb.render("KanbanSelection", {'widget': self}));
|
||||
this.$el.find('.oe_legend').click(self.do_action.bind(self));
|
||||
},
|
||||
do_action: function(e) {
|
||||
var self = this;
|
||||
var li = $(e.target).closest( "li" );
|
||||
if (li.length) {
|
||||
var value = {};
|
||||
value[self.name] = String(li.data('value'));
|
||||
return self.parent.view.dataset._model.call('write', [[self.record_id], value, self.parent.view.dataset.get_context()]).done(self.reload_record.bind(self.parent));
|
||||
}
|
||||
},
|
||||
reload_record: function() {
|
||||
this.do_reload();
|
||||
},
|
||||
});
|
||||
|
||||
instance.web_kanban.fields_registry = new instance.web.Registry({});
|
||||
instance.web_kanban.fields_registry.add('priority','instance.web_kanban.Priority');
|
||||
instance.web_kanban.fields_registry.add('kanban_state_selection','instance.web_kanban.KanbanSelection');
|
||||
};
|
||||
|
||||
// vim:et fdc=0 fdl=0 foldnestmax=3 fdm=syntax:
|
||||
|
|
Loading…
Reference in New Issue