From 2dcdc64f5088bb9fcaaf22004a66a2cf85f7b108 Mon Sep 17 00:00:00 2001 From: Chris Lawton <chris.lawton@torchbox.com> Date: Wed, 15 May 2019 12:23:04 +0100 Subject: [PATCH] don't duplicate markup --- .../activity/templates/activity/include/listing_base.html | 6 +++--- opentech/static_src/src/javascript/apply/edit-comment.js | 8 ++------ 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/opentech/apply/activity/templates/activity/include/listing_base.html b/opentech/apply/activity/templates/activity/include/listing_base.html index 8f13bc06b..95352d4d9 100644 --- a/opentech/apply/activity/templates/activity/include/listing_base.html +++ b/opentech/apply/activity/templates/activity/include/listing_base.html @@ -17,9 +17,9 @@ </a> </p> {% endif %} - {% if activity.edited %} - <p class="feed__meta-item feed__meta-item--last-edited">(Last edited: <span class="js-last-edited">{{ activity.edited|date:"Y-m-d H:i" }}</span>)</p> - {% endif %} + <p class="feed__meta-item feed__meta-item--last-edited" {% if not activity.edited %} hidden {% endif %}> + (Last edited: <span class="js-last-edited">{{ activity.edited|date:"Y-m-d H:i" }}</span>) + </p> {% endif %} {% if activity.private %} diff --git a/opentech/static_src/src/javascript/apply/edit-comment.js b/opentech/static_src/src/javascript/apply/edit-comment.js index e9a83be63..3b7c3d88d 100644 --- a/opentech/static_src/src/javascript/apply/edit-comment.js +++ b/opentech/static_src/src/javascript/apply/edit-comment.js @@ -123,12 +123,8 @@ const updateLastEdited = (el, date) => { const parsedDate = new Date(date).toISOString().split('T')[0]; const time = new Date(date).toLocaleTimeString([], {hour: '2-digit', minute: '2-digit'}); - if ($(el).closest(feedContent).find(lastEdited).length) { - $(el).closest(feedContent).find(lastEdited).html(`${parsedDate} ${time}`); - } - else { - $(`<p class="feed__meta-item feed__meta-item--last-edited">(Last edited: <span class="js-last-edited">${parsedDate} ${time}</span>)</p>`).insertAfter($(el).closest(feedContent).find(editButton).parent()); - } + $(el).closest(feedContent).find(lastEdited).parent().attr('hidden', false); + $(el).closest(feedContent).find(lastEdited).html(`${parsedDate} ${time}`); }; const updateComment = (el, id, comment, editUrl, commentMarkdown) => { -- GitLab