{"action":"created","issue":{"url":"https://api.github.com/repos/xpepermint/contextablejs/issues/4","repository_url":"https://api.github.com/repos/xpepermint/contextablejs","labels_url":"https://api.github.com/repos/xpepermint/contextablejs/issues/4/labels{/name}","comments_url":"https://api.github.com/repos/xpepermint/contextablejs/issues/4/comments","events_url":"https://api.github.com/repos/xpepermint/contextablejs/issues/4/events","html_url":"https://github.com/xpepermint/contextablejs/issues/4","id":193720579,"number":4,"title":"Saving only changed and valid fields","user":{"login":"xpepermint","id":174279,"avatar_url":"https://avatars.githubusercontent.com/u/174279?v=3","gravatar_id":"","url":"https://api.github.com/users/xpepermint","html_url":"https://github.com/xpepermint","followers_url":"https://api.github.com/users/xpepermint/followers","following_url":"https://api.github.com/users/xpepermint/following{/other_user}","gists_url":"https://api.github.com/users/xpepermint/gists{/gist_id}","starred_url":"https://api.github.com/users/xpepermint/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xpepermint/subscriptions","organizations_url":"https://api.github.com/users/xpepermint/orgs","repos_url":"https://api.github.com/users/xpepermint/repos","events_url":"https://api.github.com/users/xpepermint/events{/privacy}","received_events_url":"https://api.github.com/users/xpepermint/received_events","type":"User","site_admin":false},"labels":[{"id":437453816,"url":"https://api.github.com/repos/xpepermint/contextablejs/labels/enhancement","name":"enhancement","color":"84b6eb","default":true},{"id":488582180,"url":"https://api.github.com/repos/xpepermint/contextablejs/labels/feature","name":"feature","color":"5319e7","default":false},{"id":437453819,"url":"https://api.github.com/repos/xpepermint/contextablejs/labels/question","name":"question","color":"cc317c","default":true}],"state":"open","locked":false,"assignee":{"login":"xpepermint","id":174279,"avatar_url":"https://avatars.githubusercontent.com/u/174279?v=3","gravatar_id":"","url":"https://api.github.com/users/xpepermint","html_url":"https://github.com/xpepermint","followers_url":"https://api.github.com/users/xpepermint/followers","following_url":"https://api.github.com/users/xpepermint/following{/other_user}","gists_url":"https://api.github.com/users/xpepermint/gists{/gist_id}","starred_url":"https://api.github.com/users/xpepermint/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xpepermint/subscriptions","organizations_url":"https://api.github.com/users/xpepermint/orgs","repos_url":"https://api.github.com/users/xpepermint/repos","events_url":"https://api.github.com/users/xpepermint/events{/privacy}","received_events_url":"https://api.github.com/users/xpepermint/received_events","type":"User","site_admin":false},"assignees":[{"login":"xpepermint","id":174279,"avatar_url":"https://avatars.githubusercontent.com/u/174279?v=3","gravatar_id":"","url":"https://api.github.com/users/xpepermint","html_url":"https://github.com/xpepermint","followers_url":"https://api.github.com/users/xpepermint/followers","following_url":"https://api.github.com/users/xpepermint/following{/other_user}","gists_url":"https://api.github.com/users/xpepermint/gists{/gist_id}","starred_url":"https://api.github.com/users/xpepermint/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xpepermint/subscriptions","organizations_url":"https://api.github.com/users/xpepermint/orgs","repos_url":"https://api.github.com/users/xpepermint/repos","events_url":"https://api.github.com/users/xpepermint/events{/privacy}","received_events_url":"https://api.github.com/users/xpepermint/received_events","type":"User","site_admin":false}],"milestone":null,"comments":2,"created_at":"2016-12-06T09:20:52Z","updated_at":"2016-12-06T19:28:26Z","closed_at":null,"body":"by @michaelsorich, at https://github.com/xpepermint/vue-contextable/issues/4\r\n\r\nI will eventually have a rather large model and I intend to regularly autosave the model via a rest api. I intend to send only the fields and values that have changed since the last save which typically will only be a small fraction of the model (I could send a serialized version of the complete model and let the server sort it out, but I am hoping that I can do so on the client and only send the pertinent changes).\r\n\r\nThe presence of one or more fields that are currently invalid will not prevent saving. Currently I am intending that fields that are invalid will not be sent to the server for saving, but other valid changed fields will be sent (even though some fields are invalid).\r\n\r\nThus, “if (m.isChanged() && m.isValid())” isn’t quite what I wish as it will only be true if all fields are valid. As long as there is at least one field that is both changed and valid then the result should be true (i.e. there is data that can be sent to the server as a partial update/PATCH). I am happy to implement this as a new method on extended model and field classes so this is not too much of an issue if I can work out how to properly extend Model and Field.\r\n\r\nIn vue-contextable, the construction of the Model instance is not explicit. For example, I cannot see something like ‘let m = Model(…)’ - if so it would be trivial to substitute my extended version of the ReactiveModel.\r\n\r\nBased on the example, my understanding of the standard setup is:\r\n\r\n* A contextable context object is made (const context = new Context())\r\n\r\n* Then a schema is passed in which appears to create a contextable.Model instance (e.g. context.defineModel('User', new Schema(…)) which is then stored in the context object. It would not seem easy to replace Model with an extended version at this stage without rewriting context.defineModel and createModel.\r\n\r\nIt is possible to access the Model from the context but not to set the model which seems to make it difficult to replace it with an extended version at this stage (e.g. class Modelv2 extends context[‘Lease’]{…}; context[‘Lease’] = Modelv2).\r\n\r\n* I presume that somewhere in the initialisation process (not sure where) the defineReactiveModel function from vue-contextable is called which retrieves the model from the context, extends it (to become a ReactiveModel), and then stores it in the vm variable. It is not clear to me how I would override the ReactiveModel definition (which is itself embedded in a defineReactiveModel function) in order to replace it with an extended version which would be called by the appropriate function in the course of initialization.\r\n\r\nThere is likely a much simpler way of extending the functionality of ReactiveModel and Field but I am not seeing it at the moment. Any hints would be appreciated."},"comment":{"url":"https://api.github.com/repos/xpepermint/contextablejs/issues/comments/265247530","html_url":"https://github.com/xpepermint/contextablejs/issues/4#issuecomment-265247530","issue_url":"https://api.github.com/repos/xpepermint/contextablejs/issues/4","id":265247530,"user":{"login":"xpepermint","id":174279,"avatar_url":"https://avatars.githubusercontent.com/u/174279?v=3","gravatar_id":"","url":"https://api.github.com/users/xpepermint","html_url":"https://github.com/xpepermint","followers_url":"https://api.github.com/users/xpepermint/followers","following_url":"https://api.github.com/users/xpepermint/following{/other_user}","gists_url":"https://api.github.com/users/xpepermint/gists{/gist_id}","starred_url":"https://api.github.com/users/xpepermint/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xpepermint/subscriptions","organizations_url":"https://api.github.com/users/xpepermint/orgs","repos_url":"https://api.github.com/users/xpepermint/repos","events_url":"https://api.github.com/users/xpepermint/events{/privacy}","received_events_url":"https://api.github.com/users/xpepermint/received_events","type":"User","site_admin":false},"created_at":"2016-12-06T19:28:26Z","updated_at":"2016-12-06T19:28:26Z","body":"A quick follow up ... I started upgrading the underlying [objectschema](https://github.com/xpepermint/objectschemajs) package. I hope I'll finish it by tomorrow. After this upgrade a new `filter` method will be available thus you will be able to extract an object with keys that pass the `test`:\r\n\r\n```js\r\nmodel.serialize() // -> convert to Object\r\nmodel.filter((field) => field.isChanged() && field.isValid()) // -> convert to Object with changed and valid keys\r\n```\r\n"}}
{"actor":{"display_login":"xpepermint"}}