/*!
 *
 * Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved.
 * \copyright
 * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN
 * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER.
 *
 * \file    PreTreatmentConsumablesStack.qml
 * \author  (last)      Behrouz NematiPour
 * \date    (last)      02-Feb-2023
 * \author  (original)  Behrouz NematiPour
 * \date    (original)  18-Mar-2021
 *
 */

// Qt
import QtQuick 2.12

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

/*!
 * \brief   the pre-treatment consumables stack screen
 */
StackItem { id: _root
    objectName: "_PreTreatmentConsumblesStack"

    stackView.initialItem   : null

    property int stackStepIndex : 2

    PreTreatmentBase { id: _preTreatmentConsumablesInstall
        header.confirmVisible   : true
        title.text              : qsTr("Consumables Installation")
        instructionBased        : true
    }

    PreTreatmentBase { id: _preTreatmentConsumablesSelfTest
        header.confirmVisible   : false /* the state shall automatically change after user confirms the consumables installation */
        header.confirmEnabled   : vPreTreatmentStates.selfTestConsumables_complete
        isComplete              : vPreTreatmentStates.selfTestConsumables_complete
        title.text              : qsTr("Consumables Self Test")
        completeText            : qsTr("Self Test Complete!")
        // check List
        hasCheckList            : true
        checkListStepNames      : [
            //qsTr("Water Quality Check"), // this happens too fast and cannot be sent to the UI.
            qsTr("BiCarb Pump Check"),
            qsTr("Acid Pump Check"  ),
        ]
    }

    Connections { target: vPreTreatmentStates
        function onSelfTestConsumables_installChanged       ( vValue ) { page(  _preTreatmentConsumablesInstall                      , vValue       )}
        function onselfTestConsumables_primeEntered         ( vValue ) {/*      _preTreatmentConsumablesSelfTest.checkList.setItem( 0, vValue )*/    }
        function onSelfTestConsumables_biCarbPumpEntered    ( vValue ) {        _preTreatmentConsumablesSelfTest.checkList.setItem( 0, vValue       )}
        function onSelfTestConsumables_acidPumpEntered      ( vValue ) {        _preTreatmentConsumablesSelfTest.checkList.setItem( 1, vValue       )}
    }

    Connections { target: _preTreatmentConsumablesInstall
        function onConfirmClicked                           ( vValue ) {
            vPreTreatmentAdjustmentConsumablesConfirm.doConfirm()
            page( _preTreatmentConsumablesSelfTest )
        }
    }

    Connections { target: _preTreatmentConsumablesSelfTest
        function onConfirmClicked                           ( vValue ) { /* the state shall automatically change after user confirms the consumables installation */ }
    }

    onVisibleChanged: {
        if (visible) {
            _mainMenu.hidden = true
        }
        else {
            stackView.initialItem = null
        }
    }
}
