- Create a new Stakeholder by using a default profile base on his type.
+ Create a new Stakeholder by selecting a default profile.
add
@@ -203,16 +203,19 @@
(alertOutput)="saveStakeholder()"
[okDisabled]="stakeholderFb && (stakeholderFb.invalid || (stakeholderFb.pristine && index !==-1))">
-
+
@@ -227,6 +230,12 @@
label="Type" [options]="stakeholderUtils.types" type="select">
+
+
No default profiles has been found for this type.
+
0"
+ dashboard-input class="uk-form-row" [formInput]="stakeholderFb.get('defaultId')"
+ label="Profile" [options]="defaultStakeholdersOptions" type="select">
+
diff --git a/src/app/manageStakeholders/manageStakeholders.component.ts b/src/app/manageStakeholders/manageStakeholders.component.ts
index 418742a..7fcd96d 100644
--- a/src/app/manageStakeholders/manageStakeholders.component.ts
+++ b/src/app/manageStakeholders/manageStakeholders.component.ts
@@ -34,6 +34,8 @@ export class ManageStakeholdersComponent implements OnInit, OnDestroy {
public displayDefaultStakeholders: Stakeholder[];
public displayStakeholders: Stakeholder[];
+ public defaultStakeholdersOptions: Option[] = [];
+
/**
* Top filters
*/
@@ -126,6 +128,16 @@ export class ManageStakeholdersComponent implements OnInit, OnDestroy {
this.displayStakeholders = this.filterByKeyword(this.stakeholders, value);
}
+ onTypeChange(value) {
+ this.defaultStakeholdersOptions = [];
+ this.defaultStakeholders.filter(stakeholder => stakeholder.type === value).forEach(stakeholder => {
+ this.defaultStakeholdersOptions.push({
+ label: stakeholder.name,
+ value: stakeholder._id
+ })
+ });
+ }
+
private filterPrivacy(stakeholders: Stakeholder[], value): Stakeholder[] {
if (value === 'all') {
@@ -169,10 +181,11 @@ export class ManageStakeholdersComponent implements OnInit, OnDestroy {
}
this.stakeholderFb = this.fb.group({
_id: this.fb.control(this.stakeholder._id),
+ defaultId: this.fb.control(this.stakeholder.defaultId),
+ name: this.fb.control(this.stakeholder.name, Validators.required),
index_name: this.fb.control(this.stakeholder.index_name, Validators.required),
index_id: this.fb.control(this.stakeholder.index_id, Validators.required),
index_shortName: this.fb.control(this.stakeholder.index_shortName, Validators.required),
- defaultId: this.fb.control((isDefault) ? null : 'id'),
creationDate: this.fb.control(this.stakeholder.creationDate),
alias: this.fb.control(this.stakeholder.alias,
[
@@ -189,8 +202,14 @@ export class ManageStakeholdersComponent implements OnInit, OnDestroy {
type: this.fb.control(this.stakeholder.type, Validators.required),
topics: this.fb.control(this.stakeholder.topics),
managers: this.fb.control(this.stakeholder.managers),
- logoUrl: this.fb.control(this.stakeholder.logoUrl)
+ logoUrl: this.fb.control(this.stakeholder.logoUrl),
});
+ this.subscriptions.push(this.stakeholderFb.get('type').valueChanges.subscribe(value => {
+ this.onTypeChange(value);
+ }));
+ if(!isDefault) {
+ this.stakeholderFb.setControl('defaultId', this.fb.control(this.stakeholder.defaultId, Validators.required));
+ }
if (this.index !== -1) {
if (this.stakeholderFb.value.type) {
setTimeout(() => {
@@ -217,15 +236,12 @@ export class ManageStakeholdersComponent implements OnInit, OnDestroy {
public saveStakeholder() {
if (this.index === -1) {
if (!this.stakeholderFb.value.isDefault) {
- let stakeholder = this.defaultStakeholders.find(value => value.type === this.stakeholderFb.value.type);
- this.stakeholderFb.get('defaultId').setValue(stakeholder._id);
+ let stakeholder = this.defaultStakeholders.find(value => value._id === this.stakeholderFb.value.defaultId);
this.stakeholderFb.setValue(this.stakeholderUtils.createFunderFromDefaultProfile(this.stakeholderFb.value,
stakeholder.topics));
- /* this.stakeholderFb.setValue(this.stakeholderUtils.createFunderFromDefaultProfile(this.stakeholderFb.value,
- StakeholderCreator.createFunderDefaultProfile().topics));*/
- } else {
+ } /*else {
this.stakeholderFb.setValue(StakeholderCreator.createFunderDefaultProfile(this.stakeholderFb.value));
- }
+ }*/
this.stakeholderService.buildStakeholder(this.properties.monitorServiceAPIURL,
this.stakeholderFb.value).subscribe(stakeholder => {
if (stakeholder.defaultId === null) {
diff --git a/src/app/topic/indicators.component.ts b/src/app/topic/indicators.component.ts
index 6e2a8b6..8cc5acd 100644
--- a/src/app/topic/indicators.component.ts
+++ b/src/app/topic/indicators.component.ts
@@ -482,7 +482,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
}
this.filterCharts();
this.indicatorFb = null;
- UIkit.notification('Section has been successfully saved', {
+ UIkit.notification('Indicator has been successfully saved', {
status: 'success',
timeout: 3000,
pos: 'top-left'
diff --git a/src/app/utils/entities/stakeholder.ts b/src/app/utils/entities/stakeholder.ts
index 6040dc9..f83f26f 100644
--- a/src/app/utils/entities/stakeholder.ts
+++ b/src/app/utils/entities/stakeholder.ts
@@ -14,6 +14,7 @@ export type SourceType = 'statistics' | 'search' | 'metrics' | 'stats-tool' | 'o
export class Stakeholder {
_id: string;
type: StakeholderType;
+ name: string;
index_id;
index_name: string;
index_shortName: string;
diff --git a/src/app/utils/entities/stakeholderCreator.ts b/src/app/utils/entities/stakeholderCreator.ts
index 986e82e..8bdd2d5 100644
--- a/src/app/utils/entities/stakeholderCreator.ts
+++ b/src/app/utils/entities/stakeholderCreator.ts
@@ -22,8 +22,6 @@ export class StakeholderCreator {
impact.categories.push(this.createEmptyCategory("Economic Impact","Indicators based on patents and collaboration between industry and academia","economic-impact"));
impact.categories.push(this.createEmptyCategory("Societal Impact","Indicators that correlate research results with SDGs","societal-impact"));
funder.topics.push(impact);
-
- console.log(funder);
return funder;
}