mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-18 07:23:03 +00:00
[835] Auto-save in new Item Submission form breaks the form
Methods renaming
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
[formId]="formId"
|
[formId]="formId"
|
||||||
[group]="formGroup"
|
[group]="formGroup"
|
||||||
[hasErrorMessaging]="model.hasErrorMessages"
|
[hasErrorMessaging]="model.hasErrorMessages"
|
||||||
[hidden]="model.hidden"
|
[hidden]="model.hidden"linke
|
||||||
[layout]="formLayout"
|
[layout]="formLayout"
|
||||||
[model]="model"
|
[model]="model"
|
||||||
[ngClass]="[getClass(model, 'element', 'host'), getClass(model, 'grid', 'host')]"
|
[ngClass]="[getClass(model, 'element', 'host'), getClass(model, 'grid', 'host')]"
|
||||||
|
@@ -20,7 +20,7 @@ export class SubmissionServiceStub {
|
|||||||
getSubmissionStatus = jasmine.createSpy('getSubmissionStatus');
|
getSubmissionStatus = jasmine.createSpy('getSubmissionStatus');
|
||||||
getSubmissionSaveProcessingStatus = jasmine.createSpy('getSubmissionSaveProcessingStatus');
|
getSubmissionSaveProcessingStatus = jasmine.createSpy('getSubmissionSaveProcessingStatus');
|
||||||
getSubmissionDepositProcessingStatus = jasmine.createSpy('getSubmissionDepositProcessingStatus');
|
getSubmissionDepositProcessingStatus = jasmine.createSpy('getSubmissionDepositProcessingStatus');
|
||||||
hasNotSavedModification = jasmine.createSpy('hasNotSavedModification');
|
hasUnsavedModification = jasmine.createSpy('hasUnsavedModification');
|
||||||
isSectionHidden = jasmine.createSpy('isSectionHidden');
|
isSectionHidden = jasmine.createSpy('isSectionHidden');
|
||||||
isSubmissionLoading = jasmine.createSpy('isSubmissionLoading');
|
isSubmissionLoading = jasmine.createSpy('isSubmissionLoading');
|
||||||
notifyNewSection = jasmine.createSpy('notifyNewSection');
|
notifyNewSection = jasmine.createSpy('notifyNewSection');
|
||||||
|
@@ -12,7 +12,7 @@
|
|||||||
<button type="button"
|
<button type="button"
|
||||||
class="btn btn-info"
|
class="btn btn-info"
|
||||||
id="save"
|
id="save"
|
||||||
[disabled]="(processingSaveStatus | async) || !(hasNotSavedModification | async)"
|
[disabled]="(processingSaveStatus | async) || !(hasUnsavedModification | async)"
|
||||||
(click)="save($event)">
|
(click)="save($event)">
|
||||||
<span>{{'submission.general.save' | translate}}</span>
|
<span>{{'submission.general.save' | translate}}</span>
|
||||||
</button>
|
</button>
|
||||||
|
@@ -225,7 +225,7 @@ describe('SubmissionFormFooterComponent Component', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should disable save button when all modifications had been saved', () => {
|
it('should disable save button when all modifications had been saved', () => {
|
||||||
comp.hasNotSavedModification = observableOf(false);
|
comp.hasUnsavedModification = observableOf(false);
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
const saveBtn: any = fixture.debugElement.query(By.css('#save'));
|
const saveBtn: any = fixture.debugElement.query(By.css('#save'));
|
||||||
@@ -233,7 +233,7 @@ describe('SubmissionFormFooterComponent Component', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should enable save button when there are not saved modifications', () => {
|
it('should enable save button when there are not saved modifications', () => {
|
||||||
comp.hasNotSavedModification = observableOf(true);
|
comp.hasUnsavedModification = observableOf(true);
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
const saveBtn: any = fixture.debugElement.query(By.css('#save'));
|
const saveBtn: any = fixture.debugElement.query(By.css('#save'));
|
||||||
|
@@ -52,7 +52,7 @@ export class SubmissionFormFooterComponent implements OnChanges {
|
|||||||
/**
|
/**
|
||||||
* A boolean representing if submission form has unsaved modifications
|
* A boolean representing if submission form has unsaved modifications
|
||||||
*/
|
*/
|
||||||
public hasNotSavedModification: Observable<boolean>;
|
public hasUnsavedModification: Observable<boolean>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize instance variables
|
* Initialize instance variables
|
||||||
@@ -78,7 +78,7 @@ export class SubmissionFormFooterComponent implements OnChanges {
|
|||||||
this.processingSaveStatus = this.submissionService.getSubmissionSaveProcessingStatus(this.submissionId);
|
this.processingSaveStatus = this.submissionService.getSubmissionSaveProcessingStatus(this.submissionId);
|
||||||
this.processingDepositStatus = this.submissionService.getSubmissionDepositProcessingStatus(this.submissionId);
|
this.processingDepositStatus = this.submissionService.getSubmissionDepositProcessingStatus(this.submissionId);
|
||||||
this.showDepositAndDiscard = observableOf(this.submissionService.getSubmissionScope() === SubmissionScopeType.WorkspaceItem);
|
this.showDepositAndDiscard = observableOf(this.submissionService.getSubmissionScope() === SubmissionScopeType.WorkspaceItem);
|
||||||
this.hasNotSavedModification = this.submissionService.hasNotSavedModification();
|
this.hasUnsavedModification = this.submissionService.hasUnsavedModification();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -757,13 +757,13 @@ describe('SubmissionService test suite', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('hasNotSavedModification', () => {
|
describe('hasUnsavedModification', () => {
|
||||||
it('should call jsonPatchOperationService hasPendingOperation observable', () => {
|
it('should call jsonPatchOperationService hasPendingOperation observable', () => {
|
||||||
(service as any).jsonPatchOperationService.hasPendingOperations = jasmine.createSpy('hasPendingOperations')
|
(service as any).jsonPatchOperationService.hasPendingOperations = jasmine.createSpy('hasPendingOperations')
|
||||||
.and.returnValue(observableOf(true));
|
.and.returnValue(observableOf(true));
|
||||||
|
|
||||||
scheduler = getTestScheduler();
|
scheduler = getTestScheduler();
|
||||||
scheduler.schedule(() => service.hasNotSavedModification());
|
scheduler.schedule(() => service.hasUnsavedModification());
|
||||||
scheduler.flush();
|
scheduler.flush();
|
||||||
|
|
||||||
expect((service as any).jsonPatchOperationService.hasPendingOperations).toHaveBeenCalledWith('sections');
|
expect((service as any).jsonPatchOperationService.hasPendingOperations).toHaveBeenCalledWith('sections');
|
||||||
|
@@ -437,7 +437,7 @@ export class SubmissionService {
|
|||||||
* @return Observable<boolean>
|
* @return Observable<boolean>
|
||||||
* observable with submission unsaved modification presence
|
* observable with submission unsaved modification presence
|
||||||
*/
|
*/
|
||||||
hasNotSavedModification(): Observable<boolean> {
|
hasUnsavedModification(): Observable<boolean> {
|
||||||
return this.jsonPatchOperationService.hasPendingOperations('sections');
|
return this.jsonPatchOperationService.hasPendingOperations('sections');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user