frayerjj-frontend 0.8.35 → 0.8.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/hasMany.js +9 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "frayerjj-frontend",
3
- "version": "0.8.35",
3
+ "version": "0.8.36",
4
4
  "description": "My base frontend for various projects",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
package/src/hasMany.js CHANGED
@@ -40,15 +40,15 @@ export const hasMany = {
40
40
  if (args.notb)
41
41
  modalList.insertAdjacentHTML('beforeend', hasMany.build.checkItem(args.name, {
42
42
  id: 'notb',
43
- label: (args.notbLabel ?? hasMany.sampleArgs.messages.notbLabel),
43
+ label: (args.messages?.notbLabel ?? hasMany.sampleArgs.messages.notbLabel),
44
44
  notb: true
45
45
  }));
46
46
  // Cycle through all options
47
- Objects.values(args.options).forEach(option => {
47
+ Object.values(args.options).forEach(option => {
48
48
  modalList.insertAdjacentHTML('beforeend', hasMany.build.checkItem(args.name, option));
49
49
  // If option is selected, add to list
50
50
  if (option.checked)
51
- list.insertAdjacentHTML('beforeend', hasMany.build.item(args.name, option));
51
+ list.insertAdjacentHTML('beforeend', hasMany.build.listItem(args.name, option));
52
52
  });
53
53
  // Create modal
54
54
  let randomId = modal.randomId('hasmany');
@@ -56,7 +56,7 @@ export const hasMany = {
56
56
  id: randomId,
57
57
  title: args.title,
58
58
  body: modalList.outerHTML,
59
- buttons: [ { text: args.messages.close ?? hasMany.sampleArgs.messages.close } ]
59
+ buttons: [ { text: args.messages?.close ?? hasMany.sampleArgs.messages.close } ]
60
60
  }));
61
61
  // Create button to open modal
62
62
  let button = document.createElement('button');
@@ -64,7 +64,7 @@ export const hasMany = {
64
64
  button.className = 'btn btn-outline-secondary btn-block';
65
65
  button.setAttribute('data-bs-toggle', 'modal');
66
66
  button.setAttribute('data-bs-target', '#' + randomId);
67
- button.textContent = args.messages.button ?? hasMany.sampleArgs.messages.button;
67
+ button.textContent = args.messages?.button ?? hasMany.sampleArgs.messages.button;
68
68
  // Add elements to container
69
69
  container.appendChild(input);
70
70
  container.appendChild(list);
@@ -125,7 +125,7 @@ export const hasMany = {
125
125
  input.addEventListener('change', ev => {
126
126
  if (ev.target.checked) {
127
127
  // Add item to list
128
- document.querySelector('#id_' + args.name).insertAdjacentHTML('beforeend', hasMany.build.item(args.name, {
128
+ document.querySelector('#id_' + args.name).insertAdjacentHTML('beforeend', hasMany.build.listItem(args.name, {
129
129
  id: ev.target.value,
130
130
  label: ev.target.nextElementSibling.textContent
131
131
  }));
@@ -140,13 +140,14 @@ export const hasMany = {
140
140
  // Add event listener for None of the Below
141
141
  if (args.notb)
142
142
  document.querySelector('.hasmany-' + args.name + 'notb').addEventListener('change', ev => {
143
- if (ev.target.checked)
143
+ if (ev.target.checked) {
144
144
  // Uncheck all other items
145
- document.querySelectorAll('hasmany-' + args.name).forEach(input => {
145
+ document.querySelectorAll('.hasmany-' + args.name).forEach(input => {
146
146
  input.checked = false;
147
147
  });
148
148
  // Remove all items from list
149
149
  document.querySelector('#id_' + args.name).innerHTML = '';
150
+ }
150
151
  });
151
152
  });
152
153
  }