Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

Commit

Permalink
fix: advanced tables
Browse files Browse the repository at this point in the history
  • Loading branch information
elizavetaRa committed Jan 24, 2022
1 parent c1bf185 commit af0e2bd
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions src/components/molecules/OcTable/OcTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
</oc-thead>
<oc-tbody v-if="selected === 'None' || !selected">
<oc-tr
v-for="(item, trIndex) in data"
v-for="(item, trIndex) in tableData"
:key="`oc-tbody-tr-${itemDomSelector(item) || trIndex}`"
:ref="`row-${trIndex}`"
v-bind="extractTbodyTrProps(item, trIndex)"
Expand Down Expand Up @@ -268,7 +268,7 @@ export default {
mixins: [SortMixin],
props: {
/**
* Web view in which the table is shown. Used to save sorting settings
* Web view in which the table is shown. Used to save sorting settings
* -**
*/
view: {
Expand Down Expand Up @@ -485,11 +485,7 @@ export default {
: false
},
},
<<<<<<< HEAD
=======
mounted(){
mounted() {
if (this.view) {
const sortBy = localStorage.getItem(`sortBy:${this.view}`)
if (sortBy) {
Expand All @@ -501,7 +497,6 @@ export default {
// But we still need to call once for descending...
this.$emit(this.constants.EVENT_THEAD_CLICKED, this.fields[1])
}
} else {
const field = this.fields.find(field => field.name === sortByObj.name)
// If the field no longer exists, ignore
Expand All @@ -511,14 +506,16 @@ export default {
}
}
} else {
localStorage.setItem(`sortBy:${this.view}`, JSON.stringify({name: this.fields[1].name, desc: false}));
localStorage.setItem(
`sortBy:${this.view}`,
JSON.stringify({ name: this.fields[1].name, desc: false })
)
}
} else {
console.warn('Property view not set for table, ignoring persistent sorting')
console.warn("Property view not set for table, ignoring persistent sorting")
}
},
>>>>>>> Persistent sort by
methods: {
dragOver(event) {
event.preventDefault()
Expand Down Expand Up @@ -752,13 +749,15 @@ export default {
return this.resultArray[index].open
},
clickedField(field) {
// Default logic
this.$emit(this.constants.EVENT_THEAD_CLICKED, field)
// Persistent sorting logic
if (this.view) {
localStorage.setItem(`sortBy:${this.view}`, JSON.stringify({name: this.sortBy, desc: this.isDesc}));
localStorage.setItem(
`sortBy:${this.view}`,
JSON.stringify({ name: this.sortBy, desc: this.isDesc })
)
}
// Groupping logic
Expand Down

0 comments on commit af0e2bd

Please sign in to comment.