Skip to content
Snippets Groups Projects
Commit 851acf39 authored by L. Ellenbeck's avatar L. Ellenbeck
Browse files

Merge branch 'Topic/712-organizations' into 'Product/483-organizations'

Topic/712 organizations

See merge request coscine/vue/project-creation!36
parents 9f1744a4 a3682d8f
No related branches found
No related tags found
2 merge requests!38Product/483 organizations,!36Topic/712 organizations
......@@ -103,7 +103,8 @@
:hide-selected="true"
:label="disciplineLabel"
:track-by="disciplineLabel"
:placeholder="$t('projectDiscipline')">
: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"
<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="institutes"
:options="organizations"
:multiple="true"
:hide-selected="true"
label="displayName"
track-by="displayName"
:placeholder="$t('projectInstitute')">
track-by="url"
:placeholder="$t('projectOrganization')"
>
<template slot="singleLabel" slot-scope="props" v-bind:disabled="!(this.isOwner || isNewProject)">
{{ props.option.displayName }}
</template>
......@@ -136,9 +138,11 @@
v-bind:disabled="!(this.isOwner || isNewProject)"
:options="keywordoptions"
:placeholder="$t('projectKeywords')"
:multiple="true" :taggable="true"
:multiple="true"
:taggable="true"
:tag-placeholder="$t('tagPlaceholder')"
@tag="addTag">
@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) {
......@@ -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>
......
......@@ -5,3 +5,8 @@ declare var coscine: {
};
declare var _spPageContextInfo: any;
declare class Organization {
url: string;
displayName: string;
};
\ No newline at end of file
......@@ -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:',
......
......@@ -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:',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment