Merge lp:~openerp-dev/openobject-addons/saas-3-fix-grid-editor-chm into lp:~openerp/openobject-addons/saas-3
- saas-3-fix-grid-editor-chm
- Merge into saas-3
Proposed by
jke-openerp
Status: | Work in progress |
---|---|
Proposed branch: | lp:~openerp-dev/openobject-addons/saas-3-fix-grid-editor-chm |
Merge into: | lp:~openerp/openobject-addons/saas-3 |
Diff against target: |
225 lines (+114/-61) 4 files modified
website_sale/controllers/main.py (+17/-0) website_sale/static/src/js/website_sale.editor.js (+33/-0) website_sale/static/src/xml/website_sale.xml (+60/-0) website_sale/views/website_sale.xml (+4/-61) |
To merge this branch: | bzr merge lp:~openerp-dev/openobject-addons/saas-3-fix-grid-editor-chm |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
OpenERP Core Team | Pending | ||
Review via email:
|
Commit message
Description of the change
To post a comment you must log in.
Unmerged revisions
- 9299. By Christophe Matthieu (OpenERP)
-
[IMP] website_sale: remove grid editor from the xml view to speed up loading (60 lines * number of product less) and avoid wrong change in the xml view
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'website_sale/controllers/main.py' |
2 | --- website_sale/controllers/main.py 2014-03-11 09:30:50 +0000 |
3 | +++ website_sale/controllers/main.py 2014-03-11 14:20:12 +0000 |
4 | @@ -288,6 +288,23 @@ |
5 | } |
6 | return request.website.render("website_sale.products", values) |
7 | |
8 | + @http.route(['/shop/styles/'], type='json', auth="user", website=True, multilang=True) |
9 | + def styles(self): |
10 | + styles = [] |
11 | + try: |
12 | + style_obj = request.registry.get('product.style') |
13 | + style_ids = style_obj.search(request.cr, request.uid, [], context=request.context) |
14 | + styles = style_obj.read(request.cr, request.uid, style_ids, [], context=request.context) |
15 | + except: |
16 | + pass |
17 | + return styles |
18 | + |
19 | + @http.route(['/shop/products/styles/'], type='json', auth="user", website=True) |
20 | + def style_in_product(self, product_ids): |
21 | + product_obj = request.registry.get('product.template') |
22 | + products = product_obj.browse(request.cr, request.uid, product_ids, context=request.context) |
23 | + return dict([(product.id, [s.id for s in product.website_style_ids]) for product in products]) |
24 | + |
25 | @http.route(['/shop/product/<model("product.template"):product>/'], type='http', auth="public", website=True, multilang=True) |
26 | def product(self, product, search='', category='', filters='', **kwargs): |
27 | if category: |
28 | |
29 | === modified file 'website_sale/static/src/js/website_sale.editor.js' |
30 | --- website_sale/static/src/js/website_sale.editor.js 2014-02-06 14:52:36 +0000 |
31 | +++ website_sale/static/src/js/website_sale.editor.js 2014-03-11 14:20:12 +0000 |
32 | @@ -13,6 +13,14 @@ |
33 | this.$(".dropdown:has(.oe_content_menu)").removeClass("hidden"); |
34 | return res; |
35 | }, |
36 | + edit: function () { |
37 | + this.on('rte:ready', this, add_grid_editor); |
38 | + return this._super.apply(this, arguments); |
39 | + }, |
40 | + save: function () { |
41 | + $("#products_grid table td[data-id] .oe_product_cart .css_options").remove(); |
42 | + return this._super(); |
43 | + }, |
44 | events: _.extend({}, website.EditorBar.prototype.events, { |
45 | 'click a[data-action=new_product]': function (ev) { |
46 | ev.preventDefault(); |
47 | @@ -34,6 +42,31 @@ |
48 | location.href = location.href.replace(/(\?|#|$).*/, search + location.hash); |
49 | } |
50 | |
51 | + function add_grid_editor () { |
52 | + var $products = $("#products_grid table td[data-id]"); |
53 | + if ($products.length) { |
54 | + var styles,product_styles; |
55 | + var def1 = openerp.jsonRpc('/shop/styles/', 'call', {}).then(function(data) {styles=data;}); |
56 | + var def2 = openerp.jsonRpc('/shop/products/styles/', 'call', { |
57 | + 'product_ids': $products.map(function () {return $(this).data("id");}).toArray() |
58 | + }).then(function(data) {product_styles=data;}); |
59 | + |
60 | + $.when(def1, def2).then(function () { |
61 | + $products.each(function () { |
62 | + var product = $(this).data(); |
63 | + var template = openerp.qweb.render('website_sale.grid_editor', { |
64 | + "styles": styles, |
65 | + "style_in_product": function (style_id) { |
66 | + return product_styles[product.id].indexOf(style_id) != -1; |
67 | + }, |
68 | + "product": product |
69 | + }); |
70 | + $(".oe_product_cart",this).prepend( template ); |
71 | + }); |
72 | + }); |
73 | + } |
74 | + } |
75 | + |
76 | $(document).on('click', '.js_options .js_go_to_top,.js_options .js_go_to_bottom,.js_options .js_go_up,.js_options .js_go_down', function (event) { |
77 | var $a = $(event.currentTarget); |
78 | var $data = $a.parents(".js_options:first"); |
79 | |
80 | === modified file 'website_sale/static/src/xml/website_sale.xml' |
81 | --- website_sale/static/src/xml/website_sale.xml 2013-11-19 12:26:05 +0000 |
82 | +++ website_sale/static/src/xml/website_sale.xml 2014-03-11 14:20:12 +0000 |
83 | @@ -4,4 +4,64 @@ |
84 | <li><a id="create-new-product" href="#" data-action="new_product">New Product</a></li> |
85 | </t> |
86 | </t> |
87 | +<t t-name="website_sale.grid_editor"> |
88 | + <div class="css_options" contentEditable="false"> |
89 | + <div t-attf-class="dropdown js_options" t-att-data-id="product.id"> |
90 | + <button class="btn btn-default" t-att-id="'dopprod-%s' % product.id" role="button" data-toggle="dropdown">Options <span class="caret"></span></button> |
91 | + <ul class="dropdown-menu" role="menu" t-att-aria-labelledby="'dopprod-%s' % product.id"> |
92 | + <li class='dropdown-submenu'> |
93 | + <a tabindex="-1" href="#">Size</a> |
94 | + <ul class="dropdown-menu" name="size"> |
95 | + <li> |
96 | + <table> |
97 | + <tr> |
98 | + <td class="selected"></td> |
99 | + <td t-att-class="product.website_size_x > 1 and 'selected'"></td> |
100 | + <td t-att-class="product.website_size_x > 2 and 'selected'"></td> |
101 | + <td t-att-class="product.website_size_x > 3 and 'selected'"></td> |
102 | + </tr> |
103 | + <tr> |
104 | + <td t-att-class="product.website_size_y > 1 and 'selected'"></td> |
105 | + <td t-att-class="product.website_size_y > 1 and product.website_size_x > 1 and 'selected'"></td> |
106 | + <td t-att-class="product.website_size_y > 1 and product.website_size_x > 2 and 'selected'"></td> |
107 | + <td t-att-class="product.website_size_y > 1 and product.website_size_x > 3 and 'selected'"></td> |
108 | + </tr> |
109 | + <tr> |
110 | + <td t-att-class="product.website_size_y > 2 and 'selected'"></td> |
111 | + <td t-att-class="product.website_size_y > 2 and product.website_size_x > 1 and 'selected'"></td> |
112 | + <td t-att-class="product.website_size_y > 2 and product.website_size_x > 2 and 'selected'"></td> |
113 | + <td t-att-class="product.website_size_y > 2 and product.website_size_x > 3 and 'selected'"></td> |
114 | + </tr> |
115 | + <tr> |
116 | + <td t-att-class="product.website_size_y > 3 and 'selected'"></td> |
117 | + <td t-att-class="product.website_size_y > 3 and product.website_size_x > 1 and 'selected'"></td> |
118 | + <td t-att-class="product.website_size_y > 3 and product.website_size_x > 2 and 'selected'"></td> |
119 | + <td t-att-class="product.website_size_y > 3 and product.website_size_x > 3 and 'selected'"></td> |
120 | + </tr> |
121 | + </table> |
122 | + </li> |
123 | + </ul> |
124 | + </li> |
125 | + <li class='dropdown-submenu'> |
126 | + <a tabindex="-1" href="#">Styles</a> |
127 | + <ul class="dropdown-menu" name="style"> |
128 | + <t t-foreach="styles" t-as="style"> |
129 | + <li t-att-class="style_in_product(style.id) and 'active' or ''"><a href="#" t-att-data-id="style.id" t-att-data-class="style.html_class"><t t-esc="style.name"/></a></li> |
130 | + </t> |
131 | + </ul> |
132 | + </li> |
133 | + <li class='dropdown-submenu'> |
134 | + <a tabindex="-1" href="#">Promote</a> |
135 | + <ul class="dropdown-menu" name="sequence"> |
136 | + <li><a href="#" class="js_go_to_top">Push to top</a></li> |
137 | + <li><a href="#" class="js_go_up">Push up</a> |
138 | + </li> |
139 | + <li><a href="#" class="js_go_down">Push down</a></li> |
140 | + <li><a href="#" class="js_go_to_bottom">Push to bottom</a></li> |
141 | + </ul> |
142 | + </li> |
143 | + </ul> |
144 | + </div> |
145 | + </div> |
146 | +</t> |
147 | </templates> |
148 | |
149 | === modified file 'website_sale/views/website_sale.xml' |
150 | --- website_sale/views/website_sale.xml 2014-03-11 09:30:50 +0000 |
151 | +++ website_sale/views/website_sale.xml 2014-03-11 14:20:12 +0000 |
152 | @@ -119,69 +119,12 @@ |
153 | <t t-set="product" t-value="td_product['product']"/> |
154 | <td t-att-colspan="td_product['x'] != 1 and td_product['x']" |
155 | t-att-rowspan="td_product['y'] != 1 and td_product['y']" |
156 | - t-attf-class="oe_product oe_grid oe-height-#{td_product['y']*2} #{ td_product['class'] }"> |
157 | + t-attf-class="oe_product oe_grid oe-height-#{td_product['y']*2} #{ td_product['class'] }" |
158 | + t-att-data-website_size_x="product.website_size_x" |
159 | + t-att-data-website_size_y="product.website_size_y" |
160 | + t-att-data-id="product.id"> |
161 | |
162 | <div class="oe_product_cart" t-att-data-publish="product.website_published and 'on' or 'off'"> |
163 | - |
164 | - <div class="css_options" t-ignore="true" groups="base.group_website_publisher"> |
165 | - <div t-attf-class="dropdown js_options" t-att-data-id="product.id"> |
166 | - <button class="btn btn-default" t-att-id="'dopprod-%s' % product.id" role="button" data-toggle="dropdown">Options <span class="caret"></span></button> |
167 | - <ul class="dropdown-menu" role="menu" t-att-aria-labelledby="'dopprod-%s' % product.id"> |
168 | - <li class='dropdown-submenu'> |
169 | - <a tabindex="-1" href="#">Size</a> |
170 | - <ul class="dropdown-menu" name="size"> |
171 | - <li><a href="#"> |
172 | - <table> |
173 | - <tr> |
174 | - <td class="selected"></td> |
175 | - <td t-att-class="product.website_size_x > 1 and 'selected'"></td> |
176 | - <td t-att-class="product.website_size_x > 2 and 'selected'"></td> |
177 | - <td t-att-class="product.website_size_x > 3 and 'selected'"></td> |
178 | - </tr> |
179 | - <tr> |
180 | - <td t-att-class="product.website_size_y > 1 and 'selected'"></td> |
181 | - <td t-att-class="product.website_size_y > 1 and product.website_size_x > 1 and 'selected'"></td> |
182 | - <td t-att-class="product.website_size_y > 1 and product.website_size_x > 2 and 'selected'"></td> |
183 | - <td t-att-class="product.website_size_y > 1 and product.website_size_x > 3 and 'selected'"></td> |
184 | - </tr> |
185 | - <tr> |
186 | - <td t-att-class="product.website_size_y > 2 and 'selected'"></td> |
187 | - <td t-att-class="product.website_size_y > 2 and product.website_size_x > 1 and 'selected'"></td> |
188 | - <td t-att-class="product.website_size_y > 2 and product.website_size_x > 2 and 'selected'"></td> |
189 | - <td t-att-class="product.website_size_y > 2 and product.website_size_x > 3 and 'selected'"></td> |
190 | - </tr> |
191 | - <tr> |
192 | - <td t-att-class="product.website_size_y > 3 and 'selected'"></td> |
193 | - <td t-att-class="product.website_size_y > 3 and product.website_size_x > 1 and 'selected'"></td> |
194 | - <td t-att-class="product.website_size_y > 3 and product.website_size_x > 2 and 'selected'"></td> |
195 | - <td t-att-class="product.website_size_y > 3 and product.website_size_x > 3 and 'selected'"></td> |
196 | - </tr> |
197 | - </table> |
198 | - </a></li> |
199 | - </ul> |
200 | - </li> |
201 | - <li class='dropdown-submenu'> |
202 | - <a tabindex="-1" href="#">Styles</a> |
203 | - <ul class="dropdown-menu" name="style"> |
204 | - <t t-foreach="styles" t-as="style"> |
205 | - <li t-att-class="style_in_product(style, product) and 'active' or ''"><a href="#" t-att-data-id="style.id" t-att-data-class="style.html_class"><t t-esc="style.name"/></a></li> |
206 | - </t> |
207 | - </ul> |
208 | - </li> |
209 | - <li class='dropdown-submenu'> |
210 | - <a tabindex="-1" href="#">Promote</a> |
211 | - <ul class="dropdown-menu" name="sequence"> |
212 | - <li><a href="#" class="js_go_to_top">Push to top</a></li> |
213 | - <li><a href="#" class="js_go_up">Push up</a> |
214 | - </li> |
215 | - <li><a href="#" class="js_go_down">Push down</a></li> |
216 | - <li><a href="#" class="js_go_to_bottom">Push to bottom</a></li> |
217 | - </ul> |
218 | - </li> |
219 | - </ul> |
220 | - </div> |
221 | - </div> |
222 | - |
223 | <t t-set="product_image_big" t-value="td_product['x']+td_product['y'] > 2"/> |
224 | <t t-call="website_sale.products_cart"/> |
225 | </div> |