Issues (87)

tcms/testcases/static/testcases/js/mutable.js (1 issue)

Labels
Severity
1
$(document).ready(function () {
2
  $('#text_templates').change(function () {
3
    markdownEditor.codemirror.setValue($(this).val())
0 ignored issues
show
The variable markdownEditor seems to be never declared. If this is a global, consider adding a /** global: markdownEditor */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
4
  })
5
6
  if ($('#id_category').find('option').length === 0) {
7
    populateProductCategory()
8
  }
9
10
  $('#add_id_product').click(function () {
11
    return showRelatedObjectPopup(this)
12
  })
13
14
  $('#add_id_category').click(function () {
15
    return showRelatedObjectPopup(this)
16
  })
17
18
  document.getElementById('id_product').onchange = function () {
19
    $('#id_product').selectpicker('refresh')
20
    populateProductCategory()
21
  }
22
23
  document.getElementById('id_category').onchange = function () {
24
    $('#id_category').selectpicker('refresh')
25
  }
26
27
  $('.selectpicker').selectpicker()
28
  $('.bootstrap-switch').bootstrapSwitch()
29
})
30
31
function populateProductCategory () {
32
  const productId = $('#id_product').val()
33
34
  if (productId === null) {
35
    $('#add_id_category').addClass('disabled')
36
  } else {
37
    $('#add_id_category').removeClass('disabled')
38
  }
39
40
  const href = $('#add_id_category')[0].href
41
  $('#add_id_category')[0].href = href.slice(0, href.indexOf('&product'))
42
  $('#add_id_category')[0].href += `&product=${productId}`
43
  $('#id_category').find('option').remove()
44
  updateCategorySelectFromProduct()
45
}
46