web mailing list archives

web@odoo-community.org

Avatar

Re: [OCA/web] [ADD] web_widget_switchcase (#1064)

by Simone Orsi <notifications@github.com> - 10/10/2018 14:07:24

@simahawk requested changes on this pull request.


In web_widget_char_switchcase/__manifest__.py:

> @@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+# Copyright 2018 Simone Rubino - Agile Business Group
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
+{
+    "name": "Web Char Switchcase Widget",
+    "version": "10.0.1.0.0",
+    "author": "Agile Business Group, "
+              "Odoo Community Association (OCA)",
+    "license": "AGPL-3",
+    "category": "Web",
+    "website": "https://github.com/OCA/web/tree/"

https://github.com/OCA/web is enough (and you won't have to update the URL)


In web_widget_char_switchcase/static/src/js/web_widget_char_switchcase.js:

> +        init: function (field_manager, node) {
+            this._super(field_manager, node);
+            this.options = _.defaults(this.options, {
+                transform: this.transformations[0]
+            });
+            this.current_transformation = this.options['transform'];
+            if (!_.contains(this.transformations, this.current_transformation))
+                console.error(this.current_transformation + ' case unknown');
+        },
+        initialize_content: function() {
+            var res = this._super();
+            var self = this;
+            if(this.$input) {
+                this.$input.keyup(function(){
+                    var old_val = self.$input.val();
+                    var new_val = self.transform(old_val);

I'd set a transform_handler at init, so that you won't have to switch at each char typed


You are receiving this because you are on a team that was mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.