From dc8598ae818ccd85aa81b3273a1b973a8d26b49f Mon Sep 17 00:00:00 2001 From: Matteo Pagliazzi Date: Fri, 3 Mar 2017 19:38:17 +0100 Subject: [PATCH] Client: Guilds Discovery (#8529) * wip: add guilds discovery page * add public guilds page * fix and add tests for the groups utilities mixin --- .../unit/specs/mixins/groupsUtilities.spec.js | 61 +++++++++++++++++++ website/client/assets/less/forms.less | 7 +++ website/client/assets/less/index.less | 1 + .../assets/less/semantic-ui/semantic.less | 2 +- .../client/components/inventory/stable.vue | 25 +++----- .../social/guilds/discovery/index.vue | 47 ++++++++++++++ .../guilds/discovery/publicGuildItem.vue | 24 ++++++++ website/client/components/social/index.vue | 4 +- website/client/mixins/groupsUtilities.js | 25 ++++++++ website/client/router.js | 13 +++- website/client/store/actions/guilds.js | 6 ++ website/client/store/actions/index.js | 11 ++-- website/client/store/getters/index.js | 4 +- website/client/store/helpers/internals.js | 8 +-- website/client/store/state.js | 1 + 15 files changed, 209 insertions(+), 30 deletions(-) create mode 100644 test/client/unit/specs/mixins/groupsUtilities.spec.js create mode 100644 website/client/assets/less/forms.less create mode 100644 website/client/components/social/guilds/discovery/index.vue create mode 100644 website/client/components/social/guilds/discovery/publicGuildItem.vue create mode 100644 website/client/mixins/groupsUtilities.js create mode 100644 website/client/store/actions/guilds.js diff --git a/test/client/unit/specs/mixins/groupsUtilities.spec.js b/test/client/unit/specs/mixins/groupsUtilities.spec.js new file mode 100644 index 0000000000..ada7f52657 --- /dev/null +++ b/test/client/unit/specs/mixins/groupsUtilities.spec.js @@ -0,0 +1,61 @@ +import groupsUtilities from 'client/mixins/groupsUtilities'; +import { TAVERN_ID } from 'common/script/constants'; +import Vue from 'vue'; + +describe('Groups Utilities Mixin', () => { + let instance, user; + + before(() => { + instance = new Vue({ + mixins: [groupsUtilities], + }); + + user = { + _id: '123', + party: { + _id: '456', + }, + guilds: ['789'], + }; + }); + + describe('isMemberOfGroup', () => { + it('registers as a method', () => { + expect(instance.isMemberOfGroup).to.be.a.function; + }); + + it('returns true when the group is the Tavern', () => { + expect(instance.isMemberOfGroup(user, { + _id: TAVERN_ID, + })).to.equal(true); + }); + + it('returns true when the group is the user\'s party', () => { + expect(instance.isMemberOfGroup(user, { + type: 'party', + _id: user.party._id, + })).to.equal(true); + }); + + it('returns false when the group is not the user\'s party', () => { + expect(instance.isMemberOfGroup(user, { + type: 'party', + _id: 'not my party', + })).to.equal(false); + }); + + it('returns true when the group is not a guild of which the user is a member', () => { + expect(instance.isMemberOfGroup(user, { + type: 'guild', + _id: user.guilds[0], + })).to.equal(true); + }); + + it('returns false when the group is not a guild of which the user is a member', () => { + expect(instance.isMemberOfGroup(user, { + type: 'guild', + _id: 'not my guild', + })).to.equal(false); + }); + }); +}); \ No newline at end of file diff --git a/website/client/assets/less/forms.less b/website/client/assets/less/forms.less new file mode 100644 index 0000000000..bd256066ea --- /dev/null +++ b/website/client/assets/less/forms.less @@ -0,0 +1,7 @@ +.label-primary { + font-weight: bold; +} + +.nested-field { + padding-left: 1.5rem; +} \ No newline at end of file diff --git a/website/client/assets/less/index.less b/website/client/assets/less/index.less index 1397606124..da8c3da799 100644 --- a/website/client/assets/less/index.less +++ b/website/client/assets/less/index.less @@ -1,5 +1,6 @@ // CSS that doesn't belong to any specific Vue compoennt @import './utilities'; +@import './forms'; @import './loading-screen'; body { diff --git a/website/client/assets/less/semantic-ui/semantic.less b/website/client/assets/less/semantic-ui/semantic.less index d078ed3a2b..be2f24744d 100644 --- a/website/client/assets/less/semantic-ui/semantic.less +++ b/website/client/assets/less/semantic-ui/semantic.less @@ -30,7 +30,7 @@ // & { @import "~semantic-ui-less/definitions/elements/loader"; } // & { @import "~semantic-ui-less/definitions/elements/rail"; } // & { @import "~semantic-ui-less/definitions/elements/reveal"; } -// & { @import "~semantic-ui-less/definitions/elements/segment"; } +& { @import "~semantic-ui-less/definitions/elements/segment"; } // & { @import "~semantic-ui-less/definitions/elements/step"; } /* Collections */ diff --git a/website/client/components/inventory/stable.vue b/website/client/components/inventory/stable.vue index defda26840..3e50b471e9 100644 --- a/website/client/components/inventory/stable.vue +++ b/website/client/components/inventory/stable.vue @@ -9,35 +9,35 @@ .ui.form .field .ui.checkbox - input(type='checkbox') + input(type="checkbox") label.label-primary(v-once) {{ $t('pets') }} .field.nested-field .ui.checkbox - input(type='checkbox') + input(type="checkbox") label(v-once) {{ $t('hatchingPotions') }} .field.nested-field .ui.checkbox - input(type='checkbox') + input(type="checkbox") label(v-once) {{ $t('quest') }} .field.nested-field .ui.checkbox - input(type='checkbox') + input(type="checkbox") label(v-once) {{ $t('special') }} .field .ui.checkbox - input(type='checkbox') + input(type="checkbox") label.label-primary(v-once) {{ $t('mounts') }} .field.nested-field .ui.checkbox - input(type='checkbox') + input(type="checkbox") label(v-once) {{ $t('hatchingPotions') }} .field.nested-field .ui.checkbox - input(type='checkbox') + input(type="checkbox") label(v-once) {{ $t('quest') }} .field.nested-field .ui.checkbox - input(type='checkbox') + input(type="checkbox") label(v-once) {{ $t('special') }} .thirteen.wide.column @@ -60,18 +60,9 @@ h2 Mounts h2 Quest Mounts h2 Rare Mounts -