Merge pull request #312 from tecnovert/ui

ui: Combine bid sent and received fields.
This commit is contained in:
tecnovert
2025-06-08 18:31:47 +00:00
committed by GitHub
6 changed files with 75 additions and 93 deletions

View File

@@ -329,8 +329,10 @@ const SwapTypeManager = {
} else {
swapTypeElement.disabled = false;
swapTypeElement.classList.remove('select-disabled');
if (['xmr_swap', 'seller_first'].includes(swapTypeElement.value) == false) {
swapTypeElement.value = 'xmr_swap';
}
}
let swapTypeHidden = DOM.get('swap_type_hidden');
if (makeHidden) {
@@ -353,10 +355,6 @@ const SwapTypeManager = {
}
};
function set_swap_type_enabled(coinFrom, coinTo, swapTypeElement) {
SwapTypeManager.setSwapTypeEnabled(coinFrom, coinTo, swapTypeElement);
}
const UIEnhancer = {
handleErrorHighlighting: () => {
const errMsgs = document.querySelectorAll('p.error_msg');

View File

@@ -76,7 +76,7 @@
</th>
</tr>
</thead>
{% if data.was_sent == 'True' %}
{% if data.was_sent %}
<tr class="opacity-100 text-gray-500 dark:text-gray-100 hover:bg-coolGray-200 dark:hover:bg-gray-600">
<td class="py-3 px-6 bold">Swap</td>
<td class="py-3 px-6">
@@ -103,7 +103,7 @@
<td class="py-3 px-6 bold">Bid Rate</td>
<td class="py-3 px-6">{{ data.bid_rate }}</td>
</tr>
{% if data.was_sent == 'True' %}
{% if data.was_sent %}
<tr class="opacity-100 text-gray-500 dark:text-gray-100 hover:bg-coolGray-200 dark:hover:bg-gray-600">
<td class="py-3 px-6 bold">You Send</td>
<td class="py-3 px-6">
@@ -183,12 +183,8 @@
<td class="py-3 px-6">{{ data.expired_at }}</td>
</tr>
<tr class="opacity-100 text-gray-500 dark:text-gray-100 hover:bg-coolGray-200 dark:hover:bg-gray-600">
<td class="py-3 px-6 bold">Sent</td>
<td class="py-3 px-6">{{ data.was_sent }}</td>
</tr>
<tr class="opacity-100 text-gray-500 dark:text-gray-100 hover:bg-coolGray-200 dark:hover:bg-gray-600">
<td class="py-3 px-6 bold">Received</td>
<td class="py-3 px-6">{{ data.was_received }}</td>
<td class="py-3 px-6 bold">Bid Type</td>
<td class="py-3 px-6" id="bidtype">{% if data.was_sent and data.was_received %}Self Bid{% elif data.was_sent %}Sent{% elif data.was_received %}Received{% endif %}</td>
</tr>
<tr class="opacity-100 text-gray-500 dark:text-gray-100 hover:bg-coolGray-200 dark:hover:bg-gray-600">
<td class="py-3 px-6 bold">Initiate Tx</td>
@@ -543,7 +539,7 @@
<button name="abandon_bid" type="submit" value="Abandon Bid" onclick="return confirmPopup();" class="flex flex-wrap justify-center w-full px-4 py-2.5 font-medium text-sm text-white hover:text-red border border-red-500 hover:border-red-500 hover:bg-red-600 bg-red-500 rounded-md shadow-button focus:ring-0 focus:outline-none">Abandon Bid</button>
</div>
{% endif %}
{% if data.was_received == 'True' and not edit_bid and data.can_accept_bid %}
{% if data.was_received and not edit_bid and data.can_accept_bid %}
<div class="w-full md:w-auto p-1.5">
<button name="accept_bid" value="Accept Bid" type="submit" onclick='return confirmPopup("Accept");' class="flex flex-wrap justify-center w-full px-4 py-2.5 bg-blue-500 hover:bg-blue-600 font-medium text-sm text-white border border-blue-500 rounded-md shadow-button focus:ring-0 focus:outline-none">Accept Bid</button>
</div>

View File

@@ -76,7 +76,7 @@
</th>
</tr>
</thead>
{% if data.was_sent == 'True' %}
{% if data.was_sent %}
<tr class="opacity-100 text-gray-500 dark:text-gray-100 hover:bg-coolGray-200 dark:hover:bg-gray-600">
<td class="py-3 px-6 bold">Swap</td>
<td class="py-3 px-6">
@@ -103,7 +103,7 @@
<td class="py-3 px-6 bold">Bid Rate</td>
<td class="py-3 px-6">{{ data.bid_rate }}</td>
</tr>
{% if data.was_sent == 'True' %}
{% if data.was_sent %}
<tr class="opacity-100 text-gray-500 dark:text-gray-100 hover:bg-coolGray-200 dark:hover:bg-gray-600">
<td class="py-3 px-6 bold">You Send</td>
<td class="py-3 px-6">
@@ -188,12 +188,8 @@
<td class="py-3 px-6">{{ data.expired_at }}</td>
</tr>
<tr class="opacity-100 text-gray-500 dark:text-gray-100 hover:bg-coolGray-200 dark:hover:bg-gray-600">
<td class="py-3 px-6 bold">Sent</td>
<td class="py-3 px-6">{{ data.was_sent }}</td>
</tr>
<tr class="opacity-100 text-gray-500 dark:text-gray-100 hover:bg-coolGray-200 dark:hover:bg-gray-600">
<td class="py-3 px-6 bold">Received</td>
<td class="py-3 px-6">{{ data.was_received }}</td>
<td class="py-3 px-6 bold">Bid Type</td>
<td class="py-3 px-6" id="bidtype">{% if data.was_sent and data.was_received %}Self Bid{% elif data.was_sent %}Sent{% elif data.was_received %}Received{% endif %}{% if data.reverse_bid %} (Transposed){% endif %}</td>
</tr>
{% if data.coin_a_lock_refund_tx_est_final != 'None' %}
<tr class="opacity-100 text-gray-500 dark:text-gray-100 hover:bg-coolGray-200 dark:hover:bg-gray-600">
@@ -819,7 +815,7 @@
<button name="abandon_bid" type="submit" value="Abandon Bid" onclick="return confirmPopup();" class="flex flex-wrap justify-center w-full px-4 py-2.5 font-medium text-sm text-white hover:text-red border border-red-500 hover:border-red-500 hover:bg-red-600 bg-red-500 rounded-md focus:ring-0 focus:outline-none">Abandon Bid</button>
</div>
{% endif %}
{% if data.was_received == 'True' and not edit_bid and data.can_accept_bid %}
{% if data.was_received and not edit_bid and data.can_accept_bid %}
<div class="w-full md:w-auto p-1.5">
<button name="accept_bid" value="Accept Bid" type="submit" onclick='return confirmPopup("Accept");' class="flex flex-wrap justify-center w-full px-4 py-2.5 bg-blue-500 hover:bg-blue-600 font-medium text-sm text-white border border-blue-500 rounded-md focus:ring-0 focus:outline-none">Accept Bid</button>
</div>

View File

@@ -110,7 +110,7 @@
</tr>
<tr class="opacity-100 text-gray-500 dark:text-gray-100 hover:bg-coolGray-200 dark:hover:bg-gray-600">
<td class="py-3 px-6 bold">Swap Type</td>
<td class="py-3 px-6">{{ data.swap_type }}{% if data.reverse == true %} (Reversed){% endif %}</td>
<td class="py-3 px-6">{{ data.swap_type }}{% if data.reverse == true %} (Transposed){% endif %}</td>
</tr>
<tr class="opacity-100 text-gray-500 dark:text-gray-100 hover:bg-coolGray-200 dark:hover:bg-gray-600">
<td class="py-3 px-6 bold">{% if data.sent %}You Send{% else %}You Get{% endif %}</td>

View File

@@ -348,8 +348,8 @@ def describeBid(
if for_api
else format_timestamp(bid.expire_at, with_seconds=True)
),
"was_sent": "True" if bid.was_sent else "False",
"was_received": "True" if bid.was_received else "False",
"was_sent": bid.was_sent,
"was_received": bid.was_received,
"initiate_tx": getTxIdHex(bid, TxTypes.ITX, " " + ci_leader.ticker()),
"initiate_conf": (
"None"

View File

@@ -239,10 +239,8 @@ def test_swap_dir(driver):
assert num_found >= 2
driver.get(f"{node1_url}/bid/{bid_1_id}")
td_sent = driver.find_element(
"xpath", "//td[contains(text(), 'Sent')]/following-sibling::td"
)
assert "False" in td_sent.get_attribute("innerHTML")
td_dir = driver.find_element(By.ID, "bidtype")
assert "Received" == td_dir.get_attribute("innerHTML")
td_ys = driver.find_element(
"xpath", "//td[contains(text(), 'You Send')]/following-sibling::td"
)
@@ -253,10 +251,8 @@ def test_swap_dir(driver):
assert "Monero" in td_yg.get_attribute("innerHTML")
driver.get(f"{node2_url}/bid/{bid_1_id}")
td_sent = driver.find_element(
"xpath", "//td[contains(text(), 'Sent')]/following-sibling::td"
)
assert "True" in td_sent.get_attribute("innerHTML")
td_dir = driver.find_element(By.ID, "bidtype")
assert "Sent" == td_dir.get_attribute("innerHTML")
td_ys = driver.find_element(
"xpath", "//td[contains(text(), 'You Send')]/following-sibling::td"
)
@@ -267,10 +263,8 @@ def test_swap_dir(driver):
assert "Particl" in td_yg.get_attribute("innerHTML")
driver.get(f"{node1_url}/bid/{bid_3_id}")
td_sent = driver.find_element(
"xpath", "//td[contains(text(), 'Sent')]/following-sibling::td"
)
assert "True" in td_sent.get_attribute("innerHTML")
td_dir = driver.find_element(By.ID, "bidtype")
assert "Sent (Transposed)" == td_dir.get_attribute("innerHTML")
td_ys = driver.find_element(
"xpath", "//td[contains(text(), 'You Send')]/following-sibling::td"
)
@@ -281,10 +275,8 @@ def test_swap_dir(driver):
assert "Monero" in td_yg.get_attribute("innerHTML")
driver.get(f"{node2_url}/bid/{bid_3_id}")
td_sent = driver.find_element(
"xpath", "//td[contains(text(), 'Sent')]/following-sibling::td"
)
assert "False" in td_sent.get_attribute("innerHTML")
td_dir = driver.find_element(By.ID, "bidtype")
assert "Received (Transposed)" == td_dir.get_attribute("innerHTML")
td_ys = driver.find_element(
"xpath", "//td[contains(text(), 'You Send')]/following-sibling::td"
)