Skip to content

Commit

Permalink
Refactor new get form methond in forms service to be promise based an…
Browse files Browse the repository at this point in the history
…d fix all references
  • Loading branch information
alejandro-bulgaris-qcif committed Jun 27, 2024
1 parent 8e31a5f commit 88812dc
Show file tree
Hide file tree
Showing 5 changed files with 208 additions and 230 deletions.
8 changes: 4 additions & 4 deletions test/unit/services/FormsService.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('The FormsService', function () {
type: 'rdmp'
}
};
FormsService.getForm(brand, '', true, '', record).subscribe(form => {
FormsService.getForm(brand, '', true, '', record).then(form => {
expect(form).to.have.property('name', formName);
done();
})
Expand All @@ -55,7 +55,7 @@ describe('The FormsService', function () {
type: 'rdmp'
}
};
FormsService.getForm(brand, '', true, '', record).subscribe(form => {
FormsService.getForm(brand, '', true, '', record).then(form => {
expect(form).to.have.property('name', formName);
done();
})
Expand All @@ -64,7 +64,7 @@ describe('The FormsService', function () {
it('should return the form', function (done) {
let brand = BrandingService.getDefault();
let formName = 'default-1.0-draft';
FormsService.getForm(brand, formName, true, 'rdmp', {}).subscribe(form => {
FormsService.getForm(brand, formName, true, 'rdmp', {}).then(form => {
expect(form).to.have.property('name', formName);
done();
})
Expand All @@ -73,7 +73,7 @@ describe('The FormsService', function () {
it('should return the autogenerated form', function (done) {
let brand = BrandingService.getDefault();
let formName = 'generated-view-only';
FormsService.getForm(brand, formName, true, 'rdmp', {}).subscribe(form => {
FormsService.getForm(brand, formName, true, 'rdmp', {}).then(form => {
expect(form).to.have.property('name', formName);
done();
})
Expand Down
4 changes: 2 additions & 2 deletions typescript/api/controllers/RecordController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ export module Controllers {
if (!hasEditAccess) {
return this.ajaxFail(req, res, null, {message: TranslationService.t('edit-error-no-permissions')});

Check warning on line 262 in typescript/api/controllers/RecordController.ts

View check run for this annotation

Codecov / codecov/patch

typescript/api/controllers/RecordController.ts#L262

Added line #L262 was not covered by tests
}
form = await FormsService.getForm(brand, formParam, editMode, '', currentRec).toPromise();
form = await FormsService.getForm(brand, formParam, editMode, '', currentRec);
if (_.isEmpty(form)) {
return this.ajaxFail(req, res, null, {message: `Error, getting form ${formParam} for OID: ${oid}`});

Check warning on line 266 in typescript/api/controllers/RecordController.ts

View check run for this annotation

Codecov / codecov/patch

typescript/api/controllers/RecordController.ts#L266

Added line #L266 was not covered by tests
}
Expand All @@ -271,7 +271,7 @@ export module Controllers {
if (!hasViewAccess) {
return this.ajaxFail(req, res, null, {message: TranslationService.t('view-error-no-permissions')});

Check warning on line 272 in typescript/api/controllers/RecordController.ts

View check run for this annotation

Codecov / codecov/patch

typescript/api/controllers/RecordController.ts#L272

Added line #L272 was not covered by tests
}
form = await FormsService.getForm(brand, formParam, editMode, '', currentRec).toPromise();
form = await FormsService.getForm(brand, formParam, editMode, '', currentRec);
if (_.isEmpty(form)) {
return this.ajaxFail(req, res, null, {message: `Error, getting form ${formParam} for OID: ${oid}`});

Check warning on line 276 in typescript/api/controllers/RecordController.ts

View check run for this annotation

Codecov / codecov/patch

typescript/api/controllers/RecordController.ts#L276

Added line #L276 was not covered by tests
}
Expand Down
2 changes: 1 addition & 1 deletion typescript/api/controllers/webservice/RecordController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1085,7 +1085,7 @@ export module Controllers {
let keys = _.keys(meta1);

Check warning on line 1085 in typescript/api/controllers/webservice/RecordController.ts

View check run for this annotation

Codecov / codecov/patch

typescript/api/controllers/webservice/RecordController.ts#L1085

Added line #L1085 was not covered by tests

for(let key of keys) {

Check warning on line 1087 in typescript/api/controllers/webservice/RecordController.ts

View check run for this annotation

Codecov / codecov/patch

typescript/api/controllers/webservice/RecordController.ts#L1087

Added line #L1087 was not covered by tests
if(_.get(meta1,key,'') != _.get(meta2,key,'')) {
if(!_.isEqual(meta1?.[key],meta2?.[key])) {
return false;

Check warning on line 1089 in typescript/api/controllers/webservice/RecordController.ts

View check run for this annotation

Codecov / codecov/patch

typescript/api/controllers/webservice/RecordController.ts#L1089

Added line #L1089 was not covered by tests
}
}
Expand Down
Loading

0 comments on commit 88812dc

Please sign in to comment.