mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
[835] Auto-save in new Item Submission form breaks the form
Disable autosave when timer is equal to 0
This commit is contained in:
@@ -915,6 +915,13 @@ describe('SubmissionService test suite', () => {
|
||||
});
|
||||
|
||||
describe('startAutoSave', () => {
|
||||
|
||||
let environmentAutoSaveTimerOriginalValue;
|
||||
|
||||
beforeEach(() => {
|
||||
environmentAutoSaveTimerOriginalValue = environment.submission.autosave.timer;
|
||||
});
|
||||
|
||||
it('should start Auto Save', fakeAsync(() => {
|
||||
const duration = environment.submission.autosave.timer * (1000 * 60);
|
||||
|
||||
@@ -930,6 +937,19 @@ describe('SubmissionService test suite', () => {
|
||||
sub.unsubscribe();
|
||||
(service as any).autoSaveSub.unsubscribe();
|
||||
}));
|
||||
|
||||
it('should not start Auto Save if timer is 0', fakeAsync(() => {
|
||||
environment.submission.autosave.timer = 0;
|
||||
|
||||
service.startAutoSave('826');
|
||||
|
||||
expect((service as any).autoSaveSub).toBeUndefined();
|
||||
}));
|
||||
|
||||
afterEach(() => {
|
||||
environment.submission.autosave.timer = environmentAutoSaveTimerOriginalValue;
|
||||
})
|
||||
|
||||
});
|
||||
|
||||
describe('stopAutoSave', () => {
|
||||
|
@@ -562,6 +562,10 @@ export class SubmissionService {
|
||||
*/
|
||||
startAutoSave(submissionId) {
|
||||
this.stopAutoSave();
|
||||
if (environment.submission.autosave.timer === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// AUTOSAVE submission
|
||||
// Retrieve interval from config and convert to milliseconds
|
||||
const duration = environment.submission.autosave.timer * (1000 * 60);
|
||||
|
Reference in New Issue
Block a user