diff --git a/app/components/confirmed-in/template.hbs b/app/components/confirmed-in/template.hbs index 44614dc..65ac4f0 100644 --- a/app/components/confirmed-in/template.hbs +++ b/app/components/confirmed-in/template.hbs @@ -1,3 +1,5 @@ -{{#unless this.isConfirmed}} +{{#if this.isConfirmed}} +Confirmed at block {{@confirmedAtBlock}} (~ {{this.confirmedInHumanTime}} ago) +{{else}} Confirming in {{this.confirmedInBlocks}} blocks (~ {{this.confirmedInHumanTime}}) -{{/unless}} +{{/if}} diff --git a/app/components/reimbursement-item/component.js b/app/components/reimbursement-item/component.js new file mode 100644 index 0000000..e3a7f3a --- /dev/null +++ b/app/components/reimbursement-item/component.js @@ -0,0 +1,68 @@ +import Component from '@glimmer/component'; +import { action } from '@ember/object'; +import { tracked } from '@glimmer/tracking'; +import { inject as service } from '@ember/service'; +import config from 'kredits-web/config/environment'; +import fmtDateLocalized from 'kredits-web/helpers/fmt-date-localized'; + +export default class ReimbursementItemComponent extends Component { + @service kredits; + @tracked showExpenseDetails = false; + + constructor(owner, args) { + super(owner, args); + if (this.isUnconfirmed && !this.isVetoed) { + this.showExpenseDetails = true; + } + } + + get ipfsGatewayUrl () { + return config.ipfs.gatewayUrl; + } + + get isConfirmed () { + return (this.args.reimbursement.confirmedAt - this.kredits.currentBlock) <= 0; + } + + get isUnconfirmed () { + return !this.isConfirmed; + } + + get isVetoed () { + return this.args.reimbursement.vetoed; + } + + get showVetoButton () { + return this.isUnconfirmed && this.kredits.currentUserIsCore; + } + + get showConfirmedIn () { + return !this.isVetoed && + (this.showExpenseDetails || this.isUnconfirmed); + } + + get expenses () { + return this.args.reimbursement.expenses; + } + + get expensesDateRange () { + const dates = this.expenses.map(e => e.date).uniq().sort(); + let out = fmtDateLocalized.compute(dates.firstObject) + if (dates.length > 1) { + out += ' - ' + fmtDateLocalized.compute(dates.lastObject) + } + return out; + } + + @action + toggleExpenseDetails () { + this.showExpenseDetails = !this.showExpenseDetails; + } + + @action + veto (id) { + this.kredits.vetoReimbursement(id).then(transaction => { + console.debug('[controllers:budget] Veto submitted to chain: '+transaction.hash); + }); + } +} diff --git a/app/components/reimbursement-item/template.hbs b/app/components/reimbursement-item/template.hbs new file mode 100644 index 0000000..408860e --- /dev/null +++ b/app/components/reimbursement-item/template.hbs @@ -0,0 +1,41 @@ +
  • +

    + + + + + Expenses covered by {{@reimbursement.contributor.name}} + +

    +

    + + {{sats-to-btc @reimbursement.amount}}BTC +

    + + {{#if this.showExpenseDetails}} + + {{/if}} + +
    +

    + {{#if this.showConfirmedIn}} + + {{else}} + {{#unless this.isVetoed}}{{this.expensesDateRange}}{{/unless}} + {{/if}} +

    +

    + + Inspect IPFS data + + {{#if this.showVetoButton}} + + {{/if}} +

    +
    +
  • diff --git a/app/components/reimbursement-list/component.js b/app/components/reimbursement-list/component.js index 79c260d..34f7820 100644 --- a/app/components/reimbursement-list/component.js +++ b/app/components/reimbursement-list/component.js @@ -1,23 +1,10 @@ import Component from '@glimmer/component'; import { sort } from '@ember/object/computed'; -import { action } from '@ember/object'; import { inject as service } from '@ember/service'; -import config from 'kredits-web/config/environment'; export default class ReimbursementListComponent extends Component { @service kredits; itemSorting = Object.freeze(['pendingStatus:asc', 'id:desc']); @sort('args.items', 'itemSorting') itemsSorted; - - get ipfsGatewayUrl () { - return config.ipfs.gatewayUrl; - } - - @action - veto (id) { - this.kredits.vetoReimbursement(id).then(transaction => { - console.debug('[controllers:budget] Veto submitted to chain: '+transaction.hash); - }); - } } diff --git a/app/components/reimbursement-list/template.hbs b/app/components/reimbursement-list/template.hbs index 50dcedf..3988acc 100644 --- a/app/components/reimbursement-list/template.hbs +++ b/app/components/reimbursement-list/template.hbs @@ -1,38 +1,5 @@ -