update devDependencies, update tests for new validator, fixes for validation issues
[squeep-indie-auther] / src / template / admin-ticket-html.js
index 492c40d1dfc3d4fba87a0936cff1883359ed8cc1..a0475adc09122d0f9f29dd2b5629b5cc6bc612d5 100644 (file)
@@ -5,6 +5,7 @@
  */
 
 const th = require('./template-helper');
+const { sessionNavLinks } = require('@squeep/authentication-module');
 
 
 function renderProfileOption(profile) {
@@ -15,7 +16,7 @@ function renderScopeCheckboxTR(scope) {
   const defaultChecked = ['read'];
   const checked = defaultChecked.includes(scope) ? ' checked' : '';
   return `<tr class="scope">
-\t<td><input type="checkbox" id="scopes-${scope}" name="scopes" value="${scope}"${checked}></td>
+\t<td><input type="checkbox" id="scopes-${scope}" name="scopes[]" value="${scope}"${checked}></td>
 \t<td>${scope}</td>
 </tr>`;
 }
@@ -26,10 +27,10 @@ function mainContent(ctx) {
   const elideScopes = ['profile', 'email'];
   const allScopes = Object.keys(ctx?.profilesScopes?.scopeIndex || {});
   const displayScopes = (allScopes).filter((scope) => !elideScopes.includes(scope));
-  const scopesCheckboxRows = th.indented(4, displayScopes.map((scope) => renderScopeCheckboxTR(scope)))
+  const scopesCheckboxRows = th.indented(5, displayScopes.map((scope) => renderScopeCheckboxTR(scope)))
     .join('\n');
   return `<section>
-\t<form action="" method="POST">
+\t<form method="POST">
 \t\t<div>
 \t\t\tYou may proactively send a ticket to a third-party site,
 \t\t\twhich they may redeem for an access token which grants additional
@@ -52,14 +53,16 @@ ${profileOptions}
 <fieldset>
 <legend>Scopes</legend>
 \t\t\t<table>
+\t\t\t\t<tbody>
 ${scopesCheckboxRows}
+\t\t\t\t</tbody>
 \t\t\t</table>
 </fieldset>
 \t\t\t<br>
 \t\t\t<label for="scopes-adhoc">Additional Scopes (space separated):</label>
 \t\t\t<input type="text" id="scopes-adhoc" name="adhoc" size="96">
 \t\t\t<br>
-\t\t\t<button name="action" value="proffer-ticket">Send Ticket</button>
+\t\t\t<button type="submit" name="action" value="proffer-ticket">Send Ticket</button>
 \t\t</fieldset>
 \t</form>
 </section>`;
@@ -79,20 +82,18 @@ ${scopesCheckboxRows}
  * @returns {String}
  */
 module.exports = (ctx, options) => {
+  const pagePathLevel = 1;
   const htmlOptions = {
+    padeIdentifier: 'ticketProffer',
     pageTitle: options.manager.pageTitle + ' - Ticket Proffer',
     logoUrl: options.manager.logoUrl,
     footerEntries: options.manager.footerEntries,
-    navLinks: [
-      {
-        text: 'Admin',
-        href: '../admin/',
-      },
-    ],
     errorContent: ['Unable to send ticket.'],
   };
+  th.navLinks(pagePathLevel, ctx, htmlOptions);
+  sessionNavLinks(pagePathLevel, ctx, htmlOptions);
   const content = [
     mainContent(ctx),
   ];
-  return th.htmlPage(2, ctx, htmlOptions, content);
+  return th.htmlPage(pagePathLevel, ctx, htmlOptions, content);
 };
\ No newline at end of file