Skip to content

Commit b55931a

Browse files
refactor: TTL-886 improve logic for required fields for internal apps
1 parent c766e7f commit b55931a

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

src/app/modules/time-entries/pages/time-entries.component.ts

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -153,26 +153,12 @@ export class TimeEntriesComponent implements OnInit, OnDestroy, AfterViewInit {
153153
this.toastrService.error(`You are on the clock and this entry overlaps it, ${message}.`);
154154
this.isActiveEntryOverlapping = false;
155155
} else {
156-
if (this.entry.project_name.includes('(Applications)')) {
157-
if (event.entry.uri === '' && event.entry.description === '') {
158-
const message = 'The description field or ticket field should not be empty';
159-
this.toastrService.error(`Some fields are empty, ${message}.`);
160-
} else {
161-
this.doSave(event);
162-
}
163-
} else {
156+
if (this.requiredFieldsForInternalAppExist(event)) {
164157
this.doSave(event);
165158
}
166159
}
167160
} else {
168-
if (this.entry.project_name.includes('(Applications)')) {
169-
if (event.entry.uri === '' && event.entry.description === '') {
170-
const message = 'The description field or ticket field should not be empty';
171-
this.toastrService.error(`Some fields are empty, ${message}.`);
172-
} else {
173-
this.doSave(event);
174-
}
175-
} else {
161+
if (this.requiredFieldsForInternalAppExist(event)) {
176162
this.doSave(event);
177163
}
178164
}
@@ -275,4 +261,16 @@ export class TimeEntriesComponent implements OnInit, OnDestroy, AfterViewInit {
275261
});
276262
}
277263
}
264+
265+
// Check required fields for internal apps (Ticket number or Description field should exist).
266+
requiredFieldsForInternalAppExist(event) {
267+
const emptyFields = event.entry.uri === '' && event.entry.description === '';
268+
const isInternalApp = this.entry.project_name.includes('(Applications)');
269+
if (isInternalApp && emptyFields) {
270+
const message = 'The description field or ticket field should not be empty';
271+
this.toastrService.error(`Some fields are empty, ${message}.`);
272+
return false;
273+
}
274+
return true;
275+
}
278276
}

0 commit comments

Comments
 (0)