|
@ -13,18 +13,21 @@ |
|
|
<div class="flex flex-row"> |
|
|
<div class="flex flex-row"> |
|
|
<span |
|
|
<span |
|
|
class="rounded-l border border-r-0 border-slate-400 bg-slate-200 w-1/3 text-center px-2 py-2" |
|
|
class="rounded-l border border-r-0 border-slate-400 bg-slate-200 w-1/3 text-center px-2 py-2" |
|
|
>Hours</span |
|
|
@click="changeUnitCode()" |
|
|
> |
|
|
> |
|
|
|
|
|
{{ UNIT_SHORT[unitCode] }} |
|
|
|
|
|
</span> |
|
|
<div |
|
|
<div |
|
|
class="border border-r-0 border-slate-400 bg-slate-200 px-4 py-2" |
|
|
class="border border-r-0 border-slate-400 bg-slate-200 px-4 py-2" |
|
|
@click="decrement()" |
|
|
@click="decrement()" |
|
|
|
|
|
v-if="amountInput !== '0'" |
|
|
> |
|
|
> |
|
|
<fa icon="chevron-left" /> |
|
|
<fa icon="chevron-left" /> |
|
|
</div> |
|
|
</div> |
|
|
<input |
|
|
<input |
|
|
type="text" |
|
|
type="text" |
|
|
class="w-full border border-r-0 border-slate-400 px-2 py-2 text-center" |
|
|
class="w-full border border-r-0 border-slate-400 px-2 py-2 text-center" |
|
|
v-model="hours" |
|
|
v-model="amountInput" |
|
|
/> |
|
|
/> |
|
|
<div |
|
|
<div |
|
|
class="rounded-r border border-slate-400 bg-slate-200 px-4 py-2" |
|
|
class="rounded-r border border-slate-400 bg-slate-200 px-4 py-2" |
|
@ -81,12 +84,31 @@ export default class GiftedDialog extends Vue { |
|
|
activeDid = ""; |
|
|
activeDid = ""; |
|
|
apiServer = ""; |
|
|
apiServer = ""; |
|
|
|
|
|
|
|
|
|
|
|
amountInput = "0"; |
|
|
giver?: GiverInputInfo; // undefined means no identified giver agent |
|
|
giver?: GiverInputInfo; // undefined means no identified giver agent |
|
|
description = ""; |
|
|
description = ""; |
|
|
givenToUser = false; |
|
|
givenToUser = false; |
|
|
hours = "0"; |
|
|
unitCode = "HUR"; |
|
|
visible = false; |
|
|
visible = false; |
|
|
|
|
|
|
|
|
|
|
|
/* eslint-disable prettier/prettier */ |
|
|
|
|
|
UNIT_SHORT: Record<string, string> = { |
|
|
|
|
|
"BTC": "BTC", |
|
|
|
|
|
"ETH": "ETH", |
|
|
|
|
|
"HUR": "Hours", |
|
|
|
|
|
"USD": "US $", |
|
|
|
|
|
}; |
|
|
|
|
|
/* eslint-enable prettier/prettier */ |
|
|
|
|
|
|
|
|
|
|
|
/* eslint-disable prettier/prettier */ |
|
|
|
|
|
UNIT_LONG: Record<string, string> = { |
|
|
|
|
|
"BTC": "BTC", |
|
|
|
|
|
"ETH": "ETH", |
|
|
|
|
|
"HUR": "hours", |
|
|
|
|
|
"USD": "dollars", |
|
|
|
|
|
}; |
|
|
|
|
|
/* eslint-enable prettier/prettier */ |
|
|
|
|
|
|
|
|
async created() { |
|
|
async created() { |
|
|
try { |
|
|
try { |
|
|
await db.open(); |
|
|
await db.open(); |
|
@ -115,7 +137,7 @@ export default class GiftedDialog extends Vue { |
|
|
this.giver = giver; |
|
|
this.giver = giver; |
|
|
// if we show "given to user" selection, default checkbox to true |
|
|
// if we show "given to user" selection, default checkbox to true |
|
|
this.givenToUser = this.showGivenToUser; |
|
|
this.givenToUser = this.showGivenToUser; |
|
|
this.hours = "0"; |
|
|
this.amountInput = "0"; |
|
|
|
|
|
|
|
|
this.visible = true; |
|
|
this.visible = true; |
|
|
} |
|
|
} |
|
@ -125,12 +147,21 @@ export default class GiftedDialog extends Vue { |
|
|
this.visible = false; |
|
|
this.visible = false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
changeUnitCode() { |
|
|
|
|
|
const units = Object.keys(this.UNIT_SHORT); |
|
|
|
|
|
const index = units.indexOf(this.unitCode); |
|
|
|
|
|
this.unitCode = units[(index + 1) % units.length]; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
increment() { |
|
|
increment() { |
|
|
this.hours = `${(parseFloat(this.hours) || 0) + 1}`; |
|
|
this.amountInput = `${(parseFloat(this.amountInput) || 0) + 1}`; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
decrement() { |
|
|
decrement() { |
|
|
this.hours = `${Math.max(0, (parseFloat(this.hours) || 1) - 1)}`; |
|
|
this.amountInput = `${Math.max( |
|
|
|
|
|
0, |
|
|
|
|
|
(parseFloat(this.amountInput) || 1) - 1, |
|
|
|
|
|
)}`; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
cancel() { |
|
|
cancel() { |
|
@ -142,7 +173,7 @@ export default class GiftedDialog extends Vue { |
|
|
this.description = ""; |
|
|
this.description = ""; |
|
|
this.giver = undefined; |
|
|
this.giver = undefined; |
|
|
this.givenToUser = this.showGivenToUser; |
|
|
this.givenToUser = this.showGivenToUser; |
|
|
this.hours = "0"; |
|
|
this.amountInput = "0"; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
async confirm() { |
|
|
async confirm() { |
|
@ -160,7 +191,8 @@ export default class GiftedDialog extends Vue { |
|
|
await this.recordGive( |
|
|
await this.recordGive( |
|
|
this.giver?.did as string | undefined, |
|
|
this.giver?.did as string | undefined, |
|
|
this.description, |
|
|
this.description, |
|
|
parseFloat(this.hours), |
|
|
parseFloat(this.amountInput), |
|
|
|
|
|
this.unitCode, |
|
|
).then(() => { |
|
|
).then(() => { |
|
|
this.eraseValues(); |
|
|
this.eraseValues(); |
|
|
}); |
|
|
}); |
|
@ -186,12 +218,13 @@ export default class GiftedDialog extends Vue { |
|
|
* |
|
|
* |
|
|
* @param giverDid may be null |
|
|
* @param giverDid may be null |
|
|
* @param description may be an empty string |
|
|
* @param description may be an empty string |
|
|
* @param hours may be 0 |
|
|
* @param amountInput may be 0 |
|
|
*/ |
|
|
*/ |
|
|
public async recordGive( |
|
|
public async recordGive( |
|
|
giverDid?: string, |
|
|
giverDid?: string, |
|
|
description?: string, |
|
|
description?: string, |
|
|
hours?: number, |
|
|
amountInput?: number, |
|
|
|
|
|
unitCode?: string, |
|
|
) { |
|
|
) { |
|
|
if (!this.activeDid) { |
|
|
if (!this.activeDid) { |
|
|
this.$notify( |
|
|
this.$notify( |
|
@ -206,13 +239,15 @@ export default class GiftedDialog extends Vue { |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (!description && !hours) { |
|
|
if (!description && !amountInput) { |
|
|
this.$notify( |
|
|
this.$notify( |
|
|
{ |
|
|
{ |
|
|
group: "alert", |
|
|
group: "alert", |
|
|
type: "danger", |
|
|
type: "danger", |
|
|
title: "Error", |
|
|
title: "Error", |
|
|
text: "You must enter a description or some number of hours.", |
|
|
text: `You must enter a description or some number of ${ |
|
|
|
|
|
this.UNIT_LONG[this.unitCode] |
|
|
|
|
|
}.`, |
|
|
}, |
|
|
}, |
|
|
-1, |
|
|
-1, |
|
|
); |
|
|
); |
|
@ -228,7 +263,8 @@ export default class GiftedDialog extends Vue { |
|
|
giverDid, |
|
|
giverDid, |
|
|
this.givenToUser ? this.activeDid : undefined, |
|
|
this.givenToUser ? this.activeDid : undefined, |
|
|
description, |
|
|
description, |
|
|
hours, |
|
|
amountInput, |
|
|
|
|
|
unitCode, |
|
|
this.projectId, |
|
|
this.projectId, |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|