Skip to content

Commit 4c62b60

Browse files
committed
Expand tests, bug fixes
1 parent ee5b4bf commit 4c62b60

16 files changed

Lines changed: 739 additions & 167 deletions

frontend/pages/admin.ejs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<%- include('head.ejs') %>
22
<img src="<%= tenant.logo %>" alt="<%= tenant.name %>">
3-
<h1><%= tenant.customText && tenant.customText.adminTitle ? tenant.customText.adminTitle : 'Commission Management' %></h1>
4-
<p><%= tenant.customText && tenant.customText.adminDescription ? tenant.customText.adminDescription : 'Manage commissions created on your platform.' %></p>
3+
<h1><%= tenant.customText?.adminTitle %></h1>
4+
<p><%= tenant.customText?.adminDescription %></p>
55
<div class="buttons">
6-
<a class="button" href="<%= tenant.domain %><%= tenant.path %>/create"><%= tenant.customText && tenant.customText.newCommissionTitle ? tenant.customText.newCommissionTitle : 'New Commission' %></a>
6+
<a class="button" href="<%= tenant.domain %><%= tenant.path %>/create"><%= tenant.customText?.newCommissionTitle %></a>
77
<div id="sync" class="button"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 23 23" fill="none">
88
<path d="M18.5949 5.16663C16.8618 3.32009 14.3989 2.16663 11.6666 2.16663C6.41992 2.16663 2.16663 6.41992 2.16663 11.6666C2.16663 16.9133 6.41992 21.1666 11.6666 21.1666C14.3989 21.1666 16.8618 20.0132 18.5949 18.1666M17.3236 7.98035L20.9804 7.98035L20.9804 4.3235" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" />
99
</svg> Sync</div>
10-
<a class="button" href="<%= tenant.domain %>"><%= (tenant.customText && tenant.customText.backToLabel ? tenant.customText.backToLabel : 'Back to ') + tenant.name %></a>
10+
<a class="button" href="<%= tenant.domain %>"><%= (tenant.customText?.backToLabel) + tenant.name %></a>
1111
</div>
1212
<div class="commissions">
1313
<% session[vars.commissions].forEach(commission => { %>

frontend/pages/auth.ejs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<%- include('head.ejs') %>
22
<img src="<%= tenant.logo %>" alt="<%= tenant.name %>">
3-
<h1><%= tenant.customText && tenant.customText.authTitle ? tenant.customText.authTitle : 'Authentication Required' %></h1>
4-
<p><%= tenant.customText && tenant.customText.authDescription ? tenant.customText.authDescription : ('You\'ll need to log into your ' + (tenant.auth.provider || tenant.name) + ' account before managing your commissions.') %></p>
3+
<h1><%= tenant.customText?.authTitle %></h1>
4+
<p><%= tenant.customText?.authDescription %></p>
55
<% if (tenant.auth.url) { %>
66
<div class="buttons">
7-
<div href="<%= tenant.auth.url %>" class="button"><%= tenant.customText && tenant.customText.authContinueLabel ? tenant.customText.authContinueLabel : 'Continue' %></div>
7+
<div href="<%= tenant.auth.url %>" class="button"><%= tenant.customText?.authContinueLabel %></div>
88
</div>
99
<% } %>
1010
<%- include('foot.ejs') %>

frontend/pages/commission.ejs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
<%- include('head.ejs') %>
22
<img src="<%= tenant.logo %>" alt="<%= tenant.name %>">
33
<h1><%= title %></h1>
4-
<% if (commission.locked) { %><p><%= tenant.customText && tenant.customText.commissionLocked ? tenant.customText.commissionLocked : 'This commission is locked from user editing.' %></p><% } %>
4+
<% if (commission.locked) { %><p><%= tenant.customText?.commissionLocked %></p><% } %>
55
<table>
66
<tbody>
77
<tr>
8-
<th><%= tenant.customText && tenant.customText.labelStatus ? tenant.customText.labelStatus : 'Status' %></th>
8+
<th><%= tenant.customText?.labelStatus %></th>
99
<td><%= commission.status %></td>
1010
</tr>
1111
<tr>
12-
<th><%= tenant.customText && tenant.customText.labelOwner ? tenant.customText.labelOwner : 'Owner' %></th>
13-
<td><%= commission.user %><%= (commission.user === session[vars.userId]) ? (' ' + (tenant.customText && tenant.customText.youLabel ? tenant.customText.youLabel : '(you)')) : '' %></td>
12+
<th><%= tenant.customText?.labelOwner %></th>
13+
<td><%= commission.user %><%= (commission.user === session[vars.userId]) ? (' ' + (tenant.customText?.youLabel)) : '' %></td>
1414
</tr>
1515
<% if (commission.amount !== null) { %>
1616
<tr>
17-
<th><%= tenant.customText && tenant.customText.labelAmount ? tenant.customText.labelAmount : 'Amount' %></th>
17+
<th><%= tenant.customText?.labelAmount %></th>
1818
<td><%= commission.amount %> <%= commission.currency %></td>
1919
</tr>
2020
<% } %>
2121
<% if (commission.date !== null) { %>
2222
<tr>
23-
<th><%= tenant.customText && tenant.customText.labelDate ? tenant.customText.labelDate : 'Date' %></th>
23+
<th><%= tenant.customText?.labelDate %></th>
2424
<td><%= new Date(commission.date).toLocaleString() %></td>
2525
</tr>
2626
<% } %>
2727
<tr>
28-
<th><%= tenant.customText && tenant.customText.labelAssignedTo ? tenant.customText.labelAssignedTo : 'Assigned To' %></th>
28+
<th><%= tenant.customText?.labelAssignedTo %></th>
2929
<td><%= (commission.assignedTo || []).map(assignedTo => vars.users.find(user => user[vars.userId] === assignedTo) ? (vars.users.find(user => user[vars.userId] === assignedTo)[vars.userName] || vars.users.find(user => user[vars.userId] === assignedTo)[vars.userId]) : null).filter(assignedTo => assignedTo).join(', ') || '-' %></td>
3030
</tr>
3131
</tbody>

frontend/pages/create.ejs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<%- include('head.ejs') %>
22
<img src="<%= tenant.logo %>" alt="<%= tenant.name %>">
3-
<h1><%= tenant.customText && tenant.customText.newCommissionTitle ? tenant.customText.newCommissionTitle : 'New Commission' %></h1>
4-
<p><%= tenant.customText && tenant.customText.createEstimatedTime ? tenant.customText.createEstimatedTime : 'Estimated time to complete: 2 minutes' %></p>
3+
<h1><%= tenant.customText?.newCommissionTitle %></h1>
4+
<p><%= tenant.customText?.createEstimatedTime %></p>
55
<% var step = 1; fields.forEach(field => { %>
66
<div class="inputField <%= field.required ? 'required' : '' %>" id="<%= field.id %>" step="<%= step %>">
77
<h3><%= field.label %><%= field.required ? '*' : '' %></h3>
8-
<p><%= field.required ? (tenant.customText && tenant.customText.labelRequired ? tenant.customText.labelRequired : 'Required') : (tenant.customText && tenant.customText.labelOptional ? tenant.customText.labelOptional : 'Optional') %><%= field.description ? ': ' + field.description : '' %></p>
8+
<p><%= field.required ? (tenant.customText?.labelRequired) : (tenant.customText?.labelOptional) %><%= field.description ? ': ' + field.description : '' %></p>
99
<% if (field.type === 'textarea') { %>
1010
<textarea id="<%= field.id %>Textarea" placeholder="<%= field.placeholder || '' %>"></textarea>
1111
<% } else if (field.type === 'checkbox') { %>
@@ -16,7 +16,7 @@
1616
<% if (!field.required) { %>
1717
<div class="radioOption">
1818
<input type="radio" id="none" name="none" value="">
19-
<label for="none"><%= tenant.customText && tenant.customText.noneLabel ? tenant.customText.noneLabel : 'None' %></label>
19+
<label for="none"><%= tenant.customText?.noneLabel %></label>
2020
</div>
2121
<% } %>
2222
<% (field.options || []).forEach(option => { %>
@@ -29,7 +29,7 @@
2929
<% } else if (field.type === 'select') { %>
3030
<select id="<%= field.id %>Select">
3131
<% if (!field.required) { %>
32-
<option value=""><%= tenant.customText && tenant.customText.noneLabel ? tenant.customText.noneLabel : 'None' %></option>
32+
<option value=""><%= tenant.customText?.noneLabel %></option>
3333
<% } %>
3434
<% (field.options || []).forEach(option => { %>
3535
<option value="<%= option.value %>"><%= option.label %></option>
@@ -38,7 +38,7 @@
3838
<% } else if (field.type === 'multiselect') { %>
3939
<select id="<%= field.id %>Select" multiple>
4040
<% if (!field.required) { %>
41-
<option value="">None</option>
41+
<option value=""><%= tenant.customText?.noneLabel %></option>
4242
<% } %>
4343
<% (field.options || []).forEach(option => { %>
4444
<option value="<%= option.value %>"><%= option.label %></option>
@@ -50,11 +50,11 @@
5050
</div>
5151
<% step++; }) %>
5252
<div class="buttons">
53-
<div id="back" class="button hidden"><%= tenant.customText && tenant.customText.backLabel ? tenant.customText.backLabel : 'Back' %></div>
54-
<div id="next" class="button active hidden"><%= tenant.customText && tenant.customText.nextLabel ? tenant.customText.nextLabel : 'Next' %></div>
55-
<div id="start" class="button active"><%= tenant.customText && tenant.customText.startLabel ? tenant.customText.startLabel : 'Start' %></div>
56-
<div id="create" class="button active hidden"><%= tenant.customText && tenant.customText.createLabel ? tenant.customText.createLabel : 'Create' %></div>
57-
<a id="success" class="button active hidden" href="<%= tenant.domain %><%= tenant.path %>"><%= tenant.customText && tenant.customText.returnLabel ? tenant.customText.returnLabel : 'Return' %></a>
58-
<a id="error" class="button active hidden" href="<%= tenant.domain %><%= tenant.path %>/create"><%= tenant.customText && tenant.customText.restartLabel ? tenant.customText.restartLabel : 'Restart' %></a>
53+
<div id="back" class="button hidden"><%= tenant.customText?.backLabel %></div>
54+
<div id="next" class="button active hidden"><%= tenant.customText?.nextLabel %></div>
55+
<div id="start" class="button active"><%= tenant.customText?.startLabel %></div>
56+
<div id="create" class="button active hidden"><%= tenant.customText?.createLabel %></div>
57+
<a id="success" class="button active hidden" href="<%= tenant.domain %><%= tenant.path %>"><%= tenant.customText?.returnLabel %></a>
58+
<a id="error" class="button active hidden" href="<%= tenant.domain %><%= tenant.path %>/create"><%= tenant.customText?.restartLabel %></a>
5959
</div>
6060
<%- include('foot.ejs') %>

frontend/pages/dev.ejs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<%- include('head.ejs') %>
22
<img src="<%= tenant.logo %>" alt="<%= tenant.name %>">
3-
<h1><%= tenant.customText && tenant.customText.devTitle ? tenant.customText.devTitle : 'Commission Management' %></h1>
4-
<p><%= tenant.customText && tenant.customText.devDescription ? tenant.customText.devDescription : 'Manage commissions assigned to you.' %></p>
3+
<h1><%= tenant.customText?.devTitle %></h1>
4+
<p><%= tenant.customText?.devDescription %></p>
55
<div class="buttons">
6-
<a class="button" href="<%= tenant.domain %><%= tenant.path %>/create"><%= tenant.customText && tenant.customText.newCommissionTitle ? tenant.customText.newCommissionTitle : 'New Commission' %></a>
6+
<a class="button" href="<%= tenant.domain %><%= tenant.path %>/create"><%= tenant.customText?.newCommissionTitle %></a>
77
<div id="sync" class="button"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 23 23" fill="none">
88
<path d="M18.5949 5.16663C16.8618 3.32009 14.3989 2.16663 11.6666 2.16663C6.41992 2.16663 2.16663 6.41992 2.16663 11.6666C2.16663 16.9133 6.41992 21.1666 11.6666 21.1666C14.3989 21.1666 16.8618 20.0132 18.5949 18.1666M17.3236 7.98035L20.9804 7.98035L20.9804 4.3235" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" />
9-
</svg> <%= tenant.customText && tenant.customText.syncLabel ? tenant.customText.syncLabel : 'Sync' %></div>
10-
<a class="button" href="<%= tenant.domain %>"><%= (tenant.customText && tenant.customText.backToLabel ? tenant.customText.backToLabel : 'Back to ') + tenant.name %></a>
9+
</svg> <%= tenant.customText?.syncLabel %></div>
10+
<a class="button" href="<%= tenant.domain %>"><%= (tenant.customText?.backToLabel) + tenant.name %></a>
1111
</div>
1212
<div class="commissions">
1313
<% session[vars.commissions].filter(commission => (commission.assignedTo || []).includes(session[vars.userId])).forEach(commission => { %>

frontend/pages/edit.ejs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
<% if (role === 'admin') { %>
55
<% if (!vars.disableFieldEditing.includes('status')) { %>
66
<div class="inputField active" id="status">
7-
<h3><%= tenant.customText && tenant.customText.labelStatus ? tenant.customText.labelStatus : 'Status' %>*</h3>
8-
<p><%= tenant.customText && tenant.customText.labelStatusDescription ? tenant.customText.labelStatusDescription : 'Required: Commission status.' %></p>
7+
<h3><%= tenant.customText?.labelStatus %>*</h3>
8+
<p><%= tenant.customText?.labelStatusDescription %></p>
99
<select id="statusSelect">
1010
<% vars.possibleStatuses.forEach(option => { %>
1111
<option value="<%= option.value %>" <%= (option.value === commission.status) ? 'selected' : '' %>><%= option.label %></option>
@@ -15,8 +15,8 @@
1515
<% } %>
1616
<% if (!vars.disableFieldEditing.includes('owner')) { %>
1717
<div class="inputField active" id="owner">
18-
<h3><%= tenant.customText && tenant.customText.labelOwner ? tenant.customText.labelOwner : 'Owner' %>*</h3>
19-
<p><%= tenant.customText && tenant.customText.labelOwnerDescription ? tenant.customText.labelOwnerDescription : 'Required: Commission owner.' %></p>
18+
<h3><%= tenant.customText?.labelOwner %>*</h3>
19+
<p><%= tenant.customText?.labelOwnerDescription %></p>
2020
<% if ((vars.users || []).filter(user => getUserRole(user) === 'user').length) { %>
2121
<select id="ownerSelect">
2222
<option value="">None</option>
@@ -31,37 +31,37 @@
3131
<% } %>
3232
<% if (!vars.disableFieldEditing.includes('amount')) { %>
3333
<div class="inputField active" id="amount">
34-
<h3><%= tenant.customText && tenant.customText.labelAmount ? tenant.customText.labelAmount : 'Amount' %></h3>
35-
<p><%= tenant.customText && tenant.customText.labelAmountDescription ? tenant.customText.labelAmountDescription : 'Optional: Commission amount.' %></p>
34+
<h3><%= tenant.customText?.labelAmount %></h3>
35+
<p><%= tenant.customText?.labelAmountDescription %></p>
3636
<input id="amountInput" type="number" step="0.01" placeholder="<%= (commission.amount !== null) ? commission.amount : '' %>" value="<%= (commission.amount !== null) ? commission.amount : '' %>">
3737
</div>
3838
<% } %>
3939
<% if (!vars.disableFieldEditing.includes('currency')) { %>
4040
<div class="inputField active" id="currency">
41-
<h3><%= tenant.customText && tenant.customText.labelCurrency ? tenant.customText.labelCurrency : 'Currency' %></h3>
42-
<p><%= tenant.customText && tenant.customText.labelCurrencyDescription ? tenant.customText.labelCurrencyDescription : 'Optional: Commission currency.' %></p>
41+
<h3><%= tenant.customText?.labelCurrency %></h3>
42+
<p><%= tenant.customText?.labelCurrencyDescription %></p>
4343
<input id="currencyInput" type="text" placeholder="<%= (commission.currency !== null) ? commission.currency : '' %>" value="<%= (commission.currency !== null) ? commission.currency : '' %>">
4444
</div>
4545
<% } %>
4646
<% if (!vars.disableFieldEditing.includes('date')) { %>
4747
<div class="inputField active" id="date">
48-
<h3><%= tenant.customText && tenant.customText.labelDate ? tenant.customText.labelDate : 'Date' %></h3>
49-
<p><%= tenant.customText && tenant.customText.labelDateDescription ? tenant.customText.labelDateDescription : 'Optional: Commission creation date.' %></p>
48+
<h3><%= tenant.customText?.labelDate %></h3>
49+
<p><%= tenant.customText?.labelDateDescription %></p>
5050
<input id="dateInput" type="datetime-local" placeholder="<%= (commission.date !== null) ? new Date(commission.date).toISOString().slice(0,16) : '' %>" value="<%= (commission.date !== null) ? new Date(commission.date).toISOString().slice(0,16) : '' %>">
5151
</div>
5252
<% } %>
5353
<% if (!vars.disableFieldEditing.includes('locked')) { %>
5454
<div class="inputField active" id="locked">
55-
<h3><%= tenant.customText && tenant.customText.labelLocked ? tenant.customText.labelLocked : 'Locked' %></h3>
56-
<p><%= tenant.customText && tenant.customText.labelLockedDescription ? tenant.customText.labelLockedDescription : 'Optional: Whether or not the commission is locked from user editing.' %></p>
55+
<h3><%= tenant.customText?.labelLocked %></h3>
56+
<p><%= tenant.customText?.labelLockedDescription %></p>
5757
<input id="lockedInput" type="checkbox" class="hidden" <%= commission.locked ? 'checked' : '' %>>
5858
<div class="checkbox">|||</div>
5959
</div>
6060
<% } %>
6161
<% if (!vars.disableFieldEditing.includes('assignedTo')) { %>
6262
<div class="inputField active" id="assignedTo">
63-
<h3><%= tenant.customText && tenant.customText.labelAssignedTo ? tenant.customText.labelAssignedTo : 'Assigned To' %></h3>
64-
<p><%= tenant.customText && tenant.customText.labelAssignedToDescription ? tenant.customText.labelAssignedToDescription : 'Optional: The developer to assign this commission to.' %></p>
63+
<h3><%= tenant.customText?.labelAssignedTo %></h3>
64+
<p><%= tenant.customText?.labelAssignedToDescription %></p>
6565
<% if ((vars.users || []).filter(user => getUserRole(user) !== 'user').length) { %>
6666
<select id="assignedToSelect" multiple>
6767
<option value="">None</option>
@@ -120,7 +120,7 @@
120120
<tbody>
121121
<tr>
122122
<th>
123-
<h3><%= tenant.customText && tenant.customText.labelTasks ? tenant.customText.labelTasks : 'Tasks' %></h3>
123+
<h3><%= tenant.customText?.labelTasks %></h3>
124124
</th>
125125
</tr>
126126
<% commission.tasks.forEach(task => { %>
@@ -131,21 +131,21 @@
131131
<% }) %>
132132
<tr>
133133
<th>
134-
<div id="addTask" class="button"><%= tenant.customText && tenant.customText.newTaskLabel ? tenant.customText.newTaskLabel : 'New Task' %></div>
134+
<div id="addTask" class="button"><%= tenant.customText?.newTaskLabel %></div>
135135
</th>
136136
</tr>
137137
</tbody>
138138
</table>
139139
<div class="inputField active" id="sendEmail">
140-
<h3><%= tenant.customText && tenant.customText.labelSendEmail ? tenant.customText.labelSendEmail : 'Send Email' %></h3>
141-
<p><%= tenant.customText && tenant.customText.labelSendEmailDescription ? tenant.customText.labelSendEmailDescription : 'Optional: Send an email to the user regarding this update.' %></p>
140+
<h3><%= tenant.customText?.labelSendEmail %></h3>
141+
<p><%= tenant.customText?.labelSendEmailDescription %></p>
142142
<input id="sendEmailInput" type="checkbox" class="hidden">
143143
<div class="checkbox">|||</div>
144144
</div>
145145
<% } %>
146146
<div class="buttons">
147-
<% if (!commission.locked || (role !== 'user')) { %><div id="save" class="button"><%= tenant.customText && tenant.customText.saveLabel ? tenant.customText.saveLabel : 'Save' %></div><% } %>
148-
<a id="error" class="button active hidden" href="<%= tenant.domain %><%= tenant.path %>/<%= commission.id %>/edit"><%= tenant.customText && tenant.customText.restartLabel ? tenant.customText.restartLabel : 'Restart' %></a>
147+
<% if (!commission.locked || (role !== 'user')) { %><div id="save" class="button"><%= tenant.customText?.saveLabel %></div><% } %>
148+
<a id="error" class="button active hidden" href="<%= tenant.domain %><%= tenant.path %>/<%= commission.id %>/edit"><%= tenant.customText?.restartLabel %></a>
149149
</div>
150150
<script>
151151
const commissionId = '<%= commission.id %>';

frontend/pages/error.ejs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<%- include('head.ejs') %>
22
<% if ((typeof tenant !== 'undefined') && tenant && tenant.logo && tenant.name) { %><img src="<%= tenant.logo %>" alt="<%= tenant.name %>"><% } %>
3-
<% if (typeof title !== 'undefined') { %><h1> <%= title || (tenant.customText && tenant.customText.errorTitle ? tenant.customText.errorTitle : 'Error') %></h1><% } %>
4-
<% if (typeof message !== 'undefined') { %><p><%= message || (tenant.customText && tenant.customText.errorMessage ? tenant.customText.errorMessage : '') %></p><% } %>
3+
<% if (typeof title !== 'undefined') { %><h1> <%= title || tenant.customText?.errorTitle %></h1><% } %>
4+
<% if (typeof message !== 'undefined') { %><p><%= message || tenant.customText?.errorMessage %></p><% } %>
55
<%- include('foot.ejs') %>

frontend/pages/foot.ejs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
</div>
22
<% if (typeof tenant !== 'undefined') { %>
3-
<p class="fixed">© <%= new Date().getFullYear() %> <%= tenant.customText && tenant.customText.brandName ? tenant.customText.brandName : 'CommTrackr' %></p>
4-
<p class="fixed2"><%= tenant.customText && tenant.customText.changesSaved ? tenant.customText.changesSaved : 'Changes saved' %></p>
5-
<p class="fixed3"><%= tenant.customText && tenant.customText.changesRestored ? tenant.customText.changesRestored : 'Changes restored' %></p>
6-
<p class="fixed4"><%= tenant.customText && tenant.customText.backArrow ? tenant.customText.backArrow : '← Back' %></p>
7-
<p class="fixed5"><%= tenant.customText && tenant.customText.clearChanges ? tenant.customText.clearChanges : 'Clear changes' %></p>
3+
<p class="fixed">© <%= new Date().getFullYear() %> <%= tenant.customText?.brandName %></p>
4+
<p class="fixed2"><%= tenant.customText?.changesSaved %></p>
5+
<p class="fixed3"><%= tenant.customText?.changesRestored %></p>
6+
<p class="fixed4"><%= tenant.customText?.backArrow %></p>
7+
<p class="fixed5"><%= tenant.customText?.clearChanges %></p>
88
<% } else { %>
99
<p class="fixed">Internal error</p>
1010
<% } %>

0 commit comments

Comments
 (0)