-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from reside-ic/mrc-1876
mrc-1876 proof of concept for cost calculations in tables
- Loading branch information
Showing
9 changed files
with
115 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<template> | ||
<table> | ||
<thead> | ||
<tr> | ||
<th v-for="col in config">{{col.displayName}}</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr v-for="row in filteredData"> | ||
<td v-for="col in config"> | ||
<span>{{evaluateCell(col, row)}}</span> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</template> | ||
<script lang="ts"> | ||
import {defineComponent} from "@vue/composition-api"; | ||
import {FilteringProps, useFiltering} from "./filteredData"; | ||
import {ColumnDefinition} from "./fakeAPIData"; | ||
import {useTransformation} from "./tranformedData"; | ||
import numeral from "numeral"; | ||
interface Props extends FilteringProps { | ||
config: ColumnDefinition[] | ||
} | ||
export default defineComponent({ | ||
props: {data: Array, config: Array, settings: Object}, | ||
setup(props: Props) { | ||
const {filteredData} = useFiltering(props); | ||
const {evaluateFormula} = useTransformation(props); | ||
const evaluateCell = (col: ColumnDefinition, row: any) => { | ||
let value = ""; | ||
if (!col.valueTransform) { | ||
value = row[col.valueCol] | ||
} else if (col.valueTransform[row[col.valueCol]]) { | ||
value = evaluateFormula(col.valueTransform[row[col.valueCol]]) | ||
} | ||
if (col.format) { | ||
value = numeral(value).format(col.format) | ||
} | ||
return value; | ||
}; | ||
return { | ||
filteredData, | ||
evaluateCell | ||
} | ||
} | ||
}) | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,4 @@ new Vue({ | |
Cost | ||
} | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters