From fbca9f167d6258ab6e1b9f86d33d0537790f5f25 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Tue, 23 Aug 2022 00:25:27 +0000 Subject: [PATCH] More subscription license work --- wwwroot/js/app.ravLicense.js | 355 ++++++++++-------- .../js/templates/app.ravLicense.handlebars | 115 ++++-- 2 files changed, 280 insertions(+), 190 deletions(-) diff --git a/wwwroot/js/app.ravLicense.js b/wwwroot/js/app.ravLicense.js index 1b6ced3..d85c9d9 100644 --- a/wwwroot/js/app.ravLicense.js +++ b/wwwroot/js/app.ravLicense.js @@ -13,18 +13,19 @@ /*global $, app */ app.ravLicense = (function () { - "use strict"; - //---------------- BEGIN MODULE SCOPE VARIABLES -------------- - var stateMap = {}, - configModule, - initModule, - onGenerate, - onRevoke; - //----------------- END MODULE SCOPE VARIABLES --------------- + "use strict"; + //---------------- BEGIN MODULE SCOPE VARIABLES -------------- + var stateMap = {}, + configModule, + initModule, + onGenerate, + onRevoke, + onPerpetualChanged; + //----------------- END MODULE SCOPE VARIABLES --------------- - //------------------- BEGIN UTILITY METHODS ------------------ - //-------------------- END UTILITY METHODS ------------------- - /* + //------------------- BEGIN UTILITY METHODS ------------------ + //-------------------- END UTILITY METHODS ------------------- + /* public class dtoRavLicense { [Required] @@ -55,165 +56,195 @@ app.ravLicense = (function () { */ - //------------------- BEGIN EVENT HANDLERS ------------------- - onGenerate = function (event) { - event.preventDefault(); - $.gevent.publish("app-clear-error"); - //get form data - var formData = $("form").serializeArray({ - checkboxesAsBools: true - }); + //------------------- BEGIN EVENT HANDLERS ------------------- + onGenerate = function (event) { + event.preventDefault(); + $.gevent.publish("app-clear-error"); + //get form data + var formData = $("form").serializeArray({ + checkboxesAsBools: true + }); - var submitData = app.utilB.objectifyFormDataArray(formData); - //do features separately, above can't deal with multi select and we need to add schedtechs anyway - let features = []; - features.push({ - Feature: "ServiceTechs", - Count: Number($("#techcount").val()) - }); - let options = $("#options").val(); + var submitData = app.utilB.objectifyFormDataArray(formData); + //do features separately, above can't deal with multi select and we need to add schedtechs anyway + let features = []; - for (let i = 0; i < options.length; i++) { - features.push({ Feature: options[i], Count: 0 }); - } + if ($("#perpetual").prop("checked")) { + features.push({ + Feature: "ServiceTechs", + Count: Number($("#techcount").val()) + }); + } else { + features.push({ + Feature: "ActiveInternalUsers", + Count: Number($("#subusercount").val()) + }); - submitData["features"] = features; - //submit - // alert("STUB submit"); - app.api.createRavLicense(submitData, function (res) { - if (res.error) { - $.gevent.publish("app-show-error", res.msg); - } else { - page( - "#!/ravLicenses/" + - stateMap.id + - "/" + - stateMap.context.params.cust_id + features.push({ + Feature: "ActiveCustomerUsers", + Count: Number($("#subcustcount").val()) + }); + } + + let options = $("#options").val(); + + for (let i = 0; i < options.length; i++) { + features.push({ Feature: options[i], Count: 0 }); + } + + submitData["features"] = features; + //submit + // alert("STUB submit"); + app.api.createRavLicense(submitData, function (res) { + if (res.error) { + $.gevent.publish("app-show-error", res.msg); + } else { + page( + "#!/ravLicenses/" + + stateMap.id + + "/" + + stateMap.context.params.cust_id + ); + return false; + } + }); + + return false; //prevent default + }; + + onRevoke = function (event) { + event.preventDefault(); + $("#registeredTo").val("REVOKED"); + $("#licenseExpires").prop("checked", true); + var yesterday = moment().add(-1, "days").toISOString().substring(0, 10); + $('input[type="date"]').val(yesterday); + + return false; //prevent default + }; + + onPerpetualChanged = function (event) { + event.preventDefault(); + + $("#perpettechcountblock").toggleClass("d-none"); + $("#subusercountblock").toggleClass("d-none"); + $("#subcustcountblock").toggleClass("d-none"); + return false; //prevent default + }; + + // onSelectAllAddOns = function (event) { + // event.preventDefault(); + // $('#wbi').prop('checked', true); + // $('#mbi').prop('checked', true); + // $('#ri').prop('checked', true); + // $('#qbi').prop('checked', true); + // $('#qboi').prop('checked', true); + // $('#pti').prop('checked', true); + // $('#quickNotification').prop('checked', true); + // $('#exportToXls').prop('checked', true); + // $('#outlookSchedule').prop('checked', true); + // $('#oli').prop('checked', true); + // $('#importExportCSVDuplicate').prop('checked', true); + + // return false; //prevent default + // }; + + // onTemplates = function(event) { + // event.preventDefault(); + // alert("STUB: templates"); + + // return false; //prevent default + // }; + + //-------------------- END EVENT HANDLERS -------------------- + + //------------------- BEGIN PUBLIC METHODS ------------------- + //CONFIGMODULE + // + configModule = function (context) { + stateMap.context = context.context; + if (stateMap.context.params.id) { + stateMap.id = stateMap.context.params.id; + } + }; + + //INITMODULE + // + initModule = function ($container) { + if (typeof $container === "undefined") { + $container = $("#app-shell-main-content"); + } + $container.html(Handlebars.templates["app.ravLicense"]({})); + + ///ravLicense/:id + //id is always site id and this form is only to make a new license, not to view one + + //case 3233 customer list + //Fill customer list combo + // var customerList = {}; + + //get company name to pre-fill regto + //api/site/77/name + + app.api.get("site/" + stateMap.id + "/newlicenseinfo", function (res) { + if (res.error) { + $.gevent.publish("app-show-error", res.msg); + } else { + $("#registeredTo").val(res.name); + $("#dbId").val(res.dbid); + } + }); + + //Context menu + app.nav.contextClear(); + + ////app.nav.setContextTitle("License"); + + //make context menu + + //Context menu + app.nav.contextClear(); + app.nav.contextAddButton( + "btn-generate", + "Generate and Send", + "key", + onGenerate ); - return false; - } - }); - return false; //prevent default - }; + // app.nav.contextAddButton('btn-select-all-addons', 'All', 'check-all', onSelectAllAddOns); + // app.nav.contextAddLink("licenseRequests/", "Requests", "voice"); + // app.nav.contextAddLink("licenseTemplates/", "", "layers"); + //case 3233 - onRevoke = function (event) { - event.preventDefault(); - $("#registeredTo").val("REVOKED"); - $("#licenseExpires").prop("checked", true); - var yesterday = moment().add(-1, "days").toISOString().substring(0, 10); - $('input[type="date"]').val(yesterday); + app.nav.contextAddLink( + "ravLicenses/" + + stateMap.id + + "/" + + stateMap.context.params.cust_id, + "Licenses", + "ticket" + ); //from here to new license - return false; //prevent default - }; + app.nav.contextAddButton("btn-revoke", "Revoke", "nuke", onRevoke); - // onSelectAllAddOns = function (event) { - // event.preventDefault(); - // $('#wbi').prop('checked', true); - // $('#mbi').prop('checked', true); - // $('#ri').prop('checked', true); - // $('#qbi').prop('checked', true); - // $('#qboi').prop('checked', true); - // $('#pti').prop('checked', true); - // $('#quickNotification').prop('checked', true); - // $('#exportToXls').prop('checked', true); - // $('#outlookSchedule').prop('checked', true); - // $('#oli').prop('checked', true); - // $('#importExportCSVDuplicate').prop('checked', true); + //set all date inputs to today plus one year + var oneYearFromNow = moment() + .add(1, "years") + .toISOString() + .substring(0, 10); + $('input[type="date"]').val(oneYearFromNow); + $("#siteId").val(stateMap.id); - // return false; //prevent default - // }; + //var oneMonthFromNow = moment().add(1, 'months').toISOString().substring(0, 10); + //$('#lockoutDate').val(oneMonthFromNow); + // bind actions + $("#btn-revoke").bind("click", onRevoke); + $("#perpetual").bind("change", onPerpetualChanged); + }; - // onTemplates = function(event) { - // event.preventDefault(); - // alert("STUB: templates"); - - // return false; //prevent default - // }; - - //-------------------- END EVENT HANDLERS -------------------- - - //------------------- BEGIN PUBLIC METHODS ------------------- - //CONFIGMODULE - // - configModule = function (context) { - stateMap.context = context.context; - if (stateMap.context.params.id) { - stateMap.id = stateMap.context.params.id; - } - }; - - //INITMODULE - // - initModule = function ($container) { - if (typeof $container === "undefined") { - $container = $("#app-shell-main-content"); - } - $container.html(Handlebars.templates["app.ravLicense"]({})); - - ///ravLicense/:id - //id is always site id and this form is only to make a new license, not to view one - - //case 3233 customer list - //Fill customer list combo - // var customerList = {}; - - //get company name to pre-fill regto - //api/site/77/name - - app.api.get("site/" + stateMap.id + "/newlicenseinfo", function (res) { - if (res.error) { - $.gevent.publish("app-show-error", res.msg); - } else { - $("#registeredTo").val(res.name); - $("#dbId").val(res.dbid); - } - }); - - //Context menu - app.nav.contextClear(); - - ////app.nav.setContextTitle("License"); - - //make context menu - - //Context menu - app.nav.contextClear(); - app.nav.contextAddButton( - "btn-generate", - "Generate and Send", - "key", - onGenerate - ); - // app.nav.contextAddButton('btn-select-all-addons', 'All', 'check-all', onSelectAllAddOns); - // app.nav.contextAddLink("licenseRequests/", "Requests", "voice"); - // app.nav.contextAddLink("licenseTemplates/", "", "layers"); - //case 3233 - - app.nav.contextAddLink( - "ravLicenses/" + stateMap.id + "/" + stateMap.context.params.cust_id, - "Licenses", - "ticket" - ); //from here to new license - - //set all date inputs to today plus one year - var oneYearFromNow = moment() - .add(1, "years") - .toISOString() - .substring(0, 10); - $('input[type="date"]').val(oneYearFromNow); - $("#siteId").val(stateMap.id); - - //var oneMonthFromNow = moment().add(1, 'months').toISOString().substring(0, 10); - //$('#lockoutDate').val(oneMonthFromNow); - // bind actions - $("#btn-revoke").bind("click", onRevoke); - }; - - // return public methods - return { - configModule: configModule, - initModule: initModule - }; - //------------------- END PUBLIC METHODS --------------------- + // return public methods + return { + configModule: configModule, + initModule: initModule + }; + //------------------- END PUBLIC METHODS --------------------- })(); diff --git a/wwwroot/js/templates/app.ravLicense.handlebars b/wwwroot/js/templates/app.ravLicense.handlebars index c32d9b7..26dd8d3 100644 --- a/wwwroot/js/templates/app.ravLicense.handlebars +++ b/wwwroot/js/templates/app.ravLicense.handlebars @@ -2,82 +2,141 @@
- +
- +
- +
- +
- +
-
-
- - -
-
- - -
+
-
+
- - + + +
+
+ +
+
+ + +
+
+ +
+
+ +
- - - + +
-
-
+ {{!--
-
+
--}}
\ No newline at end of file