Skip to content

Commit

Permalink
feat(#429): update module prop watches (#536)
Browse files Browse the repository at this point in the history
* feat(#429): update module prop watches

* chore(#429): added changesets
  • Loading branch information
Decipher authored Jul 18, 2022
1 parent fc811db commit 2f2a7cc
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 25 deletions.
5 changes: 5 additions & 0 deletions .changeset/itchy-roses-cross.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"druxt-site": minor
---

Added watch for 'theme' prop
5 changes: 5 additions & 0 deletions .changeset/three-emus-deny.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"druxt-entity": minor
---

Added watch for 'settings' prop
5 changes: 5 additions & 0 deletions .changeset/tidy-melons-add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"druxt-views": minor
---

Added watch for 'arguments' prop
4 changes: 4 additions & 0 deletions packages/entity/src/components/DruxtEntity.vue
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ export default {
this.$fetch()
},
settings() {
this.$fetch()
},
schemaType() {
this.$fetch()
},
Expand Down
6 changes: 6 additions & 0 deletions packages/site/src/components/DruxtSite.vue
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ export default {
regions: ({ model, value }) => model || value || [],
},
watch: {
theme() {
this.$fetch()
}
},
methods: {
...mapActions({ getCollection: 'druxt/getCollection' }),
},
Expand Down
34 changes: 17 additions & 17 deletions packages/views/src/components/DruxtView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ export default {
},
watch: {
async '$route.query'(to) {
'$route.query'(to) {
if (!Object.entries(to || {}).length) {
this.model = {
filter: {},
Expand All @@ -290,42 +290,42 @@ export default {
}
},
async displayId() {
await this.$fetch()
arguments() {
this.$fetch()
},
displayId() {
this.$fetch()
},
'model.filter': {
deep: true,
async handler(to, from) {
handler(to, from) {
if (!Object.entries(to || {}).length && !Object.entries(from || {}).length) {
return
}
await this.$fetch()
this.$fetch()
},
},
async 'model.page'(to, from) {
'model.page'(to, from) {
if (to !== from) {
await this.$fetch()
this.$fetch()
}
},
async 'model.sort'(to, from) {
'model.sort'(to, from) {
if (to !== from) {
await this.$fetch()
this.$fetch()
}
},
async query() {
await this.$fetch()
},
async uuid() {
await this.$fetch()
uuid() {
this.$fetch()
},
async viewId() {
await this.$fetch()
viewId() {
this.$fetch()
},
},
Expand Down
14 changes: 6 additions & 8 deletions packages/views/test/components/DruxtView.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,21 +140,19 @@ describe('DruxtView', () => {
expect(wrapper.vm.getQuery(wrapper.vm.component.settings)).toStrictEqual({})

// Watches.
expect(mocks.$fetch).toHaveBeenCalledTimes(0)
expect(mocks.$fetch).toHaveBeenCalledTimes(2)
await DruxtView.watch.displayId.call(mocks)
expect(mocks.$fetch).toHaveBeenCalledTimes(1)
expect(mocks.$fetch).toHaveBeenCalledTimes(3)
wrapper.vm.model.page = 1
await localVue.nextTick()
expect(mocks.$fetch).toHaveBeenCalledTimes(2)
expect(mocks.$fetch).toHaveBeenCalledTimes(4)
wrapper.vm.model.sort = 'nid'
await localVue.nextTick()
expect(mocks.$fetch).toHaveBeenCalledTimes(3)
await DruxtView.watch.query.call(mocks)
expect(mocks.$fetch).toHaveBeenCalledTimes(4)
await DruxtView.watch.uuid.call(mocks)
expect(mocks.$fetch).toHaveBeenCalledTimes(5)
await DruxtView.watch.viewId.call(mocks)
await DruxtView.watch.uuid.call(mocks)
expect(mocks.$fetch).toHaveBeenCalledTimes(6)
await DruxtView.watch.viewId.call(mocks)
expect(mocks.$fetch).toHaveBeenCalledTimes(7)
})

test('fetch by uuid', async () => {
Expand Down

0 comments on commit 2f2a7cc

Please sign in to comment.