0 votes

is there a Possibility to force user not to forget the Upload of an attachment in a Document ?

Can I test on a attribute of the Upload button or form in the list of attachments, or what would be the best way to test if there is still attachement that hasn't been uploaded ?

asked in Efficy/ Client side by (618 points)

1 Answer

0 votes

Hi Stijn, here under the code I added in one of our projects:

MacroEditCustom.txt

/* for docu's add check if newly chosen file is uploaded */
AddFileForm {[
  ...
<input class="upload-input" type="file" data-change-msg="updateFileClassLoading;$this" exclude >
 ...
<input class="upload-submit button" type="button" data-msg="setFileClassLoading" value="<%GetLabel('Upload')%>">
...
]}

MacroEditSCustom.txt

JsScriptsTRW.Docu {[
<script>
...
function CheckIfAllFilesUploaded() {
        if ($('.upload-input').val() != '' && !$('.upload-input').hasClass('file-loading')) {
            alert('<%GetLabel(NOT_ALL_THE_SELECTED_FILES_ARE_UPLOADED)%>');
            var tab = $('#upload-subform').closest('div.content').attr('id');
            if (tab != undefined && tab.length > 0) {
                $('a[href="#' + tab + '"]')[0].click();
            }
            return false;
        }
        return true
    }
function BeforeSubmit(ApplyChanges) {

        // check first if selected files are uploaded
        if (!CheckIfAllFilesUploaded()) return false;

        if (SubmitFileLoaders()) {
...

editdetailsCmd.js (custom)

// file upload helper functions
function updateFileClassLoading($this) {
    if ($this.val() == '') $this.removeClass("file-loading");
}
function setFileClassLoading() {
    var $fileInput = $('.upload-input');
    if ($fileInput.val() != '') $fileInput.addClass("file-loading");
}

edit.js (custom)

   ...
    _docuValidation: function() {

            window.Validate = function(errorMessage, checkType) {
                var cebAction = $('#CEB_ACTION').val();

                // check first if selected files are uploaded
                if (!CheckIfAllFilesUploaded()) return false;
  ...
answered by (123 points)
edited by
in which file ?
I updated the answer
1,249 questions
1,518 answers
1,858 comments
328 users