UNPKG

product-admin

Version:

EA admin screens

63 lines (57 loc) 1.77 kB
<link rel="import" href="../admin-shared-styles/admin-shared-styles.html" /> <link rel="import" href="../bms-behaviors-util/bms-behaviors-util.html" /> <dom-module id="product-table-check"> <template> <style include="admin-shared-styles"></style> <iron-ajax id="updateProductsRequest" method="PUT" headers='{"accept": "application/json", "timeout": 120000, "Cache-Control": "no-cache"}' content-type="application/json" handle-as="json" ></iron-ajax> <paper-checkbox checked$="{{isActive}}" on-change="checkboxChanged"></paper-checkbox> </template> </div> </template> <script> (function(util) { return Polymer({ is: 'product-table-check', behaviors: [ Polymer.AppLocalizeBehavior, bms.behaviors.util ], properties: { product: { type: Object, value: {} }, isActive: { type: Boolean, }, updateProductsUrl: { type: String }, }, observers: [ 'productUpdated(product.active)' ], productUpdated: function (activeValue) { if (!activeValue) return; this.isActive = JSON.parse(activeValue); }, checkboxChanged: function(event) { this.set('product.active', (this.product.active === 'true') ? 'false' : 'true'); this.updateProductRequest(); }, updateProductRequest: function(active){ let theReq = this.$.updateProductsRequest; theReq.url = [util.properties.BASE_PATH.value, "updateProduct", this.product.pk].join("/"); theReq.body = this.product; theReq.generateRequest(); } }); })(bms.behaviors.util); </script> </dom-module>