From 9da473c343e3e77cf40c18183d36e0543a27bcc8 Mon Sep 17 00:00:00 2001 From: sachinkulkarni12 Date: Wed, 25 Feb 2015 19:42:17 +0530 Subject: [PATCH] MIFOSX-1888:New feature based configuration file to specify which fields should be editable/read only/hidden --- UIconfig.json | 37 ++++++ app/scripts/config/UIconfig.json | 34 ++++++ .../loanAccount/EditLoanAccAppController.js | 8 +- .../loanAccount/NewLoanAccAppController.js | 8 +- .../controllers/main/MainController.js | 4 +- app/scripts/mifosXComponents-build.js | 3 +- app/scripts/mifosXComponents.js | 3 +- app/scripts/modules/csv.js | 2 +- app/scripts/services/UIConfigService.js | 42 +++++++ app/views/loans/editloanaccount.html | 103 +++++++++-------- app/views/loans/newloanaccount.html | 109 ++++++++++-------- 11 files changed, 249 insertions(+), 104 deletions(-) create mode 100644 UIconfig.json create mode 100644 app/scripts/config/UIconfig.json create mode 100644 app/scripts/services/UIConfigService.js diff --git a/UIconfig.json b/UIconfig.json new file mode 100644 index 00000000..0ccaee9d --- /dev/null +++ b/UIconfig.json @@ -0,0 +1,37 @@ +// Configuration file for making the fields hide , show and Read only +// To enable the configuration create a folder called config under app/scripts and copy the UIconfig.json file under app/scripts/config +//Any of the values set to true the respected fields are hidden and the values set to false the fields are visible in the respected page. +{ + "enableUIDisplayConfiguration": true, + "uiDisplayConfigurations": { + "loanAccount": { + "isHiddenField": { + "fundId": true, + "linkAccountId": true, + "createStandingInstruction": true, + "numberOfRepayments": true, + "repaymentEvery": true, + "repaymentFrequencyType": true, + "repaymentFrequencyNthDayType": true, + "repaymentFrequencyDayOfWeekType": true, + "interestChargedFromDate": true, + "repaymentsStartingFromDate": true, + "interestType": true, + "amortizationType": true, + "interestCalculationPeriodType": true, + "inArrearsTolerance": true, + "graceOnInterestCharged": true, + "transactionProcessingStrategyId": true, + "graceOnInterestPayment": true, + "graceOnArrearsAgeing": true + }, + "isHiddenSection": { + "interestRecalculationSection": true, + "collateralSection": true + }, + "isReadOnlyField": { + "loanTermFrequencyType": true + } + } + } +} \ No newline at end of file diff --git a/app/scripts/config/UIconfig.json b/app/scripts/config/UIconfig.json new file mode 100644 index 00000000..1fb22f2c --- /dev/null +++ b/app/scripts/config/UIconfig.json @@ -0,0 +1,34 @@ +{ + "enableUIDisplayConfiguration": true, + "uiDisplayConfigurations": { + "loanAccount": { + "isHiddenField": { + "fundId": true, + "linkAccountId": true, + "createStandingInstruction": true, + "numberOfRepayments": true, + "repaymentEvery": true, + "repaymentFrequencyType": true, + "repaymentFrequencyNthDayType": true, + "repaymentFrequencyDayOfWeekType": true, + "interestChargedFromDate": true, + "repaymentsStartingFromDate": true, + "interestType": true, + "amortizationType": true, + "interestCalculationPeriodType": true, + "inArrearsTolerance": true, + "graceOnInterestCharged": true, + "transactionProcessingStrategyId": true, + "graceOnInterestPayment": true, + "graceOnArrearsAgeing": true + }, + "isHiddenSection": { + "interestRecalculationSection": true, + "collateralSection": true + }, + "isReadOnlyField": { + "loanTermFrequencyType": true + } + } + } +} \ No newline at end of file diff --git a/app/scripts/controllers/loanAccount/EditLoanAccAppController.js b/app/scripts/controllers/loanAccount/EditLoanAccAppController.js index 861e8818..71cac773 100755 --- a/app/scripts/controllers/loanAccount/EditLoanAccAppController.js +++ b/app/scripts/controllers/loanAccount/EditLoanAccAppController.js @@ -1,6 +1,6 @@ (function (module) { mifosX.controllers = _.extend(module, { - EditLoanAccAppController: function (scope, routeParams, resourceFactory, location, dateFilter) { + EditLoanAccAppController: function (scope, routeParams, resourceFactory, location, dateFilter, uiConfigService) { scope.previewRepayment = false; scope.formData = {}; @@ -240,6 +240,10 @@ } + + uiConfigService.appendConfigToScope(scope); + + scope.submit = function () { // Make sure charges and collaterals are empty before initializing. delete scope.formData.charges; @@ -294,7 +298,7 @@ } } }); - mifosX.ng.application.controller('EditLoanAccAppController', ['$scope', '$routeParams', 'ResourceFactory', '$location', 'dateFilter', mifosX.controllers.EditLoanAccAppController]).run(function ($log) { + mifosX.ng.application.controller('EditLoanAccAppController', ['$scope', '$routeParams', 'ResourceFactory', '$location', 'dateFilter', 'UIConfigService', mifosX.controllers.EditLoanAccAppController]).run(function ($log) { $log.info("EditLoanAccAppController initialized"); }); }(mifosX.controllers || {})); \ No newline at end of file diff --git a/app/scripts/controllers/loanAccount/NewLoanAccAppController.js b/app/scripts/controllers/loanAccount/NewLoanAccAppController.js index a1ecc021..2a9ab1c6 100755 --- a/app/scripts/controllers/loanAccount/NewLoanAccAppController.js +++ b/app/scripts/controllers/loanAccount/NewLoanAccAppController.js @@ -1,6 +1,6 @@ (function (module) { mifosX.controllers = _.extend(module, { - NewLoanAccAppController: function (scope, routeParams, resourceFactory, location, dateFilter) { + NewLoanAccAppController: function (scope, routeParams, resourceFactory, location, dateFilter, uiConfigService) { scope.previewRepayment = false; scope.clientId = routeParams.clientId; scope.groupId = routeParams.groupId; @@ -10,12 +10,14 @@ scope.collateralFormData = {}; //For collaterals scope.inparams = {resourceType: 'template', activeOnly: 'true'}; scope.date = {}; + scope.date.first = new Date(); if (scope.clientId) { scope.inparams.clientId = scope.clientId; scope.formData.clientId = scope.clientId; } + if (scope.groupId) { scope.inparams.groupId = scope.groupId; scope.formData.groupId = scope.groupId; @@ -191,6 +193,8 @@ } + uiConfigService.appendConfigToScope(scope); + scope.submit = function () { // Make sure charges and collaterals are empty before initializing. delete scope.formData.charges; @@ -251,7 +255,7 @@ } } }); - mifosX.ng.application.controller('NewLoanAccAppController', ['$scope', '$routeParams', 'ResourceFactory', '$location', 'dateFilter', mifosX.controllers.NewLoanAccAppController]).run(function ($log) { + mifosX.ng.application.controller('NewLoanAccAppController', ['$scope', '$routeParams', 'ResourceFactory', '$location', 'dateFilter', 'UIConfigService', mifosX.controllers.NewLoanAccAppController]).run(function ($log) { $log.info("NewLoanAccAppController initialized"); }); }(mifosX.controllers || {})); diff --git a/app/scripts/controllers/main/MainController.js b/app/scripts/controllers/main/MainController.js index 55eef52a..f18922ae 100644 --- a/app/scripts/controllers/main/MainController.js +++ b/app/scripts/controllers/main/MainController.js @@ -1,8 +1,9 @@ (function (module) { mifosX.controllers = _.extend(module, { - MainController: function (scope, location, sessionManager, translate, $rootScope, localStorageService, keyboardManager, $idle, tmhDynamicLocale) { + MainController: function (scope, location, sessionManager, translate, $rootScope, localStorageService, keyboardManager, $idle, tmhDynamicLocale, uiConfigService) { scope.version = "1.26.0"; scope.releasedate = "22/Dec/14"; //Day/Month/Year + uiConfigService.init(); //hides loader scope.domReady = true; scope.activity = {}; @@ -331,6 +332,7 @@ 'localStorageService', 'keyboardManager', '$idle', 'tmhDynamicLocale', + 'UIConfigService', mifosX.controllers.MainController ]).run(function ($log) { $log.info("MainController initialized"); diff --git a/app/scripts/mifosXComponents-build.js b/app/scripts/mifosXComponents-build.js index 789d3785..b7f53835 100644 --- a/app/scripts/mifosXComponents-build.js +++ b/app/scripts/mifosXComponents-build.js @@ -8,7 +8,8 @@ define(['Q', 'underscore', 'mifosX'], function (Q) { 'HttpServiceProvider.js', 'AuthenticationService.js', 'SessionManager.js', - 'Paginator.js' + 'Paginator.js', + 'UIConfigService.js' ], controllers: [ 'controllers.js' diff --git a/app/scripts/mifosXComponents.js b/app/scripts/mifosXComponents.js index 73596c3e..88a336f8 100755 --- a/app/scripts/mifosXComponents.js +++ b/app/scripts/mifosXComponents.js @@ -11,7 +11,8 @@ define(['Q', 'underscore', 'mifosX'], function (Q) { 'HttpServiceProvider', 'AuthenticationService', 'SessionManager', - 'Paginator' + 'Paginator', + 'UIConfigService' ], controllers: [ 'main/MainController', diff --git a/app/scripts/modules/csv.js b/app/scripts/modules/csv.js index 0ad5834a..26d6767a 100644 --- a/app/scripts/modules/csv.js +++ b/app/scripts/modules/csv.js @@ -4,7 +4,7 @@ // and are loaded in the correct order to satisfy dependency injection // before all nested files are concatenated by Grunt -// Config +// config angular.module('ngCsv.config', []). value('ngCsv.config', { debug: true diff --git a/app/scripts/services/UIConfigService.js b/app/scripts/services/UIConfigService.js new file mode 100644 index 00000000..7a13fa1d --- /dev/null +++ b/app/scripts/services/UIConfigService.js @@ -0,0 +1,42 @@ +(function (module) { + mifosX.services = _.extend(module, { + + UIConfigService: function ($q,$http,$templateCache) { + this.appendConfigToScope = function(scope){ + + var jsonData = $templateCache.get("configJsonObj"); + if(jsonData != null && jsonData != ""){ + jsonData.then(function(data) { + if(data != '' && data != null && data != 'undefined'){ + if(data.enableUIDisplayConfiguration != null && data.enableUIDisplayConfiguration == true){ + scope.response = data; + } + } + }) + } + }; + + this.init = function() { + var deferred = $q.defer(); + $http.get('scripts/config/UIconfig.json').success(function(data) { + deferred.resolve(data); + $templateCache.put("configJsonObj", deferred.promise); + }).error(function(data) { + deferred.reject(data); + }).catch(function(e){ + console.log("Configuration file not found"); + }); + + }; + } + + + + }); + + mifosX.ng.services.service('UIConfigService', ['$q','$http','$templateCache',mifosX.services.UIConfigService]).run(function ($log) { + $log.info("UIConfigService initialized"); + + }); + +}(mifosX.services || {})); diff --git a/app/views/loans/editloanaccount.html b/app/views/loans/editloanaccount.html index c5fa71a0..a04af7ba 100755 --- a/app/views/loans/editloanaccount.html +++ b/app/views/loans/editloanaccount.html @@ -43,8 +43,8 @@ - - + + - + - + @@ -137,22 +144,22 @@ -   - - + + - - + + @@ -182,57 +189,57 @@   {{loanaccountinfo.interestRateFrequencyType.value}} - - + + - - +