From 2cc99de152f8c71eb324e9accc6a1d4ff143c71d Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Wed, 17 Jun 2020 23:12:12 +0000 Subject: [PATCH] --- Controllers/SiteController.cs | 15 +- wwwroot/js/app.ravLicense.js | 242 +++++++++--------- .../js/templates/app.ravLicense.handlebars | 2 +- 3 files changed, 131 insertions(+), 128 deletions(-) diff --git a/Controllers/SiteController.cs b/Controllers/SiteController.cs index b6a3e8a..552e90f 100644 --- a/Controllers/SiteController.cs +++ b/Controllers/SiteController.cs @@ -94,14 +94,25 @@ namespace rockfishCore.Controllers return BadRequest(ModelState); } - var ret = await ct.Site + var ret = await ct.Site.AsNoTracking() .Select(r => new { r.Id, r.Name, r.CustomerId }) .Where(r => r.Id == id) .FirstAsync(); return Ok(ret); } - + //Get api/site/77/name + [HttpGet("{id}/customerinfo")] + public async Task GetCustomerInfo([FromRoute] long id) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + var custId = await ct.Site.AsNoTracking().Where(z => z.Id == id).Select(z => z.CustomerId).FirstAsync(); + var custInfo = await ct.Customer.AsNoTracking().Where(z => z.Id == custId).Select(z => new { z.Name, z.Id }).SingleAsync(); + return Ok(custInfo); + } // GET: api/Site [HttpGet] diff --git a/wwwroot/js/app.ravLicense.js b/wwwroot/js/app.ravLicense.js index eebf01a..554bbd2 100644 --- a/wwwroot/js/app.ravLicense.js +++ b/wwwroot/js/app.ravLicense.js @@ -13,17 +13,17 @@ /*global $, app */ app.ravLicense = (function () { - 'use strict'; - //---------------- BEGIN MODULE SCOPE VARIABLES -------------- - var + "use strict"; + //---------------- BEGIN MODULE SCOPE VARIABLES -------------- + var stateMap = {}, + configModule, + initModule, + onGenerate; + //----------------- END MODULE SCOPE VARIABLES --------------- - stateMap = {}, - configModule, initModule, onGenerate; - //----------------- END MODULE SCOPE VARIABLES --------------- - - //------------------- BEGIN UTILITY METHODS ------------------ - //-------------------- END UTILITY METHODS ------------------- -/* + //------------------- BEGIN UTILITY METHODS ------------------ + //-------------------- END UTILITY METHODS ------------------- + /* public class dtoRavLicense { [Required] @@ -54,140 +54,132 @@ app.ravLicense = (function () { */ - //------------------- BEGIN EVENT HANDLERS ------------------- - onGenerate = function (event) { + //------------------- BEGIN EVENT HANDLERS ------------------- + onGenerate = function (event) { + event.preventDefault(); + $.gevent.publish("app-clear-error"); + //get form data + var formData = $("form").serializeArray({ + checkboxesAsBools: true + }); - event.preventDefault(); - $.gevent.publish('app-clear-error'); - //get form data - var formData = $("form").serializeArray({ - checkboxesAsBools: true - }); + var submitData = app.utilB.objectifyFormDataArray(formData); - var submitData = app.utilB.objectifyFormDataArray(formData); + //clean up the data before submit - //clean up the data before submit + //submit + alert("STUB submit"); + // app.api.createRavLicense(submitData, function (res) { + // if (res.error) { + // $.gevent.publish('app-show-error', res.msg); + // } else { + // $('#key').val(res); + // return false; + // } + // }); - //submit - alert("STUB submit"); - // app.api.createRavLicense(submitData, function (res) { - // if (res.error) { - // $.gevent.publish('app-show-error', res.msg); - // } else { - // $('#key').val(res); - // return false; - // } - // }); + return false; //prevent default + }; - 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 + // }; - // 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); + // onTemplates = function(event) { + // event.preventDefault(); + // alert("STUB: templates"); + // return false; //prevent default + // }; + //-------------------- END EVENT HANDLERS -------------------- - // return false; //prevent default - // }; + //------------------- BEGIN PUBLIC METHODS ------------------- + //CONFIGMODULE + // + configModule = function (context) { + stateMap.context = context.context; + if (stateMap.context.params.id) { + stateMap.id = stateMap.context.params.id; + } + }; - // onTemplates = function(event) { - // event.preventDefault(); - // alert("STUB: templates"); + //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 - // return false; //prevent default - // }; + //case 3233 customer list + //Fill customer list combo + // var customerList = {}; + //get company name to pre-fill regto + //api/site/77/name - //-------------------- END EVENT HANDLERS -------------------- + app.api.get("site/" + stateMap.id + "/customerinfo", function (res) { + if (res.error) { + $.gevent.publish("app-show-error", res.msg); + } else { + $("#registeredTo").val(res.name); + } + }); - //------------------- BEGIN PUBLIC METHODS ------------------- - //CONFIGMODULE - // - configModule = function (context) { - stateMap.context = context.context; - if (stateMap.context.params.id) { - stateMap.id = stateMap.context.params.id; - } - }; + //Context menu + app.nav.contextClear(); - //INITMODULE - // - initModule = function ($container) { - if (typeof $container === 'undefined') { - $container = $('#app-shell-main-content'); - } - $container.html(Handlebars.templates['app.ravLicense']({})); + ////app.nav.setContextTitle("License"); - ///ravLicense/:id/:site_id - //either fetch one to display or start one to create - debugger; - - //case 3233 customer list - //Fill customer list combo - // var customerList = {}; + //make context menu - - // //get customers - // app.api.get('customer/list', function (res) { - // if (res.error) { - // $.gevent.publish('app-show-error', res.msg); - // } else { + //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("licenses/", "List", ""); - // var html = ''; + //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); - // for (var i = 0, len = res.length; i < len; ++i) { - // html += (''); - // customerList[res[i]['id']] = res[i]['name']; - // } - // $('#customerId').append(html); - // } - // }); + //var oneMonthFromNow = moment().add(1, 'months').toISOString().substring(0, 10); + //$('#lockoutDate').val(oneMonthFromNow); + }; - - //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("licenses/", "List", ""); - - - //set all date inputs to today plus one year - var oneYearFromNow = moment().add(1, 'years').toISOString().substring(0, 10); - $('input[type="date"]').val(oneYearFromNow); - - //var oneMonthFromNow = moment().add(1, 'months').toISOString().substring(0, 10); - //$('#lockoutDate').val(oneMonthFromNow); - - }; - - // return public methods - return { - configModule: configModule, - initModule: initModule - }; - //------------------- END PUBLIC METHODS --------------------- -}()); \ No newline at end of file + // 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 4726880..ecc8053 100644 --- a/wwwroot/js/templates/app.ravLicense.handlebars +++ b/wwwroot/js/templates/app.ravLicense.handlebars @@ -14,7 +14,7 @@
- +