Skip to content

Commit

Permalink
Merge branch 'fix/sp1-form-edit-with-user-profile-and-tablet-name' in…
Browse files Browse the repository at this point in the history
…to release/v3.31.1
  • Loading branch information
esurface committed Oct 22, 2024
2 parents 49af6de + 7000d61 commit 07f379f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,29 @@ export class GroupUploadsEditComponent implements OnInit {
}

this.formPlayer.formResponseId = this.responseId
this.formPlayer.$afterSubmit.subscribe(async () => {
// This will fire if the response was never completed
await this.saveResponse()
this.router.navigate([`../`], { relativeTo: this.route })
})
this.formPlayer.$afterResubmit.subscribe(async () => {
let response = this.formPlayer.formEl.store.getState()

if (this.appConfig.syncProtocol === '1') {
this.restoreSP1DocumentVariables(response)
}

// at this point the form has been locked by tangy-form
// form player will ignore the save unless we force it to save
await this.formPlayer.saveResponse(response, true)
// This will fire if the response was completed
await this.saveResponse()
this.router.navigate([`../`], { relativeTo: this.route })
})
await this.formPlayer.render(true, {disableComponents:['TANGY-GPS']})
}

async saveResponse() {
let response = this.formPlayer.formEl.store.getState()
if (this.appConfig.syncProtocol === '1') {
this.restoreSP1DocumentVariables(response)
}

await this.formPlayer.saveResponse(response)
this.router.navigate([`../`], { relativeTo: this.route })
}

async getSP1DocumentVariables() {
// In SP1, syncing.service adds userProfileId and tabletUserName in the first item input of the response document.
// Editing the form inadvertently removes those values because they are not in the form HTML.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<button *ngIf="!formResponse.verified" mat-raised-button color="accent" (click)="verify()">{{'Verify'|translate}}</button>
<button *ngIf="formResponse.verified" mat-raised-button color="accent" (click)="unverify()">{{'Unverify'|translate}}</button>

<a routerLink="edit" mat-raised-button color="accent">{{'Edit'|translate}}</a>
<a *ngIf="editingAllowed" routerLink="edit" mat-raised-button color="accent">{{'Edit'|translate}}</a>

<button *ngIf="formResponse.archived" mat-raised-button color="accent" (click)="unarchive()">{{'Unarchive'|translate}}</button>
<button *ngIf="!formResponse.archived" mat-raised-button color="accent" (click)="archive()">{{'Archive'|translate}}</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export class GroupUploadsViewComponent implements OnInit {
responseId
groupId
formResponse
editingAllowed = true

constructor(
private route:ActivatedRoute,
Expand Down Expand Up @@ -51,6 +52,13 @@ export class GroupUploadsViewComponent implements OnInit {
// If you pass the responseId, but the form player already has a response, responseId will be ignored
this.formResponse = await this.tangyFormService.getResponse(this.responseId)
this.formPlayer.response = this.formResponse

const disabledFormIds = ['attendance','behavior','scoring'];
if(this.formResponse.archived || this.formResponse.verified ||
disabledFormIds.includes(this.formResponse.form.id)) {
this.editingAllowed = false
}

await this.formPlayer.render()
}

Expand Down

0 comments on commit 07f379f

Please sign in to comment.