Skip to content

Commit 6132d36

Browse files
Sync click with other launchers
1 parent 93efeaa commit 6132d36

File tree

8 files changed

+98
-64
lines changed

8 files changed

+98
-64
lines changed

lib/click/controllers/eg002ActivateClickwrap.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
const path = require("path");
8-
const { activateClickwrap } = require("../examples/activateClickwrap");
8+
const { activateClickwrap, getInactiveClickwraps } = require("../examples/activateClickwrap");
99
const dsConfig = require("../../../config/index.js").config;
1010

1111
const eg002ActivateClickwrap = exports;
@@ -37,8 +37,7 @@ eg002ActivateClickwrap.createController = async (req, res) => {
3737
accessToken: req.user.accessToken,
3838
basePath: dsConfig.clickAPIUrl,
3939
accountId: req.session.accountId,
40-
clickwrapName: req.session.clickwrapName,
41-
clickwrapId: req.session.clickwrapId
40+
clickwrapId: req.body.clickwrapId
4241
};
4342

4443
// Call the worker method
@@ -78,11 +77,16 @@ eg002ActivateClickwrap.getController = async (req, res) => {
7877
// since they have not yet entered any information into the form
7978
const tokenOK = req.dsAuth.checkToken();
8079
if (tokenOK){
80+
const args = {
81+
accessToken: req.user.accessToken,
82+
basePath: dsConfig.clickAPIUrl,
83+
accountId: req.session.accountId,
84+
};
8185
sourceFile = (path.basename(__filename))[5].toLowerCase() + (path.basename(__filename)).substr(6);
8286
res.render("pages/click-examples/eg002ActivateClickwrap", {
8387
eg: eg, csrfToken: req.csrfToken(),
8488
title: "Activate a clickwrap",
85-
clickwrapOk: req.session.hasOwnProperty("clickwrapId"),
89+
clickwrapsData: await getInactiveClickwraps(args),
8690
sourceFile: sourceFile,
8791
sourceUrl: dsConfig.githubExampleUrl + 'click/examples/' + sourceFile,
8892
documentation: dsConfig.documentation + eg,

lib/click/controllers/eg003CreateNewClickwrapVersion.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66

77
const path = require("path");
8+
const { getClickwraps } = require("../examples/listClickwraps");
89
const { createNewClickwrapVersion } = require("../examples/createNewClickwrapVersion");
910
const dsConfig = require("../../../config/index.js").config;
1011

@@ -37,8 +38,8 @@ eg003CreateNewClickwrapVersion.createController = async (req, res) => {
3738
accessToken: req.user.accessToken,
3839
basePath: dsConfig.clickAPIUrl,
3940
accountId: req.session.accountId,
40-
clickwrapId: req.session.clickwrapId,
41-
clickwrapName: req.session.clickwrapName,
41+
clickwrapName: req.body.clickwrapName,
42+
clickwrapId: req.body.clickwrapId,
4243
docFile: path.resolve(demoDocumentsPath, dsConfig.docTermsPdf)
4344
};
4445

@@ -79,11 +80,16 @@ eg003CreateNewClickwrapVersion.getController = async (req, res) => {
7980

8081
const tokenOK = req.dsAuth.checkToken();
8182
if (tokenOK){
83+
const args = {
84+
accessToken: req.user.accessToken,
85+
basePath: dsConfig.clickAPIUrl,
86+
accountId: req.session.accountId,
87+
};
8288
sourceFile = (path.basename(__filename))[5].toLowerCase() + (path.basename(__filename)).substr(6);
8389
res.render("pages/click-examples/eg003CreateNewClickwrapVersion", {
8490
eg: eg, csrfToken: req.csrfToken(),
8591
title: "Creating a new clickwrap version",
86-
clickwrapOk: req.session.hasOwnProperty("clickwrapId"),
92+
clickwrapsData: await getClickwraps(args),
8793
sourceFile: sourceFile,
8894
sourceUrl: dsConfig.githubExampleUrl + 'click/examples/' + sourceFile,
8995
documentation: dsConfig.documentation + eg,

lib/click/controllers/eg005ClickwrapResponses.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
const path = require("path");
88
const dsConfig = require("../../../config/index.js").config;
99
const { getClickwrapAgreements } = require("../examples/clickwrapResponses");
10+
const { getClickwraps } = require("../examples/listClickwraps");
1011
const validator = require("validator");
1112

1213
const eg005ClickwrapResponses = exports;
@@ -38,9 +39,8 @@ eg005ClickwrapResponses.createController = async (req, res) => {
3839
accessToken: user.accessToken,
3940
basePath: dsConfig.clickAPIUrl,
4041
accountId: session.accountId,
41-
clickwrapId: session.clickwrapId,
42-
clientUserId: validator.escape(body.clientUserId)
43-
};
42+
clickwrapId: body.clickwrapId,
43+
}
4444

4545
// Call the worker method
4646
try {
@@ -79,11 +79,16 @@ eg005ClickwrapResponses.getController = async (req, res) => {
7979

8080
const tokenOK = req.dsAuth.checkToken();
8181
if (tokenOK){
82+
const args = {
83+
accessToken: req.user.accessToken,
84+
basePath: dsConfig.clickAPIUrl,
85+
accountId: req.session.accountId,
86+
};
8287
sourceFile = (path.basename(__filename))[5].toLowerCase() + (path.basename(__filename)).substr(6);
8388
res.render("pages/click-examples/eg005ClickwrapResponses", {
8489
eg: eg, csrfToken: req.csrfToken(),
8590
title: "Getting clickwrap responses",
86-
clickwrapOk: req.session.hasOwnProperty("clickwrapId"),
91+
clickwrapsData: await getClickwraps(args),
8792
sourceFile: sourceFile,
8893
sourceUrl: dsConfig.githubExampleUrl + 'click/examples/' + sourceFile,
8994
documentation: dsConfig.documentation + eg,

lib/click/examples/activateClickwrap.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,17 @@ const activateClickwrap = async (args) => {
3737
return result;
3838
};
3939

40-
module.exports = { activateClickwrap };
40+
// get inactive clickwraps
41+
const getInactiveClickwraps = async (args) => {
42+
// Call the Click API
43+
// Create Click API client
44+
const dsApiClient = new docusignClick.ApiClient();
45+
dsApiClient.setBasePath(args.basePath)
46+
dsApiClient.addDefaultHeader("Authorization", "Bearer " + args.accessToken);
47+
const accountApi = new docusignClick.AccountsApi(dsApiClient);
48+
49+
// Get a list of inactive clickwraps
50+
return await accountApi.getClickwraps(args.accountId, {status: 'inactive'});
51+
}
52+
53+
module.exports = { activateClickwrap, getInactiveClickwraps };

lib/click/examples/clickwrapResponses.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ const getClickwrapAgreements = async (args) => {
2020
const accountApi = new docusignClick.AccountsApi(dsApiClient);
2121

2222
const options = {
23-
clientUserId: args.clientUserId,
2423
status: "agreed"
2524
};
2625

views/pages/click-examples/eg002ActivateClickwrap.ejs

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,29 @@
1818

1919
<% include ../../partials/gitSource %>
2020

21-
<% if (clickwrapOk) { %>
22-
<p>The clickwrap you created via example 1 will be queried.</p>
23-
24-
<form class="eg" action="" method="post" data-busy="form">
25-
<input type="hidden" name="_csrf" value="<%- csrfToken %>">
26-
<button type="submit" class="btn btn-docu">Continue</button>
27-
</form>
28-
<% } else { %>
29-
<p>Problem: please first create a clickwrap using
30-
<a href="eg001">example 1.</a><br/>Thank you.
21+
<% if (clickwrapsData.clickwraps.length == 0) { %>
22+
<p>Problem: You do not have clickwraps to activate. Go to example#1 and create one:
23+
<a href="eg001">create clickwrap</a><br/>Thank you.
3124
</p>
3225
<form class="eg" action="eg001" method="get">
3326
<button type="submit" class="btn btn-docu">Continue</button>
3427
</form>
28+
<% } else { %>
29+
<p>Please choose a clickwrap to activate</p>
30+
31+
<form class="eg" action="" method="post" data-busy="form-download">
32+
<div class="form-group">
33+
<label for="clickwrapId">Clickwrap</label>
34+
<select class="custom-select" id="clickwrapId"
35+
name="clickwrapId">
36+
<% for(var i=0; i < clickwrapsData.clickwraps.length; i++) { %>
37+
<option value="<%=clickwrapsData.clickwraps[i].clickwrapId%>"><%= clickwrapsData.clickwraps[i].clickwrapName %></option>
38+
<% } %>
39+
</select>
40+
</div>
41+
<input type="hidden" name="_csrf" value="<%- csrfToken %>">
42+
<button type="submit" class="btn btn-docu">Submit</button>
43+
</form>
3544
<% } %>
3645

3746
<% include ../../partials/examplesFoot %>

views/pages/click-examples/eg003CreateNewClickwrapVersion.ejs

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,32 @@
2121

2222
<% include ../../partials/gitSource %>
2323

24-
<% if (clickwrapOk) { %>
25-
<p>The clickwrap you created via example 1 will be queried.</p>
26-
27-
<form class="eg" action="" method="post" data-busy="form">
28-
<input type="hidden" name="_csrf" value="<%- csrfToken %>">
29-
<button type="submit" class="btn btn-docu">Continue</button>
30-
</form>
31-
<% } else { %>
32-
<p>Problem: please first create a clickwrap using
33-
<a href="eg001">example 1.</a><br/>Thank you.
24+
<% if (clickwrapsData.clickwraps.length == 0) { %>
25+
<p>Problem: You do not have clickwraps to activate. Go to example#1 and create one:
26+
<a href="eg001">create clickwrap</a><br/>Thank you.
3427
</p>
3528
<form class="eg" action="eg001" method="get">
3629
<button type="submit" class="btn btn-docu">Continue</button>
3730
</form>
31+
<% } else { %>
32+
33+
<form class="eg" action="" method="post" data-busy="form-download">
34+
<div class="form-group">
35+
<label for="clickwrapId">Clickwrap</label>
36+
<select class="custom-select" id="clickwrapId"
37+
name="clickwrapId">
38+
<% for(var i=0; i < clickwrapsData.clickwraps.length; i++) { %>
39+
<option value="<%=clickwrapsData.clickwraps[i].clickwrapId%>"><%= clickwrapsData.clickwraps[i].clickwrapName %></option>
40+
<% } %>
41+
</select>
42+
</div>
43+
<div class="form-group">
44+
<label for="clickwrapName">New Name</label>
45+
<input type="text" class="form-control" id="clickwrapName" name="clickwrapName" required/>
46+
</div>
47+
<input type="hidden" name="_csrf" value="<%- csrfToken %>">
48+
<button type="submit" class="btn btn-docu">Submit</button>
49+
</form>
3850
<% } %>
3951

4052
<% include ../../partials/examplesFoot %>

views/pages/click-examples/eg005ClickwrapResponses.ejs

Lines changed: 17 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -17,43 +17,29 @@
1717

1818
<% include ../../partials/gitSource %>
1919

20-
<% if (clickwrapOk) { %>
2120

22-
<p>
23-
First, test your clickwrap:
24-
</p>
25-
26-
<ul>
27-
<li>Log in to your developer account and select the <strong>Manage</strong> page.
28-
<li>Select the <strong>Clickwraps</strong> tab.
29-
<li>
30-
In the list of active clickwraps, locate the one you want to test, then click
31-
the dropdown arrow to the right of <strong>COPY CODE</strong> and select <strong>Test Clickwrap</strong>.
32-
</li>
33-
<li>In the Test Clickwrap dialog box, click <strong>TEST CLICKWRAP</strong>.
34-
<li>In the Test Your Clickwrap browser page, in the <strong>Unique ID</strong> field enter any string, then click <strong>Test Clickwrap</strong>.
35-
<li>Review your displayed clickwrap and click <strong>I AGREE</strong> (or the equivalent button you configured) to complete the test.
36-
</ul>
37-
38-
<p>
39-
Then enter the same string you used to test your clickwrap in the field below.
21+
<% if (clickwrapsData.clickwraps.length == 0) { %>
22+
<p>Problem: You do not have clickwraps to activate. Go to example#1 and create one:
23+
<a href="eg001">create clickwrap</a><br/>Thank you.
4024
</p>
25+
<form class="eg" action="eg001" method="get">
26+
<button type="submit" class="btn btn-docu">Continue</button>
27+
</form>
28+
<% } else { %>
29+
<p>Please choose a clickwrap</p>
4130
42-
<form class="eg" action="" method="post" data-busy="form">
31+
<form class="eg" action="" method="post" data-busy="form-download">
4332
<div class="form-group">
44-
<label for="clientUserId">Unique ID</label>
45-
<input type="text" class="form-control" id="clientUserId"
46-
name="clientUserId" required>
33+
<label for="clickwrapId">Clickwrap</label>
34+
<select class="custom-select" id="clickwrapId"
35+
name="clickwrapId">
36+
<% for(var i=0; i < clickwrapsData.clickwraps.length; i++) { %>
37+
<option value="<%=clickwrapsData.clickwraps[i].clickwrapId%>"><%= clickwrapsData.clickwraps[i].clickwrapName %></option>
38+
<% } %>
39+
</select>
4740
</div>
4841
<input type="hidden" name="_csrf" value="<%- csrfToken %>">
49-
<button type="submit" class="btn btn-docu">Continue</button>
50-
</form>
51-
<% } else { %>
52-
<p>Problem: please first create a clickwrap using
53-
<a href="eg001">example 1.</a><br/>Thank you.
54-
</p>
55-
<form class="eg" action="eg001" method="get">
56-
<button type="submit" class="btn btn-docu">Continue</button>
42+
<button type="submit" class="btn btn-docu">Submit</button>
5743
</form>
5844
<% } %>
5945

0 commit comments

Comments
 (0)