
// 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()
    signal goToPreviousStep()

    function initStack() { page ( _postTreatmentDisconnectPatient ) }

    function continueClicked() {
        switch ( _root.subStepIndex ) {
        case PostTreatmentDisconnectStack.Step.DisconnectPatient:
            page ( _postTreatmentDrainConsumables )
            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
        onVisibleChanged    : if (visible) { _root.subStepIndex = PostTreatmentDisconnectStack.Step.DisconnectPatient ; updateModel()   }
        subStepName         : qsTr("Disconnect Patient BloodLines")
    }

    PostTreatmentBase { id: _postTreatmentDrainConsumables
        onVisibleChanged    : if (visible) { _root.subStepIndex = PostTreatmentDisconnectStack.Step.DrainConsumable                     }
    }
}
