primitive color picker, asset form
This commit is contained in:
parent
9a5a0b27a2
commit
374551d2bb
12 changed files with 207 additions and 57 deletions
|
@ -8,9 +8,18 @@ import magpie
|
|||
import magpie.Components as Components
|
||||
|
||||
Item {
|
||||
signal success
|
||||
property string name: qsTr("New asset")
|
||||
property string icon: "wallet"
|
||||
property color color: "green"
|
||||
property int currency: 1
|
||||
|
||||
property string title: qsTr("New asset")
|
||||
|
||||
signal confirm (name: string, icon: string, color: color, currency: int)
|
||||
signal cancel
|
||||
|
||||
id: form
|
||||
|
||||
Column {
|
||||
id: inner
|
||||
spacing: 5
|
||||
|
@ -18,7 +27,7 @@ Item {
|
|||
|
||||
Label {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
text: qsTr("New asset")
|
||||
text: title
|
||||
font.pixelSize: 14
|
||||
}
|
||||
|
||||
|
@ -36,7 +45,9 @@ Item {
|
|||
|
||||
TextField {
|
||||
id: titleField
|
||||
text: "New Asset"
|
||||
text: name
|
||||
|
||||
onTextChanged: name = text
|
||||
}
|
||||
|
||||
Label {
|
||||
|
@ -45,15 +56,36 @@ Item {
|
|||
|
||||
Components.IconPicker {
|
||||
id: iconField
|
||||
icon: "list-add"
|
||||
icon: form.icon
|
||||
|
||||
onIconChanged: form.icon = icon
|
||||
}
|
||||
|
||||
Label {
|
||||
text: qsTr("Color") + ":";
|
||||
}
|
||||
|
||||
TextField {
|
||||
Components.ColorPicker {
|
||||
id: colorField
|
||||
color: form.color
|
||||
|
||||
onColorChanged: form.color = colorField.color
|
||||
}
|
||||
|
||||
Label {
|
||||
text: qsTr("Currency") + ":";
|
||||
}
|
||||
|
||||
ComboBox {
|
||||
id: currencyField
|
||||
|
||||
textRole: "title" //"code"
|
||||
valueRole: "id"
|
||||
|
||||
model: Magpie.currencies
|
||||
|
||||
Component.onCompleted: currentIndex = indexOfValue(currency)
|
||||
onActivated: index => currency = currentValue
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -66,47 +98,14 @@ Item {
|
|||
}
|
||||
|
||||
Button {
|
||||
text: qsTr("Create")
|
||||
onClicked: inner.confirm()
|
||||
text: qsTr("Confirm")
|
||||
onClicked: inner.onConfirmClick()
|
||||
}
|
||||
}
|
||||
|
||||
Components.Modal {
|
||||
id: modal
|
||||
}
|
||||
|
||||
function confirm () {
|
||||
function onConfirmClick () {
|
||||
//TODO validation
|
||||
send(titleField.text, iconField.icon, colorField.text);
|
||||
}
|
||||
|
||||
function send (title, icon, color) {
|
||||
if (modal.inProgress)
|
||||
return;
|
||||
|
||||
titleField.text = title;
|
||||
iconField.icon = icon;
|
||||
colorField.text = color;
|
||||
|
||||
modal.inProgress = true;
|
||||
modal.status = qsTr("Creating new asset ") + " " + title + "...";
|
||||
modal.open();
|
||||
|
||||
API.addAsset(title, icon, "blue", function (err, result) {
|
||||
if (!modal.inProgress)
|
||||
return;
|
||||
|
||||
modal.inProgress = false;
|
||||
if (err)
|
||||
modal.status = err;
|
||||
else
|
||||
modal.status = qsTr("Success");
|
||||
|
||||
if (!!result) {
|
||||
modal.close();
|
||||
success();
|
||||
}
|
||||
});
|
||||
confirm(name, icon, form.color, currency);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -11,7 +11,7 @@ qt_add_qml_module(magpieForms
|
|||
QML_FILES
|
||||
Login.qml
|
||||
Register.qml
|
||||
AddAsset.qml
|
||||
Asset.qml
|
||||
)
|
||||
|
||||
target_link_libraries(magpie PRIVATE magpieForms)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue