<commit_before>(function () {
    'use strict';

    angular.module('references')
            .directive('scientillaDocumentsList', scientillaDocumentsList);

    function scientillaDocumentsList() {
        return {
            restrict: 'E',
            templateUrl: 'partials/scientillaDocumentsList.html',
            controller: scientillaDocumentsListController,
            controllerAs: 'vm',
            scope: {},
            bindToController: {
                researchEntity: "="
            }
        };
    }

    scientillaDocumentsListController.$inject = [
        '$rootScope'
    ];

    function scientillaDocumentsListController($rootScope) {
        var vm = this;
        vm.documents = [];
        
        vm.deleteDocument = deleteDocument;
        vm.verifyDocument = verifyDocument;
        vm.createNewUrl = vm.researchEntity.getNewReferenceUrl();

        activate();
        
        function activate() {
            getDocuments();
            $rootScope.$on('draft.verified', getDocuments);
        }
        
        function getDocuments() {
            vm.researchEntity.getList('privateReferences',  {populate: ['privateCoauthors']})
                    .then(function(documents) {
                        Scientilla.toDocumentsCollection(documents);
                        vm.documents = documents;
                    });
        }

        function deleteDocument(reference) {
            vm.researchEntity.one('references', reference.id).remove()
                    .then(function () {
                        _.remove(vm.researchEntity.references, reference);
                    });
        }
        <commit_msg>When a document is delete, all the documents are reloaded.<commit_after>(function () {
    'use strict';

    angular.module('references')
            .directive('scientillaDocumentsList', scientillaDocumentsList);

    function scientillaDocumentsList() {
        return {
            restrict: 'E',
            templateUrl: 'partials/scientillaDocumentsList.html',
            controller: scientillaDocumentsListController,
            controllerAs: 'vm',
            scope: {},
            bindToController: {
                researchEntity: "="
            }
        };
    }

    scientillaDocumentsListController.$inject = [
        '$rootScope'
    ];

    function scientillaDocumentsListController($rootScope) {
        var vm = this;
        vm.documents = [];
        
        vm.deleteDocument = deleteDocument;
        vm.verifyDocument = verifyDocument;
        vm.createNewUrl = vm.researchEntity.getNewReferenceUrl();

        activate();
        
        function activate() {
            getDocuments();
            $rootScope.$on('draft.verified', getDocuments);
        }
        
        function getDocuments() {
            vm.researchEntity.getList('privateReferences',  {populate: ['privateCoauthors']})
                    .then(function(documents) {
                        Scientilla.toDocumentsCollection(documents);
                        vm.documents = documents;
                    });
        }

        function deleteDocument(reference) {
            vm.researchEntity.one('references', reference.id).remove()
                    .then(function () {
                        getDocuments();
                    });
        }
        
{'fraction_non_alphanumeric': 0.10276442307692307, 'fraction_numerical': 0.0, 'mean_word_length': 1.6868442292171106, 'pattern_counts': {'":': 0, '<': 3, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3226896', 'n_tokens_mistral': 822, 'n_tokens_neox': 749, 'n_words': 120}