Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div class="row">
- <div class="col-sm-4 pull-right">
- <div class="form-group" ng-if="isShowDropdown">
- <select id="ddlStates" class="form-control" ng-disabled="readOnly || isFormISO"
- ng-model="lobStateSelected" ng-change="addNewLob(lobStateSelected,this)" ng-options="lb.LobValue for lb in originalLobData">
- <option value="">{{::languageStrings.lbl_AddanewLOB}}</option>
- </select>
- </div>
- </div>
- </div>
- <div class="row" ng-repeat="lobItem in lobStateItemData track by $index">
- <div ng-show="lobItem.LobId" class="col-md-12 sa-state-container">
- <h4><span>{{lobItem.LobValue}}</span> <a href="" ng-click="removeLobIfo(lobItem)" class="link" ng-hide="readOnly || isFormISO">{{::languageStrings.lbl_RemovethisLOB}}<span class="glyphicon glyphicon-trash" aria-hidden="true"></span></a> </h4>
- <div class="row">
- <div class="col-md-12">
- <table class="table-theme-one">
- <thead>
- <tr>
- <th valign="top" class="col-sm-4 required"><label for=""><span ng-if="formStatusId === 'X'">*</span>{{::languageStrings.lbl_State}}</label></th>
- <th valign="top" class="col-sm-3 required"><label for=""><span ng-if="formStatusId === 'X'">*</span>{{::languageStrings.lbl_EffectiveDate}}</label></th>
- <th valign="top" class="col-sm-3"><label for="">{{::languageStrings.lbl_WithdrawnDate}}</label></th>
- <th ng-if="!readOnly" valign="top" class="col-sm-2"></th>
- </tr>
- <tr>
- <th valign="top" class="col-sm-4" ng-class="{'has-error':stateInvalid{{$index}}}">
- <div class="btn-group btn-block btn-group-sm">
- <vm-multi-select multi-select-control="stateMultiSelect" options="lobItem.StateData.stateList" selected-model="lobItem.selectedStates" events="formEvents" checkboxes="true" extra-settings="settings" translation-texts="translationTexts" disable="readOnly || isFormISO">
- </vm-multi-select>
- </div>
- <p ng-show="stateInvalid{{$index}}">{{::languageStrings.lbl_State_is_required}}</p>
- </th>
- <th valign="top" class="col-sm-3" ng-class="{'has-error':effectiveDateInvalid{{$index}}}">
- <div class="input-group date">
- <input type="text" readonly class="timeselect form-control input-sm" placeholder="{{dateFormat | lowercase}}" ng-change="effectiveChanged({{$index}}, lobItem.StateData)"
- data-show-weeks="false" show-button-bar="false" uib-datepicker-popup='{{dateFormat}}' datepicker-localdate datepicker-append-to-body="true" ng-model="lobItem.StateData.EffectiveDate" id="dateCustomeFive" is-open="openedInterLineEffectiveDate$index"
- close-text="Close" />
- <span class="input-group-btn">
- <button type="button" class="btn btn-default input-sm" ng-disabled="readOnly || isFormISO" ng-click="openedInterLineEffectiveDate$index = !openedInterLineEffectiveDate$index"><i class="glyphicon glyphicon-calendar"></i></button>
- </span>
- </div>
- <p ng-show="effectiveDateInvalid{{$index}}">{{::languageStrings.lbl_EffectiveDate_is_required}}</p>
- </th>
- <th valign="top" class="col-sm-3">
- <div class="input-group date">
- <input type="text" readonly class="timeselect form-control input-sm" placeholder="{{dateFormat | lowercase}}" datepicker-options="lobItem.StateData.dateOptions"
- data-show-weeks="false" show-button-bar="false" uib-datepicker-popup='{{dateFormat}}' datepicker-localdate datepicker-append-to-body="true" ng-model="lobItem.StateData.WithdrawnDate" is-open="openedInterLineWithDrawnDate$index"
- close-text="Close" />
- <span class="input-group-btn">
- <button type="button" class="btn btn-default input-sm" ng-disabled="readOnly || isFormISO" ng-click="openedInterLineWithDrawnDate$index = !openedInterLineWithDrawnDate$index"><i class="glyphicon glyphicon-calendar"></i></button>
- </span>
- </div>
- </th>
- <th valign="top" class="col-sm-2"><button id="btnAddStates" class="btn btn-primary btn-sm " value="Add" ng-click="addStateInfo(lobItem.StateData,lobItem.StateData.showLobState)" ng-disabled="readOnly || isFormISO">{{::languageStrings.lbl_Add}}</button></th>
- </tr>
- </thead>
- <tbody>
- <tr ng-repeat="state in lobItem.StateItemData | orderBy : 'StateName'">
- <td><span>{{state.StateName}}</span></td>
- <td valign="top">
- <div class="input-group date">
- <input type="text" readonly class="timeselect form-control input-sm" placeholder="{{dateFormat | lowercase}}" ng-change="effectiveChanged({{$index}}, state)"
- data-show-weeks="false" show-button-bar="false" uib-datepicker-popup='{{dateFormat}}' datepicker-localdate datepicker-append-to-body="true" ng-model="state.EffectiveDate" is-open="openedEffectiveDate$index"
- close-text="Close" />
- <span class="input-group-btn">
- <button type="button" class="btn btn-default input-sm" ng-disabled="readOnly || isFormISO" ng-click="openedEffectiveDate$index = !openedEffectiveDate$index"><i class="glyphicon glyphicon-calendar"></i></button>
- </span>
- </div>
- </td>
- <td valign="top">
- <div class="input-group date">
- <input type="text" readonly class="timeselect form-control input-sm" placeholder="{{dateFormat | lowercase}}" datepicker-options="state.dateOptions"
- data-show-weeks="false" show-button-bar="false" uib-datepicker-popup='{{dateFormat}}' datepicker-localdate datepicker-append-to-body="true" ng-model="state.WithdrawnDate" is-open="openedWithdrawnDate$index"
- close-text="Close" />
- <span class="input-group-btn" ng-init="state.dateOptions.minDate = state.EffectiveDate">
- <button type="button" class="btn btn-default input-sm" ng-disabled="readOnly || isFormISO" ng-click="openedWithdrawnDate$index = !openedWithdrawnDate$index"><i class="glyphicon glyphicon-calendar"></i></button>
- </span>
- </div>
- </td>
- <td valign="top">
- <a href="" name="Remove" value="remove" ng-click="removeStateInfo(state)" ng-if="!readOnly && !isFormISO">{{::languageStrings.lbl_Remove}}</a>
- <span ng-if="readOnly || isFormISO">{{::languageStrings.lbl_Remove}}</span>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- </div>
- </div>
- </div>
- <div ng-show="selectedLOB">
- <h4><span>{{selectedLOB}}</span></h4>
- <div class="row">
- <div class="col-md-12">
- <table class="table-theme-one">
- <thead>
- <tr>
- <th valign="top" class="col-sm-4 required" ng-class="{'has-error':stateInvalid0}"><label for=""><span ng-if="formStatusId == 2">*</span>{{::languageStrings.lbl_State}}</label></th>
- <th valign="top" class="col-sm-3 required" ng-class="{'has-error':effectiveDateInvalid0}"><label for=""><span ng-if="formStatusId == 2">*</span>{{::languageStrings.lbl_EffectiveDate}}</label></th>
- <th valign="top" class="col-sm-3"><label>{{::languageStrings.lbl_WithdrawnDate}}</label></th>
- <th valign="top" class="col-sm-2"></th>
- </tr>
- <tr>
- <th valign="top" class="col-sm-4" ng-class="{'has-error':stateInvalid0}">
- <div class="btn-group btn-block btn-group-sm">
- <vm-multi-select multi-select-control="stateMultiSelect" options="stateList" selected-model="selectedStates" events="formEvents" checkboxes="true" extra-settings="settings" translation-texts="translationTexts" disable="readOnly || isFormISO">
- </vm-multi-select>
- </div>
- <p ng-show="stateInvalid0">{{::languageStrings.lbl_State_is_required}}</p>
- </th>
- <th valign="top" class="col-sm-3" ng-class="{'has-error':effectiveDateInvalid0}">
- <div class="input-group date" id="datetimepicker1">
- <input type="text" readonly class="timeselect form-control input-sm" placeholder="{{dateFormat | lowercase}}" ng-change="effectiveChanged(-1, stateObj)"
- data-show-weeks="false" show-button-bar="false" uib-datepicker-popup='{{dateFormat}}' datepicker-localdate datepicker-append-to-body="true" ng-model="stateObj.EffectiveDate" is-open="status.openedEffectiveDate"
- close-text="Close" />
- <span class="input-group-btn">
- <button type="button" class="btn btn-default input-sm" ng-disabled="readOnly || isFormISO" ng-click="status.openedEffectiveDate = !status.openedEffectiveDate"><i class="glyphicon glyphicon-calendar"></i></button>
- </span>
- </div>
- <p ng-show="effectiveDateInvalid0">{{::languageStrings.lbl_EffectiveDate_is_required}}</p>
- </th>
- <th valign="top" class="col-sm-3">
- <div class="input-group date" id="datetimepicker1">
- <input type="text" readonly class="timeselect form-control input-sm" placeholder="{{dateFormat | lowercase}}" datepicker-options="stateObj.dateOptions"
- data-show-weeks="false" show-button-bar="false" uib-datepicker-popup='{{dateFormat}}' datepicker-localdate datepicker-append-to-body="true" ng-model="stateObj.WithdrawnDate" is-open="status.openedWithdrawnDate"
- close-text="Close" />
- <span class="input-group-btn">
- <button type="button" class="btn btn-default input-sm" ng-disabled="readOnly || isFormISO" ng-click="status.openedWithdrawnDate = !status.openedWithdrawnDate"><i class="glyphicon glyphicon-calendar"></i></button>
- </span>
- </div>
- </th>
- <th valign="top" class="col-sm-2"><button id="btnAddStates" class="btn btn-primary btn-sm" value="Add" ng-click="addStateInfo(stateObj,selectedLOBId)" ng-disabled="readOnly || isFormISO">{{::languageStrings.lbl_Add}}</button></th>
- </tr>
- </thead>
- <tbody>
- <tr ng-repeat="stateItem in stateData | orderBy : 'StateName'">
- <td><span>{{stateItem.StateName}}</span></td>
- <td valign="top">
- <div class="input-group date">
- <input type="text" readonly class="timeselect form-control input-sm" placeholder="{{dateFormat | lowercase}}" ng-change="effectiveChanged({{$index}}, stateItem)"
- data-show-weeks="false" show-button-bar="false" uib-datepicker-popup='{{dateFormat}}' datepicker-localdate datepicker-append-to-body="true" ng-model="stateItem.EffectiveDate" is-open="openedEffectiveDate"
- close-text="Close" />
- <span class="input-group-btn">
- <button type="button" class="btn btn-default input-sm" ng-disabled="readOnly || isFormISO" ng-click="openedEffectiveDate = !openedEffectiveDate"><i class="glyphicon glyphicon-calendar"></i></button>
- </span>
- </div>
- </td>
- <td valign="top">
- <div class="input-group date">
- <input type="text" readonly class="timeselect form-control input-sm" placeholder="{{dateFormat | lowercase}}" datepicker-options="stateItem.dateOptions"
- data-show-weeks="false" show-button-bar="false" uib-datepicker-popup='{{dateFormat}}' datepicker-localdate datepicker-append-to-body="true" ng-model="stateItem.WithdrawnDate" is-open="openedWithdrawnDate"
- close-text="Close" />
- <span class="input-group-btn" ng-init="stateItem.dateOptions.minDate = stateItem.EffectiveDate">
- <button type="button" class="btn btn-default input-sm" ng-disabled="readOnly || isFormISO" ng-click="openedWithdrawnDate = !openedWithdrawnDate"><i class="glyphicon glyphicon-calendar"></i></button>
- </span>
- </div>
- </td>
- <td valign="top">
- <a href="" name="Remove" value="remove" ng-click="removeStateInfo(stateItem)" ng-if="!readOnly && !isFormISO">{{::languageStrings.lbl_Remove}}</a>
- <span ng-if="readOnly || isFormISO">{{::languageStrings.lbl_Remove}}</span>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- </div>
- </div>
- // <copyright file="stateApplicability.js" company="Verisk">
- // Copyright 2015
- // </copyright>
- // <summary>
- // State Applicability Controller
- // </summary>
- /// <summary>
- // stateApplicabilityDirectiveCtrl
- /// </summary>
- /// <param name="$scope">The $scope.</param>
- /// <param name="$vmModal">The $VM modal.</param>
- /// <param name="vmConfig">The vm configuration.</param>
- /// <param name="$filter">The $filter.</param>
- app.controller('stateApplicabilityDirectiveCtrl', ['$scope', '$vmModal', 'vmConfig', '$filter', '$rootScope', function ($scope, $vmModal, vmConfig, $filter, $rootScope) {
- //$scope.dateOptions =[];
- //$scope.singleDateOptions = { };
- /// <summary>
- // effectiveChanged
- /// </summary>
- /// <param name="idx">The index.</param>
- /// <param name="val">The value.</param>
- $scope.effectiveChanged = function (idx, stateData) {
- // $scope.stateData = $filter('orderBy')($scope.stateData, 'StateName');
- // if (idx === -1) {
- //$scope.singleDateOptions.minDate = val;
- stateData.dateOptions = {
- minDate: stateData.EffectiveDate
- };
- console.log('stateData', stateData, stateData.EffectiveDate);
- if (stateData.WithdrawnDate && stateData.EffectiveDate > stateData.WithdrawnDate) {
- stateData.WithdrawnDate = null;
- }
- // } else {
- // $scope.stateData[idx].dateOptions = {
- // minDate: val
- // };
- //$scope.dateOptions[idx].minDate = val;
- //if ($scope.stateData[idx] && $scope.stateData[idx].WithdrawnDate && new Date(val).getTime() > new Date($scope.stateData[idx].WithdrawnDate).getTime()) {
- // $scope.stateData[idx].WithdrawnDate = null;
- //}
- // }
- if (idx >= 0) {
- $scope['effectiveDateInvalid' + idx] = false;
- }
- //idx = idx === -1 ? 0 : idx;
- //$scope['effectiveDateInvalid' + idx] = false;
- };
- $scope.languageStrings = vmConfig.languageStrings;
- var stateApplicability = $scope.stateApplicabilityControl,
- stateMultiSelect;
- $scope.stateMultiSelect = stateMultiSelect = {};
- /// <summary>
- // clear states
- /// </summary>
- stateApplicability.clearStates = function () {
- stateMultiSelect.clearAllSelection();
- };
- $scope.settings = {
- idProp: 'StateCode',
- displayProp: 'StateName',
- externalIdProp: ''
- };
- $scope.translationTexts = {
- dynamicButtonTextSuffix: 'State(s) selected',
- buttonDefaultText: 'Select'
- };
- $scope.formEvents = {
- /// <summary>
- // onItemSelect
- /// </summary>
- /// <param name="item">The item.</param>
- onItemSelect: function (item) {
- var lobId = item.lobId === undefined ? $scope.selectedLOBId : item.lobId;
- item.LobId = lobId;
- $scope.selectedOptions = $scope.selectedStates;
- var noOfLobs = $scope.lobStateItemData.length || $scope.selectedOptions.length;
- for (var idx = 0; idx < noOfLobs; ++idx) {
- if ($scope['stateInvalid' + idx]) {
- $scope['stateInvalid' + idx] = false;
- }
- }
- },
- /// <summary>
- // onItemDeselect
- /// </summary>
- /// <param name="item">The item.</param>
- /// <returns>broad casts selectedStateChanges</returns>
- onItemDeselect: function (item) {
- var lobId = item.lobId === undefined ? $scope.selectedLOBId : item.lobId;
- for (var stateIndex = 0; stateIndex < $scope.stateData.length; stateIndex++) {
- if ($scope.stateData[stateIndex].StateId === item.StateCode) {
- $scope.stateData.splice(stateIndex, 1);
- }
- }
- for (var lobIndex = 0; lobIndex < $scope.lobStateItemData.length; lobIndex++) {
- if (($scope.lobStateItemData[lobIndex].LobId === lobId) && ($scope.lobStateItemData[lobIndex].StateItemData !== undefined)) {
- for (var j = 0; j < $scope.lobStateItemData[lobIndex].StateItemData.length; j++) {
- if ($scope.lobStateItemData[lobIndex].StateItemData[j].StateId === item.StateCode) {
- $scope.lobStateItemData[lobIndex].StateItemData.splice(j, 1);
- }
- }
- }
- }
- $scope.selectedOptions = $scope.selectedStates;
- $rootScope.$broadcast('selectedStateChanges', { data: $scope.lobStateItemData.length > 0 ? $scope.lobStateItemData : $scope.stateData });
- }
- };
- /// <summary>
- // triggers on validateStateInfo
- /// </summary>
- /// <param name="event">The event.</param>
- /// <param name="args">The arguments.</param>
- $scope.$on('validateStateInfo', function (event, args) {
- if (args.data.length === 0) {
- $scope.stateInvalid0 = true;
- $scope.effectiveDateInvalid0 = true;
- }
- });
- }]);
- /// <summary>
- // stateApplicability directive
- /// </summary>
- /// <param name="$rootScope">The $root scope.</param>
- /// <param name="$vmModal">The $VM modal.</param>
- /// <param name="vmConfig">The vm configuration.</param>
- /// <param name="roleAccessService">The role access service.</param>
- /// <returns>directive</returns>
- app.directive('stateApplicability', ['$rootScope', '$vmModal', 'vmConfig', 'roleAccessService', 'viewFormService', function ($rootScope, $vmModal, vmConfig, roleAccessService, viewFormService) {
- var directive = {};
- directive.restrict = 'E';
- directive.require = 'ngModel';
- directive.$scope = {
- ngModel: '=',
- stateData: '=',
- statesList: '=',
- formInfo: '=',
- stateApplicabilityControl: '='
- };
- directive.templateUrl = '/Content/templates/StateApplicabilityTemp.tmpl.html';
- directive.controller = 'stateApplicabilityDirectiveCtrl';
- /// <summary>
- // directive link
- /// </summary>
- /// <param name="$scope">The $scope.</param>
- directive.link = function ($scope) {
- $scope.lobStateItemData = [];
- $scope.selectedStates = [];
- $scope.interLineStateData = [];
- $scope.lobStateItemData.StateItemData = [];
- $scope.dateFormat = vmConfig.dateFormat;
- /// <summary>
- // getAllModules
- /// </summary>
- /// <param name="accessModulesData">The access modules data.</param>
- /// <returns>sets scope variable</returns>
- roleAccessService.isUserISOTenant(function (isIsoTenant) {
- $scope.isIsoTenant = isIsoTenant;
- roleAccessService.getAllModules(function (accessModulesData) {
- var auditAccessModule = _.findWhere(accessModulesData, { 'Module': 'EditMetaData', Function: 'StateApplicability' });
- if (auditAccessModule || ($scope.isIsoTenant && viewFormService.getFormIdentifier().FormStatusId === 'P')) {
- $scope.readOnly = false;
- } else {
- $scope.readOnly = true;
- }
- });
- });
- /// <summary>
- // triggers when applyViewStateInfo
- /// </summary>
- /// <param name="event">The event.</param>
- /// <param name="args">The arguments.</param>
- /// <returns>broad casts selected states</returns>
- $scope.$on('applyViewStateInfo', function (event, args) {
- if (args.generalInfo !== undefined && args.lobStates.length !== 0) {
- $scope.setViewState(args.generalInfo.Library);
- var lobStatesInfo = [];
- if (args.generalInfo.GeneralLOBId === 'IL') {
- for (var stateIndex = 0; stateIndex < args.stateInfo.length; stateIndex++) {
- for (var lobIndex = 0; lobIndex < args.lobStates.length; lobIndex++) {
- if (args.stateInfo[stateIndex].LobId === args.lobStates[lobIndex].LobId) {
- lobStatesInfo.push({
- LobId: args.lobStates[lobIndex].LobId,
- LobValue: args.lobStates[lobIndex].LobValue
- });
- }
- }
- }
- if (args.stateInfo.length !== 0) {
- /// <summary>
- // lobStatesInfo
- /// </summary>
- /// <param name="item">The item.</param>
- /// <returns>LobId array</returns>
- lobStatesInfo = _.uniq(lobStatesInfo, function (item) {
- return item.LobId;
- });
- var sortedLobStatesInfo = _.sortBy(lobStatesInfo, 'LobId');
- $scope.originalLobData = args.lobStates;
- for (var lobStateDataIndex = 0; lobStateDataIndex < $scope.originalLobData.length; lobStateDataIndex++) {
- for (var lobStatesInfoIndex = 0; lobStatesInfoIndex < sortedLobStatesInfo.length; lobStatesInfoIndex++) {
- if (sortedLobStatesInfo[lobStatesInfoIndex].LobId === $scope.originalLobData[lobStateDataIndex].LobId) {
- $scope.originalLobData.splice(lobStateDataIndex, 1);
- }
- }
- }
- $scope.lobStateItemData = sortedLobStatesInfo;
- } else {
- $scope.originalLobData = args.lobStates;
- }
- }
- for (var lobStateItemDataIndex = 0; lobStateItemDataIndex < $scope.lobStateItemData.length; lobStateItemDataIndex++) {
- $scope.lobStateItemData[lobStateItemDataIndex].selectedStates = [];
- var interLineStates = angular.copy(args.stateList);
- /// <summary>
- // fills selectedStates
- /// </summary>
- /// <param name="stateItem">The state item.</param>
- angular.forEach(interLineStates, function (stateItem) {
- for (var stateInfoIndex = 0; stateInfoIndex < args.stateInfo.length; stateInfoIndex++) {
- if (args.stateInfo[stateInfoIndex].StateId === stateItem.StateCode && $scope.lobStateItemData[lobStateItemDataIndex].LobId === args.stateInfo[stateInfoIndex].LobId) {
- stateItem.lobId = args.stateInfo[stateInfoIndex].LobId;
- $scope.lobStateItemData[lobStateItemDataIndex].selectedStates.push(stateItem);
- break;
- }
- }
- });
- $scope.lobStateItemData[lobStateItemDataIndex].StateData = { stateList: interLineStates, EffectiveDate: '', WithdrawnDate: '' };
- $scope.lobStateItemData[lobStateItemDataIndex].StateItemData = [];
- var sortedLobStates = _.sortBy(lobStatesInfo, 'LobId');
- if (sortedLobStates.length > 0) {
- $scope.lobStateItemData[lobStateItemDataIndex].StateData.showLobState = sortedLobStates[lobStateItemDataIndex].LobId;
- $scope.lobStateItemData[lobStateItemDataIndex].StateData.showLobStateName = sortedLobStates[lobStateItemDataIndex].LobValue;
- }
- }
- var selectedStates = [];
- /// <summary>
- // fills selectedStates
- /// </summary>
- /// <param name="stateItem">The state item.</param>
- angular.forEach(args.stateList, function (stateItem) {
- for (var stateDataIndex = 0; stateDataIndex < args.stateInfo.length; stateDataIndex++) {
- if (args.stateInfo[stateDataIndex].StateId === stateItem.StateCode) {
- selectedStates.push(stateItem);
- }
- }
- });
- $scope.selectedStates = selectedStates;
- for (var i = 0; i < $scope.lobStateItemData.length; i++) {
- for (var j = 0; j < args.stateInfo.length; j++) {
- if (args.stateInfo[j].LobId === $scope.lobStateItemData[i].LobId) {
- $scope.lobStateItemData[i].StateItemData.push(args.stateInfo[j]);
- }
- }
- }
- $rootScope.$broadcast('selectedStateChanges', { data: $scope.lobStateItemData.length > 0 ? $scope.lobStateItemData : $scope.stateData });
- }
- });
- /// <summary>
- // setViewState
- /// </summary>
- /// <param name="library">The library.</param>
- /// <returns>sets scope variables</returns>
- $scope.setViewState = function (library) {
- $scope.isFormISO = false;
- if (library === 'ISO') {
- $scope.isFormISO = true;
- }
- };
- /// <summary>
- // Add new lob
- /// </summary>
- /// <param name="selectedData">The selected data.</param>
- /// <param name="stateData">The state data.</param>
- $scope.addNewLob = function (selectedData, stateData) {
- if (selectedData != null) {
- $scope.selectedStates = [];
- stateData.lobStateSelected.selectedStates = [];
- stateData.lobStateSelected.StateItemData = [];
- if (stateData.lobStateSelected.StateData) {
- stateData.lobStateSelected.StateData.EffectiveDate = null;
- stateData.lobStateSelected.StateData.WithdrawnDate = null;
- }
- var stateTempList = angular.copy($scope.stateList);
- /// <summary>
- // foreach item in stateTempList sets selectedData lobid
- /// </summary>
- /// <param name="item">The item.</param>
- /// <returns></returns>
- angular.forEach(stateTempList, function (item) {
- item.lobId = selectedData.LobId;
- });
- $scope.originalLobData.splice(stateData.originalLobData.indexOf(selectedData), 1);
- $scope.lobStateItemData.push(selectedData);
- for (var i = 0; i < $scope.lobStateItemData.length; i++) {
- if ($scope.lobStateItemData[i].selectedStates) {
- $scope.lobStateItemData[i].selectedStates = $scope.lobStateItemData[i].selectedStates;
- } else {
- $scope.lobStateItemData[i].selectedStates = [];
- }
- if ($scope.lobStateItemData[i].StateData === undefined) {
- $scope.lobStateItemData[i].StateData = { stateList: stateTempList, EffectiveDate: '', WithdrawnDate: '', showLobState: selectedData.LobId, showLobStateName: selectedData.LobValue };
- }
- }
- }
- };
- /// <summary>
- // removeLobIfo
- /// </summary>
- /// <param name="data">The data.</param>
- /// <returns>broad casts selectedStateChanges </returns>
- $scope.removeLobIfo = function (data) {
- if (data) {
- data.StateItemData = [];
- data.selectedStates = [];
- data.StateData.EffectiveDate = null;
- data.StateData.WithdrawnDate = null;
- }
- $scope.lobStateItemData.splice($scope.lobStateItemData.indexOf(data), 1);
- $scope.originalLobData.push(data);
- $rootScope.$broadcast('selectedStateChanges', { data: $scope.lobStateItemData });
- };
- /// <summary>
- // checkStatesSelected
- /// </summary>
- /// <returns> boolean </returns>
- $scope.checkStatesSelected = function () {
- return $scope.selectedStates.length > 0 ? true : ($scope.selectedStates.length === 0 ? false : true);
- };
- /// <summary>
- // Add state information
- /// </summary>
- /// <param name="data">The data.</param>
- /// <param name="lobId">The lob identifier.</param>
- /// <returns>broad casts selectedStateChanges</returns>
- $scope.addStateInfo = function (data, lobId) {
- var effectiveDate,
- stateIndex,
- withdrawnDate;
- var interlineStateCount = 0;
- /// <summary>
- // foreach item in lobStateItemData sets variables
- /// </summary>
- /// <param name="item">The item.</param>
- /// <param name="idx">The index.</param>
- /// <returns>sets scope variables</returns>
- angular.forEach($scope.lobStateItemData, function (item, idx) {
- if (item.LobId === lobId) {
- interlineStateCount = item.selectedStates.length;
- stateIndex = idx;
- }
- });
- stateIndex = stateIndex || 0;
- $scope['stateInvalid' + stateIndex] = false;
- $scope['effectiveDateInvalid' + stateIndex] = false;
- if ($scope.selectedLOBId !== 'IL') {
- if ($scope.selectedStates.length === 0) {
- $scope['stateInvalid' + stateIndex] = true;
- return;
- }
- } else {
- if ($scope.selectedLOBId === 'IL' && interlineStateCount === 0) {
- $scope['stateInvalid' + stateIndex] = true;
- return;
- }
- }
- if (data) {
- effectiveDate = data.EffectiveDate;
- withdrawnDate = data.WithdrawnDate;
- } else {
- if ($scope.stateObj) {
- effectiveDate = $scope.stateObj.EffectiveDate;
- withdrawnDate = $scope.stateObj.WithdrawnDate;
- } else {
- $scope['effectiveDateInvalid' + stateIndex] = true;
- return;
- }
- }
- withdrawnDate = withdrawnDate === null ? '' : withdrawnDate;
- if (!effectiveDate || effectiveDate === '' || (withdrawnDate !== '' && new Date(withdrawnDate) < new Date(effectiveDate))) {
- $scope['effectiveDateInvalid' + stateIndex] = true;
- } else {
- console.log('stateIndex', stateIndex);
- $scope.addStateAfterValidation(data, lobId);
- }
- $rootScope.$broadcast('selectedStateChanges', { data: $scope.lobStateItemData.length > 0 ? $scope.lobStateItemData : $scope.stateData });
- };
- /// <summary>
- // Add state
- /// </summary>
- /// <param name="data">The data.</param>
- /// <param name="lobId">The lob identifier.</param>
- /// <returns>sets scope variables</returns>
- $scope.addStateAfterValidation = function (data, lobId) {
- console.log('addStateAfterValidation', lobId, data);
- for (var stateIndex = 0; stateIndex < $scope.selectedStates.length; stateIndex++) {
- if ($scope.selectedStates[stateIndex].LobId === lobId) {
- //console.log('stateIndex', stateIndex, $scope.dateOptions[stateIndex] && $scope.dateOptions[stateIndex].minDate);
- //if (!$scope.dateOptions[stateIndex]) {
- // $scope.dateOptions[stateIndex] = {
- // minDate: data.EffectiveDate
- // };
- //}
- var stateData = {
- EffectiveDate: data.EffectiveDate, LobId: lobId, StateId: $scope.selectedStates[stateIndex].StateCode, StateName: $scope.selectedStates[stateIndex].StateName, WithdrawnDate: data.WithdrawnDate,
- dateOptions: {
- minDate: data.EffectiveDate
- }
- };
- $scope.stateData.push(stateData);
- $scope.interLineStateData.push(stateData);
- }
- }
- for (var lobIndex = 0; lobIndex < $scope.lobStateItemData.length; lobIndex++) {
- console.log('$scope.lobStateItemData', lobIndex, $scope.lobStateItemData[lobIndex]);
- if ($scope.lobStateItemData[lobIndex].LobId === lobId) {
- //if (!$scope.dateOptions[stateIndex]) {
- // $scope.dateOptions[lobIndex] = {};
- //}
- //$scope.dateOptions[lobIndex].minDate = $scope.lobStateItemData[lobIndex].StateData.EffectiveDate;
- for (var j = 0; j < $scope.lobStateItemData[lobIndex].selectedStates.length; j++) {
- var stateData = {
- EffectiveDate: $scope.lobStateItemData[lobIndex].StateData.EffectiveDate, LobId: lobId, StateId: $scope.lobStateItemData[lobIndex].selectedStates[j].StateCode, StateName: $scope.lobStateItemData[lobIndex].selectedStates[j].StateName, WithdrawnDate: $scope.lobStateItemData[lobIndex].StateData.WithdrawnDate,
- dateOptions: {
- minDate: $scope.lobStateItemData[lobIndex].StateData.EffectiveDate
- }
- };
- $scope.stateData.push(stateData);
- $scope.interLineStateData.push(stateData);
- }
- }
- }
- /// <summary>
- // uniqueList of stateData
- /// </summary>
- /// <param name="item">The item.</param>
- /// <returns>StateId array</returns>
- var uniqueList = _.uniq($scope.stateData, function (item) {
- return item.StateId;
- });
- var uniqueInterLineList = [];
- /// <summary>
- // fills uniqueInterLineList using foreach
- /// </summary>
- /// <param name="interLineItem">The inter line item.</param>
- /// <returns>uniqueInterLineList</returns>
- angular.forEach($scope.interLineStateData, function (interLineItem) {
- if (interLineItem.LobId === lobId) {
- uniqueInterLineList.push(interLineItem);
- }
- });
- /// <summary>
- // uniqueInterLineList
- /// </summary>
- /// <param name="item">The item.</param>
- /// <returns>StateId array</returns>
- uniqueInterLineList = _.uniq(uniqueInterLineList, function (item) {
- return item.StateId;
- });
- $scope.interLineStateData = uniqueInterLineList;
- $scope.stateData = uniqueList;
- for (var i = 0; i < $scope.lobStateItemData.length; i++) {
- if (!$scope.lobStateItemData[i].StateItemData) {
- $scope.lobStateItemData[i].StateItemData = [];
- }
- if ($scope.lobStateItemData[i].StateItemData.length > 0) {
- for (var interLineIndex = 0; interLineIndex < uniqueInterLineList.length; interLineIndex++) {
- if (uniqueInterLineList[interLineIndex].LobId === $scope.lobStateItemData[i].LobId) {
- $scope.lobStateItemData[i].StateItemData.push(uniqueInterLineList[interLineIndex]);
- }
- }
- /// <summary>
- // uniqueStateList
- /// </summary>
- /// <param name="item">The item.</param>
- /// <returns> StateId array </returns>
- var uniqueStateList = _.uniq($scope.lobStateItemData[i].StateItemData, function (item) {
- return item.StateId;
- });
- $scope.lobStateItemData[i].StateItemData = uniqueStateList;
- } else {
- for (var uniqueInterlineIndex = 0; uniqueInterlineIndex < uniqueInterLineList.length; uniqueInterlineIndex++) {
- if (uniqueInterLineList[uniqueInterlineIndex].LobId === $scope.lobStateItemData[i].LobId) {
- $scope.lobStateItemData[i].StateItemData.push(uniqueInterLineList[uniqueInterlineIndex]);
- }
- }
- }
- }
- if ($scope.stateObj) {
- $scope.stateObj.EffectiveDate = null;
- $scope.stateObj.WithdrawnDate = null;
- }
- for (var lobClearIndex = 0; lobClearIndex < $scope.lobStateItemData.length; lobClearIndex++) {
- if ($scope.lobStateItemData[lobClearIndex].LobId === lobId && $scope.lobStateItemData[lobClearIndex].StateData) {
- $scope.lobStateItemData[lobClearIndex].StateData.EffectiveDate = null;
- $scope.lobStateItemData[lobClearIndex].StateData.WithdrawnDate = null;
- }
- }
- };
- /// <summary>
- // removes state information
- /// </summary>
- /// <param name="data">The data.</param>
- /// <returns>broad casts selectedStateChanges</returns>
- $scope.removeStateInfo = function (data) {
- /// <summary>
- // Selected States
- /// </summary>
- /// <param name="curItem">The current item.</param>
- /// <returns>boolean</returns>
- $scope.tempSelectedStates = $.grep($scope.selectedStates, function (curItem) {
- return curItem.StateName !== data.StateName;
- });
- $scope.selectedStates = $scope.tempSelectedStates;
- for (var i = 0; i < $scope.lobStateItemData.length; i++) {
- if ($scope.lobStateItemData[i].LobId === data.LobId) {
- if ($scope.lobStateItemData[i].StateItemData !== undefined) {
- for (var lobIndex = 0; lobIndex < $scope.lobStateItemData[i].StateItemData.length; lobIndex++) {
- if ($scope.lobStateItemData[i].StateItemData[lobIndex].StateId === data.StateId) {
- $scope.lobStateItemData[i].StateItemData.splice(lobIndex, 1);
- }
- }
- }
- if ($scope.lobStateItemData[i].selectedStates !== undefined) {
- for (var j = 0; j < $scope.lobStateItemData[i].selectedStates.length; j++) {
- if ($scope.lobStateItemData[i].selectedStates[j].StateCode === data.StateId) {
- $scope.lobStateItemData[i].selectedStates.splice(j, 1);
- }
- }
- }
- }
- }
- $scope.stateData.splice($scope.stateData.indexOf(data), 1);
- $scope.interLineStateData.splice($scope.interLineStateData.indexOf(data), 1);
- $rootScope.$broadcast('selectedStateChanges', { data: $scope.lobStateItemData.length > 0 ? $scope.lobStateItemData : $scope.stateData });
- };
- /// <summary>
- // Lob changes
- /// </summary>
- /// <param name="event">The event.</param>
- /// <param name="args">The arguments.</param>
- /// <returns>broad casts selectedStateChanges</returns>
- $rootScope.$on('lobChanges', function (event, args) {
- $scope.stateInvalid0 = false;
- $scope.effectiveDateInvalid0 = false;
- if (args.data !== null) {
- $scope.isShowDropdown = args.data.LobId === 'IL' ? true : false;
- $scope.selectedLOB = args.data.LobId === 'IL' ? null : args.data.LobValue;
- $scope.selectedLOBId = args.data.LobId;
- $scope.stateData = [];
- $scope.lobStateItemData = [];
- if ($scope.selectedLOBId === 'IL' && $scope.isIsoTenant) {
- $scope.originalLobData = _.where($scope.originalLobData, { 'LOBType': 'ISO' });
- }
- /// <summary>
- // sets scope variables
- /// </summary>
- /// <param name="item">The item.</param>
- angular.forEach($scope.stateList, function (item) {
- item.IsChecked = false;
- item.lobId = args.data.LobId;
- });
- $scope.selectedStates = [];
- } else {
- $scope.selectedLOB = null;
- $scope.isShowDropdown = false;
- $scope.stateData = [];
- $scope.lobStateItemData = [];
- $scope.selectedStates = [];
- }
- $rootScope.$broadcast('selectedStateChanges', { data: $scope.lobStateItemData });
- });
- };
- return directive;
- }]);
- /// <summary>
- // stateApplicabilityCtrl
- /// </summary>
- /// <param name="$scope">The $scope.</param>
- /// <param name="$uibModalInstance">The $uib modal instance.</param>
- /// <param name="vmConfig">The vm configuration.</param>
- app.controller('stateApplicabilityCtrl', ['$scope', '$uibModalInstance', 'vmConfig', function ($scope, $uibModalInstance, vmConfig) {
- $scope.languageStrings = vmConfig.languageStrings;
- /// <summary>
- // closes $uibModalInstance
- /// </summary>
- $scope.close = function () {
- $uibModalInstance.close();
- };
- }]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement