/*!
 *
 * Copyright (c) 2023-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    SettingsDGCleaning.qml
 * \author  (last)      Behrouz NematiPour
 * \date    (last)      28-May-2023
 * \author  (original)  Behrouz NematiPour
 * \date    (original)  26-May-2023
 *
 */

// Qt
import QtQuick 2.12

// Project
import Gui.Actions 0.1;

//  Qml imports
import "qrc:/globals"
import "qrc:/components"
import "qrc:/compounds"

/*!
 * \brief   SettingsDG provides user options to manually initiate the DG Cleaning
 *          and give the last DG CLeanaing Status
 */
SettingsBase { id: _root

    confirmVisible  : false
    TouchGrid {
        anchors.horizontalCenter: parent.horizontalCenter

        colCount    : 1
        colSpacing  : 0
        rowCount    : 6
        rowSpacing  : 0
        itemHeight  : 50
        itemWidth   : 800
        touchable   : false
        itemsHasLine: [
            0, // title
            1,1,1,1,1,
        ]
        itemsValueLeftMargin: 500
        itemsUnitLeftMargin : 700
        itemsText   : [
            "Cleaning Last Status"                                  , // title
            qsTr("Last Basic Flush Complete"                       ),
            qsTr("Last Chemical Disinfect Start"                   ),
            qsTr("Last Chemical Disinfect Complete"                ),
            qsTr("Last Chemical Disinfect Flush Complete"          ),
            qsTr("Last Heat Disinfect Complete"                    ),
        ]
        itemsValue  : [
            ""                                                      ,
            vAdjustDGCleaningUsage.lastBasicFlushCompleteDate       ,
            vAdjustDGCleaningUsage.lastChemDisStartDate             ,
            vAdjustDGCleaningUsage.lastChemDisCompleteDate          ,
            vAdjustDGCleaningUsage.lastChemDisFlushCompleteDate     ,
            vAdjustDGCleaningUsage.lastHeatDisCompleteDate          ,
        ]
        itemsUnit   : [
            ""                                                      ,
            vAdjustDGCleaningUsage.lastBasicFlushCompleteTime       ,
            vAdjustDGCleaningUsage.lastChemDisStartTime             ,
            vAdjustDGCleaningUsage.lastChemDisCompleteTime          ,
            vAdjustDGCleaningUsage.lastChemDisFlushCompleteTime     ,
            vAdjustDGCleaningUsage.lastHeatDisCompleteTime          ,
        ]
    }

    onVisibleChanged: {
        if ( ! visible ) {
            _root.notificationText = ""
        }
        else {
            vAdjustDGCleaningUsage.doAdjustment()
        }

    }

    Footer { id: _footer
        anchors.bottomMargin: Variables.mainMenuHeight + Variables.notificationHeight + Variables.minVGap
        childrenWidth: parent.width / 3
        children: [
            TouchRect { text.text: qsTr("Proceed to Cleaning Mode")
                        onClicked: { vDisinfectAdjustDisinfect      .doDisinfectInitiate    () }
            }
        ]
    }

    // ----- Responses
    Connections { target:  vDisinfectAdjustDisinfect
        function onAdjustment_DisinfectModeTriggered ( vValue ) {
            if ( vDisinfectAdjustDisinfect.adjustment_Accepted ){ _root.notificationText = ""                               }
            else                                                { _root.notificationText = vDisinfectAdjustDisinfect.text() }
        }
    }
}
