From 9a1f8a808d5a7fca86049f44b2ef5aecceaab528 Mon Sep 17 00:00:00 2001 From: Angel Montenegro Date: Thu, 14 Dec 2023 16:13:39 -0600 Subject: [PATCH] Remove togglz that have to do with contributors (#2120) --- .../work-contributors.component.html | 3 - .../work-contributors.component.spec.ts | 3 +- .../work-contributors.component.ts | 9 +- .../work-bibtex-modal.component.ts | 164 ++++++++---------- 4 files changed, 81 insertions(+), 98 deletions(-) diff --git a/src/app/record/components/work-contributors/work-contributors.component.html b/src/app/record/components/work-contributors/work-contributors.component.html index 8242d352bb..fae9214381 100644 --- a/src/app/record/components/work-contributors/work-contributors.component.html +++ b/src/app/record/components/work-contributors/work-contributors.component.html @@ -33,7 +33,6 @@

@@ -102,7 +101,6 @@

@@ -384,7 +382,6 @@

diff --git a/src/app/record/components/work-contributors/work-contributors.component.spec.ts b/src/app/record/components/work-contributors/work-contributors.component.spec.ts index d744452116..66ced82841 100644 --- a/src/app/record/components/work-contributors/work-contributors.component.spec.ts +++ b/src/app/record/components/work-contributors/work-contributors.component.spec.ts @@ -86,8 +86,7 @@ describe('WorkContributorsComponent', () => { const mockFormGroup: UntypedFormGroup = new UntypedFormGroup({}) component['parentForm'].form = mockFormGroup component.userRecord = getUserRecord() - component.togglzAddOtherContributors = true - + fixture.detectChanges() loader = TestbedHarnessEnvironment.loader(fixture) }) diff --git a/src/app/record/components/work-contributors/work-contributors.component.ts b/src/app/record/components/work-contributors/work-contributors.component.ts index 821d85c92f..c534ca65dd 100644 --- a/src/app/record/components/work-contributors/work-contributors.component.ts +++ b/src/app/record/components/work-contributors/work-contributors.component.ts @@ -69,8 +69,7 @@ export class WorkContributorsComponent implements OnInit, OnDestroy { maxNumberOfContributors = 49 maxNumberOfContributorsSummary = 10 privateName = 'Name is private' - togglzAddOtherContributors: boolean - + contributionRoles = ContributionRoles recordHolderContribution: Contributor @@ -89,9 +88,7 @@ export class WorkContributorsComponent implements OnInit, OnDestroy { private workService: RecordWorksService, private affiliationService: RecordAffiliationService ) { - _togglz - .getStateOf('ADD_OTHER_WORK_CONTRIBUTORS') - .subscribe((value) => (this.togglzAddOtherContributors = value)) + } get contributorsFormArray() { @@ -220,7 +217,7 @@ export class WorkContributorsComponent implements OnInit, OnDestroy { 'contributors' ) as UntypedFormArray - if (this.togglzAddOtherContributors && this.contributors?.length > 0) { + if (this.contributors?.length > 0) { if (!this.recordHolderContribution && !this.recordHolderAsContributor) { this.addRecordHolderAsContributor() } diff --git a/src/app/record/components/work-stack-group/modals/work-bibtex-modal/work-bibtex-modal.component.ts b/src/app/record/components/work-stack-group/modals/work-bibtex-modal/work-bibtex-modal.component.ts index 74f6602406..0f0e3bae6e 100644 --- a/src/app/record/components/work-stack-group/modals/work-bibtex-modal/work-bibtex-modal.component.ts +++ b/src/app/record/components/work-stack-group/modals/work-bibtex-modal/work-bibtex-modal.component.ts @@ -49,94 +49,85 @@ export class WorkBibtexModalComponent implements OnInit, OnDestroy { ngOnInit(): void {} bibTexInputChange($fileInputEvent: any) { - this._togglz - .getStateOf('ADD_OTHER_WORK_CONTRIBUTORS_WITH_BIBTEX') - .subscribe((ADD_OTHER_WORK_CONTRIBUTORS_WITH_BIBTEX_TOGGLZ) => { - this.bibtexErrorParsingText = undefined - this.bibtexErrorParsing = false - this.loadingWorks = true - const textFiles = $fileInputEvent.target.files - for (const bibtex of textFiles) { - const reader = new FileReader() - reader.readAsText(bibtex) - - const that = this - - reader.onloadend = function (e) { - let parsed = null - try { - parsed = bibtexParse.toJSON(reader.result) - - if ( - typeof parsed === 'string' && - parsed.substring(0, 5).toLowerCase().indexOf('error') > -1 - ) { - that.bibtexErrorParsingText = parsed - that.bibtexErrorParsing = true - that.loadingWorks = false - } else { - if (parsed) { - const newWorks = [] - if (parsed.length === 0) { - that.bibtexErrorNoEntries = true - that.loadingWorks = false - } - while (parsed.length > 0) { - const cur = parsed.shift() - const bibtexEntry = cur.entryType.toLowerCase() - if ( - bibtexEntry !== 'preamble' && - bibtexEntry !== 'comment' - ) { - newWorks.push( - that.populateWork( - cur, - ADD_OTHER_WORK_CONTRIBUTORS_WITH_BIBTEX_TOGGLZ - ) + this.bibtexErrorParsingText = undefined + this.bibtexErrorParsing = false + this.loadingWorks = true + const textFiles = $fileInputEvent.target.files + for (const bibtex of textFiles) { + const reader = new FileReader() + reader.readAsText(bibtex) + const that = this + reader.onloadend = function (e) { + let parsed = null + try { + parsed = bibtexParse.toJSON(reader.result) + if ( + typeof parsed === 'string' && + parsed.substring(0, 5).toLowerCase().indexOf('error') > -1 + ) { + that.bibtexErrorParsingText = parsed + that.bibtexErrorParsing = true + that.loadingWorks = false + } else { + if (parsed) { + const newWorks = [] + if (parsed.length === 0) { + that.bibtexErrorNoEntries = true + that.loadingWorks = false + } + while (parsed.length > 0) { + const cur = parsed.shift() + const bibtexEntry = cur.entryType.toLowerCase() + if ( + bibtexEntry !== 'preamble' && + bibtexEntry !== 'comment' + ) { + newWorks.push( + that.populateWork( + cur ) - } + ) } - if (newWorks.length > 0) { - that._recordWorksService - .worksValidate(newWorks) - .pipe(first()) - .subscribe((data) => { - that.worksFromBibtex = [] - data.forEach((work) => { - that.worksFromBibtex.push(work) - if (work.errors.length > 0 && !that.isAnInvalidWork) { - that.isAnInvalidWork = true - that._snackBar.showValidationError() - } - }) - that.worksFromBibtex.forEach((w) => { - const newPutCode = 'new-' + that.addedWorkCount++ - w.putCode = { - value: newPutCode, - } - that.group[newPutCode] = new UntypedFormGroup({ - checked: new UntypedFormControl(false), - }) + } + if (newWorks.length > 0) { + that._recordWorksService + .worksValidate(newWorks) + .pipe(first()) + .subscribe((data) => { + that.worksFromBibtex = [] + data.forEach((work) => { + that.worksFromBibtex.push(work) + if (work.errors.length > 0 && !that.isAnInvalidWork) { + that.isAnInvalidWork = true + that._snackBar.showValidationError() + } + }) + that.worksFromBibtex.forEach((w) => { + const newPutCode = 'new-' + that.addedWorkCount++ + w.putCode = { + value: newPutCode, + } + that.group[newPutCode] = new UntypedFormGroup({ + checked: new UntypedFormControl(false), }) - that.importForm = new UntypedFormGroup(that.group) - that.loadingWorks = false }) - } + that.importForm = new UntypedFormGroup(that.group) + that.loadingWorks = false + }) } } - } catch (e) { - that.bibtexErrorParsingText = e - that.bibtexErrorParsing = true - that.loadingWorks = false } + } catch (e) { + that.bibtexErrorParsingText = e + that.bibtexErrorParsing = true + that.loadingWorks = false } } - }) + } } populateWork( - bibJSON, - ADD_OTHER_WORK_CONTRIBUTORS_WITH_BIBTEX_TOGGLZ: boolean + bibJSON ): Work { const work = {} as Work const bibtex = bibtexParse.toBibtex([bibJSON]) @@ -270,18 +261,17 @@ export class WorkBibtexModalComponent implements OnInit, OnDestroy { value: lowerKeyTags['url'], } } - - if (ADD_OTHER_WORK_CONTRIBUTORS_WITH_BIBTEX_TOGGLZ) { - work.contributorsGroupedByOrcid = [] - if (lowerKeyTags.hasOwnProperty('author')) { - const authors = this.removeEndingAnd(lowerKeyTags['author']) - this.addContributors(authors.split(' and '), 'author', work) - } - if (lowerKeyTags.hasOwnProperty('editor')) { - const editors = this.removeEndingAnd(lowerKeyTags['editor']) - this.addContributors(editors.split(' and '), 'editor', work) - } + + work.contributorsGroupedByOrcid = [] + if (lowerKeyTags.hasOwnProperty('author')) { + const authors = this.removeEndingAnd(lowerKeyTags['author']) + this.addContributors(authors.split(' and '), 'author', work) + } + if (lowerKeyTags.hasOwnProperty('editor')) { + const editors = this.removeEndingAnd(lowerKeyTags['editor']) + this.addContributors(editors.split(' and '), 'editor', work) } + } return work }