@@ -14,7 +14,9 @@ import { CedarTemplateFormComponent } from '@osf/shared/components/shared-metada
1414import {
1515 ContributorsDialogComponent ,
1616 DescriptionDialogComponent ,
17+ FundingDialogComponent ,
1718 LicenseDialogComponent ,
19+ ResourceInformationDialogComponent ,
1820} from '@osf/shared/components/shared-metadata/dialogs' ;
1921import { SharedMetadataComponent } from '@osf/shared/components/shared-metadata/shared-metadata.component' ;
2022import { MetadataResourceEnum , ResourceType } from '@osf/shared/enums' ;
@@ -40,6 +42,7 @@ import {
4042 GetCustomItemMetadata ,
4143 GetResourceMetadata ,
4244 MetadataSelectors ,
45+ UpdateCustomItemMetadata ,
4346 UpdateResourceDetails ,
4447 UpdateResourceLicense ,
4548} from './store' ;
@@ -73,32 +76,31 @@ export class MetadataComponent implements OnInit {
7376 private resourceId = '' ;
7477
7578 tabs = signal < MetadataTabsModel [ ] > ( [ ] ) ;
76- protected readonly selectedTab = signal ( 'osf' ) ;
79+ readonly selectedTab = signal ( 'osf' ) ;
7780
7881 selectedCedarRecord = signal < CedarMetadataRecordData | null > ( null ) ;
7982 selectedCedarTemplate = signal < CedarMetadataDataTemplateJsonApi | null > ( null ) ;
8083 cedarFormReadonly = signal < boolean > ( true ) ;
81- protected metadata = select ( MetadataSelectors . getResourceMetadata ) ;
82- protected isMetadataLoading = select ( MetadataSelectors . getLoading ) ;
83- protected customItemMetadata = select ( MetadataSelectors . getCustomItemMetadata ) ;
84- protected fundersList = select ( MetadataSelectors . getFundersList ) ;
85- protected contributors = select ( ContributorsSelectors . getContributors ) ;
86- protected isContributorsLoading = select ( ContributorsSelectors . isContributorsLoading ) ;
87- protected cedarRecords = select ( MetadataSelectors . getCedarRecords ) ;
88- protected cedarTemplates = select ( MetadataSelectors . getCedarTemplates ) ;
89- protected selectedSubjects = select ( SubjectsSelectors . getSelectedSubjects ) ;
90- protected isSubjectsUpdating = select ( SubjectsSelectors . areSelectedSubjectsLoading ) ;
84+ metadata = select ( MetadataSelectors . getResourceMetadata ) ;
85+ isLoading = select ( MetadataSelectors . getLoading ) ;
86+ customItemMetadata = select ( MetadataSelectors . getCustomItemMetadata ) ;
87+ contributors = select ( ContributorsSelectors . getContributors ) ;
88+ isContributorsLoading = select ( ContributorsSelectors . isContributorsLoading ) ;
89+ cedarRecords = select ( MetadataSelectors . getCedarRecords ) ;
90+ cedarTemplates = select ( MetadataSelectors . getCedarTemplates ) ;
91+ selectedSubjects = select ( SubjectsSelectors . getSelectedSubjects ) ;
92+ isSubjectsUpdating = select ( SubjectsSelectors . areSelectedSubjectsLoading ) ;
9193 resourceType = signal < ResourceType > ( this . activeRoute . parent ?. snapshot . data [ 'resourceType' ] || ResourceType . Project ) ;
94+ isSubmitting = select ( MetadataSelectors . getSubmitting ) ;
9295
9396 provider = environment . defaultProvider ;
9497
95- protected actions = createDispatchMap ( {
98+ actions = createDispatchMap ( {
9699 getResourceMetadata : GetResourceMetadata ,
97100 updateMetadata : UpdateResourceDetails ,
98101 updateResourceLicense : UpdateResourceLicense ,
99102 getCustomItemMetadata : GetCustomItemMetadata ,
100- // updateCustomItemMetadata: UpdateCustomItemMetadata,
101- // getFundersList: GetFundersList,
103+ updateCustomItemMetadata : UpdateCustomItemMetadata ,
102104 getContributors : GetAllContributors ,
103105 // getUserInstitutions: GetUserInstitutions,
104106 // getCedarRecords: GetCedarMetadataRecords,
@@ -145,6 +147,7 @@ export class MetadataComponent implements OnInit {
145147 } ) ;
146148
147149 effect ( ( ) => {
150+ console . log ( 'customItemMetadata:' , this . customItemMetadata ( ) ) ;
148151 const metadata = this . metadata ( ) ;
149152 if ( this . resourceType ( ) === ResourceType . Registration ) {
150153 if ( metadata ) {
@@ -259,7 +262,6 @@ export class MetadataComponent implements OnInit {
259262 }
260263
261264 onTagsChanged ( tags : string [ ] ) : void {
262- console . log ( 'Tags changed:' , tags ) ;
263265 this . actions . updateMetadata ( this . resourceId , this . resourceType ( ) , { tags } ) ;
264266 }
265267
@@ -316,39 +318,32 @@ export class MetadataComponent implements OnInit {
316318 }
317319
318320 openEditResourceInformationDialog ( ) : void {
319- // const dialogRef = this.dialogService.open(ResourceInformationDialogComponent, {
320- // header: this.translateService.instant('project.metadata.resourceInformation.dialog.header'),
321- // width: '500px',
322- // focusOnShow: false,
323- // closeOnEscape: true,
324- // modal: true,
325- // closable: true,
326- // data: {
327- // currentProject: this.currentProject(),
328- // customItemMetadata: this.customItemMetadata(),
329- // },
330- // });
331- // dialogRef.onClose
332- // .pipe(
333- // filter((result) => !!result && (result.resourceType || result.resourceLanguage)),
334- // switchMap((result) => {
335- // const projectId = this.currentProject()?.id;
336- // if (projectId) {
337- // const currentMetadata = this.customItemMetadata();
338- // const updatedMetadata = {
339- // ...currentMetadata,
340- // language: result.resourceLanguage || currentMetadata?.language,
341- // resource_type_general: result.resourceType || currentMetadata?.resource_type_general,
342- // funder: currentMetadata?.funders,
343- // };
344- // return this.actions.updateCustomItemMetadata(projectId, updatedMetadata);
345- // }
346- // return EMPTY;
347- // })
348- // )
349- // .subscribe({
350- // next: () => this.toastService.showSuccess('project.metadata.resourceInformation.updated'),
351- // });
321+ const currentCustomMetadata = this . customItemMetadata ( ) ;
322+ const dialogRef = this . dialogService . open ( ResourceInformationDialogComponent , {
323+ header : this . translateService . instant ( 'project.metadata.resourceInformation.dialog.header' ) ,
324+ width : '500px' ,
325+ focusOnShow : false ,
326+ closeOnEscape : true ,
327+ modal : true ,
328+ closable : true ,
329+ data : {
330+ customItemMetadata : currentCustomMetadata ,
331+ } ,
332+ } ) ;
333+ dialogRef . onClose
334+ . pipe (
335+ filter ( ( result ) => ! ! result && ( result . resourceTypeGeneral || result . language ) ) ,
336+ switchMap ( ( result ) => {
337+ const updatedMetadata = {
338+ ...currentCustomMetadata ,
339+ ...result ,
340+ } ;
341+ return this . actions . updateCustomItemMetadata ( this . resourceId , updatedMetadata ) ;
342+ } )
343+ )
344+ . subscribe ( {
345+ next : ( ) => this . toastService . showSuccess ( 'project.metadata.resourceInformation.updated' ) ,
346+ } ) ;
352347 }
353348
354349 openEditLicenseDialog ( ) : void {
@@ -381,57 +376,33 @@ export class MetadataComponent implements OnInit {
381376 }
382377
383378 openEditFundingDialog ( ) : void {
384- // this.actions.getFundersList();
385- // const dialogRef = this.dialogService.open(FundingDialogComponent, {
386- // header: this.translateService.instant('project.metadata.funding.dialog.header'),
387- // width: '600px',
388- // focusOnShow: false,
389- // closeOnEscape: true,
390- // modal: true,
391- // closable: true,
392- // data: {
393- // currentProject: this.currentProject(),
394- // },
395- // });
396- // dialogRef.onClose
397- // .pipe(
398- // filter((result) => !!result && result.fundingEntries),
399- // switchMap((result) => {
400- // const projectId = this.currentProject()?.id;
401- // if (projectId) {
402- // const currentMetadata = this.customItemMetadata() || {
403- // language: 'en',
404- // resource_type_general: 'Dataset',
405- // funders: [],
406- // };
407- // const updatedMetadata = {
408- // ...currentMetadata,
409- // funders: result.fundingEntries.map(
410- // (entry: {
411- // funderName?: string;
412- // funderIdentifier?: string;
413- // funderIdentifierType?: string;
414- // awardNumber?: string;
415- // awardUri?: string;
416- // awardTitle?: string;
417- // }) => ({
418- // funder_name: entry.funderName || '',
419- // funder_identifier: entry.funderIdentifier || '',
420- // funder_identifier_type: entry.funderIdentifierType || '',
421- // award_number: entry.awardNumber || '',
422- // award_uri: entry.awardUri || '',
423- // award_title: entry.awardTitle || '',
424- // })
425- // ),
426- // };
427- // return this.actions.updateCustomItemMetadata(projectId, updatedMetadata);
428- // }
429- // return EMPTY;
430- // })
431- // )
432- // .subscribe({
433- // next: () => this.toastService.showSuccess('project.metadata.funding.updated'),
434- // });
379+ const currentCustomMetadata = this . customItemMetadata ( ) ;
380+
381+ const dialogRef = this . dialogService . open ( FundingDialogComponent , {
382+ header : this . translateService . instant ( 'project.metadata.funding.dialog.header' ) ,
383+ width : '600px' ,
384+ focusOnShow : false ,
385+ closeOnEscape : true ,
386+ modal : true ,
387+ closable : true ,
388+ data : {
389+ funders : currentCustomMetadata ?. funders || [ ] ,
390+ } ,
391+ } ) ;
392+ dialogRef . onClose
393+ . pipe (
394+ filter ( ( result ) => ! ! result && result . fundingEntries ) ,
395+ switchMap ( ( result ) => {
396+ const updatedMetadata = {
397+ ...currentCustomMetadata ,
398+ funders : result . fundingEntries ,
399+ } ;
400+ return this . actions . updateCustomItemMetadata ( this . resourceId , updatedMetadata ) ;
401+ } )
402+ )
403+ . subscribe ( {
404+ next : ( ) => this . toastService . showSuccess ( 'project.metadata.funding.updated' ) ,
405+ } ) ;
435406 }
436407
437408 openEditAffiliatedInstitutionsDialog ( ) : void {
0 commit comments