Merge pull request #14765 from howard-stearns/artist-stocking-inventory

Case 20657: artist stocking inventory
This commit is contained in:
Howard Stearns 2019-02-19 10:46:01 -08:00 committed by GitHub
commit d7d6ff53ca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 69 additions and 40 deletions

View file

@ -33,15 +33,19 @@ Rectangle {
property bool balanceReceived: false;
property bool availableUpdatesReceived: false;
property bool itemInfoReceived: false;
property bool dataReady: itemInfoReceived && ownershipStatusReceived && balanceReceived && availableUpdatesReceived;
property string baseItemName: "";
property string itemName;
property string itemId;
property string itemHref;
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 string certificateId;
property double balanceAfterPurchase;
property bool alreadyOwned: false;
property bool alreadyOwned: false; // Including proofs
property int itemPrice: -1;
property bool isCertified;
property string itemType: "unknown";
@ -56,6 +60,8 @@ Rectangle {
property string referrer;
property bool isInstalled;
property bool isUpdating;
property string availability: "available";
property string creator: "";
property string baseAppURL;
property int currentUpdatesPage: 1;
// Style
@ -434,7 +440,7 @@ Rectangle {
anchors.top: parent.top;
anchors.left: itemPreviewImage.right;
anchors.leftMargin: 12;
anchors.right: itemPriceContainer.left;
anchors.right: parent.right;
anchors.rightMargin: 8;
height: 30;
// Style
@ -449,21 +455,22 @@ Rectangle {
Item {
id: itemPriceContainer;
// Anchors
anchors.top: parent.top;
anchors.right: parent.right;
anchors.top: itemNameText.bottom;
anchors.topMargin: 8;
anchors.left: itemNameText.left;
height: 30;
width: itemPriceTextLabel.width + itemPriceText.width + 20;
width: itemPriceText.width + 20;
// "HFC" balance label
// "HFC" label
HiFiGlyphs {
id: itemPriceTextLabel;
visible: !(root.isUpdating && root.itemEdition > 0) && (root.itemPrice > 0);
visible: !isTradingIn && (root.itemPrice > 0);
text: hifi.glyphs.hfc;
// Size
size: 30;
// Anchors
anchors.right: itemPriceText.left;
anchors.rightMargin: 4;
anchors.right: parent.right;
//anchors.rightMargin: 4;
anchors.top: parent.top;
anchors.topMargin: 0;
width: paintedWidth;
@ -473,13 +480,15 @@ Rectangle {
}
FiraSansSemiBold {
id: itemPriceText;
text: (root.isUpdating && root.itemEdition > 0) ? "FREE\nUPDATE" : ((root.itemPrice === -1) ? "--" : ((root.itemPrice > 0) ? root.itemPrice : "FREE"));
text: isTradingIn ? "FREE\nUPDATE" :
(isStocking ? "Free for creator" :
((root.itemPrice === -1) ? "--" : ((root.itemPrice > 0) ? root.itemPrice : "FREE")));
// Text size
size: (root.isUpdating && root.itemEdition > 0) ? 20 : 26;
size: isTradingIn ? 20 : 26;
// Anchors
anchors.top: parent.top;
anchors.right: parent.right;
anchors.rightMargin: 16;
anchors.left: itemPriceTextLabel.visible ? itemPriceTextLabel.right : parent.left;
anchors.leftMargin: 4;
width: paintedWidth;
height: paintedHeight;
// Style
@ -571,7 +580,7 @@ Rectangle {
// "View in Inventory" button
HifiControlsUit.Button {
id: viewInMyPurchasesButton;
visible: false;
visible: isCertified && dataReady && (isUpdating ? !hasSomethingToTradeIn : alreadyOwned);
color: hifi.buttons.blue;
colorScheme: hifi.colorSchemes.light;
anchors.top: buyTextContainer.visible ? buyTextContainer.bottom : checkoutActionButtonsContainer.top;
@ -592,8 +601,8 @@ Rectangle {
// "Buy" button
HifiControlsUit.Button {
id: buyButton;
visible: !((root.itemType === "avatar" || root.itemType === "app") && viewInMyPurchasesButton.visible)
enabled: (root.balanceAfterPurchase >= 0 && ownershipStatusReceived && balanceReceived && availableUpdatesReceived) || (!root.isCertified) || root.isUpdating;
visible: isTradingIn || !alreadyOwned || isStocking || !(root.itemType === "avatar" || root.itemType === "app");
enabled: (root.balanceAfterPurchase >= 0 && dataReady) || (!root.isCertified) || root.isUpdating;
color: viewInMyPurchasesButton.visible ? hifi.buttons.white : hifi.buttons.blue;
colorScheme: hifi.colorSchemes.light;
anchors.top: viewInMyPurchasesButton.visible ? viewInMyPurchasesButton.bottom :
@ -602,10 +611,15 @@ Rectangle {
height: 50;
anchors.left: parent.left;
anchors.right: parent.right;
text: (root.isUpdating && root.itemEdition > 0) ? "CONFIRM UPDATE" : (((root.isCertified) ? ((ownershipStatusReceived && balanceReceived && availableUpdatesReceived) ?
((viewInMyPurchasesButton.visible && !root.isUpdating) ? "Get It Again" : "Confirm") : "--") : "Get Item"));
text: isTradingIn ?
"CONFIRM UPDATE" :
(((root.isCertified) ?
(dataReady ?
((viewInMyPurchasesButton.visible && !root.isUpdating) ? "Get It Again" : "Confirm") :
"--") :
"Get Item"));
onClicked: {
if (root.isUpdating && root.itemEdition > 0) {
if (isTradingIn) {
// If we're updating an app, the existing app needs to be uninstalled.
// This call will fail/return `false` if the app isn't installed, but that's OK.
if (root.itemType === "app") {
@ -1063,7 +1077,11 @@ Rectangle {
buyButton.color = hifi.buttons.red;
root.shouldBuyWithControlledFailure = true;
} else {
buyButton.text = (root.isCertified ? ((ownershipStatusReceived && balanceReceived && availableUpdatesReceived) ? (root.alreadyOwned ? "Buy Another" : "Buy"): "--") : "Get Item");
buyButton.text = (root.isCertified ?
(dataReady ?
(root.alreadyOwned ? "Buy Another" : "Buy") :
"--") :
"Get Item");
buyButton.color = hifi.buttons.blue;
root.shouldBuyWithControlledFailure = false;
}
@ -1091,6 +1109,8 @@ Rectangle {
root.itemPrice = result.data.cost;
root.itemAuthor = result.data.creator;
root.itemType = result.data.item_type || "unknown";
root.availability = result.data.availability;
root.creator = result.data.creator;
if (root.itemType === "unknown") {
root.itemHref = result.data.review_url;
} else {
@ -1139,7 +1159,7 @@ Rectangle {
signal sendToScript(var message);
function canBuyAgain() {
return (root.itemType === "entity" || root.itemType === "wearable" || root.itemType === "contentSet" || root.itemType === "unknown");
return root.itemType === "entity" || root.itemType === "wearable" || root.itemType === "contentSet" || root.itemType === "unknown" || isStocking;
}
function handleContentSets() {
@ -1185,29 +1205,23 @@ Rectangle {
function refreshBuyUI() {
if (root.isCertified) {
if (root.ownershipStatusReceived && root.balanceReceived && root.availableUpdatesReceived) {
if (dataReady) {
buyText.text = "";
// If the user IS on the checkout page for the updated version of an owned item...
if (root.isUpdating) {
// If the user HAS already selected a specific edition to update...
if (root.itemEdition > 0) {
if (hasSomethingToTradeIn) {
buyText.text = "By pressing \"Confirm Update\", you agree to trade in your old item for the updated item that replaces it.";
buyTextContainer.color = "#FFFFFF";
buyTextContainer.border.color = "#FFFFFF";
// Else if the user HAS NOT selected a specific edition to update...
} else {
viewInMyPurchasesButton.visible = true;
handleBuyAgainLogic();
}
// If the user IS NOT on the checkout page for the updated verison of an owned item...
// (i.e. they are checking out an item "normally")
} else {
if (root.alreadyOwned) {
viewInMyPurchasesButton.visible = true;
}
handleBuyAgainLogic();
}
} else {

View file

@ -121,7 +121,7 @@ Rectangle {
marketplaceItem.description = result.data.description;
marketplaceItem.attributions = result.data.attributions;
marketplaceItem.license = result.data.license;
marketplaceItem.available = result.data.availability === "available";
marketplaceItem.availability = result.data.availability;
marketplaceItem.created_at = result.data.created_at;
marketplaceItemScrollView.contentHeight = marketplaceItemContent.height;
itemsList.visible = false;
@ -539,7 +539,7 @@ Rectangle {
creator: model.creator
category: model.primary_category
price: model.cost
available: model.availability === "available"
availability: model.availability
isLoggedIn: root.isLoggedIn;
onShowItem: {
@ -711,7 +711,7 @@ Rectangle {
topMargin: 10;
leftMargin: 15;
}
height: visible ? childrenRect.height : 0
height: visible ? 36 : 0
RalewayRegular {
id: sortText
@ -733,8 +733,9 @@ Rectangle {
top: parent.top
leftMargin: 20
}
width: root.isLoggedIn ? 342 : 262
height: 36
height: parent.height
radius: 4
border.width: 1

View file

@ -33,11 +33,11 @@ Rectangle {
property string creator: ""
property var categories: []
property int price: 0
property string availability: "unknown"
property var attributions: []
property string description: ""
property string license: ""
property string posted: ""
property bool available: false
property string created_at: ""
property bool isLoggedIn: false;
property int edition: -1;
@ -264,9 +264,15 @@ Rectangle {
}
height: 50
text: root.edition >= 0 ? "UPGRADE FOR FREE" : (root.available ? (root.price ? root.price : "FREE") : "UNAVAILABLE (not for sale)")
enabled: root.edition >= 0 || root.available
buttonGlyph: root.available ? (root.price ? hifi.glyphs.hfc : "") : ""
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 : "") : ""
color: hifi.buttons.blue
onClicked: root.buy();

View file

@ -34,7 +34,7 @@ Rectangle {
property string creator: ""
property string category: ""
property int price: 0
property bool available: false
property string availability: "unknown"
property bool isLoggedIn: false;
signal buy()
@ -299,8 +299,16 @@ Rectangle {
bottomMargin: 10
}
text: root.price ? root.price : "FREE"
buttonGlyph: root.price ? hifi.glyphs.hfc : ""
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 : "") : ""
color: hifi.buttons.blue;
onClicked: root.buy();