• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pulibrary / tigerdata-app / fc2633c4-cc7b-4bea-9c64-e1529c22d576

24 Jun 2025 06:44PM UTC coverage: 72.09% (-0.02%) from 72.107%
fc2633c4-cc7b-4bea-9c64-e1529c22d576

Pull #1564

circleci

hectorcorrea
Prettier
Pull Request #1564: Adds a test for the remove department functionality

4 of 18 branches covered (22.22%)

0 of 1 new or added line in 1 file covered. (0.0%)

2991 of 4149 relevant lines covered (72.09%)

487.61 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/app/javascript/entrypoints/departmentAutocomplete.js
1
function removeDepartment(event) {
×
2
  const li = event.currentTarget.parentElement;
×
3
  li.remove();
×
4
}
×
5

6
function registerRemove() {
×
7
  $('.remove-department').on('input', (event) => {
×
8
    removeDepartment(event);
×
9
  });
×
10

11
  $('.remove-department').keyup((event) => {
×
12
    if (event.keyCode === 13) removeDepartment(event);
×
13
  });
×
14

15
  $('.remove-user-role').click((event) => {
×
16
    removeDepartment(event);
×
17
  });
×
18
}
×
19

20
function addNewDepartment(value, dataValue) {
×
21
  const ul = document.querySelector('.selected-departments');
×
22
  const li = document.createElement('li');
×
23
  li.classList.add('selected-item');
×
24
  li.appendChild(document.createTextNode(value));
×
25
  const newDiv = document.createElement('div');
×
26
  newDiv.classList.add('remove-department');
×
27
  newDiv.classList.add('remove-item');
×
28
  newDiv.focus = true;
×
29
  newDiv.tabIndex = 0;
×
NEW
30
  newDiv.title = 'Remove department';
×
31
  li.appendChild(newDiv);
×
32
  const input = document.createElement('input');
×
33
  input.type = 'hidden';
×
34
  input.value = JSON.stringify(dataValue);
×
35
  input.name = 'request[departments][]';
×
36
  li.appendChild(input);
×
37
  ul.appendChild(li);
×
38
  registerRemove();
×
39
}
×
40

41
// eslint-disable-next-line import/prefer-default-export
×
42
export function departmentAutocomplete() {
×
43
  $('#department_find').on('input', (event) => {
×
44
    const current = event.currentTarget;
×
45
    const { value } = current;
×
46

47
    // We add a non-breaking back space to each option to see when a option has been entered into the text input as
×
48
    //  no user would type a   into the input.  When the HTML5 option is selected we can see clearly that it has;
×
49
    //  This solution was grabbed from https://stackoverflow.com/a/74598110/16862920
×
50
    if (value.slice(-1) === '\xa0') {
×
51
      const cleanValue = value.slice(0, -1);
×
52
      addNewDepartment(
×
53
        cleanValue,
×
54
        $(`#princeton_departments [value="${value}"]`).data('value'),
×
55
      );
×
56
      current.value = '';
×
57
    }
×
58
  });
×
59

60
  registerRemove();
×
61
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc