// SPDX-FileCopyrightText: 2023 Yury Gubich // SPDX-License-Identifier: GPL-3.0-or-later import QtQuick import QtQuick.Controls import magpie import magpie.Forms as Forms import magpie.Components as Components Item { StackView { id: stack initialItem: main anchors.fill: parent } Component { id: main Main { onAddAsset: stack.push(addAssetForm); } } Component { id: addAssetForm Forms.Asset { onCancel: stack.pop() onConfirm: function (title, icon, color, currency) { if (modal.inProgress) return; modal.inProgress = true; modal.status = qsTr("Creating new asset ") + " " + title + "..."; modal.open(); API.addAsset(title, icon, color, currency, function (err, result) { if (!modal.inProgress) return; modal.inProgress = false; if (err) modal.status = err; else modal.status = qsTr("Success"); if (!!result) { modal.close(); stack.pop() } }); } } } Connections { target: Magpie function onDisplayError (err) { modal.status = err; modal.open(); } } Components.Modal { id: modal closable: true } }