Skip to content
This repository has been archived by the owner on May 2, 2022. It is now read-only.

Commit

Permalink
Merge pull request #877 from swarmcity/S01E05-live
Browse files Browse the repository at this point in the history
Deselect & Cancel
  • Loading branch information
xardass authored Dec 2, 2018
2 parents 68546d3 + 9c3d008 commit 025609d
Show file tree
Hide file tree
Showing 6 changed files with 134 additions and 26 deletions.
29 changes: 27 additions & 2 deletions src/pages/detail/detail-simpledeal-funded.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@
@apply --layout-flex;
@apply --body-default;
color: var(--sc-grey4);
-webkit-user-select: text;
-moz-user-select: text;
-ms-user-select: text;
user-select: text;
}

.price {
Expand Down Expand Up @@ -162,6 +166,27 @@
opacity: 0.5;
}


.dont-break-out {

/* These are technically the same, but use both */
overflow-wrap: break-word;
word-wrap: break-word;

-ms-word-break: break-all;
/* This is the dangerous one in WebKit, as it breaks things wherever */
word-break: break-all;
/* Instead use this non-standard one: */
word-break: break-word;

/* Adds a hyphen where the word breaks, if supported (No Blink) */
-ms-hyphens: auto;
-moz-hyphens: auto;
-webkit-hyphens: auto;
hyphens: auto;

}

@media only screen and (-webkit-min-device-pixel-ratio: 1.5),
only screen and (min--moz-device-pixel-ratio: 1.5),
only screen and (min-resolution: 240dpi) {
Expand All @@ -175,7 +200,7 @@
<template is="dom-if" if="[[_isInvolved(item.seekerAddress, reply.providerAddress, address)]]">
<div class="whitebox">
<div class="descriptionbox">
<div class="description">[[reply.message]]</div>
<div class="description dont-break-out">[[reply.message]]</div>
<div class="price">for [[_formatValue(item.itemValue)]] SWT</div>
</div>
<div class="date">
Expand Down Expand Up @@ -323,7 +348,7 @@
}

_checkPending(status) {
return status == '1'? "greenbox" : "greenbox pending";
return status == '1' ? "greenbox" : "greenbox pending";
}
}
window.customElements.define(
Expand Down
48 changes: 41 additions & 7 deletions src/pages/detail/detail-simpledeal-selected.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,32 @@
background-color: var(--sc-blue);
}

.container[wide-layout] .bluebox {
@apply --layout-horizontal;
@apply --layout-start;
padding: 40px;
}

.disabled {
opacity: 0.5;
}

.container[wide-layout] .flex {
@apply --layout-flex;
}

.container[wide-layout] .white-text {
margin-top: 20px;
text-align: left;

}

.container[wide-layout] .white-subtext {
margin-top: 5px;
text-align: left;

}

.white-text {
@apply --body-bold;
color: var(--sc-white);
Expand All @@ -122,10 +144,16 @@
}

.button {
@apply --text-button-small;
@apply --small-bold;
@apply --text-button-big;
@apply --body-bold;
margin: 40px 0;
color: var(--sc-white);
width: 250px;
}

.container[wide-layout] .button {
margin: 0;

}

.button:active {
Expand Down Expand Up @@ -225,11 +253,14 @@
</div>
</template>
<template is="dom-if" if="[[!_isReplier(reply.replierAddress, address)]]">
<div class="white-text">You selected [[reply.username]] to make a deal.</div>
<div class="white-subtext">Waiting for [[reply.username]] to respond</div>
<!-- <div class="button">
unselect [[reply.username]]
</div> -->
<div class="text">
<div class="white-text">You selected [[reply.username]] to make a deal.</div>
<div class="white-subtext">Waiting for [[reply.username]] to respond</div>
</div>
<div class="flex"></div>
<div class="button" on-tap="_deselect">
deselect [[reply.username]]
</div>
</template>

</div>
Expand Down Expand Up @@ -322,6 +353,9 @@
_fund() {
this.dispatchEvent(new CustomEvent('fund'));
}
_deselect() {
this.dispatchEvent(new CustomEvent('deselect'));
}
/**
* Verifies user balance and displays error message
*/
Expand Down
74 changes: 61 additions & 13 deletions src/pages/detail/detail-simpledeal.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@

<template is="dom-if" if="{{_isEqualTo(status, 'selected')}}">
<detail-simpledeal-selected address="[[address]]" item="[[item]]" balance="[[balance]]" reply="[[_getProviderReply(item)]]"
on-status="_handleOnStatus" on-fund="_handleOnFund"></detail-simpledeal-selected>
on-status="_handleOnStatus" on-fund="_handleOnFund" on-deselect="_handleOnDeselect"></detail-simpledeal-selected>
</template>

<template is="dom-if" if="{{_isEqualTo(status, 'funded')}}">
Expand Down Expand Up @@ -141,7 +141,7 @@
<detail-button-payout on-payout="_handleOnPayout"></detail-button-payout>
</template>

<template is="dom-if" if="{{_showCancelButton()}}">
<template is="dom-if" if="{{_showCancelButton(item, address)}}">
<detail-button-cancel on-cancel="_handleOnCancel"></detail-button-cancel>
</template>

Expand Down Expand Up @@ -304,17 +304,16 @@
}
}

_showCancelButton(status, userAddress) {
// needs fix on simpledeal contract first -- see hackmd
return false
// (
// this.item
// && this.item.status == '0'
// && this.item.providerAddress
// && this.item.providerAddress != '0x0000000000000000000000000000000000000000'
// && this.item.seekerAddress
// && this.item.seekerAddress == userAddress
// )
_showCancelButton(item, userAddress) {
return (
item
&& item.status
&& item.status == '0'
&& item.providerAddress
&& item.providerAddress == '0x0000000000000000000000000000000000000000'
&& item.seekerAddress
&& item.seekerAddress == userAddress
)
}

_showConflictButton(item, status) {
Expand Down Expand Up @@ -559,6 +558,54 @@
}
});
}

_handleOnDeselect() {
this.$.unlock._getPrivateKey().then(res => {
try {
const { privateKey, address, publicKey } = res;
if (!privateKey) {
throw Error("Missing address");
}
const seeker = {
address,
privateKey
};

const provider = {
address: '0x0000000000000000000000000000000000000000',
};

const item = {
itemHash: this.item.itemHash,
hashtag: this.hashtag.address
};

this.$.simpledeal
.selectReplier({ seeker, provider, item })
.then(receipt => {
console.log(
"Successfully deselected replier, receipt:",
receipt
);
this.dispatch({
type: "UPDATE_ITEM",
hashtagAddress: item.hashtag,
itemHash: item.itemHash,
data: {
providerAddress: provider.address,
status: "selected-pending"
}
});
})
.catch(err => {
console.log("Error deselecting replier:", err);
});
} catch (e) {
console.error("Error deselecting replier (catch block): ", e.stack);
}
});

}
_handleOnCancel() {
this.$.unlock._getPrivateKey().then(res => {
try {
Expand All @@ -576,6 +623,7 @@
.cancelItem({ seeker, itemHash, hashtagAddress })
.then(receipt => {
console.log("Successfully cancelled item, receipt:", receipt);
this._handleOnClose();
this.dispatch({
type: "UPDATE_ITEM",
hashtagAddress,
Expand Down
2 changes: 1 addition & 1 deletion src/pages/hashtag/hashtag-simpledeal-item.html
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@
[[_formatDate(item)]]
</div>
</div>
<div class="replycount">[[_replycount(item)]]</div>
<div class="replycount">[[item.status]]</div>
<div class="replyicon"></div>
<template is="dom-if" if="[[_hasProvider(item)]]">
<iron-image class="item-avatar-topright" sizing="cover" preload src="https://scapiweb3-c.swarm.city/img/[[item.providerAvatarHash]]"
Expand Down
6 changes: 3 additions & 3 deletions src/pages/hashtag/hashtag-simpledeal.html
Original file line number Diff line number Diff line change
Expand Up @@ -165,18 +165,18 @@
this.hashtag.metadata &&
this.hashtag.metadata.maintainer &&
this.hashtag.maintainerAddress &&
this.hashtag.maintainerAddress == this.address) &&(
this.hashtag.maintainerAddress == this.address) && (
item.status &&
item.status == '3'
)) involved = true;
}
if (item.status && (item.status == '2' || item.status == '4')) involved = false
if (item.status && (item.status == '2' || item.status == '4'|| item.status == '5' || item.status == '5-pending')) involved = false
return involved;
}

_isNotInvolved(item) {
return (
!this._isInvolved(item) && (item.status || {}) != '1' && (item.status || {}) != '3' && (item.seekerAddress || {}) != '0x0000000000000000000000000000000000000000');
!this._isInvolved(item) && (item.status || {}) != '1' && (item.status || {}) != '3' && (item.status || {}) != '5' && (item.status || {}) != '5-pending' && (item.seekerAddress || {}) != '0x0000000000000000000000000000000000000000');
}

_handleOnDetail(e) {
Expand Down
1 change: 1 addition & 0 deletions src/redux/sagas/hashtag-saga.html
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@
// Step 1. Store the item info
console.log('Handling ItemChange', event)
const { itemHash, newstatus, providerAddress } = event.returnValues

yield put({
type: 'UPDATE_ITEM', hashtagAddress, itemHash, data: {
status: newstatus,
Expand Down

0 comments on commit 025609d

Please sign in to comment.