Skip to content

Commit

Permalink
fix: moved convertLineBreaks to utils
Browse files Browse the repository at this point in the history
  • Loading branch information
HenryT-CG committed Oct 26, 2024
1 parent 1fcdc70 commit 6da544a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
Configuration
} from 'src/app/shared/generated'
import { SharedModule } from 'src/app/shared/shared.module'
import { convertLineBreaks } from 'src/app/shared/utils'
import { environment } from 'src/environments/environment'

@Component({
Expand Down Expand Up @@ -58,6 +59,7 @@ export class OneCXAnnouncementBannerComponent implements ocxRemoteComponent, ocx
private currentDate = new Date().toISOString()
private announcementsSubject = new BehaviorSubject<AnnouncementAbstract[] | undefined>([])
public announcements$: Observable<AnnouncementAbstract[] | undefined> = this.announcementsSubject.asObservable()
convertLineBreaks = convertLineBreaks

constructor(
@Inject(BASE_URL) private readonly baseUrl: ReplaySubject<string>,
Expand Down Expand Up @@ -141,9 +143,4 @@ export class OneCXAnnouncementBannerComponent implements ocxRemoteComponent, ocx
return []
}
}

// display simple formatted text
public convertLineBreaks(text?: string) {
return text?.replace(/(?:\r\n|\r|\n)/g, '<br/>') ?? ''
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
} from '@onecx/portal-integration-angular'

import { SharedModule } from 'src/app/shared/shared.module'
import { copyToClipboard } from 'src/app/shared/utils'
import { convertLineBreaks, copyToClipboard } from 'src/app/shared/utils'
import { AnnouncementAbstract, AnnouncementInternalAPIService, Configuration } from 'src/app/shared/generated'
import { environment } from 'src/environments/environment'

Expand Down Expand Up @@ -53,6 +53,7 @@ export class OneCXAnnouncementListActiveComponent implements ocxRemoteComponent,
public announcements$: Observable<AnnouncementAbstract[] | undefined> = this.announcementsSubject.asObservable()
public displayDetailDialog = false
copyToClipboard = copyToClipboard
convertLineBreaks = convertLineBreaks

constructor(
@Inject(BASE_URL) private readonly baseUrl: ReplaySubject<string>,
Expand Down Expand Up @@ -107,9 +108,4 @@ export class OneCXAnnouncementListActiveComponent implements ocxRemoteComponent,
})
)
}

// display simple formatted text
public convertLineBreaks(text?: string) {
return text?.replace(/(?:\r\n|\r|\n)/g, '<br/>') ?? ''
}
}
2 changes: 1 addition & 1 deletion src/app/shared/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ describe('util functions', () => {
})
})

describe('sortByLocale', () => {
describe('convertLineBreaks', () => {
it('should convert line breaks to br', () => {
const text = '123\r456'

Expand Down

0 comments on commit 6da544a

Please sign in to comment.