Skip to content

Adding an element as first in container-col, it's not sorted as first #647

Description

@DavidBruchmann

the element might be the last in the col, or between too.

The following changed method execute() in paste.js is fixing it.
The comments in the code mark my changes:

    execute(element) {
        const colPos = Paste.determineColumn(element);
        const txContainerParent = Paste.determineTxContainerParent(element);
        const closestElement = element.closest(this.elementIdentifier);
        const targetFound = closestElement.dataset.uid;
        let targetPid;
        if (typeof targetFound === 'undefined') {
            targetPid = parseInt(closestElement.dataset.page, 10);
        }
        else {
            targetPid = 0 - parseInt(targetFound, 10);
        }
        const language = parseInt(element.closest('[data-language-uid]').dataset.languageUid, 10);
        // CHANGE FROM const TO let:
        let parameters = {
            CB: {
                paste: 'tt_content|' + targetPid,
                pad: 'normal',
                update: {
                    colPos: colPos,
                    sys_language_uid: language,
                    tx_container_parent: txContainerParent,
                },
            },
        };
        // NEW CONDITION to add the sorting parameter:
        if (txContainerParent && typeof targetFound === 'undefined') {
          parameters.CB.update.sorting = 0;
        }
        DataHandler.process(parameters).then((result) => {
            if (!result.hasErrors) {
                window.location.reload();
            }
        });
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions