
// Qt
import QtQuick 2.12

// Project
import "qrc:/globals"
import "qrc:/components"
import "qrc:/compounds"

TreatmentAdjustmentBase { id: _root
    contentItem.objectName: "TreatmentAdjustmentHDF"
    titleText           : qsTr("HDF Adjustments")

    titlePixelSize      : Fonts.fontPixelSection
    height              : Variables.smallDialogHeight
    width               : Variables.smallDialogWidth

    function confirm() {
        vTreatmentCreate.hdfTreatmentMode           = _treatmentModeControl.currentIndex
        vTreatmentCreate.substitutionFluidVolume    = _prescribedFluidVolume.value
        _root.close()
    }

    onOpened: {
        _treatmentModeControl.currentIndex  = vTreatmentCreate.hdfTreatmentMode
        _prescribedFluidVolume.value        = vTreatmentCreate.substitutionFluidVolume
    }

    Column { id: _column
        spacing: Variables.defaultMargin * 2

        anchors {
            verticalCenter      : _root.contentItem.verticalCenter
            verticalCenterOffset: Variables.defaultMargin * -3 // better align label with dialog height
            horizontalCenter    : _root.contentItem.horizontalCenter
        }

        LabelUnitContainer { id: _treatmentMode
            objectName      : "_treatmentMode"
            text            : qsTr("Treatment Mode")
            width           : Variables.adjustmentLabelUnitContainerWidth
            height          : Variables.adjustmentLabelUnitContainerHeight
            onEditClicked   : _root.treatmentHDFEditClicked()

            contentItem : ValueAdjusterCustom { id: _treatmentModeControl
                value       : vTreatmentCreate.hdfTreatmentMode
                model       : vTreatmentRanges.hdfTreatmentModeOptions
            }
        }

        LabelUnitValueAdjuster { id: _prescribedFluidVolume
            objectName          : "_prescribedFluidVolume"
            text                : qsTr("Prescribed Sub. Fluid Volume")
            width               : Variables.adjustmentLabelUnitContainerWidth
            height              : Variables.adjustmentLabelUnitContainerHeight
            unitText            : Variables.unitVolume
            decimal             : Variables.substitutionPrecision
            valueTextColor      : Colors.offWhite
            isActive            : true
            minimum             : vTreatmentRanges.substitutionVolumeMin
            maximum             : vTreatmentRanges.substitutionVolumeMax
            step                : vTreatmentRanges.substitutionVolumeRes
            value               : vTreatmentCreate.substitutionFluidVolume
            defaultValue        : vTreatmentRanges.substitutionVolumeDef

            onDidChange         : function(vValue) {
                value = vValue
            }
        }
    }

    ConfirmButton { id : _confirmButton
        anchors {
            bottom          : _root.contentItem.bottom
            bottomMargin    : Variables.defaultMargin * 4
            horizontalCenter: _root.contentItem.horizontalCenter
        }

        width       : Variables.defaultButtonWidth
        height      : Variables.defaultButtonHeight

        anchors {
            top     : undefined
            right   : undefined
            margins : 0
        }

        onClicked   : {
            _root.confirm()
        }
    }
}
