diff --git a/src/CreateProject.vue b/src/CreateProject.vue index 1af219cfa81f8a8e2863fc7ea6236ecf361a946d..101cc1a7cba49f1c0ef75e692be25b8c4cb66761 100644 --- a/src/CreateProject.vue +++ b/src/CreateProject.vue @@ -96,14 +96,15 @@ </b-form-group> <b-form-group class="mandatory" label-for="Discipline" label-cols-sm="3" label-align-sm="right" :label="$t('projectDisciplineLabel')"> <multiselect id="Discipline" - v-model="form.Discipline" - v-bind:disabled="!(this.isOwner || isNewProject)" - :options="disciplines" - :multiple="true" - :hide-selected="true" - :label="disciplineLabel" - :track-by="disciplineLabel" - :placeholder="$t('projectDiscipline')"> + v-model="form.Discipline" + v-bind:disabled="!(this.isOwner || isNewProject)" + :options="disciplines" + :multiple="true" + :hide-selected="true" + :label="disciplineLabel" + :track-by="disciplineLabel" + :placeholder="$t('projectDiscipline')" + > <template slot="singleLabel" slot-scope="props" v-bind:disabled="!(this.isOwner || isNewProject)"> {{ props.option[disciplineLabel] }} </template> @@ -112,16 +113,17 @@ </template> </multiselect> </b-form-group> - <b-form-group class="mandatory" label-for="Institute" label-cols-sm="3" label-align-sm="right" :label="$t('projectInstituteLabel')"> - <multiselect id="Institute" - v-model="form.Institute" - v-bind:disabled="!(this.isOwner || isNewProject)" - :options="institutes" - :multiple="true" - :hide-selected="true" - label="displayName" - track-by="displayName" - :placeholder="$t('projectInstitute')"> + <b-form-group class="mandatory" label-for="Organization" label-cols-sm="3" label-align-sm="right" :label="$t('projectOrganizationLabel')"> + <multiselect id="Organization" + v-model="form.Organization" + v-bind:disabled="!(this.isOwner || isNewProject)" + :options="organizations" + :multiple="true" + :hide-selected="true" + label="displayName" + track-by="url" + :placeholder="$t('projectOrganization')" + > <template slot="singleLabel" slot-scope="props" v-bind:disabled="!(this.isOwner || isNewProject)"> {{ props.option.displayName }} </template> @@ -132,13 +134,15 @@ </b-form-group> <b-form-group label-for="Keywords" label-cols-sm="3" label-align-sm="right" :label="$t('projectKeywordsLabel')"> <multiselect id="Keywords" - v-model="form.Keywords" - v-bind:disabled="!(this.isOwner || isNewProject)" - :options="keywordoptions" - :placeholder="$t('projectKeywords')" - :multiple="true" :taggable="true" - :tag-placeholder="$t('tagPlaceholder')" - @tag="addTag"> + v-model="form.Keywords" + v-bind:disabled="!(this.isOwner || isNewProject)" + :options="keywordoptions" + :placeholder="$t('projectKeywords')" + :multiple="true" + :taggable="true" + :tag-placeholder="$t('tagPlaceholder')" + @tag="addTag" + > </multiselect> </b-form-group> <b-form-group class="mandatory" label-for="Visibility" label-cols-sm="3" label-align-sm="right" :label="$t('projectVisibilityLabel')" v-bind:disabled="!(this.isOwner || isNewProject)"> @@ -235,7 +239,7 @@ import { de, en } from 'vuejs-datepicker/dist/locale'; import { validationMixin } from 'vuelidate'; import { required, minLength, maxLength } from 'vuelidate/lib/validators'; import tag_inputs_helper from './utils/tag_inputs_helper'; -import { ProjectApi, ProjectRoleApi, DisciplineApi, InstituteApi, VisibilityApi, redirectToProject, ActivatedFeaturesApi } from '@coscine/api-connection'; +import { ProjectApi, ProjectRoleApi, DisciplineApi, OrganizationApi, VisibilityApi, redirectToProject, ActivatedFeaturesApi } from '@coscine/api-connection'; import { GuidUtil } from '@coscine/app-util'; import locales from './locale/locales'; @@ -302,7 +306,7 @@ export default Vue.extend({ Discipline: { required, }, - Institute: { + Organization: { required, }, Keywords: { @@ -347,7 +351,7 @@ export default Vue.extend({ StartDate: new Date(), EndDate: new Date(), Discipline: [] as object[], - Institute: [] as object[], + Organization: [] as Organization[], Keywords: [] as object[], Visibility: {}, GrantId: '', @@ -361,14 +365,14 @@ export default Vue.extend({ StartDate: new Date(), EndDate: new Date(), Discipline: [] as object[], - Institute: [] as object[], + Organization: [] as Organization[], Keywords: [] as object[], Visibility: {}, GrantId: '', ParentId: String, }, disciplines: [] as object[], - institutes: [] as object[], + organizations: [] as Organization[], visibilities: [] as object[], keywordoptions: [] as object[], disabledEndDates: {to: new Date(1000, 1, 1) }, @@ -400,9 +404,9 @@ export default Vue.extend({ this.$v.form!.Discipline!.$touch() } }, - 'form.Institute': function(newVal, oldVal) { + 'form.Organization': function(newVal, oldVal) { if(oldVal.length > 0) { - this.$v.form!.Institute!.$touch() + this.$v.form!.Organization!.$touch() } }, 'form.Keywords': function(newVal, oldVal) { @@ -491,7 +495,7 @@ export default Vue.extend({ this.displayNameIsLocked = true; }, startDateSelected(selectedStartDate: Date) { - if(selectedStartDate !== null){ + if (selectedStartDate !== null) { this.form.StartDate = new Date(this.form.StartDate); this.disabledEndDates.to = selectedStartDate; if (new Date(this.form.EndDate) < this.disabledEndDates.to) { @@ -502,7 +506,7 @@ export default Vue.extend({ dateSelected() { if (new Date(this.form.EndDate) < this.disabledEndDates.to) { this.form.EndDate = this.disabledEndDates.to; - }else { + } else { this.form.EndDate = new Date(this.form.EndDate); } }, @@ -515,7 +519,7 @@ export default Vue.extend({ this.startDateSelected(new Date(this.form.StartDate)); this.form.EndDate = new Date(data.endDate); this.form.Discipline = data.disciplines; - this.form.Institute = data.institutes; + this.form.Organization = data.organizations; const keywords = data.keywords ? data.keywords.split(';') : []; this.form.Keywords = keywords; this.form.Visibility = data.visibility; @@ -533,9 +537,9 @@ export default Vue.extend({ for (let keyword in from.Keywords) { to.Keywords.push(from.Keywords[keyword]); } - to.Institute = [] as object[]; - for (let institute in from.Institute) { - to.Institute.push(from.Institute[institute]); + to.Organization = [] as Organization[]; + for (let organization in from.Organization) { + to.Organization.push(from.Organization[organization]); } to.Discipline = [] as object[]; for (let discipline in from.Discipline) { @@ -545,8 +549,20 @@ export default Vue.extend({ to.GrantId = from.GrantId; to.ParentId = from.ParentId; }, + checkSelectedOrganisationLabels() { + if (this.organizations.length > 0) { + for (let organization in this.form.Organization) { + var orgEntry = this.form.Organization[organization] as Organization; + if (orgEntry.url === orgEntry.displayName) { + let realOrgEntry = this.organizations.find( + (entry: Organization) => entry.url === orgEntry.url) as Organization; + orgEntry.displayName = realOrgEntry.displayName; + } + } + } + }, }, - created() { + async created() { i18n.locale = this.$props.languageLocale; if (this.$props.languageLocale === 'en') { this.disciplineLabel = 'displayNameEn'; @@ -578,7 +594,8 @@ export default Vue.extend({ ProjectApi.getProjectInformation(this.projectId, (response: any) => { this.fillForm(response.data); - this.tranferFormValues(this.form, this.initialState); }); + this.tranferFormValues(this.form, this.initialState); + this.checkSelectedOrganisationLabels(); }); ProjectRoleApi.getUserRoles(this.projectId, (response: any) => { this.checkOwnership(response.data); }); } else { @@ -593,10 +610,22 @@ export default Vue.extend({ this.tranferFormValues(this.form, this.initialState); } - DisciplineApi.getDisciplines( - (response: any) => { for (const datum of response.data) { this.disciplines.push(datum); } }); - InstituteApi.getInstitutes( - (response: any) => { for (const datum of response.data) { this.institutes.push(datum); } }); + let disciplines = await DisciplineApi.getDisciplines((response: any) => { return response.data } ); + for (let discipline of disciplines) { + this.disciplines.push(discipline); + } + + let organizationUris = await OrganizationApi.getOrganizations((response: any) => { return response.data; } ); + for (let organizationUri in organizationUris) { + for (let subOrg in organizationUris[organizationUri]) { + let org = organizationUris[organizationUri][subOrg]; + let displayName = org["http://www.w3.org/1999/02/22-rdf-syntax-ns#label"][0]["value"]; + let pushedOrg = { displayName, url: subOrg }; + this.organizations.push(pushedOrg); + } + } + this.checkSelectedOrganisationLabels(); + }, }); </script> diff --git a/src/coscine.d.ts b/src/coscine.d.ts index 2c060b6d2dc3dd3fed69372297bcb2324940a8d8..35ea6554cdd6b180668edf8f55a41a8dcad8a921 100644 --- a/src/coscine.d.ts +++ b/src/coscine.d.ts @@ -5,3 +5,8 @@ declare var coscine: { }; declare var _spPageContextInfo: any; + +declare class Organization { + url: string; + displayName: string; +}; \ No newline at end of file diff --git a/src/locale/de.ts b/src/locale/de.ts index b55bd53beb3972c6f6d3062b5a2958d8f5279fbb..a15b6478d9d85ee2b7ad60832fc5c7ff654e61d9 100644 --- a/src/locale/de.ts +++ b/src/locale/de.ts @@ -29,8 +29,8 @@ export default { projectPrincipleInvestigatorsHelp: 'Dieses Feld ist erforderlich und besitzt eine Maximallänge von 500 Zeichen.', projectDisciplineLabel: 'Disziplin:', projectDiscipline: 'Disziplin', - projectInstituteLabel: 'Teilnehmende Institute:', - projectInstitute: 'Teilnehmende Institute', + projectOrganizationLabel: 'Teilnehmende Organization:', + projectOrganization: 'Teilnehmende Organization', projectVisibilityLabel: 'Sichtbarkeit:', projectVisibility: 'Sichtbarkeit', projectGrantIdLabel: 'Grant ID:', diff --git a/src/locale/en.ts b/src/locale/en.ts index de40a7e961ba57fd8a4d084f049a1c4ba3ece509..11a2ce15cf85146777e525e15c2932d111626b8c 100644 --- a/src/locale/en.ts +++ b/src/locale/en.ts @@ -29,8 +29,8 @@ export default { projectPrincipleInvestigatorsHelp: 'This is a required field and can only be up to 500 characters long.', projectDisciplineLabel: 'Discipline:', projectDiscipline: 'Discipline', - projectInstituteLabel: 'Participating Institutes:', - projectInstitute: 'Participating Institutes', + projectOrganizationLabel: 'Participating Organizations:', + projectOrganization: 'Participating Organizations', projectVisibilityLabel: 'Visibility:', projectVisibility: 'Visibility', projectGrantIdLabel: 'Grant ID:',