From patchwork Wed Jul 28 18:17:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raxel Gutierrez X-Patchwork-Id: 1510949 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20161025 header.b=CNf/gFc2; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GZhjB4j0Fz9sXN for ; Thu, 29 Jul 2021 04:17:50 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4GZhjB3RnRz3bYb for ; Thu, 29 Jul 2021 04:17:50 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20161025 header.b=CNf/gFc2; dkim-atps=neutral X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=flex--raxel.bounces.google.com (client-ip=2607:f8b0:4864:20::84a; helo=mail-qt1-x84a.google.com; envelope-from=3oj8byqukcys6pct0v33v0t.r314p8rwb36z0x787.3e0pq7.36v@flex--raxel.bounces.google.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20161025 header.b=CNf/gFc2; dkim-atps=neutral Received: from mail-qt1-x84a.google.com (mail-qt1-x84a.google.com [IPv6:2607:f8b0:4864:20::84a]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4GZhhq2ndWz30GK for ; Thu, 29 Jul 2021 04:17:31 +1000 (AEST) Received: by mail-qt1-x84a.google.com with SMTP id k2-20020ac847820000b029024ea3acef5bso1457516qtq.12 for ; Wed, 28 Jul 2021 11:17:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=rSmTKtiBn0wNLNJ5tPe46wTBq2mIxSz/uNZGFkZ/nUg=; b=CNf/gFc2seThdXkFUGx2hW/7Wo9PB8XV4mV4HWoLkrpK7m8nJ7wK9hJDNzNCtqgKba PZx6kZ35LVK5qnNRx+J6vzi3Q55P5/aW9zeNqXZJ6qWP+E0I4Qp7goCxZ9yI+/yFohuo zp1gT3NEkZAkAmOzbL+C+GXxakf5k3QTLNWjnobnD5gB2GgFwQF4pcSMugHWfaLf/XY1 Z+ixgIqHHyBoTVIYfNGYEekOaj/HKicHtY6VY6D7ElJzqdN9jxFGJgtuD/y00kn9wrxl NvSFOCOpfixxaNCZ9yg4+cD9QQCfRAeRNMr6YGPHP6BKsN2mznnLIuVYtQ3AAORD1gzF gsHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=rSmTKtiBn0wNLNJ5tPe46wTBq2mIxSz/uNZGFkZ/nUg=; b=uW+fBRLgl2aobSSrthuKMw0t9ONQVWtFjk48ijW9nJZNCMxMcZrW1NWpISv4Ot7F6z uwmnm25q/RfbMWU/5uao7Ye94aFSdLuAZudI2s03KzxG1gP7TeRYRuEjQnh9LMvxqgx1 kN9YRzbrw262gRIGLQe64rA8690e8psMNCRl56JohXC7/thcriYqrm0a1DwgoytrCvos 8HNCowkzTmu5c5RgRjiS+FpeFi/R/iGBYjrFT/d9mmkqnDR/eKcwvMRzWBPouC7RuKIi Ouige/3D1MMeO8p0kd7xBVOnl4HV6uDuIV4eaEWAw0ss3UAxnJmEgi7H5kte0a4/VQO7 gyOw== X-Gm-Message-State: AOAM530ijGPNwywd6N1DRF/MM4Vaj3/+FkxH8usuDGpJAtLEve9f8Yem zTu6QZcsb3ZvYgs7JWk5pJiOnDxZ4wBVTLmcKdu1Dbu8EPTyqkPWkEajfN5fpQ/yQcynNxcSBbA ftorzzUyqVkKxwlVxIxiQlJej5U2YoVi8WXIibR/gjgWIkPA6oyZF2PCxhaO8qKbS X-Google-Smtp-Source: ABdhPJylAuuFBK5QZT8dIGuh0jr+t4JtQesKE8FGimInePDPx7ZAJ48PFPTiTtmRDjM+bu5TpsdUfOtm9w== X-Received: from raxel-pw.c.googlers.com ([fda3:e722:ac3:cc00:14:4d90:c0a8:2fda]) (user=raxel job=sendgmr) by 2002:a0c:f084:: with SMTP id g4mr1354857qvk.52.1627496248716; Wed, 28 Jul 2021 11:17:28 -0700 (PDT) Date: Wed, 28 Jul 2021 18:17:17 +0000 In-Reply-To: <20210728181718.3613124-1-raxel@google.com> Message-Id: <20210728181718.3613124-5-raxel@google.com> Mime-Version: 1.0 References: <20210728181718.3613124-1-raxel@google.com> X-Mailer: git-send-email 2.32.0.554.ge1b32706d8-goog Subject: [PATCH v2 4/5] patch-detail: add functionality for comment status updates From: Raxel Gutierrez To: patchwork@lists.ozlabs.org X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" Use new comment detail REST API endpoint to update the addressed field value when "Addressed" or "Unaddressed" buttons are clicked. After, the request is made, the appearance of the comment status label and buttons are toggled appropriately. Signed-off-by: Raxel Gutierrez --- htdocs/css/style.css | 15 ++++- htdocs/js/submission.js | 52 ++++++++++++++++ patchwork/templates/patchwork/submission.html | 61 ++++++------------- templates/base.html | 2 +- 4 files changed, 85 insertions(+), 45 deletions(-) create mode 100644 htdocs/js/submission.js diff --git a/htdocs/css/style.css b/htdocs/css/style.css index ff34ff5..2a5c81f 100644 --- a/htdocs/css/style.css +++ b/htdocs/css/style.css @@ -27,6 +27,10 @@ pre { top: 17em; } +.hidden { + visibility: hidden; +} + /* Bootstrap overrides */ .navbar-inverse .navbar-brand > a { @@ -306,7 +310,7 @@ table.patchmeta tr th, table.patchmeta tr td { font-family: "DejaVu Sans Mono", fixed; } -#comment-status-bar { +div[id^="comment-status-bar-"] { display: flex; flex-wrap: wrap; align-items: center; @@ -316,7 +320,7 @@ table.patchmeta tr th, table.patchmeta tr td { margin: 0px 8px; } -#comment-action-addressed, #comment-action-unaddressed { +button[id^=comment-action] { background-color: var(--light-color); border-radius: 4px; } @@ -329,11 +333,16 @@ table.patchmeta tr th, table.patchmeta tr td { border-color: var(--warning-color); } -#comment-action-addressed:hover, #comment-action-unaddressed:hover { +#comment-action-addressed:hover { background-color: var(--success-color); color: var(--light-color); } +#comment-action-unaddressed:hover { + background-color: var(--warning-color); + color: var(--light-color); +} + .quote { color: #007f00; } diff --git a/htdocs/js/submission.js b/htdocs/js/submission.js new file mode 100644 index 0000000..8894890 --- /dev/null +++ b/htdocs/js/submission.js @@ -0,0 +1,52 @@ +import { updateProperty } from "./rest.js"; + +$( document ).ready(function() { + function toggleDiv(link_id, headers_id, label_show, label_hide) { + const link = document.getElementById(link_id) + const headers = document.getElementById(headers_id) + + const hidden = headers.style['display'] == 'none'; + + if (hidden) { + link.innerHTML = label_hide || 'hide'; + headers.style['display'] = 'block'; + } else { + link.innerHTML = label_show || 'show'; + headers.style['display'] = 'none'; + } + } + + $("button[id^='comment-action']").click((event) => { + const patchId = document.getElementById("patch").dataset.patchId; + const commentId = event.target.parentElement.dataset.commentId; + const url = "/api/patches/" + patchId + "/comments/" + commentId + "/"; + const data = {'addressed': event.target.value} ; + const updateMessage = { + 'none': "No comments updated", + 'some': "1 comment updated", + }; + updateProperty(url, data, updateMessage); + $("div[id^='comment-status-bar-'][data-comment-id='"+commentId+"']").toggleClass("hidden"); + }); + + // Click listener to show/hide headers + document.getElementById("toggle-patch-headers").addEventListener("click", function() { + toggleDiv("toggle-patch-headers", "patch-headers"); + }); + + // Click listener to expand/collapse series + document.getElementById("toggle-patch-series").addEventListener("click", function() { + toggleDiv("toggle-patch-series", "patch-series", "expand", "collapse"); + }); + + // Click listener to show/hide related patches + document.getElementById("toggle-related").addEventListener("click", function() { + toggleDiv("toggle-related", "related"); + }); + + // Click listener to show/hide related patches from different projects + document.getElementById("toggle-related-outside").addEventListener("click", function() { + toggleDiv("toggle-related-outside", "related-outside", "show from other projects"); + }); + +}); \ No newline at end of file diff --git a/patchwork/templates/patchwork/submission.html b/patchwork/templates/patchwork/submission.html index 4109442..e3a8909 100644 --- a/patchwork/templates/patchwork/submission.html +++ b/patchwork/templates/patchwork/submission.html @@ -5,29 +5,15 @@ {% load syntax %} {% load person %} {% load patch %} +{% load static %} + +{% block headers %} + +{% endblock %} {% block title %}{{submission.name}}{% endblock %} {% block body %} - -
{% include "patchwork/partials/download-buttons.html" %}

{{ submission.name }}

@@ -63,10 +49,7 @@ function toggle_div(link_id, headers_id, label_show, label_hide) Headers - + @@ -79,10 +62,7 @@ function toggle_div(link_id, headers_id, label_show, label_hide) {{ submission.series.name }} - +