From nobody Tue Apr 23 23:27:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=patchew-devel-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1556795905; cv=none; d=zoho.com; s=zohoarc; b=LrUWdGaK+XUW2wBPuefeanar96CM33g1W+y3EQVnOiH9qvt7AXxjKAsw/HXG8VUzhHAGZBtHRwmzIRp6ZVvn7e3tSnhOb/1qBBBVzMRcG392pd8+Q3upLwz3j/8eMZzCZqBwO6JXhBfkPioncWBAAMpy4YOKmGXgQOpyOxGtTyQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556795905; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=5Jg/vbXcr8dIMm8GGNPm/U8SzYetWAQvGGjMP9G0naI=; b=Zewsq2OujCqyen8QQKjSW9PGSgpBAYL4gq4HgyT4gQgaSwJZ5lr5ObCcYAb34sMlydCkFamW/qck/M87Ahdgz6men+C7+511JISwyke4SqvJekEOM0ComBn8oDZumfNYNJUP+P5IWhAPA97jdVZ9tM71/PJluHNnKRcAtx4L43k= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1556795905936862.8681776678409; Thu, 2 May 2019 04:18:25 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AE9A1302451A; Thu, 2 May 2019 11:18:24 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A3BDC827A8; Thu, 2 May 2019 11:18:24 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 99EFC18089CC; Thu, 2 May 2019 11:18:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x42BIL2k009057 for ; Thu, 2 May 2019 07:18:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id 54E1CA219; Thu, 2 May 2019 11:18:21 +0000 (UTC) Received: from mx1.redhat.com (ext-mx03.extmail.prod.ext.phx2.redhat.com [10.5.110.27]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4EEF1A21F for ; Thu, 2 May 2019 11:18:21 +0000 (UTC) Received: from mail-ot1-f41.google.com (mail-ot1-f41.google.com [209.85.210.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1D1D789C3A for ; Thu, 2 May 2019 11:18:14 +0000 (UTC) Received: by mail-ot1-f41.google.com with SMTP id r20so1692385otg.4 for ; Thu, 02 May 2019 04:18:14 -0700 (PDT) Received: from localhost.localdomain ([198.59.53.9]) by smtp.gmail.com with ESMTPSA id o1sm19095697otj.11.2019.05.02.04.18.12 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 May 2019 04:18:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=36aB5P9HxJ/7MADVgpJ8Bp+y5C1TPiEUdyHkO5Ze7nc=; b=uMqhgYwmMPYfQTT2ZSXi+V7NKpNowObIJNU7cPn1KBgA6oCypPEFnirNKOA9QVQUbj vcBZcS9nuXIsiuxf4NiBOXTYlncJp1t6CksqUXXKLOVTFpajJgtK7nEHUslaJcn1X3pe zABK03WIiVi1CQ0yCm9OrjsVYOSjxoe/o9FcIg9gDde4nm5pXA+BQlULjZ+NAMquQ/02 cKevuPQACkMQ4TduuijDvknOASLHYnmfIVTFJFh08MND+jPkg7q8lWY5CbebieT0yW3b VHA9PnQNgN3awY8j6FCm251TEM9BV0o/iUGganpM9asqby2HyXjAYcu3DoGm8qmVpICL nxwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=36aB5P9HxJ/7MADVgpJ8Bp+y5C1TPiEUdyHkO5Ze7nc=; b=PNN6ujpfZM4JeCiyoBg/Z/bmbxOEmpfoqAEmufolKfTFCZdTYfP/JSMQJbvv6VxC7W /TAyKq1yWJE72/oopXS/5EZTPK7Oc9cYksueCGBATbKNdiKoj0hrFTCwd9zN9OxDmvad ITIzriFwJ7mlSufa2XG1VZ8mK9UdB3peubwRhYyNhqcheLfxS6EGfSG18BcTA/OmEyTA u5wTAoy1dVzogBEQuy1M5ykiXcqsEMgHuAZHhpagITjU4P+nU1ANY9UPxZNESr1H/x8K /16PF2Eshqyh/yU4T96gg2JVBk9Fib+os8fZ26T9tzfohpi4D4UrFkqkgu6KRvPNl/Yy XGNw== X-Gm-Message-State: APjAAAUUmWk++bfmVbjZl35lBU9undzrmk34oi3yzw5V1YWMvjVBGepU Plf4xo1KQO9MiRNX0K0yVjK651JfJPQ= X-Google-Smtp-Source: APXvYqzCtiMKWH37lDGO9civirCKrwLZbPusWnNGrAL06LxRLiEmFpWRhEyg6zxaxH/Fan4/Rylvmw== X-Received: by 2002:a9d:ed2:: with SMTP id 76mr1981730otj.327.1556795893285; Thu, 02 May 2019 04:18:13 -0700 (PDT) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Thu, 2 May 2019 05:17:56 -0600 Message-Id: <20190502111804.15843-10-pbonzini@redhat.com> In-Reply-To: <20190502111804.15843-1-pbonzini@redhat.com> References: <20190502111804.15843-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 02 May 2019 11:18:14 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 02 May 2019 11:18:14 +0000 (UTC) for IP:'209.85.210.41' DOMAIN:'mail-ot1-f41.google.com' HELO:'mail-ot1-f41.google.com' FROM:'paolo.bonzini@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.126 (DKIM_SIGNED, DKIM_VALID, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, SPF_PASS) 209.85.210.41 mail-ot1-f41.google.com 209.85.210.41 mail-ot1-f41.google.com X-RedHat-Possible-Forgery: Paolo Bonzini X-Scanned-By: MIMEDefang 2.78 on 10.5.110.27 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: patchew-devel@redhat.com Subject: [Patchew-devel] [PATCH 09/17] mods: place a single Save button at the end of the forms X-BeenThere: patchew-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Patchew development and discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: patchew-devel-bounces@redhat.com Errors-To: patchew-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Thu, 02 May 2019 11:18:24 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Because the save button now acts on the whole config, we cannot anymore rely on finding the property prefix from the save button's parents. Instead, each property control has a data-property-path attribute and building the configuration dictionary is as simple as looking all of them up. Likewise, each map item has a data-property-prefix attribute which simplifies deletion and is also used to build the data-property-path when a new map item is added. --- mod.py | 25 +++++++------------------ static/js/config-editor.js | 30 ++++++++++++++++++------------ www/templates/project-detail.html | 7 +++++++ 3 files changed, 32 insertions(+), 30 deletions(-) diff --git a/mod.py b/mod.py index 4cf2e9f..1b7910c 100644 --- a/mod.py +++ b/mod.py @@ -67,15 +67,9 @@ class PatchewModule(object): members =3D [self._build_one(request, project, prefix + "." + x.name, config.get(x.name), x) for x in scm.mem= bers] - show_save_button =3D False - for m in scm.members: - if type(m) =3D=3D StringSchema: - show_save_button =3D True - break return self._render_template(request, project, TMPL_ARRAY, schema=3Dscm, members=3Dmembers, - show_save_button=3Dshow_save_button, prefix=3Dprefix) =20 def _build_string_scm(self, request, project, prefix, config, scm): @@ -206,6 +200,7 @@ TMPL_STRING =3D """ {% for schema in members %} {{ schema }} {% endfor %} -{% if show_save_button %} -
- -
-{% endif %} """ =20 TMPL_MAP_ITEM =3D """ -
-
+
+
{{ item_schema.title }} {{ item.name }} -
{{ item.html }} @@ -321,7 +310,7 @@ TMPL_MAP_ITEM =3D """ """ =20 TMPL_MAP =3D """ -
+
diff --git a/static/js/config-editor.js b/static/js/config-editor.js index 56d0781..f15211f 100644 --- a/static/js/config-editor.js +++ b/static/js/config-editor.js @@ -17,9 +17,9 @@ function save_done(btn, succeeded, error) { } =20 function collect_properties(btn, check_required) { - prefix =3D $(btn).parent().parent().find(".property-prefix").val(); properties =3D {}; $(btn).parent().parent().find(".project-property").each(function () { + path =3D $(this).data('property-path'); if (check_required && this.required && !this.value) { alert($(this).parent().find("label").html() + " is required!"); $(this).focus(); @@ -43,7 +43,7 @@ function collect_properties(btn, check_required) { } else { val =3D this.value; } - properties[prefix + this.name] =3D val; + properties[path] =3D val; }); return properties; } @@ -80,6 +80,7 @@ function map_add_item(btn) { if (!name || name =3D=3D 'null') { return; } + container =3D $(btn).parent().parent(); if (name in collect_items(btn)) { alert(test_name + " already exists."); return; @@ -88,17 +89,23 @@ function map_add_item(btn) { alert("Invalid name, no dot is allowed."); return; } - container =3D $(btn).parent().parent(); tmpl =3D container.find(".item-template").html(); - nt =3D $(tmpl) - nt.find(".item-name").html(name); - old =3D nt.find(".property-prefix").val(); - nt.find(".property-prefix").val(old + name + "."); - container.find(".items").append(nt); + nt =3D $(tmpl); + nt.find(".item-name").text(name); + prefix =3D nt.data('property-prefix') + '.' + name; + nt.data('property-prefix', prefix); + nt.find(".project-property").each(function() { + old =3D $(this).data('property-path'); + $(this).data('property-path', prefix + old); + }); + nt.find(".panel-collapse").collapse("show"); + container.find("> .items").append(nt); } + function map_delete_item(btn) { - name =3D $(btn).parent().parent().parent().find(".item-name").html(); - prefix =3D $(btn).parent().parent().parent().find(".prefix").val(); + item =3D $(btn).parent().parent().parent(); + name =3D item.find(".item-name").text(); + prefix =3D item.data('property-prefix') + "."; if (!window.confirm("Really delete '" + name +"'?")) { return; } @@ -109,8 +116,7 @@ function map_delete_item(btn) { { project: current_project(), prefix: prefix }) .done(function (data) { - container =3D $(btn).parent().parent().parent(); - container.remove(); + item.remove(); }) .fail(function (data, text, error) { $(btn).removeClass("disabled"); diff --git a/www/templates/project-detail.html b/www/templates/project-deta= il.html index adf90a3..5895314 100644 --- a/www/templates/project-detail.html +++ b/www/templates/project-detail.html @@ -78,6 +78,13 @@
{% endfor %} + {% if request.user.is_authenticated %} +
+ +
+ {% endif %}
=20