frayerjj-frontend 0.8.35 → 0.8.37
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.
- package/package.json +1 -1
- package/src/hasMany.js +27 -16
- package/src/scss/_tokenfield.scss +26 -0
package/package.json
CHANGED
package/src/hasMany.js
CHANGED
|
@@ -25,13 +25,17 @@ export const hasMany = {
|
|
|
25
25
|
msg.verbose('Building Has Many Inupt');
|
|
26
26
|
// Create container
|
|
27
27
|
let container = document.createElement('div');
|
|
28
|
+
container.className = 'hasmany';
|
|
29
|
+
// Create card wrapper
|
|
30
|
+
let card = document.createElement('div');
|
|
31
|
+
card.className = 'card';
|
|
28
32
|
// Create list of selected items
|
|
29
33
|
let list = document.createElement('ul');
|
|
30
34
|
list.id = 'id_' + args.name;
|
|
31
|
-
list.className = 'list-group list-group-flush';
|
|
35
|
+
list.className = 'list-group list-group-flush hasmany-selected-list';
|
|
32
36
|
// Create list of all options for modal
|
|
33
37
|
let modalList = document.createElement('ul');
|
|
34
|
-
modalList.className = 'list-group list-group-flush';
|
|
38
|
+
modalList.className = 'list-group list-group-flush hasmany-modal-list';
|
|
35
39
|
// Create hidden input for when there is no selected items
|
|
36
40
|
let input = document.createElement('input');
|
|
37
41
|
input.type = 'hidden';
|
|
@@ -40,15 +44,15 @@ export const hasMany = {
|
|
|
40
44
|
if (args.notb)
|
|
41
45
|
modalList.insertAdjacentHTML('beforeend', hasMany.build.checkItem(args.name, {
|
|
42
46
|
id: 'notb',
|
|
43
|
-
label: (args.notbLabel ?? hasMany.sampleArgs.messages.notbLabel),
|
|
47
|
+
label: (args.messages?.notbLabel ?? hasMany.sampleArgs.messages.notbLabel),
|
|
44
48
|
notb: true
|
|
45
49
|
}));
|
|
46
50
|
// Cycle through all options
|
|
47
|
-
|
|
51
|
+
Object.values(args.options).forEach(option => {
|
|
48
52
|
modalList.insertAdjacentHTML('beforeend', hasMany.build.checkItem(args.name, option));
|
|
49
53
|
// If option is selected, add to list
|
|
50
54
|
if (option.checked)
|
|
51
|
-
list.insertAdjacentHTML('beforeend', hasMany.build.
|
|
55
|
+
list.insertAdjacentHTML('beforeend', hasMany.build.listItem(args.name, option));
|
|
52
56
|
});
|
|
53
57
|
// Create modal
|
|
54
58
|
let randomId = modal.randomId('hasmany');
|
|
@@ -56,19 +60,24 @@ export const hasMany = {
|
|
|
56
60
|
id: randomId,
|
|
57
61
|
title: args.title,
|
|
58
62
|
body: modalList.outerHTML,
|
|
59
|
-
buttons: [ { text: args.messages
|
|
63
|
+
buttons: [ { text: args.messages?.close ?? hasMany.sampleArgs.messages.close } ]
|
|
60
64
|
}));
|
|
61
65
|
// Create button to open modal
|
|
62
66
|
let button = document.createElement('button');
|
|
63
67
|
button.type = 'button';
|
|
64
|
-
button.className = 'btn btn-outline-secondary
|
|
68
|
+
button.className = 'btn btn-outline-secondary w-100';
|
|
65
69
|
button.setAttribute('data-bs-toggle', 'modal');
|
|
66
70
|
button.setAttribute('data-bs-target', '#' + randomId);
|
|
67
|
-
button.textContent = args.messages
|
|
71
|
+
button.textContent = args.messages?.button ?? hasMany.sampleArgs.messages.button;
|
|
72
|
+
// Create card footer for action button
|
|
73
|
+
let footer = document.createElement('div');
|
|
74
|
+
footer.className = 'card-footer bg-transparent';
|
|
75
|
+
footer.appendChild(button);
|
|
68
76
|
// Add elements to container
|
|
69
77
|
container.appendChild(input);
|
|
70
|
-
|
|
71
|
-
|
|
78
|
+
card.appendChild(list);
|
|
79
|
+
card.appendChild(footer);
|
|
80
|
+
container.appendChild(card);
|
|
72
81
|
// Return container
|
|
73
82
|
return container.outerHTML;
|
|
74
83
|
},
|
|
@@ -76,10 +85,10 @@ export const hasMany = {
|
|
|
76
85
|
checkItem: (name, option) => {
|
|
77
86
|
// Create list item
|
|
78
87
|
let item = document.createElement('li');
|
|
79
|
-
item.className = 'list-group-item';
|
|
88
|
+
item.className = 'list-group-item hasmany-check-item';
|
|
80
89
|
// Create checkbox
|
|
81
90
|
let input = document.createElement('input');
|
|
82
|
-
input.classList.add('form-check-input');
|
|
91
|
+
input.classList.add('form-check-input', 'mt-0');
|
|
83
92
|
if (option.notb)
|
|
84
93
|
input.classList.add('hasmany-' + name + 'notb');
|
|
85
94
|
else
|
|
@@ -92,6 +101,7 @@ export const hasMany = {
|
|
|
92
101
|
item.appendChild(input);
|
|
93
102
|
// Create label
|
|
94
103
|
let label = document.createElement('label');
|
|
104
|
+
label.className = 'form-check-label ms-2 flex-grow-1';
|
|
95
105
|
label.setAttribute('for', name + option.id);
|
|
96
106
|
label.textContent = option.label;
|
|
97
107
|
item.appendChild(label);
|
|
@@ -103,7 +113,7 @@ export const hasMany = {
|
|
|
103
113
|
let item = document.createElement('li');
|
|
104
114
|
item.id = 'id_' + name + '_' + option.id;
|
|
105
115
|
item.textContent = option.label;
|
|
106
|
-
item.className = 'list-group-item';
|
|
116
|
+
item.className = 'list-group-item hasmany-selected-item';
|
|
107
117
|
// Create hidden input
|
|
108
118
|
let input = document.createElement('input');
|
|
109
119
|
input.type = 'hidden';
|
|
@@ -125,7 +135,7 @@ export const hasMany = {
|
|
|
125
135
|
input.addEventListener('change', ev => {
|
|
126
136
|
if (ev.target.checked) {
|
|
127
137
|
// Add item to list
|
|
128
|
-
document.querySelector('#id_' + args.name).insertAdjacentHTML('beforeend', hasMany.build.
|
|
138
|
+
document.querySelector('#id_' + args.name).insertAdjacentHTML('beforeend', hasMany.build.listItem(args.name, {
|
|
129
139
|
id: ev.target.value,
|
|
130
140
|
label: ev.target.nextElementSibling.textContent
|
|
131
141
|
}));
|
|
@@ -140,13 +150,14 @@ export const hasMany = {
|
|
|
140
150
|
// Add event listener for None of the Below
|
|
141
151
|
if (args.notb)
|
|
142
152
|
document.querySelector('.hasmany-' + args.name + 'notb').addEventListener('change', ev => {
|
|
143
|
-
if (ev.target.checked)
|
|
153
|
+
if (ev.target.checked) {
|
|
144
154
|
// Uncheck all other items
|
|
145
|
-
document.querySelectorAll('hasmany-' + args.name).forEach(input => {
|
|
155
|
+
document.querySelectorAll('.hasmany-' + args.name).forEach(input => {
|
|
146
156
|
input.checked = false;
|
|
147
157
|
});
|
|
148
158
|
// Remove all items from list
|
|
149
159
|
document.querySelector('#id_' + args.name).innerHTML = '';
|
|
160
|
+
}
|
|
150
161
|
});
|
|
151
162
|
});
|
|
152
163
|
}
|
|
@@ -33,3 +33,29 @@
|
|
|
33
33
|
right: .45rem;
|
|
34
34
|
font-size: 18pt;
|
|
35
35
|
}
|
|
36
|
+
|
|
37
|
+
.hasmany {
|
|
38
|
+
.card {
|
|
39
|
+
border-color: var(--bs-border-color);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.card-footer {
|
|
43
|
+
padding: 0.5rem;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.hasmany-selected-list .list-group-item {
|
|
47
|
+
padding-top: 0.5rem;
|
|
48
|
+
padding-bottom: 0.5rem;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.hasmany-selected-item {
|
|
52
|
+
display: flex;
|
|
53
|
+
align-items: center;
|
|
54
|
+
justify-content: space-between;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.hasmany-check-item {
|
|
58
|
+
display: flex;
|
|
59
|
+
align-items: center;
|
|
60
|
+
}
|
|
61
|
+
}
|