-
Notifications
You must be signed in to change notification settings - Fork 87
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
isDirty flag #58
Comments
There is currently no such thing. It seems like a useful idea. How would you want it to work? |
The flag would be set to false unless one of the items in the form was updated. Then it would be set to true and then optionally an array of FormItems that are "dirty" |
when should the dirty flag be cleared? |
when the form is first loaded.. All of the dirty properties of each item is cleared. Once a form item has been updated the dirty property for the item is set to true. There should also be a call the resets all of the dirty properties to clear (once a db has been updated). Thoughts? |
Thoughts For subclasses of If a child viewcontroller is presented, should it propagate It seems doable. However I think it's dangerous to assume that the UI keeps the correct state of the data model, so the state may get out of sync if users aren't careful. Maybe it's an antipattern. |
Hmmm good point.. let me think about that today. When you call validateAndReloadUI does the view not keep the state? I have the object that is used to set the initial values, I could read them all and do the comparison myself, just didn't know if a flag could work |
Thoughts? |
Do you want to discuss this via FaceTime/Signal. +45 27592923 |
we could .. let me carve out some time that works with our timezones |
hey @neoneye sorry I've. been away.. crazy two weeks here. I think I have an idea that I'm going to look in the code. You have a value object for every form item. My suggestion is to have a originalValue field that is set when the form gets loaded initially. Then at an time isDirty() is called, the form enumerates the formitems and does a simple comparison against the current value and original value. Anytime there is not an exact match, the function returns false. |
Sorry, I'm still not sure exactly how you want it to be like. I am familiar with using dirty flags, and have been doing in the past, so it's not that I don't know about it. Can you make some example code of how you want it to be like? |
Sure.. so if I have 3 form items and I don't change any of the values in those 3; when I call isDirty, the return would be false. if I update the value that is at TextFormItem1 and call isDirty, the return would be true and optionally provide the id's of what TextFormItems have been updated. This way I can present a form and if the user does not change anything and presses back I can allow it. If I check isDirty and it returns true, then I can prompt the user that changes have been made to the form and ask them if they want to commit. |
So I finally have time to get back to this. I'll update the code I just need to understand what "innerValue" is. Is there a concept in the model that has the original value vs what is currently in that field? |
The TextFieldFormItem.swift has a The |
so I think I'm going to add a new property then along the lines of INITIAL value. Then create a new function isDirty() that will do much the same that validation does with the exception that it will do a check to see if the value that is in innerValue is different than that of the INITIAL value |
Cool. Looking forward to see what you come up with. |
Ok going to work on this over the holidays. I'm going to try and add a propertyof "original value" and then compare that when isDirty is called with the current contents.. |
Is there a concept of if a form is "dirty" (has been edited) vs just displayed that you can check when someone presses a back key to see if anything has been updated?
The text was updated successfully, but these errors were encountered: