output-reconciliation-keywords.ctrl.js 2.1 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
invoiceModule.controller('outputReconciliationKeywordsController', ['$scope', '$log', 'uiGridConstants', 'SweetAlert', '$translate', 'stdAccountService', '$interval', 'orgService', '$timeout', '$q', 'commonWebService', 'loginContext', '$uibModal', 'outputReconciliationConfiguration',
    function ($scope, $log, uiGridConstants, SweetAlert, $translate, stdAccountService, $interval, orgService, $timeout, $q, commonWebService, loginContext, $uibModal, outputReconciliationConfiguration) {
        'use strict';

     
        var mainModule = {

            main: function () {

                if (!$scope.keywordsList) {
                    $scope.keywordsList = [];
                }
                $scope.addKeywords = mainModule.addKeywords;

                $scope.deleteKeywords = mainModule.deleteKeywords;
            },
            addKeywords: function () {
                var length = $scope.keywordsList.length;

                if (length >= 5) {
                    SweetAlert.warning($translate.instant('LimitKeyWords'));
                    return;
                };

                var prefixStr = '';
                if (length !== 0) {
                    prefixStr = ';';
                }

                var obj = {
                    id: window.PWC.newGuid(),
                    value: '',
                    prefix: prefixStr,
                };

                $scope.keywordsList.push(obj);
            },

            deleteKeywords: function (obj) {
                if ($scope.keywordsList && $scope.keywordsList.length > 0) {

                    var findIndex = _.indexOf($scope.keywordsList, obj);

                    if (findIndex > -1) {
                        $scope.keywordsList.splice(findIndex, 1);
                    }

                    if (findIndex === 0 && $scope.keywordsList.length >= 0) {
                        $scope.keywordsList[0].prefix = '';
                    }
                }
            },

        };

        (function initializa() {

            mainModule.main();

            $log.debug('outputReconciliationKeywordsController.ctor()...');


        })();
    }
]);