Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TAN-3444 - Prevent custom form saving if updated more recently in another browser window #9888

Open
wants to merge 21 commits into
base: master
Choose a base branch
from

Conversation

jamesspeake
Copy link
Contributor

@jamesspeake jamesspeake commented Dec 20, 2024

How this works:

  • Added new endpoint for custom_form which returns when the form was last updated on the server + when the form was opened
  • The date last updated is passed when saving the form. If the date is before the save date on the server then the save gets rejected and the following message is shown:
image
  • Added extra logging on each form save which logs the following payload to help us identify any issues:
{"pages": 0, "fields": 7, "sections": 3, "save_type": "manual", "params_size": 20145, "form_opened_at": 1735833232, "form_updated_at": 1735833478}

Changelog

Changed

  • Added new error to form editor if the form has been edited more recently in another browser

Technical

  • Added additional logging of custom form to form editing

Copy link

@cl-dev-bot
Copy link
Collaborator

cl-dev-bot commented Dec 20, 2024

Messages
📖 Changelog provided 🎉
📖 Notion issue: TAN-3444
📖

Run the e2e tests

📖 Check translation progress

Generated by 🚫 dangerJS against 4e09a4d

@jamesspeake jamesspeake marked this pull request as draft December 23, 2024 15:12
%i[options options.image map_config]
super + %i[map_config]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just tidying up this

@@ -63,14 +63,15 @@ def as_geojson

def update_all
authorize CustomField.new(resource: @custom_form), :update_all?, policy_class: IdeaCustomFieldPolicy
@participation_method = @custom_form.participation_context.pmethod
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did not need setting as a global variable

@jamesspeake jamesspeake changed the title TAN-3444 - Added additional logging to custom form editing TAN-3444 - Prevent custom form saving if updated more recently in another browser window Jan 3, 2025
@jamesspeake jamesspeake requested a review from EdwinKato January 3, 2025 12:00
@jamesspeake jamesspeake marked this pull request as ready for review January 3, 2025 12:01
triggerAutosave &&
autosaveEnabled &&
totalSubmissions === 0 &&
isDirty
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this to prevent it saving when there are no changes

import { CustomFormKeys, ICustomForm, ICustomFormParameters } from './types';

const fetchCustomForm = ({ projectId, phaseId }: ICustomFormParameters) => {
const apiEndpoint = phaseId
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think for surveys, we will always have a phaseId 🤔. But this might also be in other places so we could probably enforce it separately in another ticket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants