
// Qt
import QtQuick 2.12

// Project
//  Qml imports
import "qrc:/globals"
import "qrc:/components"
import "qrc:/pages/posttreatment"

/*!
 * \brief   the post treatment disconnect stack screen
 */
StackItem { id: _root
    stackView.initialItem   : null

    enum Step {
        DisconnectPatient   ,
        DrainConsumable     ,
        Count
    }

    property int subStepIndex: PostTreatmentDisconnectStack.Step.DisconnectPatient

    signal goToNextStep()

    function initStack() { page ( _postTreatmentDisconnectPatient ) }

    function goToDrain() {
        page ( _postTreatmentDrainConsumables )
    }

    function continueClicked() {
        switch ( _root.subStepIndex ) {
        case PostTreatmentDisconnectStack.Step.DisconnectPatient:
            vPostTreatmentAdjustmentPatientDisconnectionConfirm.doConfirm()
            break
        case PostTreatmentDisconnectStack.Step.DrainConsumable:
            goToNextStep ()
            break
        default:
            break
        }
    }

    function backClicked() {
        switch ( _root.subStepIndex ) {
        case PostTreatmentDisconnectStack.Step.DisconnectPatient:
            break
        case PostTreatmentDisconnectStack.Step.DrainConsumable:
            page ( _postTreatmentDisconnectPatient )
            break
        default:
            break
        }
    }

    function backEnabled() {
        return _root.subStepIndex === PostTreatmentDisconnectStack.Step.DrainConsumable
    }

    // ----- Screens definitions
    PostTreatmentBase { id: _postTreatmentDisconnectPatient
        instructionBased    : true
        subStepName         : qsTr("Disconnect Patient BloodLines")
        onVisibleChanged    : if (visible) { _root.subStepIndex = PostTreatmentDisconnectStack.Step.DisconnectPatient ; updateModel()   }
    }

    PostTreatmentBase { id: _postTreatmentDrainConsumables
        title.text          : qsTr("Drain Consumable Options")
        onVisibleChanged    : if (visible) { _root.subStepIndex = PostTreatmentDisconnectStack.Step.DrainConsumable                     }
    }
}
