<commit_before>(function() {

    'use strict';

    /**
     * @ngdoc controller
     * @name requisition-search.RequisitionViewController
     * @description
     * Controller for requisition view page
     */

    angular
        .module('requisition-search')
        .controller('RequisitionSearchController', RequisitionSearchController);

    RequisitionSearchController.$inject = [
        '$rootScope', '$state', 'facilityList', 'requisitionService', 'REQUISITION_STATUS',
        'dateUtils', 'loadingModalService', 'notificationService', 'offlineService', 'localStorageFactory'
    ];

    function RequisitionSearchController($rootScope, $state, facilityList, requisitionService,
                                         REQUISITION_STATUS, dateUtils, loadingModalService,
                                         notificationService, offlineService, localStorageFactory) {

        var vm = this,
            offlineRequisitions = localStorageFactory('requisitions');

        vm.loadPrograms = loadPrograms;
        vm.search = search;
        vm.openRnr = openRnr;
        vm.removeOfflineRequisition = removeOfflineRequisition;

        vm.isOfflineDisabled = isOfflineDisabled;
        vm.searchOffline = offlineService.isOffline();
        vm.facilities = facilityList;
        vm.statuses = REQUISITION_STATUS.$toList();
        vm.selectedStatuses = [];

        if (!angular.isArray(vm.facilities) || vm.facilities.length < 1) {
            vm.error = 'msg.facilities.not.found';
        }

        function isOfflineDisabled() {
            if (offlineService.isOffline()) vm.searchOffline = true;
            return offlineService.isOffline();
        }

        /**
         *
         * @ngdoc function
         * @name openRnr
         * @methodOf requisition-search.RequisitionViewController
         *
         * @description
         * Redirect to requisition page after clicking on grid row.
         *
         */
        function openRnr(requisitionId) {
            $state.go('requisitions.requisition.fullSupply', {
                rnr: requisitionId
            });
        }

        /**
         *
         * @ngdoc function
         * @name openRnr
         * @methodOf requisition-search.RequisitionViewController
         *
         * @description
         * Redirect to requisition page after clicking on grid row.
         *
         */
        function removeOfflineRequisition(requisition) {
            offlineRequisitions.removeBy('id', requisition.id);
            requisition.$availableOffline = false;
        }

        /**
         *
         * @ngdoc function
         * @name loadPrograms
         * @methodOf requisition-search.RequisitionViewController
         *
         * @description
         * Loads selected facility supported programs to program select input.
         *
         */
        function loadPrograms() {
            if (!vm.selectedFacility) {
                return;
            } else if (vm.selectedFacility.supportedPrograms) {
                vm.programs = vm.selectedFacility.supportedPrograms;
            } else {
                notificationService.error('msg.no.program.available');
            }
        }

        /**
         *
         * @ngdoc function
         * @name search
         * @methodOf requisition-search.RequisitionViewController
         *
         * @description
         * Searches requisitions by criteria selected in form.
         *
         */
        function search() {
            if (vm.selectedFacility) {
                vm.error = null;
                loadingModalService.open();
                requisitionService.search(vm.searchOffline, {
                        program: vm.selectedProgram ? vm.selectedProgram.id : null,
                        facility: vm.selectedFacility ? vm.selectedFacility.id : null,
                        createdDateFrom: vm.startDate ? vm.startDate.toISOString() : null,
                        createdDateTo: vm.endDate ? vm.endDate.toISOString() : null
                    })
                    .then(function(requisitionList) {
                        vm.requisitionList = requisitionList;
                        loadingModalService.close();
                    })
                    .catch(function() {
                        notificationService.error('msg.error.occurred');
                    })
                    .finally(loadingModalService.close);
            } else {
                notificationService.error('msg.no.facility.selected');
            }
        }
    }
})();
<commit_msg>OLMIS-1643: fixed some docs to match convention<commit_after>(function() {

    'use strict';

    /**
     * @ngdoc controller
     * @name requisition-search.RequisitionViewController
     *
     * @description
     * Controller for requisition view page
     */

    angular
        .module('requisition-search')
        .controller('RequisitionSearchController', RequisitionSearchController);

    RequisitionSearchController.$inject = [
        '$rootScope', '$state', 'facilityList', 'requisitionService', 'REQUISITION_STATUS',
        'dateUtils', 'loadingModalService', 'notificationService', 'offlineService', 'localStorageFactory'
    ];

    function RequisitionSearchController($rootScope, $state, facilityList, requisitionService,
                                         REQUISITION_STATUS, dateUtils, loadingModalService,
                                         notificationService, offlineService, localStorageFactory) {

        var vm = this,
            offlineRequisitions = localStorageFactory('requisitions');

        vm.loadPrograms = loadPrograms;
        vm.search = search;
        vm.openRnr = openRnr;
        vm.removeOfflineRequisition = removeOfflineRequisition;

        vm.isOfflineDisabled = isOfflineDisabled;
        vm.searchOffline = offlineService.isOffline();
        vm.facilities = facilityList;
        vm.statuses = REQUISITION_STATUS.$toList();
        vm.selectedStatuses = [];

        if (!angular.isArray(vm.facilities) || vm.facilities.length < 1) {
            vm.error = 'msg.facilities.not.found';
        }

        function isOfflineDisabled() {
            if (offlineService.isOffline()) vm.searchOffline = true;
            return offlineService.isOffline();
        }

        /**
         * @ngdoc method
         * @name openRnr
         * @methodOf requisition-search.RequisitionViewController
         *
         * @description
         * Redirect to requisition page after clicking on grid row.
         *
         * @param {String} requisitionId Requisition UUID
         */
        function openRnr(requisitionId) {
            $state.go('requisitions.requisition.fullSupply', {
                rnr: requisitionId
            });
        }

        /**
         * @ngdoc method
         * @name removeOfflineRequisition
         * @methodOf requisition-search.RequisitionViewController
         *
         * @description
         * Removes requisition from local storage.
         *
         * @param {Resource} requisition Requisition to remove
         */
        function removeOfflineRequisition(requisition) {
            offlineRequisitions.removeBy('id', requisition.id);
            requisition.$availableOffline = false;
        }

        /**
         * @ngdoc method
         * @name loadPrograms
         * @methodOf requisition-search.RequisitionViewController
         *
         * @description
         * Loads selected facility supported programs to program select input.
         */
        function loadPrograms() {
            if (!vm.selectedFacility) {
                return;
            } else if (vm.selectedFacility.supportedPrograms) {
                vm.programs = vm.selectedFacility.supportedPrograms;
            } else {
                notificationService.error('msg.no.program.available');
            }
        }

        /**
         * @ngdoc method
         * @name search
         * @methodOf requisition-search.RequisitionViewController
         *
         * @description
         * Searches requisitions by criteria selected in form.
         */
        function search() {
            if (vm.selectedFacility) {
                vm.error = null;
                loadingModalService.open();
                requisitionService.search(vm.searchOffline, {
                        program: vm.selectedProgram ? vm.selectedProgram.id : null,
                        facility: vm.selectedFacility ? vm.selectedFacility.id : null,
                        createdDateFrom: vm.startDate ? vm.startDate.toISOString() : null,
                        createdDateTo: vm.endDate ? vm.endDate.toISOString() : null
                    })
                    .then(function(requisitionList) {
                        vm.requisitionList = requisitionList;
                        loadingModalService.close();
                    })
                    .catch(function() {
                        notificationService.error('msg.error.occurred');
                    })
                    .finally(loadingModalService.close);
            } else {
                notificationService.error('msg.no.facility.selected');
            }
        }
    }
})();

{'fraction_non_alphanumeric': 0.09212529910811398, 'fraction_numerical': 0.0006525995214270176, 'mean_word_length': 1.705207413945278, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5012680', 'n_tokens_mistral': 2359, 'n_tokens_neox': 2196, 'n_words': 399}