From 9b30524bc0691987fe067f102baab2624366ca4c Mon Sep 17 00:00:00 2001 From: Martin Mahner Date: Fri, 21 Jun 2019 14:29:14 +0200 Subject: [PATCH] Further cleanup. --- .../dynamic_raw_id/js/dynamic_raw_id.js | 31 ++++++++++++------- dynamic_raw_id/tests/test_selenium.py | 4 +-- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/dynamic_raw_id/static/dynamic_raw_id/js/dynamic_raw_id.js b/dynamic_raw_id/static/dynamic_raw_id/js/dynamic_raw_id.js index e081a5e..74398a6 100644 --- a/dynamic_raw_id/static/dynamic_raw_id/js/dynamic_raw_id.js +++ b/dynamic_raw_id/static/dynamic_raw_id/js/dynamic_raw_id.js @@ -1,6 +1,10 @@ -// Overwrite Django's `dismissRelatedLookupPopup` to trigger a change event -// on the value change, so dynamic_raw_id can catch it and update the associated -// label. +/* global django, console */ + +/** + * Overwrite Django's `dismissRelatedLookupPopup` to trigger + * a change event on the value change, so dynamic_raw_id can + * catch it and update the associated label. + */ function dismissRelatedLookupPopup(win, chosenId) { const name = windowname_to_id(win.name); const elem = document.getElementById(name); @@ -69,15 +73,17 @@ function dismissRelatedLookupPopup(win, chosenId) { // Clear both the input field and the labels $('.dynamic_raw_id-clear-field').click(function(e) { - var $this = $(this); - $this.parent() - .find('.vForeignKeyRawIdAdminField, .vManyToManyRawIdAdminField') - .val('') - .trigger('change'); - - $this.parent() - .find('.dynamic_raw_id_label') - .html(' '); + const $this = $(this); + $this + .parent() + .find('.vForeignKeyRawIdAdminField, .vManyToManyRawIdAdminField') + .val('') + .trigger('change'); + + $this + .parent() + .find('.dynamic_raw_id_label') + .html(' '); }); // Open up the pop up window and set the focus in the input field @@ -87,6 +93,7 @@ function dismissRelatedLookupPopup(win, chosenId) { // Set the focus into the input field $(this).parent().find('input').focus(); + return false; }); diff --git a/dynamic_raw_id/tests/test_selenium.py b/dynamic_raw_id/tests/test_selenium.py index 9d2d274..7b1a51b 100644 --- a/dynamic_raw_id/tests/test_selenium.py +++ b/dynamic_raw_id/tests/test_selenium.py @@ -1,13 +1,11 @@ from __future__ import unicode_literals import time -from logging import getLogger -from unittest import skipIf -import django from django.contrib.auth.models import User from django.contrib.staticfiles.testing import StaticLiveServerTestCase from django.urls import reverse +from logging import getLogger from dynamic_raw_id.tests.testapp.models import ( CharPrimaryKeyModel,