PageGovServiceList.qml 5.33 KB
Newer Older
1
/*
2
 * Copyright (C) 2014-2019 CZ.NIC
3 4 5 6 7 8 9 10
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 13 14
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
15
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
 *
 * In addition, as a special exception, the copyright holders give
 * permission to link the code of portions of this program with the
 * OpenSSL library under certain conditions as described in each
 * individual source file, and distribute linked combinations including
 * the two.
 */

import QtQuick 2.7
import QtQuick.Controls 2.1
import cz.nic.mobileDatovka 1.0
import cz.nic.mobileDatovka.models 1.0

Component {
    id: pageGovServiceList
    Item {
        id: srvcListPage

        /* These properties must be set by caller. */
        property var pageView
        property var statusBar
        property string acntName
        property string userName

40
        property string gsInternIdSelected
41 42

        Component.onCompleted: {
43
            gov.loadServicesToModel(userName, govServiceModel)
44 45 46 47 48 49 50
            proxyGovServiceModel.setSourceModel(govServiceModel)
        }

        Component.onDestruction: {
            statusBar.visible = false
        }

51
        GovServiceListModel {
52 53 54 55 56 57 58
            id: govServiceModel
        }

        ListSortFilterProxyModel {
            id: proxyGovServiceModel

            Component.onCompleted: {
59 60
                setFilterRoles([GovServiceListModel.ROLE_GOV_SRVC_FULL_NAME,
                    GovServiceListModel.ROLE_GOV_SRVC_INST_NAME,
61
                    GovServiceListModel.ROLE_GOV_SRVC_BOXID])
62 63 64 65
            }
        }
        PageHeader {
            id: headerBar
66
            title: qsTr("E-Gov Services");
67 68 69 70 71 72 73 74 75 76 77 78 79
            onBackClicked: {
                pageView.pop()
            }
            Row {
                anchors.verticalCenter: parent.verticalCenter
                spacing: defaultMargin
                anchors.right: parent.right
                anchors.rightMargin: defaultMargin
                AccessibleImageButton {
                    id: searchButton
                    anchors.verticalCenter: parent.verticalCenter
                    sourceSize.height: imgHeightHeader
                    source: "qrc:/ui/magnify.svg"
80
                    accessibleName: qsTr("Set filter")
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
                    onClicked: {
                        govServiceList.anchors.top = filterBar.bottom
                        filterBar.visible = true
                        filterBar.filterField.forceActiveFocus()
                        Qt.inputMethod.show()
                    }
                }
            }
        }
        FilterBar {
            id: filterBar
            visible: false
            z: 1
            anchors.top: headerBar.bottom
            width: parent.width
            height: filterField.height
            color: (filterField.text.length === 0) ? datovkaPalette.alternateBase :
                    (govServiceList.count > 0) ? "#afffaf" : "#ffafaf"
            border.color: filterField.activeFocus ? "#0066ff" : "#bdbebf"

            placeholderText: qsTr("Set filter")
            fontPointSize: defaultTextFont.font.pointSize
            buttonImageHeight: imgHeight
            buttonAccessibleName: qsTr("Clear and hide filter field")

            onTextChanged: {
                proxyGovServiceModel.setFilterRegExpStr(text)
            }

            onClearClicked: {
                filterBar.visible = false
                govServiceList.anchors.top = headerBar.bottom
                Qt.inputMethod.hide()
            }
        }
        AccessibleText {
            id: emptyList
            visible: false
            color: datovkaPalette.text
            anchors.centerIn: parent
            width: parent.width
            horizontalAlignment: Text.AlignHCenter
            wrapMode: Text.Wrap
            text: (filterBar.filterField.text.length === 0) ?
125 126
                qsTr("No available e-government service.") :
                qsTr("No e-government service found that matches filter text '%1'.").arg(filterBar.filterField.text)
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
        }
        GovServiceList {
            id: govServiceList
            anchors.top: headerBar.bottom
            anchors.bottom: parent.bottom
            clip: true
            spacing: 1
            opacity: 1
            visible: true
            width: parent.width
            interactive: true
            model: proxyGovServiceModel
            onCountChanged: {
                emptyList.visible = (govServiceList.count === 0)
            }
            onGovServiceClicked: {
143 144 145 146 147 148 149 150 151
                pageView.push(pageGovService, {
                    "pageView": pageView,
                    "statusBar": statusBar,
                    "acntName" : acntName,
                    "userName": userName,
                    "gsInternId": gsInternId,
                    "gsFullName": gsFullName,
                    "gsInstName": gsInstName
                }, StackView.Immediate)
152 153 154 155
            }
        }
    }
}