From d4d0bb8352203277e9530943d73b74e98e9fcbf6 Mon Sep 17 00:00:00 2001 From: mikkark Date: Tue, 25 Feb 2014 07:03:48 +0200 Subject: [PATCH] new version without angular routing service and deep linking - works much better now - occasional ui bugs do occur --- Client/Content/Site.css | 62 +++++++++-- Client/Controllers/AccountController.cs | 10 +- Client/Scripts/Controllers/crudControllers.js | 101 +++++++----------- Client/Scripts/Vendor/jquery.livequery.min.js | 8 ++ Client/Scripts/_references.js | Bin 744 -> 914 bytes Client/Scripts/app.js | 21 +--- Client/Scripts/ui.js | 47 ++++++++ Client/Views/BasicData/BasicData.cshtml | 10 +- Client/Views/Partials/employee.html | 8 +- Client/Views/Partials/employer.html | 4 +- Client/Views/Partials/full.html | 5 - Client/Views/Partials/taxcard.html | 4 +- Client/Views/Shared/_Layout.cshtml | 8 +- Client/Web.config | 4 + Client/mikkark.SCA.Client.csproj | 4 +- Infrastructure/mikkark.SCA.Infra.csproj | 1 + .../mikkark.SCA.Persistence.csproj | 1 + Reporting/mikkark.SCA.Reporting.csproj | 1 + .../Model/AngularGenerator.html | 3 - .../Model/AngularGenerator.tt | 14 +-- SalarycalculationCore/Model/CrudController.tt | 16 +-- SalarycalculationCore/Model/Partials.tt | 24 ++--- SalarycalculationCore/mikkark.SCA.Core.csproj | 14 +-- 23 files changed, 214 insertions(+), 156 deletions(-) create mode 100644 Client/Scripts/Vendor/jquery.livequery.min.js create mode 100644 Client/Scripts/ui.js delete mode 100644 Client/Views/Partials/full.html delete mode 100644 SalarycalculationCore/Model/AngularGenerator.html diff --git a/Client/Content/Site.css b/Client/Content/Site.css index fe477e4..44b869e 100644 --- a/Client/Content/Site.css +++ b/Client/Content/Site.css @@ -14,24 +14,66 @@ input, select, -textarea { max-width: 280px; } +textarea { + max-width: 280px; +} /* styles for validation helpers */ -.field-validation-error { color: #b94a48; } +.field-validation-error { + color: #b94a48; +} -.field-validation-valid { display: none; } +.field-validation-valid { + display: none; +} -input.input-validation-error { border: 1px solid #b94a48; } +input.input-validation-error { + border: 1px solid #b94a48; +} -input[type="checkbox"].input-validation-error { border: 0 none; } +input[type="checkbox"].input-validation-error { + border: 0 none; +} + +.validation-summary-errors { + color: #b94a48; +} -.validation-summary-errors { color: #b94a48; } +.validation-summary-valid { + display: none; +} -.validation-summary-valid { display: none; } +div.active { + background-color: #e7c9d3 +} -@media (max-width: 600px) { - .facet_sidebar { +div[ng-app] div.nonactive { display: none; - } +} + +@media (min-width: 600px) { + .returnLink { + display: none; + } +} + +@media (max-width: 599px) { + div[ng-app] div.active:not(.lastActive) { + display: none; + } +} + +/* -----------------*/ +/* CSS Transitions */ +/* -----------------*/ + +.col-md-4, +.col-md-5, +.col-md-6, +.col-md-12 { + -moz-transition: width 1s; + -o-transition: width 1s; + -webkit-transition: width 1s; + transition: width 1s; } \ No newline at end of file diff --git a/Client/Controllers/AccountController.cs b/Client/Controllers/AccountController.cs index 422dd26..04c94d3 100644 --- a/Client/Controllers/AccountController.cs +++ b/Client/Controllers/AccountController.cs @@ -51,7 +51,7 @@ public async Task ExternalLoginCallback(string returnUrl) return RedirectToAction("Home", "Home"); } - await SignInAsync(loginInfo.DefaultUserName, false); + SignInAsync(loginInfo.DefaultUserName, false); return RedirectToLocal(returnUrl); } @@ -74,7 +74,7 @@ public ActionResult Login(string returnUrl) Url.Action("ExternalLoginCallback", "Account", new {ReturnUrl = returnUrl})); } - private async Task SignInAsync(string userName, bool isPersistent) + private void SignInAsync(string userName, bool isPersistent) { AuthenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie); var identity = new ClaimsIdentity(DefaultAuthenticationTypes.ApplicationCookie); @@ -119,5 +119,11 @@ public override void ExecuteResult(ControllerContext context) context.HttpContext.GetOwinContext().Authentication.Challenge(properties, LoginProvider); } } + + public ActionResult ExternalLoginDemo(string extreturnurl) + { + SignInAsync("Demouser", false); + return RedirectToLocal(extreturnurl); + } } } \ No newline at end of file diff --git a/Client/Scripts/Controllers/crudControllers.js b/Client/Scripts/Controllers/crudControllers.js index 37ccff6..2aa91d0 100644 --- a/Client/Scripts/Controllers/crudControllers.js +++ b/Client/Scripts/Controllers/crudControllers.js @@ -1,68 +1,39 @@ -// -// This file was generated by T4 code generator AngularGenerator.tt. -// Any changes made to this file manually will be lost next time the file is regenerated. -// - +'use strict'; var crudControllers = angular.module('crudControllers', []); -crudControllers.controller('fullViewController', function($scope, $route, $location) { - $scope.$on('$routeChangeSuccess', function() { - var path = $location.path(); - console.log(path); - $scope.showEmployer = false; - $scope.showEmployee = false; - if (path === '/employer') { - $scope.showEmployer = true; - } else if (path.lastIndexOf('/Employees', 0) === 0) { - $scope.showEmployer = true; - $scope.showEmployee = true; - } else if (path.lastIndexOf('/Taxcards', 0) === 0) { - $scope.showEmployer = true; - $scope.showEmployee = true; - $scope.showTaxcard = true; - } else { - $scope.showEmployer = true; - } - }); -}); - -crudControllers.controller('employeeController', function($scope, $http, $routeParams) { - - $http.get('../api/Employee/' + $routeParams.id).success(function (data) { - $scope.employee = data; - }); -} -); - -// ReSharper disable once InconsistentNaming -crudControllers.controller('employerController', function($scope, $http) { - - //if ($state.current.data.employer !== undefined) { - // $scope.employer = $state.current.data.employer; - // return; - //} - - $http.get('../api/Employer').success(function(data) { - $scope.employer = data; - -// DataStore.employer = data; - }); -} -); - - -crudControllers.controller('salarycalculationController', function($scope, $http) { - $http.get('../api/SalaryCalculation').success(function(data) { - $scope.salarycalculation = data; - }); -} -); - - -crudControllers.controller('taxcardController', function ($scope, $http, $routeParams) { - $http.get('../api/Taxcard/' + $routeParams.id).success(function (data) { - $scope.taxcard = data; - }); -} -); \ No newline at end of file +crudControllers.controller('fullViewController', ['$scope', '$http', + function ($scope, $http) { + var getEmployer = function () { + $http.get('../api/Employer').success(function (data) { + $scope.employer = data; + $scope.employee = undefined; + }); + }; + + $scope.getEmployer = getEmployer; + + getEmployer(); + + $scope.getEmployee = function (id) { + $http.get('../api/Employee/' + id).success(function (data) { + $scope.employee = data; + $scope.isactive = false; + $scope.taxcard = undefined; + }); + }; + + $scope.getTaxcard = function (id) { + $http.get('../api/Taxcard/' + id).success(function (data) { + $scope.taxcard = data; + $scope.isactive = true; + }); + }; + }]); + +//crudControllers.controller('salarycalculationController', function ($scope, $http) { +// $http.get('../api/SalaryCalculation').success(function (data) { +// $scope.salarycalculation = data; +// }); +//} +//); \ No newline at end of file diff --git a/Client/Scripts/Vendor/jquery.livequery.min.js b/Client/Scripts/Vendor/jquery.livequery.min.js new file mode 100644 index 0000000..82fba13 --- /dev/null +++ b/Client/Scripts/Vendor/jquery.livequery.min.js @@ -0,0 +1,8 @@ +/*! jquery.livequery - v1.3.6 - 2013-08-26 + * Copyright (c) + * (c) 2010, Brandon Aaron (http://brandonaaron.net) + * (c) 2012 - 2013, Alexander Zaytsev (http://hazzik.ru/en) + * Dual licensed under the MIT (MIT_LICENSE.txt) + * and GPL Version 2 (GPL_LICENSE.txt) licenses. + */ +!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?a(require("jquery")):a(jQuery)}(function(a,b){function c(a,b,c,d){return!(a.selector!=b.selector||a.context!=b.context||c&&c.$lqguid!=b.fn.$lqguid||d&&d.$lqguid!=b.fn2.$lqguid)}a.extend(a.fn,{livequery:function(b,e){var f,g=this;return a.each(d.queries,function(a,d){return c(g,d,b,e)?(f=d)&&!1:void 0}),f=f||new d(g.selector,g.context,b,e),f.stopped=!1,f.run(),g},expire:function(b,e){var f=this;return a.each(d.queries,function(a,g){c(f,g,b,e)&&!f.stopped&&d.stop(g.id)}),f}});var d=a.livequery=function(b,c,e,f){var g=this;return g.selector=b,g.context=c,g.fn=e,g.fn2=f,g.elements=a([]),g.stopped=!1,g.id=d.queries.push(g)-1,e.$lqguid=e.$lqguid||d.guid++,f&&(f.$lqguid=f.$lqguid||d.guid++),g};d.prototype={stop:function(){var b=this;b.stopped||(b.fn2&&b.elements.each(b.fn2),b.elements=a([]),b.stopped=!0)},run:function(){var b=this;if(!b.stopped){var c=b.elements,d=a(b.selector,b.context),e=d.not(c),f=c.not(d);b.elements=d,e.each(b.fn),b.fn2&&f.each(b.fn2)}}},a.extend(d,{guid:0,queries:[],queue:[],running:!1,timeout:null,registered:[],checkQueue:function(){if(d.running&&d.queue.length)for(var a=d.queue.length;a--;)d.queries[d.queue.shift()].run()},pause:function(){d.running=!1},play:function(){d.running=!0,d.run()},registerPlugin:function(){a.each(arguments,function(b,c){if(a.fn[c]&&!(a.inArray(c,d.registered)>0)){var e=a.fn[c];a.fn[c]=function(){var a=e.apply(this,arguments);return d.run(),a},d.registered.push(c)}})},run:function(c){c!==b?a.inArray(c,d.queue)<0&&d.queue.push(c):a.each(d.queries,function(b){a.inArray(b,d.queue)<0&&d.queue.push(b)}),d.timeout&&clearTimeout(d.timeout),d.timeout=setTimeout(d.checkQueue,20)},stop:function(c){c!==b?d.queries[c].stop():a.each(d.queries,d.prototype.stop)}}),d.registerPlugin("append","prepend","after","before","wrap","attr","removeAttr","addClass","removeClass","toggleClass","empty","remove","html","prop","removeProp"),a(function(){d.play()})}); \ No newline at end of file diff --git a/Client/Scripts/_references.js b/Client/Scripts/_references.js index 4ea522f2b826bf25cb935b8b14f66bd7df46c52e..03518a259aa554176825e70bd09c4896aeae79b2 100644 GIT binary patch delta 58 zcmaFCI*ENl8zXZmL*`^bCfmtvj87&XVp5xYfYEJo7L(V+eLTW?3^@#$3}pHere you can modify your own data as employer as well as the basic data related to your employees -
+
-
+
+
+
@section ScriptToRunAtTheEnd { - + + + } \ No newline at end of file diff --git a/Client/Views/Partials/employee.html b/Client/Views/Partials/employee.html index ada3fa8..2c09125 100644 --- a/Client/Views/Partials/employee.html +++ b/Client/Views/Partials/employee.html @@ -1,4 +1,6 @@ -
+
+ + Back to employer

EmployeeId: {{ employee.EmployeeId }}

Name: {{ employee.Name }}

@@ -10,7 +12,7 @@
  • - SalaryCalculationId: {{ childdata.SalaryCalculationId }} + SalaryCalculationId: {{ childdata.SalaryCalculationId }} PeriodStartDate: {{ childdata.PeriodStartDate }} PeriodEndDate: {{ childdata.PeriodEndDate }} GrossAmount: {{ childdata.GrossAmount }} NetAmount: {{ childdata.NetAmount }} Tax: {{ childdata.Tax }} EmployeeId: {{ childdata.EmployeeId }} Employee: {{ childdata.Employee }}

  • @@ -19,7 +21,7 @@
  • - TaxcardId: {{ childdata.TaxcardId }} + TaxcardId: {{ childdata.TaxcardId }} TaxPercentage: {{ childdata.TaxPercentage }} EmployeeId: {{ childdata.EmployeeId }} Employee: {{ childdata.Employee }}

  • diff --git a/Client/Views/Partials/employer.html b/Client/Views/Partials/employer.html index 57e517e..5cd6654 100644 --- a/Client/Views/Partials/employer.html +++ b/Client/Views/Partials/employer.html @@ -1,4 +1,4 @@ -
    +

    EmployerId: {{ employer.EmployerId }}

    Name: {{ employer.Name }}

    @@ -7,7 +7,7 @@
  • - EmployeeId: {{ childdata.EmployeeId }} + EmployeeId: {{ childdata.EmployeeId }} Name: {{ childdata.Name }} Phone: {{ childdata.Phone }} Email: {{ childdata.Email }} EmployerId: {{ childdata.EmployerId }} Employer: {{ childdata.Employer }}

  • diff --git a/Client/Views/Partials/full.html b/Client/Views/Partials/full.html deleted file mode 100644 index 75ed6e1..0000000 --- a/Client/Views/Partials/full.html +++ /dev/null @@ -1,5 +0,0 @@ -
    -
    -
    -
    -
    \ No newline at end of file diff --git a/Client/Views/Partials/taxcard.html b/Client/Views/Partials/taxcard.html index 4593b40..b1e8daa 100644 --- a/Client/Views/Partials/taxcard.html +++ b/Client/Views/Partials/taxcard.html @@ -1,4 +1,6 @@ -
    +
    + + Back to employee

    TaxcardId: {{ taxcard.TaxcardId }}

    TaxPercentage: {{ taxcard.TaxPercentage }}

    diff --git a/Client/Views/Shared/_Layout.cshtml b/Client/Views/Shared/_Layout.cshtml index b1da4e4..f0ee87a 100644 --- a/Client/Views/Shared/_Layout.cshtml +++ b/Client/Views/Shared/_Layout.cshtml @@ -6,7 +6,6 @@ @ViewBag.Title - My ASP.NET Application - @**@
    - +
    + @RenderBody()
    @@ -49,6 +50,7 @@ + @RenderSection("ScriptToRunAtTheEnd", required: false) \ No newline at end of file diff --git a/Client/Web.config b/Client/Web.config index cc42dc9..9ba7cd2 100644 --- a/Client/Web.config +++ b/Client/Web.config @@ -17,6 +17,9 @@ + + + @@ -44,5 +47,6 @@ + \ No newline at end of file diff --git a/Client/mikkark.SCA.Client.csproj b/Client/mikkark.SCA.Client.csproj index 2e2ae55..f9b9364 100644 --- a/Client/mikkark.SCA.Client.csproj +++ b/Client/mikkark.SCA.Client.csproj @@ -28,6 +28,7 @@ DEBUG;TRACE prompt 4 + false pdbonly @@ -121,6 +122,7 @@ + @@ -132,9 +134,9 @@ + - diff --git a/Infrastructure/mikkark.SCA.Infra.csproj b/Infrastructure/mikkark.SCA.Infra.csproj index 1da4b45..9aa0014 100644 --- a/Infrastructure/mikkark.SCA.Infra.csproj +++ b/Infrastructure/mikkark.SCA.Infra.csproj @@ -24,6 +24,7 @@ DEBUG;TRACE prompt 4 + false pdbonly diff --git a/PersistenceLayer/mikkark.SCA.Persistence.csproj b/PersistenceLayer/mikkark.SCA.Persistence.csproj index f214cf1..4f80114 100644 --- a/PersistenceLayer/mikkark.SCA.Persistence.csproj +++ b/PersistenceLayer/mikkark.SCA.Persistence.csproj @@ -20,6 +20,7 @@ DEBUG;TRACE prompt 4 + false pdbonly diff --git a/Reporting/mikkark.SCA.Reporting.csproj b/Reporting/mikkark.SCA.Reporting.csproj index 15e1ca9..6f873c5 100644 --- a/Reporting/mikkark.SCA.Reporting.csproj +++ b/Reporting/mikkark.SCA.Reporting.csproj @@ -24,6 +24,7 @@ DEBUG;TRACE prompt 4 + false pdbonly diff --git a/SalarycalculationCore/Model/AngularGenerator.html b/SalarycalculationCore/Model/AngularGenerator.html deleted file mode 100644 index 171fad3..0000000 --- a/SalarycalculationCore/Model/AngularGenerator.html +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/SalarycalculationCore/Model/AngularGenerator.tt b/SalarycalculationCore/Model/AngularGenerator.tt index 80f3655..eecf75b 100644 --- a/SalarycalculationCore/Model/AngularGenerator.tt +++ b/SalarycalculationCore/Model/AngularGenerator.tt @@ -11,6 +11,8 @@ <# // To use this generator: download the T4 Toolbox from http://www.olegsych.com/ (extension in VS) // and use the T4 Tangible Editor for code editing http://t4-editor.tangible-engineering.com/T4-Editor-Visual-T4-Editing.html (free version) + +// Note: to re-enable generation, set the custom tool back to TextTemplatingFileGenerator in the properties of this file. #> @@ -18,25 +20,25 @@ var list = new List(); foreach (Type type in System.Reflection.Assembly.GetAssembly(typeof(mikkark.SCA.Core.Model.Employee)).GetTypes()) - { + { if (type.Namespace != "mikkark.SCA.Core.Model") { continue; } - if (type.IsAbstract) continue; // only generate JS viewmodels for non-abstract classes + if (type.IsAbstract) continue; // only generate for non-abstract classes - //list.Add(type); - } + list.Add(type); + } //Create partials foreach (var type in list) - { + { var vmtemplate = new PartialsTemplate(type, list); vmtemplate.Output.Project = @"C:\Omat projektit\github\SalaryCalculationApp\Client\mikkark.SCA.Client.csproj"; vmtemplate.Output.File = @"Views\Partials\" + type.Name.ToLower() + ".html"; vmtemplate.Render(); - } + } //Create controllers var controllerTemplate = new CrudControllerTemplate(list); diff --git a/SalarycalculationCore/Model/CrudController.tt b/SalarycalculationCore/Model/CrudController.tt index 9bbbee2..0bf612d 100644 --- a/SalarycalculationCore/Model/CrudController.tt +++ b/SalarycalculationCore/Model/CrudController.tt @@ -4,10 +4,10 @@ public class CrudControllerTemplate : CSharpTemplate { private List _list; - public CrudControllerTemplate (List list) - { + public CrudControllerTemplate (List list) + { _list = list; - } + } public override string TransformText() { @@ -18,17 +18,17 @@ var crudControllers = angular.module('crudControllers', []); <#+ foreach (var type in _list) - { #> + { #> crudControllers.controller('<#= type.Name.ToLower() #>Controller', function ($scope, $http) { - $http.get('../api/<#= type.Name #>').success(function (data) { - $scope.<#= type.Name.ToLower() #> = data; - }); + $http.get('../api/<#= type.Name #>').success(function (data) { + $scope.<#= type.Name.ToLower() #> = data; + }); } ); <#+ } - return this.GenerationEnvironment.ToString(); + return this.GenerationEnvironment.ToString(); } } #> diff --git a/SalarycalculationCore/Model/Partials.tt b/SalarycalculationCore/Model/Partials.tt index 791fc6f..42481f9 100644 --- a/SalarycalculationCore/Model/Partials.tt +++ b/SalarycalculationCore/Model/Partials.tt @@ -4,11 +4,11 @@ public class PartialsTemplate : CSharpTemplate private Type _type; private List _list; - public PartialsTemplate (Type type, List list) - { + public PartialsTemplate (Type type, List list) + { _type = type; _list = list; - } + } public override string TransformText() { @@ -24,34 +24,34 @@ public class PartialsTemplate : CSharpTemplate && prop.PropertyType != typeof(byte[]) && prop.PropertyType.GetInterface("IEnumerable") != null) {#>
      -
    • +
    • <#+ var collectionType = prop.PropertyType.GetGenericArguments()[0]; for(int i = 0; i < collectionType.GetProperties().Length ; i++) { - var prop2 = collectionType.GetProperties()[i]; - if (prop2.PropertyType == typeof(string) || - prop2.PropertyType.GetInterface("IEnumerable") == null) { + var childProperty = collectionType.GetProperties()[i]; + if (childProperty.PropertyType == typeof(string) || + childProperty.PropertyType.GetInterface("IEnumerable") == null) { if (i == 0) { #> - <#= prop2.Name #>: {{ childdata.<#= prop2.Name #> }} + <#= childProperty.Name #>: {{ childdata.<#= childProperty.Name #> }} <#+ } else { #> - <#= prop2.Name #>: {{ childdata.<#= prop2.Name #> }} <#+ + <#= childProperty.Name #>: {{ childdata.<#= childProperty.Name #> }} <#+ } } } #>

      -
    • -
    + + <#+ } else { #>

    <#= prop.Name #>: {{ <#= _type.Name.ToLower() #>.<#= prop.Name #> }}

    <#+ } // end if #> @@ -60,7 +60,7 @@ public class PartialsTemplate : CSharpTemplate
    <#+ - return this.GenerationEnvironment.ToString(); + return this.GenerationEnvironment.ToString(); } } #> diff --git a/SalarycalculationCore/mikkark.SCA.Core.csproj b/SalarycalculationCore/mikkark.SCA.Core.csproj index f6d8e1b..1f2da48 100644 --- a/SalarycalculationCore/mikkark.SCA.Core.csproj +++ b/SalarycalculationCore/mikkark.SCA.Core.csproj @@ -24,6 +24,7 @@ DEBUG;TRACE prompt 4 + false pdbonly @@ -81,14 +82,8 @@ Partials.cs - TextTemplatingFileGenerator - AngularGenerator.html ..\..\Client\Scripts\Controllers\crudControllers.js -..\..\Client\Views\Partials\employee.html -..\..\Client\Views\Partials\employer.html -..\..\Client\Views\Partials\salarycalculation.html -..\..\Client\Views\Partials\taxcard.html .\AngularGenerator.html @@ -97,13 +92,6 @@ - - - True - True - AngularGenerator.tt - -