|
399 | 399 | orderMachine.append(inlines)
|
400 | 400 |
|
401 | 401 | inlines.each(function () {
|
402 |
| - const ordering = $(".field-ordering input", this).val() || 1e9 |
| 402 | + const ordering = $(".order-machine-ordering", this).val() || 1e9 |
403 | 403 | this.style.order = ordering
|
404 | 404 | ensureDraggable($(this))
|
405 | 405 | })
|
|
506 | 506 | return
|
507 | 507 |
|
508 | 508 | const select = buildDropdown(regions)
|
509 |
| - const regionInput = $inline.find(".field-region input") |
| 509 | + const regionInput = $inline.find(".order-machine-region") |
510 | 510 |
|
511 | 511 | select.className = "inline_move_to_region"
|
512 | 512 | select.value = regionInput.val()
|
|
528 | 528 | const $this = $(this)
|
529 | 529 | // Try input first and fall back to the readonly presentation
|
530 | 530 | let region =
|
531 |
| - $this.find(".field-region input").val() || |
| 531 | + $this.find(".order-machine-region").val() || |
532 | 532 | $this.find(".field-region .readonly").text()
|
533 | 533 |
|
534 | 534 | if (!ContentEditor.regionsByKey[region]) {
|
|
552 | 552 |
|
553 | 553 | function setBiggestOrdering($row) {
|
554 | 554 | const orderings = []
|
555 |
| - orderMachine.find(".field-ordering input").each(function () { |
| 555 | + orderMachine.find(".order-machine-ordering").each(function () { |
556 | 556 | if (!Number.isNaN(+this.value)) orderings.push(+this.value)
|
557 | 557 | })
|
558 | 558 | const ordering = 10 + Math.max.apply(null, orderings)
|
559 |
| - $row.find(".field-ordering input").val(ordering) |
| 559 | + $row.find(".order-machine-ordering").val(ordering) |
560 | 560 | $row.css("order", ordering)
|
561 | 561 | }
|
562 | 562 |
|
563 | 563 | function insertAdjacent(row, inline, after = false) {
|
564 |
| - const inlineOrdering = +qs(".field-ordering input", inline).value |
| 564 | + const inlineOrdering = +qs(".order-machine-ordering", inline).value |
565 | 565 | const beforeRows = []
|
566 | 566 | const afterRows = []
|
567 | 567 | orderMachine.find(".inline-related:not(.empty-form)").each(function () {
|
568 |
| - const thisOrderingField = qs(".field-ordering input", this) |
| 568 | + const thisOrderingField = qs(".order-machine-ordering", this) |
569 | 569 | if (this !== row && !Number.isNaN(+thisOrderingField.value)) {
|
570 | 570 | if (
|
571 | 571 | after
|
|
581 | 581 | beforeRows.sort((a, b) => a[1].value - b[1].value)
|
582 | 582 | afterRows.sort((a, b) => a[1].value - b[1].value)
|
583 | 583 | let rows = [].concat(beforeRows)
|
584 |
| - rows.push([row, qs(".field-ordering input", row)]) |
| 584 | + rows.push([row, qs(".order-machine-ordering", row)]) |
585 | 585 | rows = rows.concat(afterRows)
|
586 | 586 | for (let i = 0; i < rows.length; ++i) {
|
587 | 587 | const thisRow = rows[i]
|
|
657 | 657 | // Not one of our managed inlines?
|
658 | 658 | if (!ContentEditor.pluginsByPrefix[prefix]) return
|
659 | 659 |
|
660 |
| - $row.find(".field-region input").val(ContentEditor.currentRegion) |
| 660 | + $row.find(".order-machine-region").val(ContentEditor.currentRegion) |
661 | 661 | $row.find("h3 .inline_label").text(ContentEditor.messages.newItem)
|
662 | 662 | $row.attr("data-region", ContentEditor.currentRegion)
|
663 | 663 |
|
|
811 | 811 | const span = document.createElement("span")
|
812 | 812 | span.className = "order-machine-insert-target"
|
813 | 813 | inline.appendChild(span)
|
| 814 | + |
| 815 | + // Be extra careful because multiple fields could be on one line |
| 816 | + qs(`.field-ordering input[name$="-ordering"]`, inline).classList.add( |
| 817 | + "order-machine-ordering", |
| 818 | + ) |
| 819 | + qs(`.field-region input[name$="-region"]`, inline).classList.add( |
| 820 | + "order-machine-region", |
| 821 | + ) |
814 | 822 | }
|
815 | 823 |
|
816 | 824 | $(document)
|
|
889 | 897 | region: ContentEditor.currentRegion,
|
890 | 898 | scrollY: window.scrollY,
|
891 | 899 | collapsed: qsa(
|
892 |
| - ".order-machine .inline-related.collapsed:not(.empty-form) .field-ordering input", |
| 900 | + ".order-machine .inline-related.collapsed:not(.empty-form) .order-machine-ordering", |
893 | 901 | ).map((input) => input.value),
|
894 | 902 | })
|
895 | 903 | }
|
|
905 | 913 | ".order-machine .inline-related:not(.empty-form)",
|
906 | 914 | )) {
|
907 | 915 | const collapsed = state.collapsed.includes(
|
908 |
| - qs(".field-ordering input", inline).value, |
| 916 | + qs(".order-machine-ordering", inline).value, |
909 | 917 | )
|
910 | 918 | /* XXX handle sections */
|
911 | 919 | inline.classList.toggle(
|
|
0 commit comments