diff --git a/js/components/tables/spend_table.js b/js/components/tables/spend_table.js new file mode 100644 index 00000000..fd694ce7 --- /dev/null +++ b/js/components/tables/spend_table.js @@ -0,0 +1,45 @@ +import { set } from 'vue/dist/vue' +import { formatDollars } from '../../lib/dollars' + +export default { + name: 'spend-table', + + props: { + projects: Object, + workspace: Object, + environments: Object, + currentMonthIndex: String, + prevMonthIndex: String, + twoMonthsAgoIndex: String + }, + + data: function () { + return { + projectsState: this.projects + } + }, + + created: function () { + Object.keys(this.projects).forEach(project => { + set(this.projectsState[project], 'isVisible', false) + }) + }, + + methods: { + toggle: function (e, projectName) { + this.projectsState = Object.assign(this.projectsState, { + [projectName]: Object.assign(this.projectsState[projectName],{ + isVisible: !this.projectsState[projectName].isVisible + }) + }) + }, + + formatDollars: function (value) { + return formatDollars(value, false) + }, + + round: function (value) { + return Math.round(value) + } + } +} diff --git a/js/index.js b/js/index.js index 0cb08b60..2d195ce8 100644 --- a/js/index.js +++ b/js/index.js @@ -16,6 +16,7 @@ import NewProject from './components/forms/new_project' import Modal from './mixins/modal' import selector from './components/selector' import BudgetChart from './components/charts/budget_chart' +import SpendTable from './components/tables/spend_table' import CcpoApproval from './components/forms/ccpo_approval' import LocalDatetime from './components/local_datetime' @@ -36,6 +37,7 @@ const app = new Vue({ NewProject, selector, BudgetChart, + SpendTable, CcpoApproval, LocalDatetime }, diff --git a/js/lib/dollars.js b/js/lib/dollars.js index 65fc69ff..e1b60ac0 100644 --- a/js/lib/dollars.js +++ b/js/lib/dollars.js @@ -1,4 +1,11 @@ -export const formatDollars = value => `$${value.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,')}` +export const formatDollars = (value, cents = true) => { + if (typeof value === 'number') { + return cents + ? `$${value.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,')}` + : `$${value.toFixed(0).replace(/\d(?=(\d{3})+(?!\d))/g, '$&,')}` + } + return '' +} export const abbreviateDollars = (value, decimals = 1) => { if (value === null) { return null } // terminate early diff --git a/styles/elements/_graphs.scss b/styles/elements/_graphs.scss index 930f2d71..d4586210 100644 --- a/styles/elements/_graphs.scss +++ b/styles/elements/_graphs.scss @@ -15,4 +15,10 @@ meter { &::-moz-meter-bar { background: $color-primary; } + + .meter__fallback { + display: inline-block; + background: $color-primary; + height: 100%; + } } diff --git a/styles/elements/_tables.scss b/styles/elements/_tables.scss index a1dd7427..ee16d1c3 100644 --- a/styles/elements/_tables.scss +++ b/styles/elements/_tables.scss @@ -8,6 +8,10 @@ @include panel-margin; min-width: 100%; + @include ie-only { + border-collapse: separate; + } + th, td { &.table-cell--align-right { text-align: right; diff --git a/styles/sections/_reports.scss b/styles/sections/_reports.scss index ba23c580..611e28cb 100644 --- a/styles/sections/_reports.scss +++ b/styles/sections/_reports.scss @@ -217,7 +217,7 @@ } &.previous-month { - opacity: 0.65; + color: $color-gray; } &.meter-cell { @@ -250,9 +250,12 @@ @include media($medium-screen) { display: block; color: $color-white; + background-color: rgba($color-blue, 0.65); + border-radius: $gap/2; position: absolute; top: 2.3rem; - left: $gap; + left: $gap / 2; + padding: 0 ($gap / 2); } } } @@ -277,6 +280,13 @@ .spend-table__project__env { margin-left: $gap; + + &:last-child { + td, th { + padding-bottom: $gap * 5; + box-shadow: inset 0 (-$gap * 2.5) 0 $color-gray-lightest; + } + } } } } diff --git a/templates/workspaces/reports/index.html b/templates/workspaces/reports/index.html index 3da4987d..0f763890 100644 --- a/templates/workspaces/reports/index.html +++ b/templates/workspaces/reports/index.html @@ -35,7 +35,9 @@
Spending scope | {{ two_months_ago.strftime('%B %Y') }} | @@ -251,9 +261,63 @@ - {% for project_name, project_totals in monthly_totals['projects'].items() %} - - + +|||
---|---|---|---|---|
+ + | ++ + | + ++ + | + ++ + | + +
+
+
+
+ |
+
+ + {{ Icon('link') }} + + + | + ++ + | + ++ + | + ++ + | + ++ |