Skip to content

Commit

Permalink
🤖 GITHUB ACTIONS format_prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
amontenegro committed Dec 14, 2023
1 parent 9a1f8a8 commit 10ca64d
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@ <h3 class="orc-font-body">
</h3>
</label>
</div>
<ng-container
*ngIf="
contributors?.length > maxNumberOfContributors + 1
"
>
<ng-container *ngIf="contributors?.length > maxNumberOfContributors + 1">
<div class="contributors-summary orc-font-body-small">
<ng-container
*ngFor="
Expand Down Expand Up @@ -99,11 +95,7 @@ <h3 class="orc-font-body">
</div>
</div>
</ng-container>
<ng-container
*ngIf="
!(contributors?.length > maxNumberOfContributors + 1)
"
>
<ng-container *ngIf="!(contributors?.length > maxNumberOfContributors + 1)">
<ng-container formArrayName="contributors">
<div
class="row contributors-list"
Expand Down Expand Up @@ -381,9 +373,7 @@ <h3 class="orc-font-body">
</ng-container>
<div
class="row"
*ngIf="
!(contributors?.length > maxNumberOfContributors + 1)
"
*ngIf="!(contributors?.length > maxNumberOfContributors + 1)"
>
<a
class="col add-more no-gutters cy-add-another-contributor"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ describe('WorkContributorsComponent', () => {
const mockFormGroup: UntypedFormGroup = new UntypedFormGroup({})
component['parentForm'].form = mockFormGroup
component.userRecord = getUserRecord()

fixture.detectChanges()
loader = TestbedHarnessEnvironment.loader(fixture)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class WorkContributorsComponent implements OnInit, OnDestroy {
maxNumberOfContributors = 49
maxNumberOfContributorsSummary = 10
privateName = 'Name is private'

contributionRoles = ContributionRoles
recordHolderContribution: Contributor

Expand All @@ -87,9 +87,7 @@ export class WorkContributorsComponent implements OnInit, OnDestroy {
private platform: PlatformInfoService,
private workService: RecordWorksService,
private affiliationService: RecordAffiliationService
) {

}
) {}

get contributorsFormArray() {
return this.parentForm.control.controls['contributors'] as UntypedFormArray
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,74 +61,65 @@ export class WorkBibtexModalComponent implements OnInit, OnDestroy {
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 (
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
): Work {
populateWork(bibJSON): Work {
const work = {} as Work
const bibtex = bibtexParse.toBibtex([bibJSON])

Expand Down Expand Up @@ -261,7 +252,7 @@ export class WorkBibtexModalComponent implements OnInit, OnDestroy {
value: lowerKeyTags['url'],
}
}

work.contributorsGroupedByOrcid = []
if (lowerKeyTags.hasOwnProperty('author')) {
const authors = this.removeEndingAnd(lowerKeyTags['author'])
Expand All @@ -271,7 +262,6 @@ export class WorkBibtexModalComponent implements OnInit, OnDestroy {
const editors = this.removeEndingAnd(lowerKeyTags['editor'])
this.addContributors(editors.split(' and '), 'editor', work)
}

}
return work
}
Expand Down

0 comments on commit 10ca64d

Please sign in to comment.