Skip to content

Commit

Permalink
Fix logic of how the "N more" is calculated in relation editor
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed Apr 12, 2024
1 parent fabbc5f commit 6e607aa
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions app/qml/form/editors/MMFormRelationEditor.qml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ MMInputs.MMBaseInput {

contentItemHeight: privates.itemHeight * privates.rows + 2 * flow.spacing + 20 * __dp

Component.onCompleted: root.recalculate()
onWidthChanged: root.recalculate()
Component.onCompleted: root.recalculateVisibleItems()
onWidthChanged: root.recalculateVisibleItems()

title: _fieldShouldShowTitle ? _fieldTitle : ""

Expand Down Expand Up @@ -93,7 +93,10 @@ MMInputs.MMBaseInput {
// Repeater does not necesarry clear delegates immediately if they are invisible,
// we need to do hard reload in this case so that recalculateVisibleItems() is triggered

root.recalculate()
repeater.model = null
repeater.model = rmodel

root.recalculateVisibleItems()
}
}

Expand All @@ -120,11 +123,7 @@ MMInputs.MMBaseInput {
onClicked: root.openLinkedFeature( model.FeaturePair )
}

onVisibleChanged: {
if(!visible) {
repeater.invisibleIds++
}
}
onVisibleChanged: root.recalculateVisibleItems()
}
}

Expand Down Expand Up @@ -161,10 +160,17 @@ MMInputs.MMBaseInput {
}
}

function recalculate() {
repeater.invisibleIds = 0
repeater.model = null
repeater.model = rmodel
function recalculateVisibleItems() {
let invisibles_count = 0

for ( let i = 0; i < repeater.count; i++ ) {
let delegate_i = repeater.itemAt( i )
if ( delegate_i && !delegate_i.visible ) {
invisibles_count++
}
}

repeater.invisibleIds = invisibles_count
}

Loader {
Expand Down

0 comments on commit 6e607aa

Please sign in to comment.