Skip to content

Commit

Permalink
reorganized helper modules in ui folder
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Mueller committed Jan 20, 2017
1 parent 458d57c commit d9e17f7
Show file tree
Hide file tree
Showing 17 changed files with 39 additions and 39 deletions.
File renamed without changes.
Empty file added src/common/ui/formHelpers.ts
Empty file.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/income/AppComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as ReactDOM from 'react-dom'
import BillDbModel from '../common/models/BillDbModel'
import FilterComponent from './FilterComponent'
import TableComponent from './TableComponent'
import { dateFormatterYearView, dateFormatterMonthView, currencyFormatter } from '../common/helpers/formatters'
import { dateFormatterYearView, dateFormatterMonthView, currencyFormatter } from '../common/ui/formatters'
import { asc, desc } from '../common/helpers/sorters'
import { round } from '../common/helpers/math'
import * as moment from 'moment'
Expand Down
2 changes: 1 addition & 1 deletion src/income/TableComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react'
import * as ReactDOM from 'react-dom'
import { BootstrapTable, TableHeaderColumn, Options } from 'react-bootstrap-table'
import BillDbModel from '../common/models/BillDbModel'
import { dateFormatterView, currencyFormatter } from '../common/helpers/formatters'
import { dateFormatterView, currencyFormatter } from '../common/ui/formatters'
import t from '../common/helpers/i18n'

interface Props {
Expand Down
2 changes: 1 addition & 1 deletion src/main/BillsEditorComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { billExists } from '../common/services/billsService'
import { listBillTypes, getBillTypeById, createBillType } from '../common/services/billTypesService'
import { listCustomers, createCustomer, getCustomerById, deleteCustomerById } from '../common/services/customersService'
import t from '../common/helpers/i18n'
import { numberFormatterDb, numberFormatterView, dateFormatterView, dateFormatterDb, getFilename } from '../common/helpers/formatters'
import { numberFormatterDb, numberFormatterView, dateFormatterView, dateFormatterDb, getFilename } from '../common/ui/formatters'
import Textarea from 'react-textarea-autosize'

const Datetime = require('react-datetime')
Expand Down
4 changes: 2 additions & 2 deletions src/main/BillsTableComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import * as React from 'react'
import * as ReactDOM from 'react-dom'
import { BootstrapTable, TableHeaderColumn, CellEditClickMode, SelectRowMode, Options } from 'react-bootstrap-table'
import BillDbModel from '../common/models/BillDbModel'
import { dateFormatterView, currencyFormatter } from '../common/helpers/formatters'
import { preventDragAndDrop } from '../common/helpers/dom'
import { dateFormatterView, currencyFormatter } from '../common/ui/formatters'
import { preventDragAndDrop } from '../common/ui/dom'
import t from '../common/helpers/i18n'

interface Props {
Expand Down
2 changes: 1 addition & 1 deletion src/main/ExpensesEditorComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import ExpenseType from '../common/models/ExpenseTypeModel'
import { expenseExists } from '../common/services/expensesService'
import { listExpenseTypes, getExpenseTypeById, createExpenseType } from '../common/services/expenseTypesService'
import t from '../common/helpers/i18n'
import { numberFormatterDb, numberFormatterView, dateFormatterView, dateFormatterDb } from '../common/helpers/formatters'
import { numberFormatterDb, numberFormatterView, dateFormatterView, dateFormatterDb } from '../common/ui/formatters'
import { stringIsEmpty } from '../common/helpers/text'
import { getNetAmount, getVatAmount, getPreTaxAmount, hasDecimals } from '../common/helpers/math'
import Textarea from 'react-textarea-autosize'
Expand Down
4 changes: 2 additions & 2 deletions src/main/ExpensesTableComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import * as React from 'react'
import * as ReactDOM from 'react-dom'
import { BootstrapTable, TableHeaderColumn, CellEditClickMode, SelectRowMode, Options } from 'react-bootstrap-table'
import ExpenseDbModel from '../common/models/ExpenseDbModel'
import { dateFormatterView, currencyFormatter, percentageFormatter, numberFormatterView } from '../common/helpers/formatters'
import { preventDragAndDrop } from '../common/helpers/dom'
import { dateFormatterView, currencyFormatter, percentageFormatter, numberFormatterView } from '../common/ui/formatters'
import { preventDragAndDrop } from '../common/ui/dom'
import t from '../common/helpers/i18n'
import { getNetAmount, getVatAmount, hasDecimals } from '../common/helpers/math'

Expand Down
6 changes: 3 additions & 3 deletions src/main/FileViewComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as React from 'react'
import File from '../common/models/FileModel'
import { getFilename } from '../common/helpers/formatters'
import { getFilename } from '../common/ui/formatters'
import { open } from '../common/providers/fileProvider'
import { shortenFilename } from '../common/helpers/text'
import { getFileIconHtml } from '../common/helpers/icons'
import { getFileIconHtml } from '../common/ui/icons'
import t from '../common/helpers/i18n'

interface Props {
Expand All @@ -19,7 +19,7 @@ export default class FileViewComponent extends React.Component<Props, {}> {

getFileList() {
let fileList = []

for (let i = 0; i < this.props.files.length; i++) {
const file = this.props.files[i]

Expand Down
30 changes: 15 additions & 15 deletions src/stats/AppComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import * as React from 'react'
import * as ReactDOM from 'react-dom'
import FilterComponent, { SELECT_TYPE_ALL } from './FilterComponent'
import BillsFilterComponent, { SELECT_TYPE_ALL } from './BillsFilterComponent'
import BillDbModel from '../common/models/BillDbModel'
import BillTypeModel from '../common/models/BillTypeModel'
import Customer from '../common/models/CustomerModel'
import TableComponent from './TableComponent'
import PanelComponent from './PanelComponent'
import ChartComponent from './ChartComponent'
import BillsTableComponent from './BillsTableComponent'
import BillsPanelComponent from './BillsPanelComponent'
import BillsChartComponent from './BillsChartComponent'
import t from '../common/helpers/i18n'
import { asc, desc } from '../common/helpers/sorters'
import { dateFormatterYearView } from '../common/helpers/formatters'
import { dateFormatterYearView } from '../common/ui/formatters'
import * as moment from 'moment'
import { getAverage, round } from '../common/helpers/math'

Expand Down Expand Up @@ -206,7 +206,7 @@ export default class AppComponent extends React.Component<Props, {}> {

getTypesPieChartData(): number[] {
let typeSums = {}

for (let type of this.props.billTypes) {
typeSums[type.type] = 0
}
Expand All @@ -230,7 +230,7 @@ export default class AppComponent extends React.Component<Props, {}> {

getTypesIncomePieChartData(): number[] {
let typeSums = {}

for (let type of this.props.billTypes) {
typeSums[type.type] = 0
}
Expand Down Expand Up @@ -277,7 +277,7 @@ export default class AppComponent extends React.Component<Props, {}> {
return true
}
}

return false
}

Expand All @@ -291,7 +291,7 @@ export default class AppComponent extends React.Component<Props, {}> {
return (
<div>

<FilterComponent
<BillsFilterComponent
years={this.getAvailableYears()}
billTypes={this.props.billTypes}
handleYearChange={element => this.setState({selectedYear: element.target.value})}
Expand All @@ -302,27 +302,27 @@ export default class AppComponent extends React.Component<Props, {}> {
billDateToUse={this.state.billDateToUse}
/>

<TableComponent data={this.getTableData()} />
<BillsTableComponent data={this.getTableData()} />

<div className="panel-container">
<div className="row">
<div className="col-xs-1" />

<div className="col-xs-12 col-sm-4 panel-display">
<PanelComponent title={t('Jahresumsatz')} value={this.getTotal()} icon="fa-line-chart" />
<BillsPanelComponent title={t('Jahresumsatz')} value={this.getTotal()} icon="fa-line-chart" />
</div>

<div className="col-xs-2" />

<div className="col-xs-12 col-sm-4 panel-display">
<PanelComponent title={t('Unbezahlte Rechnungen')} value={this.getTotalUnpaid()} icon="fa-hourglass-1" />
<BillsPanelComponent title={t('Unbezahlte Rechnungen')} value={this.getTotalUnpaid()} icon="fa-hourglass-1" />
</div>

<div className="col-xs-1" />
<div className="col-xs-1" />
</div>
</div>

<ChartComponent
<BillsChartComponent
lineChartLabels={this.getLineChartLabels()}
lineChartDatePaidData={this.getLineChartData()}
typesPieChartLabels={this.getTypesPieChartLabels()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const colors = [
'246, 41, 106'
]

export default class ChartComponent extends React.Component<Props, State> {
export default class BillsChartComponent extends React.Component<Props, State> {

refs: {
typesPiechart;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface Props {
changeBillDateToUse
}

export default class FilterComponent extends React.Component<Props, {}> {
export default class BillsFilterComponent extends React.Component<Props, {}> {

constructor(props) {
super(props)
Expand Down Expand Up @@ -68,7 +68,7 @@ export default class FilterComponent extends React.Component<Props, {}> {
this.props.changeBillDateToUse(dateField)
}

render() {
render() {
return (
<form id="filter-container">
<label htmlFor="year">{t('Jahr')}</label>
Expand All @@ -94,14 +94,14 @@ export default class FilterComponent extends React.Component<Props, {}> {
/> {t('Rechnungsdatum')}
</label>
</p>

</form>
)
}

componentWillReceiveProps(nextProps: Props) {
const selectedYearNotAvailable = (nextProps.years.indexOf(nextProps.selectedYear) === -1)

if (selectedYearNotAvailable) {
let closestYear = nextProps.years.length >= 1
? nextProps.years[0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface Props {
icon: string
}

export default class PanelComponent extends React.Component<Props, {}> {
export default class BillsPanelComponent extends React.Component<Props, {}> {

constructor(props) {
super(props)
Expand All @@ -32,7 +32,7 @@ export default class PanelComponent extends React.Component<Props, {}> {
/>
</div>

<div className="panel-title">{this.props.title}</div>
<div className="panel-title">{this.props.title}</div>
</div>
</div>
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import * as React from 'react';
import * as ReactDOM from 'react-dom'
import { BootstrapTable, TableHeaderColumn, CellEditClickMode, SelectRowMode, Options } from 'react-bootstrap-table'
import { currencyFormatter } from '../common/helpers/formatters'
import { currencyFormatter } from '../common/ui/formatters'
import t from '../common/helpers/i18n'

interface Props {
data: any[];
}

export default class TableComponent extends React.Component<Props, {}> {
export default class BillsTableComponent extends React.Component<Props, {}> {

constructor(props) {
super(props)
Expand All @@ -29,8 +29,8 @@ export default class TableComponent extends React.Component<Props, {}> {
noDataText: t('Keine Einträge'),
sizePerPage: 5
}
return (

return (
<div id="table-container">
<BootstrapTable
data={this.props.data}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { numberFormatterDb, numberFormatterView, dateFormatterView, dateFormatterDb, currencyFormatter } from '../../../src/common/helpers/formatters'
import { numberFormatterDb, numberFormatterView, dateFormatterView, dateFormatterDb, currencyFormatter } from '../../../src/common/ui/formatters'
import { expect } from 'chai'

describe('formatters', () => {
Expand Down Expand Up @@ -56,7 +56,7 @@ describe('formatters', () => {
const result = currencyFormatter(123.45)
expect(result).to.equal('123,45 €')
})
it('should convert a number to a string with two fraction digits', () => {
it('should convert a number to a string with two fraction digits', () => {
expect(currencyFormatter(123)).to.equal('123,00 €')
expect(currencyFormatter(123.4)).to.equal('123,40 €')
})
Expand Down

0 comments on commit d9e17f7

Please sign in to comment.