Show dates in collapsed entries of confirmed reimbursements
This commit is contained in:
@@ -3,6 +3,7 @@ import { action } from '@ember/object';
|
|||||||
import { tracked } from '@glimmer/tracking';
|
import { tracked } from '@glimmer/tracking';
|
||||||
import { inject as service } from '@ember/service';
|
import { inject as service } from '@ember/service';
|
||||||
import config from 'kredits-web/config/environment';
|
import config from 'kredits-web/config/environment';
|
||||||
|
import fmtDateLocalized from 'kredits-web/helpers/fmt-date-localized';
|
||||||
|
|
||||||
export default class ReimbursementItemComponent extends Component {
|
export default class ReimbursementItemComponent extends Component {
|
||||||
@service kredits;
|
@service kredits;
|
||||||
@@ -10,9 +11,10 @@ export default class ReimbursementItemComponent extends Component {
|
|||||||
|
|
||||||
constructor(owner, args) {
|
constructor(owner, args) {
|
||||||
super(owner, args);
|
super(owner, args);
|
||||||
if (this.isUnconfirmed && !this.args.reimbursement.vetoed) {
|
if (this.isUnconfirmed && !this.isVetoed) {
|
||||||
this.showExpenseDetails = true;
|
this.showExpenseDetails = true;
|
||||||
}
|
}
|
||||||
|
console.debug(fmtDateLocalized);
|
||||||
}
|
}
|
||||||
|
|
||||||
get ipfsGatewayUrl () {
|
get ipfsGatewayUrl () {
|
||||||
@@ -27,10 +29,32 @@ export default class ReimbursementItemComponent extends Component {
|
|||||||
return !this.isConfirmed;
|
return !this.isConfirmed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get isVetoed () {
|
||||||
|
return this.args.reimbursement.vetoed;
|
||||||
|
}
|
||||||
|
|
||||||
get showVetoButton () {
|
get showVetoButton () {
|
||||||
return this.isUnconfirmed && this.kredits.currentUserIsCore;
|
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
|
@action
|
||||||
toggleExpenseDetails () {
|
toggleExpenseDetails () {
|
||||||
this.showExpenseDetails = !this.showExpenseDetails;
|
this.showExpenseDetails = !this.showExpenseDetails;
|
||||||
|
|||||||
@@ -19,8 +19,12 @@
|
|||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
<div class="meta">
|
<div class="meta">
|
||||||
<p class="confirmation-eta">
|
<p>
|
||||||
|
{{#if this.showConfirmedIn}}
|
||||||
<ConfirmedIn @confirmedAtBlock={{@reimbursement.confirmedAt}} />
|
<ConfirmedIn @confirmedAtBlock={{@reimbursement.confirmedAt}} />
|
||||||
|
{{else}}
|
||||||
|
{{#unless this.isVetoed}}{{this.expensesDateRange}}{{/unless}}
|
||||||
|
{{/if}}
|
||||||
</p>
|
</p>
|
||||||
<p class="actions">
|
<p class="actions">
|
||||||
<a href="{{this.ipfsGatewayUrl}}/{{@reimbursement.ipfsHash}}"
|
<a href="{{this.ipfsGatewayUrl}}/{{@reimbursement.ipfsHash}}"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { helper } from '@ember/component/helper';
|
import { helper } from '@ember/component/helper';
|
||||||
import getLocale from 'kredits-web/utils/get-locale';
|
import getLocale from 'kredits-web/utils/get-locale';
|
||||||
|
|
||||||
export default helper(function(dateStr) {
|
export default helper(function fmtDateLocalized(dateStr) {
|
||||||
const date = new Date(dateStr);
|
const date = new Date(dateStr);
|
||||||
const locale = getLocale();
|
const locale = getLocale();
|
||||||
return new Intl.DateTimeFormat(locale).format(date);
|
return new Intl.DateTimeFormat(locale).format(date);
|
||||||
|
|||||||
@@ -43,9 +43,6 @@ ul.reimbursement-list {
|
|||||||
flex: 1;
|
flex: 1;
|
||||||
padding: 1.6rem 0 1rem 0;
|
padding: 1.6rem 0 1rem 0;
|
||||||
|
|
||||||
&.confirmation-eta {
|
|
||||||
}
|
|
||||||
|
|
||||||
&.actions {
|
&.actions {
|
||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user