From f5afc2033feed8c932f5715005ea2c8370c1765a Mon Sep 17 00:00:00 2001 From: Howard Stearns Date: Thu, 28 Feb 2019 15:10:55 -0800 Subject: [PATCH] work through stocking vs update issues, and cleanup --- .../qml/hifi/commerce/checkout/Checkout.qml | 41 ++++++++----------- .../hifi/commerce/marketplace/Marketplace.qml | 3 +- .../commerce/marketplace/MarketplaceItem.qml | 19 ++++----- .../hifi/commerce/purchases/PurchasedItem.qml | 2 +- .../qml/hifi/commerce/wallet/Wallet.qml | 4 -- 5 files changed, 27 insertions(+), 42 deletions(-) diff --git a/interface/resources/qml/hifi/commerce/checkout/Checkout.qml b/interface/resources/qml/hifi/commerce/checkout/Checkout.qml index 9589c842e6..93ca366d37 100644 --- a/interface/resources/qml/hifi/commerce/checkout/Checkout.qml +++ b/interface/resources/qml/hifi/commerce/checkout/Checkout.qml @@ -41,8 +41,8 @@ Rectangle { property string itemAuthor; property int itemEdition: -1; property bool hasSomethingToTradeIn: alreadyOwned && (itemEdition > 0); // i.e., don't trade in your artist's proof - property bool isTradingIn: isUpdating && hasSomethingToTradeIn; - property bool isStocking: availability === 'not for sale' && creator === Account.username; + property bool isTradingIn: canUpdate && hasSomethingToTradeIn; + property bool isStocking: (availability === 'not for sale') && (creator === Account.username) && ; property string certificateId; property double balanceAfterPurchase; property bool alreadyOwned: false; // Including proofs @@ -59,7 +59,7 @@ Rectangle { property bool canRezCertifiedItems: Entities.canRezCertified() || Entities.canRezTmpCertified(); property string referrer; property bool isInstalled; - property bool isUpdating; + property bool canUpdate; property string availability: "available"; property string creator: ""; property string baseAppURL; @@ -144,6 +144,7 @@ Rectangle { } onAvailableUpdatesResult: { + // Answers the updatable original item cert data still owned by this user that are EITHER instances of this marketplace id, or update to this marketplace id. if (result.status !== 'success') { console.log("Failed to get Available Updates", result.data.message); } else { @@ -155,7 +156,7 @@ Rectangle { if (root.itemEdition !== -1 && root.itemEdition !== parseInt(result.data.updates[i].edition_number)) { continue; } - root.isUpdating = true; + root.canUpdate = true; root.baseItemName = result.data.updates[i].base_item_title; // This CertID is the one corresponding to the base item CertID that the user already owns root.certificateId = result.data.updates[i].certificate_id; @@ -166,7 +167,7 @@ Rectangle { } } - if (result.data.updates.length === 0 || root.isUpdating) { + if (result.data.updates.length === 0 || root.canUpdate) { root.availableUpdatesReceived = true; refreshBuyUI(); } else { @@ -266,13 +267,6 @@ Rectangle { } } } - MouseArea { - enabled: titleBarContainer.usernameDropdownVisible; - anchors.fill: parent; - onClicked: { - titleBarContainer.usernameDropdownVisible = false; - } - } // // TITLE BAR END // @@ -481,7 +475,7 @@ Rectangle { FiraSansSemiBold { id: itemPriceText; text: isTradingIn ? "FREE\nUPDATE" : - (isStocking ? "Free for creator" : + (isStocking ? "Free for creator" : ((root.itemPrice === -1) ? "--" : ((root.itemPrice > 0) ? root.itemPrice : "FREE"))); // Text size size: isTradingIn ? 20 : 26; @@ -580,7 +574,7 @@ Rectangle { // "View in Inventory" button HifiControlsUit.Button { id: viewInMyPurchasesButton; - visible: isCertified && dataReady && (isUpdating ? !hasSomethingToTradeIn : alreadyOwned); + visible: isCertified && dataReady && (isTradingIn ? hasSomethingToTradeIn : alreadyOwned); color: hifi.buttons.blue; colorScheme: hifi.colorSchemes.light; anchors.top: buyTextContainer.visible ? buyTextContainer.bottom : checkoutActionButtonsContainer.top; @@ -588,9 +582,9 @@ Rectangle { height: 50; anchors.left: parent.left; anchors.right: parent.right; - text: root.isUpdating ? "UPDATE TO THIS ITEM FOR FREE" : "VIEW THIS ITEM IN YOUR INVENTORY"; + text: (canUpdate && !isTradingIn) ? "UPDATE TO THIS ITEM FOR FREE" : "VIEW THIS ITEM IN YOUR INVENTORY"; onClicked: { - if (root.isUpdating) { + if (root.canUpdate) { sendToScript({method: 'checkout_goToPurchases', filterText: root.baseItemName}); } else { sendToScript({method: 'checkout_goToPurchases', filterText: root.itemName}); @@ -602,7 +596,11 @@ Rectangle { HifiControlsUit.Button { id: buyButton; visible: isTradingIn || !alreadyOwned || isStocking || !(root.itemType === "avatar" || root.itemType === "app"); - enabled: (root.balanceAfterPurchase >= 0 && dataReady) || (!root.isCertified) || root.isUpdating; + property bool checkBalance: dataReady && (root.availability === "available") + enabled: (checkBalance && (balanceAfterPurchase >= 0)) || !isCertified || isTradingIn || isStocking; + text: isTradingIn ? "Confirm Update" : + (enabled ? (viewInMyPurchasesButton.visible ? "Get It Again" : (dataReady ? "Get Item" : "--")) : + (checkBalance ? "Insufficient Funds" : availability)) color: viewInMyPurchasesButton.visible ? hifi.buttons.white : hifi.buttons.blue; colorScheme: hifi.colorSchemes.light; anchors.top: viewInMyPurchasesButton.visible ? viewInMyPurchasesButton.bottom : @@ -611,13 +609,6 @@ Rectangle { height: 50; anchors.left: parent.left; anchors.right: parent.right; - text: isTradingIn ? - "CONFIRM UPDATE" : - (((root.isCertified) ? - (dataReady ? - ((viewInMyPurchasesButton.visible && !root.isUpdating) ? "Get It Again" : "Confirm") : - "--") : - "Get Item")); onClicked: { if (isTradingIn) { // If we're updating an app, the existing app needs to be uninstalled. @@ -1209,7 +1200,7 @@ Rectangle { buyText.text = ""; // If the user IS on the checkout page for the updated version of an owned item... - if (root.isUpdating) { + if (root.canUpdate) { // If the user HAS already selected a specific edition to update... if (hasSomethingToTradeIn) { buyText.text = "By pressing \"Confirm Update\", you agree to trade in your old item for the updated item that replaces it."; diff --git a/interface/resources/qml/hifi/commerce/marketplace/Marketplace.qml b/interface/resources/qml/hifi/commerce/marketplace/Marketplace.qml index ca6838efea..a8b769703d 100644 --- a/interface/resources/qml/hifi/commerce/marketplace/Marketplace.qml +++ b/interface/resources/qml/hifi/commerce/marketplace/Marketplace.qml @@ -112,7 +112,7 @@ Rectangle { marketplaceItem.image_url = result.data.thumbnail_url; marketplaceItem.name = result.data.title; marketplaceItem.likes = result.data.likes; - if(result.data.has_liked !== undefined) { + if (result.data.has_liked !== undefined) { marketplaceItem.liked = result.data.has_liked; } marketplaceItem.creator = result.data.creator; @@ -122,6 +122,7 @@ Rectangle { marketplaceItem.attributions = result.data.attributions; marketplaceItem.license = result.data.license; marketplaceItem.availability = result.data.availability; + marketplaceItem.updated_item_id = result.updated_item_id; marketplaceItem.created_at = result.data.created_at; marketplaceItemScrollView.contentHeight = marketplaceItemContent.height; itemsList.visible = false; diff --git a/interface/resources/qml/hifi/commerce/marketplace/MarketplaceItem.qml b/interface/resources/qml/hifi/commerce/marketplace/MarketplaceItem.qml index 97e5c10a6b..e909d27e2b 100644 --- a/interface/resources/qml/hifi/commerce/marketplace/MarketplaceItem.qml +++ b/interface/resources/qml/hifi/commerce/marketplace/MarketplaceItem.qml @@ -2,7 +2,7 @@ // MarketplaceListItem.qml // qml/hifi/commerce/marketplace // -// MarketplaceListItem +// MarketplaceItem // // Created by Roxanne Skelly on 2019-01-22 // Copyright 2019 High Fidelity, Inc. @@ -34,6 +34,7 @@ Rectangle { property var categories: [] property int price: 0 property string availability: "unknown" + property string updated_item_id: "" property var attributions: [] property string description: "" property string license: "" @@ -42,7 +43,6 @@ Rectangle { property bool isLoggedIn: false; property int edition: -1; property bool supports3DHTML: false; - onCategoriesChanged: { categoriesListModel.clear(); @@ -264,15 +264,12 @@ Rectangle { } height: 50 - property bool isNFS: availability === "not for sale" // Note: server will say "sold out" or "invalidated" before it says NFS - property bool isMine: creator === Account.username - property bool isUpgrade: root.edition >= 0 - property int costToMe: ((isMine && isNFS) || isUpgrade) ? 0 : price - property bool isAvailable: costToMe >= 0 - - text: isUpgrade ? "UPGRADE FOR FREE" : (isAvailable ? (costToMe || "FREE") : availability) - enabled: isAvailable - buttonGlyph: isAvailable ? (costToMe ? hifi.glyphs.hfc : "") : "" + property bool isUpdate: root.edition >= 0 // Special case of updating from a specific older item + property bool isStocking: (creator === Account.username) && (availability === "not for sale") && !updated_item_id // Note: server will say "sold out" or "invalidated" before it says NFS + property bool isFreeSpecial: isStocking || isUpdate + enabled: isFreeSpecial || (availability === 'available') + buttonGlyph: (enabled && !isUpdate && (price > 0)) ? hifi.glyphs.hfc : "" + text: isUpdate ? "UPDATE FOR FREE" : (isStocking ? "FREE STOCK" : (enabled ? (price || "FREE") : availability)) color: hifi.buttons.blue onClicked: root.buy(); diff --git a/interface/resources/qml/hifi/commerce/purchases/PurchasedItem.qml b/interface/resources/qml/hifi/commerce/purchases/PurchasedItem.qml index df6e216b32..2c2fed1d8f 100644 --- a/interface/resources/qml/hifi/commerce/purchases/PurchasedItem.qml +++ b/interface/resources/qml/hifi/commerce/purchases/PurchasedItem.qml @@ -380,7 +380,7 @@ Item { if (updateButton.visible && uninstallButton.visible) { item.itemButtonText = ""; item.glyphSize = 20; - } else { + } else if (item) { item.itemButtonText = "Send to Trash"; item.glyphSize = 30; } diff --git a/interface/resources/qml/hifi/commerce/wallet/Wallet.qml b/interface/resources/qml/hifi/commerce/wallet/Wallet.qml index f8e2c9115b..ea74549084 100644 --- a/interface/resources/qml/hifi/commerce/wallet/Wallet.qml +++ b/interface/resources/qml/hifi/commerce/wallet/Wallet.qml @@ -40,10 +40,6 @@ Rectangle { source: "images/wallet-bg.jpg"; } - Component.onDestruction: { - KeyboardScriptingInterface.raised = false; - } - Connections { target: Commerce;