Skip to content

Commit

Permalink
Further cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
bartTC committed Jun 21, 2019
1 parent fc64d32 commit 9b30524
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
31 changes: 19 additions & 12 deletions dynamic_raw_id/static/dynamic_raw_id/js/dynamic_raw_id.js
Original file line number Diff line number Diff line change
@@ -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);
Expand Down Expand Up @@ -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
Expand All @@ -87,6 +93,7 @@ function dismissRelatedLookupPopup(win, chosenId) {

// Set the focus into the input field
$(this).parent().find('input').focus();

return false;
});

Expand Down
4 changes: 1 addition & 3 deletions dynamic_raw_id/tests/test_selenium.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down

0 comments on commit 9b30524

Please sign in to comment.