diff --git a/releases/unreleased/improve-organization-selector.yml b/releases/unreleased/improve-organization-selector.yml new file mode 100644 index 00000000..e94a6ff6 --- /dev/null +++ b/releases/unreleased/improve-organization-selector.yml @@ -0,0 +1,11 @@ +--- +title: Improved organization selector +category: added +author: Eva Millán +issue: 820 +notes: > + The organization selector that is used to affiliate individuals + now has the option to create an organization if the desired one + is not found. + Its size is also increased to improve the readability of longer + names. diff --git a/ui/src/components/EnrollModal.stories.js b/ui/src/components/EnrollModal.stories.js index 545ff1ab..a91a5bb0 100644 --- a/ui/src/components/EnrollModal.stories.js +++ b/ui/src/components/EnrollModal.stories.js @@ -15,6 +15,7 @@ const template = ` :organization='organization' :enroll='enroll' :title='title' + :add-organization='addOrganization' uuid="123" /> @@ -32,6 +33,17 @@ export const Default = () => ({ enroll() { return true; }, + addOrganization(name) { + return { + data: { + addOrganization: { + organization: { + name: name + } + } + } + } + } }, }); @@ -47,5 +59,8 @@ export const WithOrganization = () => ({ enroll() { return true; }, + addOrganization() { + return; + } }, }); diff --git a/ui/src/components/EnrollModal.vue b/ui/src/components/EnrollModal.vue index 433133c7..0551365d 100644 --- a/ui/src/components/EnrollModal.vue +++ b/ui/src/components/EnrollModal.vue @@ -1,5 +1,5 @@ diff --git a/ui/src/components/ProfileModal.stories.js b/ui/src/components/ProfileModal.stories.js index f66327cc..3c550a68 100644 --- a/ui/src/components/ProfileModal.stories.js +++ b/ui/src/components/ProfileModal.stories.js @@ -17,6 +17,7 @@ const ProfileModalTemplate = ` :enroll="mockFunction" :fetch-organizations="mockFunction" :get-countries="getCountries.bind(this)" + :add-organization="mockFunction" /> `; diff --git a/ui/src/components/ProfileModal.vue b/ui/src/components/ProfileModal.vue index d753e213..3228d348 100644 --- a/ui/src/components/ProfileModal.vue +++ b/ui/src/components/ProfileModal.vue @@ -88,6 +88,7 @@ @@ -178,6 +179,10 @@ export default { type: Function, required: true, }, + addOrganization: { + type: Function, + required: true, + }, }, data() { return { diff --git a/ui/src/mixins/enroll.js b/ui/src/mixins/enroll.js index f90de95f..f56d58fd 100644 --- a/ui/src/mixins/enroll.js +++ b/ui/src/mixins/enroll.js @@ -1,4 +1,5 @@ import { formatIndividuals } from "../utils/actions"; +import { addOrganization } from "../apollo/mutations"; const enrollMixin = { data() { @@ -85,6 +86,10 @@ const enrollMixin = { }); } }, + async addOrganization(name) { + const response = await addOrganization(this.$apollo, name); + return response; + }, }, }; diff --git a/ui/src/views/Individual.vue b/ui/src/views/Individual.vue index 89c08c02..c8ecda97 100644 --- a/ui/src/views/Individual.vue +++ b/ui/src/views/Individual.vue @@ -330,6 +330,7 @@ :uuid="mk" :enroll="enrollIndividual" :fetch-organizations="fetchOrganizations" + :add-organization="addOrganization" />