Merge lp:~jfb-tempo-consulting/unifield-web/us-4198 into lp:unifield-web

Proposed by jftempo
Status: Merged
Merged at revision: 4918
Proposed branch: lp:~jfb-tempo-consulting/unifield-web/us-4198
Merge into: lp:unifield-web
Diff against target: 170 lines (+89/-11)
3 files modified
addons/openerp/static/css/screen.css (+26/-0)
addons/openerp/static/javascript/form.js (+46/-2)
addons/openerp/static/javascript/listgrid.js (+17/-9)
To merge this branch: bzr merge lp:~jfb-tempo-consulting/unifield-web/us-4198
Reviewer Review Type Date Requested Status
UniField Dev Team Pending
Review via email: mp+345732@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'addons/openerp/static/css/screen.css'
2--- addons/openerp/static/css/screen.css 2017-09-20 15:17:48 +0000
3+++ addons/openerp/static/css/screen.css 2018-05-17 08:40:34 +0000
4@@ -2023,6 +2023,32 @@
5 text-shadow: #fff 0 1px 0;
6 }
7
8+#contextmenu ul,#contextmenu form {
9+ list-style: none;
10+ margin: 6px 5px 6px 10px;
11+ padding: 0;
12+}
13+
14+#contextmenu li,#contextmenu label {
15+ margin: 0 0 5px;
16+ color: #5b5b5b;
17+}
18+
19+#contextmenu .sideheader-a {
20+ position: relative;
21+ padding-right: 2px;
22+ border-top: 0px;
23+ border-bottom: 0px;
24+ background: url();
25+}
26+
27+#contextmenu .sideheader-a h2 {
28+ text-shadow: none;
29+ color: #FFF;
30+ border-bottom: 1px solid #FFF;
31+ font-size: 10px;
32+}
33+
34 #sidebar label {
35 margin: 5px 0 0;
36 }
37
38=== modified file 'addons/openerp/static/javascript/form.js'
39--- addons/openerp/static/javascript/form.js 2018-03-02 14:45:07 +0000
40+++ addons/openerp/static/javascript/form.js 2018-05-17 08:40:34 +0000
41@@ -1172,6 +1172,23 @@
42 });
43 }
44
45+function makeListContextMenu(rec_id, init_value){
46+ sd = $('#sidebar');
47+
48+ var $menu = jQuery('#contextmenu');
49+ $menu.attr('rec_id', rec_id);
50+ $menu.attr('init_value', init_value);
51+ $menu.empty().append(
52+ jQuery('<table cellpadding="0" cellspacing="0">').append(sd.html()));
53+
54+ var menu_width = $menu.width();
55+ var body_width = jQuery(document.body).width();
56+ if (parseInt($menu.css("left")) + menu_width > body_width) {
57+ $menu.css({left: body_width - menu_width - 10 + 'px'});
58+ }
59+ showContextMenu();
60+}
61+
62 function showContextMenu(){
63 var $menu = jQuery('#contextmenu');
64 var $ifrm = jQuery('#contextmenu_frm');
65@@ -1189,6 +1206,11 @@
66
67 function hideContextMenu(){
68 jQuery('#contextmenu, #contextmenu_frm').hide();
69+ ctx = jQuery('#contextmenu')
70+ if (ctx.attr('init_value') == 'false') {
71+ new ListView('_terp_list').onBooleanClicked(true, ctx.attr('rec_id'), true);
72+ jQuery('#_terp_list\\/'+ctx.attr('rec_id'))[0].checked = false;
73+ }
74 }
75
76 function set_to_default(field_id, model){
77@@ -1362,8 +1384,26 @@
78 var $target = jQuery(target || targetDammit(evt));
79
80 var kind = $target.attr('kind');
81+ sidebar = false;
82 if (!(kind && $target.is(':input, :enabled'))) {
83- return;
84+ if (!$target.parents('#_terp_list').length) {
85+ return;
86+ }
87+ grid = $target.parents('.grid-row')
88+ if (!grid.length || !grid.attr('record')) {
89+ return;
90+ }
91+ tick_box = grid.find('#_terp_list\\/'+grid.attr('record'))
92+ if (!tick_box.length || tick_box.disabled) {
93+ return;
94+ }
95+ sidebar = true;
96+ checked = true;
97+ if (!tick_box[0].checked) {
98+ new ListView('_terp_list').onBooleanClicked(false, grid.attr('record'), true)
99+ tick_box[0].checked=true;
100+ checked = false;
101+ }
102 }
103 var $menu = jQuery('#contextmenu').show();
104
105@@ -1390,8 +1430,12 @@
106 $menu.offset({top: 0, left: 0});
107 $menu.offset({top: click_position.y - 5, left: click_position.x - 5});
108 $menu.hide();
109- makeContextMenu(src, kind, $src.attr('relation'), $src.val(), $src.attr('hide_default_menu'));
110
111+ if (sidebar) {
112+ makeListContextMenu(grid.attr('record'), checked);
113+ } else {
114+ makeContextMenu(src, kind, $src.attr('relation'), $src.val(), $src.attr('hide_default_menu'));
115+ }
116 stopEventDammit(evt);
117 }
118
119
120=== modified file 'addons/openerp/static/javascript/listgrid.js'
121--- addons/openerp/static/javascript/listgrid.js 2018-03-02 16:02:21 +0000
122+++ addons/openerp/static/javascript/listgrid.js 2018-05-17 08:40:34 +0000
123@@ -67,7 +67,11 @@
124 if (previous_field) {
125 sel = previous_field.val() || "";
126 if (!sel) {return []};
127- return sel.split(',').map(function(b) {return parseInt(b, 10)});
128+ var listids = sel.split(',').map(function(b) {return parseInt(b, 10)});
129+ if ($('#contextmenu').is(':visible')) {
130+ return listids.reverse();
131+ }
132+ return listids
133 }
134 return [];
135 },
136@@ -198,23 +202,27 @@
137 },
138
139 onBooleanClicked: function() {
140- if (arguments.length == 2) {
141+ var nosidebar = false;
142+ if (arguments.length >= 2) {
143 var clicked = !arguments[0];
144 var id = arguments[1];
145+ nosidebar = arguments[2];
146 if (clicked) {
147 this.add_previously_selected(id);
148 } else {
149 this.remove_previously_selected(id);
150 }
151 }
152- var $sidebar = jQuery('.toggle-sidebar');
153- if ($sidebar.is('.closed')) {
154- $sidebar.click()
155- }
156- if(!this.getSelectedRecords().length) {
157- $sidebar.click();
158- }
159
160+ if (!nosidebar) {
161+ var $sidebar = jQuery('.toggle-sidebar');
162+ if ($sidebar.is('.closed')) {
163+ $sidebar.click()
164+ }
165+ if(!this.getSelectedRecords().length) {
166+ $sidebar.click();
167+ }
168+ }
169 this.selectedRow_sum();
170 },
171

Subscribers

People subscribed via source and target branches