<commit_before>/* global apx */
window.apx = window.apx||{};

/* global empty */

//////////////////////////////////////////////////////
// EDIT THE DOCUMENT OR AN ITEM
apx.edit = {};

/** Edit the document data */
apx.edit.prepareDocEditModal = function() {
    var $editDocModal = $('#editDocModal');
    $editDocModal.find('.modal-body').html(apx.spinner.html("Loading Form"));
    $editDocModal.on('shown.bs.modal', function(e){
        $('#editDocModal').find('.modal-body').load(
            apx.path.lsdoc_edit.replace('ID', apx.lsDocId),
            null,
            function(responseText, textStatus, jqXHR){
                $('#ls_doc_subjects').select2entity({dropdownParent: $('#editDocModal')});
            }
        );
    }).on('hidden.bs.modal', function(e){
        $('#editDocModal').find('.modal-body').html(apx.spinner.html("Loading Form"));
    });
    $editDocModal.find('.btn-save').on('click', function(e){
        apx.spinner.showModal("Updating document");
        $.ajax({
            url: apx.path.lsdoc_edit.replace('ID', apx.lsDocId),
            method: 'POST',
            data: $editDocModal.find('form[name=ls_doc]').serialize()
        }).done(function(data, textStatus, jqXHR){
            $editDocModal.modal('hide');
            // on successful update, reload the doc
            window.location.reload();
            /*
               var updatedData = {
               "title": $("#ls_doc_title").val(),
               "version": $("#ls_doc_version").val(),
               "adoptionStatus": $("#ls_doc_adoptionStatus").val(),
               };
               */

        }).fail(function(jqXHR, textStatus, errorThrown){
            $editDocModal.find('.modal-body').html(jqXHR.responseText);
            $('#ls_doc_subjects').select2entity({dropdownParent: $('#editDocModal')});
        });
    });
};

/** Edit an item */
apx.edit.prepareItemEditModal = function() {
    var $editItemModal = $('#editItemModal');
    $editItemModal.find('.modal-body').html(apx.spinner.html("Loading Form"));
    $editItemModal.on('shown.bs.modal', function(e){
        $('#editItemModal').find('.modal-body').load(
            apx.path.lsitem_edit.replace('ID', apx.mainDoc.currentItem.id),
            null,
            function(responseText, textStatus, jqXHR) {
                $('#ls_item_educationalAlignment').multiselect({
                    optionLabel: function(element) {
                        return $(element).html() + ' - ' + $(element).data('title');
                    },
                    numberDisplayed: 20
                });<commit_msg>fix issue with overlay not going away on error<commit_after>/* global apx */
window.apx = window.apx||{};

/* global empty */

//////////////////////////////////////////////////////
// EDIT THE DOCUMENT OR AN ITEM
apx.edit = {};

/** Edit the document data */
apx.edit.prepareDocEditModal = function() {
    var $editDocModal = $('#editDocModal');
    $editDocModal.find('.modal-body').html(apx.spinner.html("Loading Form"));
    $editDocModal.on('shown.bs.modal', function(e){
        $('#editDocModal').find('.modal-body').load(
            apx.path.lsdoc_edit.replace('ID', apx.lsDocId),
            null,
            function(responseText, textStatus, jqXHR){
                $('#ls_doc_subjects').select2entity({dropdownParent: $('#editDocModal')});
            }
        );
    }).on('hidden.bs.modal', function(e){
        $('#editDocModal').find('.modal-body').html(apx.spinner.html("Loading Form"));
    });
    $editDocModal.find('.btn-save').on('click', function(e){
        apx.spinner.showModal("Updating document");
        $.ajax({
            url: apx.path.lsdoc_edit.replace('ID', apx.lsDocId),
            method: 'POST',
            data: $editDocModal.find('form[name=ls_doc]').serialize()
        }).done(function(data, textStatus, jqXHR){
            $editDocModal.modal('hide');
            // on successful update, reload the doc
            window.location.reload();
            /*
               var updatedData = {
               "title": $("#ls_doc_title").val(),
               "version": $("#ls_doc_version").val(),
               "adoptionStatus": $("#ls_doc_adoptionStatus").val(),
               };
               */

        }).fail(function(jqXHR, textStatus, errorThrown){
            apx.spinner.hideModal();
            $editDocModal.find('.modal-body').html(jqXHR.responseText);
            $('#ls_doc_subjects').select2entity({dropdownParent: $('#editDocModal')});
        });
    });
};

/** Edit an item */
apx.edit.prepareItemEditModal = function() {
    var $editItemModal = $('#editItemModal');
    $editItemModal.find('.modal-body').html(apx.spinner.html("Loading Form"));
    $editItemModal.on('shown.bs.modal', function(e){
        $('#editItemModal').find('.modal-body').load(
            apx.path.lsitem_edit.replace('ID', apx.mainDoc.currentItem.id),
            null,
            function(responseText, textStatus, jqXHR) {
                $('#ls_item_educationalAlignment').multiselect({
                    optionLabel: function(element) {
                        return $(element).html() + ' - ' + $(element).data('title');
                    },
                    numberDisplayed: 20
                });
{'fraction_non_alphanumeric': 0.19744859101294746, 'fraction_numerical': 0.0015232292460015233, 'mean_word_length': 2.1379928315412187, 'pattern_counts': {'":': 6, '<': 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': '122166', 'n_tokens_mistral': 1525, 'n_tokens_neox': 1503, 'n_words': 217}