import { Injectable } from '@angular/core'; import { FormStatuses, RelativeFormDueDateFields } from '@features/configure-forms/form.typing'; import { ALL_SKIP_FILTER, ArrayHelpersService, TopLevelFilterOption } from '@yourcause/common'; import { I18nService } from '@yourcause/common/i18n'; @Injectable({ providedIn: 'root' }) export class FormStatusService { constructor ( private i18n: I18nService, private arrayHelper: ArrayHelpersService ) { } get relativeFormDueDateOptions () { return this.arrayHelper.sort([{ label: this.i18n.translate( 'GLOBAL:lblSubmittedDate', {}, 'Submitted date' ), value: RelativeFormDueDateFields.SUBMITTED_DATE }, { label: this.i18n.translate( 'GLOBAL:lblDateEnteredWorkflowLevel', {}, 'Date entered workflow level' ), value: RelativeFormDueDateFields.ENTERED_WFL_DATE }, { label: this.i18n.translate( 'GLOBAL:lblDateFormSent', {}, 'Date form sent' ), value: RelativeFormDueDateFields.FORM_SENT_DATE }, { label: this.i18n.translate( 'GLOBAL:lblCycleOpen', {}, 'Cycle open' ), value: RelativeFormDueDateFields.CYCLE_OPEN_DATE }, { label: this.i18n.translate( 'GLOBAL:lblCycleClose', {}, 'Cycle close' ), value: RelativeFormDueDateFields.CYCLE_CLOSE_DATE }, { label: this.i18n.translate( 'GLOBAL:lblApprovalDate', {}, 'Approval date' ), value: RelativeFormDueDateFields.APPROVAL_DATE }, { label: this.i18n.translate( 'AWARDS:textAwardDate', {}, 'Award date' ), value: RelativeFormDueDateFields.AWARD_DATE }, { label: this.i18n.translate( 'GLOBAL:lblLastPaymentDate', {}, 'Last payment date' ), value: RelativeFormDueDateFields.LAST_PAYMENT_DATE }, { label: this.i18n.translate( 'GLOBAL:lblStatusChangeDate', {}, 'Status change date' ), value: RelativeFormDueDateFields.STATUS_CHANGE_DATE }], 'label'); } /** * Returns the form status options * * @param isManager is for manager? * @returns form status options */ getFormStatusOptions (isManager = false): TopLevelFilterOption[] { const standardOptions = [{ label: this.i18n.translate( 'FORMS:textAllFormStatuses', {}, 'All form statuses' ), value: ALL_SKIP_FILTER }, { label: this.i18n.translate( 'GLOBAL:textSubmitted', {}, 'Submitted' ), value: FormStatuses.Submitted }, { label: this.i18n.translate( 'GLOBAL:textNotSubmitted', {}, 'Not submitted' ), value: 'not_submitted', customValue: FormStatuses.Submitted, filterTypeOverride: 'ne' }, { label: this.i18n.translate( 'FORMS:textFormOverdue', {}, 'Form overdue' ), value: 'overdue', customValue: true, customColumn: 'isOverdue' }, { label: this.i18n.translate( 'FORMS:textFormDue', {}, 'Form due' ), value: 'due', customValue: true, customColumn: 'isDue' }]; const managerAdditions = [{ label: this.i18n.translate( 'GLOBAL:textNotStarted', {}, 'Not started' ), value: 'not_started', customColumn: 'applicationFormId', filterTypeOverride: 'ib' }]; const applicantAdditions = [{ label: this.i18n.translate( 'GLOBAL:textNotSent', {}, 'Not sent' ), value: FormStatuses.NotSent }, { label: this.i18n.translate( 'GLOBAL:textRevisionRequested', {}, 'Revision requested' ), value: FormStatuses.RevisionRequested }]; if (isManager) { return this.arrayHelper.sort([ ...standardOptions, ...managerAdditions ], 'label'); } else { return this.arrayHelper.sort([ ...standardOptions, ...applicantAdditions ], 'label'); } } }