Skip to content

Commit 993a7ef

Browse files
committed
Fix multiselect field type, bug fixes
1 parent e2ed003 commit 993a7ef

5 files changed

Lines changed: 24 additions & 4 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ The tenant `customText` configuration allows you to override default text string
288288
"userWelcomeBefore": "Welcome, ",
289289
"userWelcomeAfter": "!",
290290
"activationTitle": "Activation",
291-
"sessionTitle": "Session",
291+
"sessionTitle": "Enable Cookies",
292292
"tenantTitle": "Configuration",
293293
"authTitle": "Authentication Required",
294294
"authDescriptionBefore": "You'll need to log into your ",

frontend/pages/edit.ejs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,15 @@
136136
</tr>
137137
</tbody>
138138
</table>
139+
<% if (!vars.disableFieldEditing.includes('sendEmail')) { %>
139140
<div class="inputField active" id="sendEmail">
140141
<h3><%= tenant.customText?.labelSendEmail %></h3>
141142
<p><%= tenant.customText?.labelSendEmailDescription %></p>
142143
<input id="sendEmailInput" type="checkbox" class="hidden">
143144
<div class="checkbox">|||</div>
144145
</div>
145146
<% } %>
147+
<% } %>
146148
<div class="buttons">
147149
<% if (!commission.locked || (role !== 'user')) { %><div id="save" class="button"><%= tenant.customText?.saveLabel %></div><% } %>
148150
<a id="error" class="button active hidden" href="<%= tenant.domain %><%= tenant.path %>/<%= commission.id %>/edit"><%= tenant.customText?.restartLabel %></a>

frontend/pages/session.ejs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<%- include('head.ejs') %>
2+
<img src="<%= tenant.logo %>" alt="<%= tenant.name %>">
3+
<h1><%= tenant.customText?.sessionTitle %></h1>
4+
<p><%= tenant.customText?.noSession %></p>
5+
<%- include('foot.ejs') %>

frontend/public/scripts.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,13 @@ window.onload = function () {
5959
});
6060
field.querySelectorAll('select').forEach(select => {
6161
if (pathStorage[field.id]) {
62-
select.value = pathStorage[field.id];
62+
if (Array.isArray(pathStorage[field.id]) && select.multiple) {
63+
Array.from(select.options).forEach(option => {
64+
option.selected = pathStorage[field.id].includes(option.value);
65+
});
66+
} else {
67+
select.value = pathStorage[field.id];
68+
};
6369
};
6470
});
6571
});
@@ -104,6 +110,10 @@ window.onload = function () {
104110
radio.checked = true;
105111
};
106112
});
113+
} else if ((input.tagName.toLowerCase() === 'select') && input.multiple && Array.isArray(restore[key])) {
114+
Array.from(input.options).forEach(option => {
115+
option.selected = restore[key].includes(option.value);
116+
});
107117
} else {
108118
input.value = restore[key];
109119
};
@@ -294,6 +304,8 @@ async function create() {
294304
radios.forEach(radio => {
295305
if (radio.checked) data[field.id] = radio.value;
296306
});
307+
} else if ((input.tagName.toLowerCase() === 'select') && input.multiple) {
308+
data[field.id] = Array.from(input.selectedOptions).map(option => option.value);
297309
} else {
298310
data[field.id] = input.value;
299311
};
@@ -373,6 +385,8 @@ async function save() {
373385
radios.forEach(radio => {
374386
if (radio.checked) data[field.id] = radio.value;
375387
});
388+
} else if ((input.tagName.toLowerCase() === 'select') && input.multiple) {
389+
data[field.id] = Array.from(input.selectedOptions).map(option => option.value);
376390
} else {
377391
data[field.id] = input.value;
378392
};

index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const customText = {
3333
userWelcomeBefore: 'Welcome, ',
3434
userWelcomeAfter: '!',
3535
activationTitle: 'Activation',
36-
sessionTitle: 'Session',
36+
sessionTitle: 'Enable Cookies',
3737
tenantTitle: 'Configuration',
3838
authTitle: 'Authentication Required',
3939
authDescriptionBefore: 'You\'ll need to log into your ',
@@ -106,7 +106,6 @@ const customText = {
106106
commissionNotFoundJson: 'The requested commission was not found.'
107107
};
108108

109-
110109
function getCustomText(key, def) {
111110
if (tenant && tenant.customText && Object.prototype.hasOwnProperty.call(tenant.customText, key)) return tenant.customText[key];
112111
return (customText[key] !== undefined) ? customText[key] : def;

0 commit comments

Comments
 (0)