Rendering of files in Editor: Change Request

Rendering of files in Editor: Change Request

rf1234rf1234 Posts: 2,991Questions: 87Answers: 421

I have the request not to make all files of a contract editable with Editor. Right now you can't select the files to be made visible in Editor. I just return blank as the file name. Then the problem occurs that you can still see the small "remove" button for the file that has no name in the Editor window. I used to save the position of those files making an array with the respective "counter" parameter to be able to delete the entries completely on Editor "open".

Surprisingly Editor kept regenerating the empty lines with the remove button if I manually deleted documents in Editor. So I could never really get rid of the empty file entries.

To resolve this I changed my approach to a not very elegant one: In an interval of 1 second I delete all "li"s that dont have a font awesome icon and hence are empty.

My request would be to have a function that allows me to exclude records from their display in Editor. That could be integrated into the "display" function or an additional function.

Here is my current code:

{    
    label: lang === 'de' ? 'Dokumentation:' : 'Documentation:',
    name: "file[].id",
    type: "uploadMany",
    display: function ( fileId, counter ) {
        var fileNameExt = ctrEditor.file( 'file', fileId ).name;
        var softDeleted = ctrEditor.file( 'file', fileId ).soft_deleted;
        //returns space for soft deleted and machine generated files
        return renderFilesEditor(fileNameExt, softDeleted);
    },
    dragDropText: dragDropText,
    uploadText:   uploadText,
    noFileText:   noFileText,
    processingText: processingText,
    fileReadText: fileReadText
}
editor
    .on('open', function (e, mode, action) {
        //remove those empty lines for hidden files in Editor (the ones that
        //have no fa icon = i element)
        setInterval(function(){
            $('div.editor_upload li:not(:has(i))').remove();
        }, 1000)
    })

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Answer ✓

    Thanks for the suggestion - it sounds perfectly reasonable to me. I've just added a commit to Editor that will allow the render function from uploadMany to return null which will result in an entry for that file not being shown. That will be in the next release of Editor. If you need it before then, search for list = $('<ul></ul>').appendTo(rendered); in the file - it just needs an if wrapper around the list.append() following that statement.

    Regards,
    Allan

  • rf1234rf1234 Posts: 2,991Questions: 87Answers: 421

    Awesome! I should have asked earlier!
    Thanks a lot, Allan!

Sign In or Register to comment.