schermate di configurazione complete: razze disponibili, mio pollaio, registro galline, clienti, backup/ripristino nel formato dell'app Android, lingua a runtime, introduzione e informazioni
- datastore: export/import JSON con le chiavi camelCase dell'app Android (breedSettings/reservations/customers), scorte e ultimo aggiornamento preservati al ripristino - settings: flag 'introduzione vista' - desktop: permesso Documents (dove finisce il backup) - nuovi controlli: tools/check_qml.py (chiavi di traduzione, simboli JS, pagine, componenti) e qmllint nella suite - versione 0.2.0
This commit is contained in:
@@ -0,0 +1,128 @@
|
||||
import QtQuick 2.2
|
||||
import Sailfish.Silica 1.0
|
||||
import "../js/i18n.js" as I18N
|
||||
|
||||
// Clienti abituali: nome, cognome e telefono. Servono a velocizzare
|
||||
// l'inserimento degli ordini (i suggerimenti sono nella scheda ordine).
|
||||
Page {
|
||||
id: page
|
||||
allowedOrientations: Orientation.All
|
||||
|
||||
property string lang: "en"
|
||||
property bool ready: false
|
||||
property var customers: []
|
||||
|
||||
function tr(key, arg) { return I18N.t(key, arg, page.lang) }
|
||||
|
||||
ListModel { id: customerModel }
|
||||
|
||||
function fullName(c) {
|
||||
var n = (c.firstName || "") + " " + (c.lastName || "")
|
||||
return n.trim()
|
||||
}
|
||||
|
||||
function reload() {
|
||||
page.lang = I18N.langFor(appSettings.language, Qt.locale().name)
|
||||
page.customers = appData.customers()
|
||||
|
||||
customerModel.clear()
|
||||
for (var i = 0; i < page.customers.length; i++) {
|
||||
customerModel.append({
|
||||
"n": i,
|
||||
"name": page.fullName(page.customers[i]),
|
||||
"phone": page.customers[i].phoneNumber || ""
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function openCustomer(index) {
|
||||
var customer = (index >= 0 && index < page.customers.length) ? page.customers[index] : null
|
||||
pageStack.push(Qt.resolvedUrl("CustomerPage.qml"),
|
||||
{ "customer": customer, "onSaved": function () { page.reload() } })
|
||||
}
|
||||
|
||||
function deleteCustomer(index) {
|
||||
var list = appData.customers().slice()
|
||||
remorse.execute(listView, page.tr("delete"), function () {
|
||||
list.splice(index, 1)
|
||||
appData.saveCustomers(list)
|
||||
page.reload()
|
||||
}, 4000)
|
||||
}
|
||||
|
||||
Component.onCompleted: page.reload()
|
||||
|
||||
onStatusChanged: {
|
||||
if (status !== PageStatus.Active)
|
||||
return
|
||||
if (page.ready)
|
||||
page.reload()
|
||||
page.ready = true
|
||||
}
|
||||
|
||||
RemorseItem { id: remorse }
|
||||
|
||||
SilicaListView {
|
||||
id: listView
|
||||
anchors.fill: parent
|
||||
|
||||
header: PageHeader { title: page.tr("customers_list") }
|
||||
model: customerModel
|
||||
|
||||
delegate: ListItem {
|
||||
id: customerItem
|
||||
contentHeight: customerText.height + Theme.paddingMedium
|
||||
|
||||
menu: ContextMenu {
|
||||
MenuItem {
|
||||
text: page.tr("edit_customer")
|
||||
onClicked: page.openCustomer(index)
|
||||
}
|
||||
MenuItem {
|
||||
text: page.tr("delete")
|
||||
onClicked: page.deleteCustomer(index)
|
||||
}
|
||||
}
|
||||
|
||||
Column {
|
||||
id: customerText
|
||||
x: Theme.horizontalPageMargin
|
||||
y: Theme.paddingMedium
|
||||
width: parent.width - 2 * Theme.horizontalPageMargin
|
||||
spacing: Theme.paddingSmall
|
||||
|
||||
Label {
|
||||
width: parent.width
|
||||
text: model.name
|
||||
color: customerItem.highlighted ? Theme.highlightColor : Theme.primaryColor
|
||||
truncationMode: TruncationMode.Fade
|
||||
}
|
||||
|
||||
Label {
|
||||
width: parent.width
|
||||
text: model.phone
|
||||
color: Theme.secondaryColor
|
||||
font.pixelSize: Theme.fontSizeExtraSmall
|
||||
truncationMode: TruncationMode.Fade
|
||||
visible: text.length > 0
|
||||
}
|
||||
}
|
||||
|
||||
onClicked: page.openCustomer(index)
|
||||
}
|
||||
|
||||
ViewPlaceholder {
|
||||
enabled: customerModel.count === 0
|
||||
text: page.tr("no_customers")
|
||||
}
|
||||
|
||||
PullDownMenu {
|
||||
MenuItem {
|
||||
text: page.tr("new_customer")
|
||||
onClicked: page.openCustomer(-1)
|
||||
}
|
||||
}
|
||||
|
||||
VerticalScrollDecorator {}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user