-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mhr History Tabs (Common Components) (#1958)
* Common Tab and Table Components with Mhr History Configurations * fixes and clean up * tab style * unit testing * plock fix * plock revert
- Loading branch information
1 parent
015089c
commit 3e389cc
Showing
13 changed files
with
359 additions
and
3 deletions.
There are no files selected for viewing
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
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,39 @@ | ||
<template> | ||
<v-table id="simple-table"> | ||
<thead> | ||
<tr> | ||
<th | ||
v-for="(header, index) in tableHeaders" | ||
:key="`${header.name}-${index}`" | ||
:class="header?.class" | ||
> | ||
{{ header.name }} | ||
</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr | ||
v-for="(item, index) in tableData" | ||
:key="`${item.name}-${index}`" | ||
> | ||
<td>{{ item.name }}</td> | ||
</tr> | ||
</tbody> | ||
</v-table> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
/** Props **/ | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
const props = withDefaults(defineProps<{ | ||
tableHeaders: Array<any>, | ||
tableData: Array<any> | ||
}>(), { | ||
tableHeaders: null, | ||
tableData: null | ||
}) | ||
</script> | ||
<style lang="scss" scoped> | ||
@import '@/assets/styles/theme'; | ||
</style> |
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,97 @@ | ||
<template> | ||
<v-card | ||
id="tabbed-container" | ||
flat | ||
> | ||
<v-tabs | ||
v-model="tab" | ||
height="55" | ||
alignTabs="center" | ||
grow | ||
> | ||
<v-tab | ||
v-for="(tabContent, index) in tabConfig" | ||
:key="`${tabContent.label}-${index}`" | ||
:value="index" | ||
class="tab upper-border mt-1" | ||
:ripple="false" | ||
> | ||
<v-icon | ||
class="mr-1" | ||
size="22" | ||
> | ||
{{ tabContent.icon }} | ||
</v-icon> | ||
<b>{{ tabContent.label }}</b> | ||
<v-spacer /> | ||
</v-tab> | ||
</v-tabs> | ||
|
||
<!-- Window Items --> | ||
<v-window | ||
v-model="tab" | ||
class="rounded-bottom bg-white" | ||
> | ||
<v-window-item | ||
v-for="(item, index) in tabConfig" | ||
:key="`tab-window-${index}`" | ||
:value="index" | ||
> | ||
<slot :name="`tab-${index}`" /> | ||
</v-window-item> | ||
</v-window> | ||
</v-card> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { ref } from 'vue' | ||
/** Props **/ | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
const props = withDefaults(defineProps<{ | ||
tabConfig?: any | ||
}>(), { | ||
tabConfig: {} | ||
}) | ||
/** Local Properties **/ | ||
const tab = ref(0) | ||
</script> | ||
<style lang="scss" scoped> | ||
@import '@/assets/styles/theme'; | ||
#tabbed-container { | ||
background-color: inherit; | ||
} | ||
.tab { | ||
min-height: 55px!important; | ||
background-color: $app-lt-blue; | ||
font-size: 1rem; | ||
letter-spacing: 0; | ||
text-transform: none!important; | ||
border-top-left-radius: 4px!important; | ||
border-top-right-radius: 4px!important; | ||
&:hover:not(.v-tab--selected) { | ||
background-color: $app-lt-blue-hover; | ||
} | ||
.v-icon { | ||
color: $app-dk-blue; | ||
} | ||
} | ||
.v-spacer { | ||
width: 225px; | ||
} | ||
.v-tab--selected { | ||
background-color: white; | ||
color: $gray9; | ||
pointer-events: none; | ||
} | ||
.upper-border { | ||
min-height: 55px; | ||
max-height: 55px; | ||
margin: 0 2.5px; | ||
} | ||
.v-window { | ||
min-height: 400px | ||
} | ||
</style> |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './mhHistoryTableHeaders' | ||
export * from './mhHistoryTabConfig' |
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,14 @@ | ||
export const mhHistoryTabConfig = [ | ||
{ | ||
label: 'Description of Home', | ||
icon: 'mdi-home' | ||
}, | ||
{ | ||
label: 'Location of Home', | ||
icon: 'mdi-map-marker' | ||
}, | ||
{ | ||
label: 'Home Owners', | ||
icon: 'mdi-account' | ||
} | ||
] |
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,88 @@ | ||
export const homeDescriptionHeaders = [ | ||
{ | ||
name: '', | ||
value: 'action', | ||
class: 'column-width-md' | ||
}, | ||
{ | ||
name: 'Manufacturer\'s Name', | ||
value: 'name', | ||
class: 'column-xs' | ||
}, | ||
{ | ||
name: 'Make/Model', | ||
value: 'makeModel', | ||
class: 'column-xs' | ||
}, | ||
{ | ||
name: 'Serial Number', | ||
value: 'serial', | ||
class: 'column-xs' | ||
}, | ||
{ | ||
name: 'Registration Date', | ||
value: 'date', | ||
class: 'column-xs' | ||
} | ||
] | ||
|
||
export const homeLocationHeaders = [ | ||
{ | ||
name: '', | ||
value: 'action', | ||
class: 'column-width-md' | ||
}, | ||
{ | ||
name: 'Town/City', | ||
value: 'townCity', | ||
class: 'column-xs' | ||
}, | ||
{ | ||
name: 'Street', | ||
value: 'street', | ||
class: 'column-xs' | ||
}, | ||
{ | ||
name: 'From', | ||
value: 'from', | ||
class: 'column-xs' | ||
}, | ||
{ | ||
name: 'To', | ||
value: 'to', | ||
class: 'column-xs' | ||
} | ||
] | ||
|
||
export const homeOwnerHeaders = [ | ||
{ | ||
name: '', | ||
value: 'action', | ||
class: 'column-width-md' | ||
}, | ||
{ | ||
name: 'Owner Name', | ||
value: 'name', | ||
class: 'column-xs' | ||
}, | ||
{ | ||
name: 'Tenancy Type', | ||
value: 'tenancyType', | ||
class: 'column-xs' | ||
}, | ||
{ | ||
name: 'Owner From', | ||
value: 'from', | ||
class: 'column-xs' | ||
}, | ||
{ | ||
name: 'Owner Until', | ||
value: 'to', | ||
class: 'column-xs' | ||
}, | ||
{ | ||
name: 'Owner Status', | ||
value: 'status', | ||
class: 'column-xs' | ||
} | ||
] |
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
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { describe, it, expect, beforeEach } from 'vitest' | ||
import { SimpleTable } from '@/components/common' | ||
import { createComponent } from './utils' | ||
|
||
const tableHeadersMock = [ | ||
{ name: 'Header 1', class: 'header-class-1' }, | ||
{ name: 'Header 2', class: 'header-class-2' }, | ||
] | ||
|
||
const tableDataMock = [ | ||
{ name: 'Row 1' }, | ||
{ name: 'Row 2' }, | ||
] | ||
|
||
describe('SimpleTable.vue', () => { | ||
let wrapper | ||
|
||
beforeEach(async () => { | ||
wrapper = await createComponent(SimpleTable, { | ||
tableHeaders: tableHeadersMock, | ||
tableData: tableDataMock, | ||
}) | ||
}) | ||
it('renders correctly', () => { | ||
expect(wrapper.exists()).toBe(true) | ||
expect(wrapper.find('#simple-table').exists()).toBe(true) | ||
expect(wrapper.findAll('thead th').length).toBe(tableHeadersMock.length) | ||
expect(wrapper.findAll('tbody tr').length).toBe(tableDataMock.length) | ||
}) | ||
|
||
it('renders table headers correctly', () => { | ||
const headers = wrapper.findAll('thead th') | ||
expect(headers.length).toBe(tableHeadersMock.length) | ||
headers.forEach((header, index) => { | ||
expect(header.text()).toBe(tableHeadersMock[index].name) | ||
expect(header.classes()).toContain(tableHeadersMock[index].class) | ||
}) | ||
}) | ||
|
||
it('renders table data correctly', () => { | ||
const rows = wrapper.findAll('tbody tr') | ||
expect(rows.length).toBe(tableDataMock.length) | ||
rows.forEach((row, index) => { | ||
expect(row.find('td').text()).toBe(tableDataMock[index].name) | ||
}) | ||
}) | ||
}) |
Oops, something went wrong.