allocation text fix; props&points suppressed during drag

This commit is contained in:
Tim
2024-05-06 15:24:47 -04:00
parent 613cb7d7f5
commit c3c5db9c23
5 changed files with 38 additions and 26 deletions

View File

@@ -19,7 +19,7 @@
label="Price"
/>
</td>
<td rowspan="2" class="weight">{{ allocationText(weights[weights.length-1]) }}</td>
<td rowspan="2" class="weight">{{ allocationTexts[weights.length-1] }}</td>
</tr>
<tr>
<td>
@@ -37,7 +37,7 @@
<tr v-for="i in innerIndexes" class="ml-5">
<td class="text-right">&nbsp;</td>
<td colspan="2" class="text-center"><i>Diagonal</i></td>
<td class="weight">{{ allocationText(weights[i]) }}</td>
<td class="weight">{{ allocationTexts[i] }}</td>
</tr>
<tr v-if="weights.length>1">
<td rowspan="2" class="label">Line B</td>
@@ -52,7 +52,7 @@
label="Price"
/>
</td>
<td rowspan="2" class="weight">{{ allocationText(weights[weights.length-1]) }}</td>
<td rowspan="2" class="weight">{{ allocationTexts[0] }}</td>
</tr>
<tr v-if="weights.length>1">
<td>
@@ -150,8 +150,6 @@ const endpoints = computed({
let [a, b] = v
a = buildLine(a)
b = buildLine(b)
// noinspection JSValidateTypes
_endpoints.value = v
update(a, b)
}
})
@@ -172,7 +170,7 @@ const price1A = computed({
set(v) {
const flatline0 = _endpoints.value[0];
update(
[{time:flatline0[0], price: v}, {time:flatline0[2], price: flatline0[3]}],
[{time:flatline0[0], price: Number(v)}, {time:flatline0[2], price: flatline0[3]}],
_endpoints.value[1]
)
}
@@ -194,7 +192,7 @@ const price1B = computed({
set(v) {
const flatline0 = _endpoints.value[0];
update(
[{time:flatline0[0], price: flatline0[1]}, {time:flatline0[2], price: v}],
[{time:flatline0[0], price: flatline0[1]}, {time:flatline0[2], price: Number(v)}],
_endpoints.value[1]
)
}
@@ -217,7 +215,7 @@ const price2A = computed({
const flatline = _endpoints.value[1];
update(
_endpoints.value[0],
[{time:flatline[0], price: v}, {time:flatline[2], price: flatline[3]}],
[{time:flatline[0], price: Number(v)}, {time:flatline[2], price: flatline[3]}],
)
}
})
@@ -239,18 +237,23 @@ const price2B = computed({
const flatline = _endpoints.value[1];
update(
_endpoints.value[0],
[{time:flatline[0], price: flatline[1]}, {time:flatline[2], price: v}],
[{time:flatline[0], price: flatline[1]}, {time:flatline[2], price: Number(v)}],
)
}
})
function update(a, b) { // a and b are lines of two points
console.log('update', a, b)
if (!vectorEquals(props.builder.lineA, a) || !vectorEquals(props.builder.lineB, b)) {
console.log('update was dirty')
_endpoints.value = [flattenLine(a), flattenLine(b)]
const newBuilder = {...props.builder}
newBuilder.lineA = a
newBuilder.lineB = b
emit('update:builder', newBuilder)
}
else
console.log('update was not dirty')
}
@@ -275,6 +278,9 @@ function setWeights(ws) {
weights.value = ws
}
const amountSymbol = computed(()=>props.order.amountIsTokenA ? co.selectedSymbol.base.s : co.selectedSymbol.quote.s )
const allocationTexts = computed(()=>weights.value.map((w)=>allocationText(w, w*props.order.amount, amountSymbol.value)))
const stdWidth = computed(()=>[0, 2 * co.meanRange, 0, 2 * co.meanRange])
@@ -321,8 +327,8 @@ function dirtyLine(a, b) {
<style scoped lang="scss">
td.weight {
width: 5em;
max-width: 8em;
min-width: 5em;
max-width: 20em;
padding-left: 0.5em;
padding-right: 0.5em;
text-align: right;