Sha256: b95f153395264b8b6b733f0d7f8c8cbfa6c06d845893554912862704cdea7bd4
Contents?: true
Size: 1.51 KB
Versions: 2
Compression:
Stored size: 1.51 KB
Contents
'use strict' dirtyable = # TODO move ignored diryifing properties to the record ignores: ['dirty', 'resource', 'route', 'initial_route', 'after_initialize', 'before_initialize', 'parent_resource', 'nested_attributes', 'reloading', 'ready', 'saving', 'saved', 'failed', 'salvation', 'sustained', 'element', 'default', 'lock', 'validate', 'validated', 'validation', 'errors', 'dirty', 'json'] reserved_filter: (name) -> @ignores.indexOf(name) == -1 record: after_initialize: [ -> @subscribe (added, removed, changed, past) -> @dirty ||= !!Object.keys($.extend {}, added, removed, changed).filter(dirtyable.reserved_filter, dirtyable).length ] # Shim browsers without Object.observe unless Object.observe $.extend dirtyable, descriptor: get: -> @observed.dirty set: (value) -> @observed.dirty = value @observation.scheduler.schedule() value dirtyable.record.after_initialize.push -> Object.defineProperty @, 'dirty', dirtyable.descriptor # Automatically dirt records without id # FIXME dirtyable.record.after_initialize.push -> # TODO rename _id to id @dirty = !!@_id # Extend indemma model = window.model # TODO better way to get parent record = window.record # TODO better way to get parent model.dirtyable = true record.mix (recordable) -> recordable.after_initialize = recordable.after_initialize.concat dirtyable.record.after_initialize model.mix (modelable ) -> # merge modelable , restful.model `export default dirtyable`
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ende-0.5.22 | components/indefinido/indemma/master/src/lib/record/dirtyable.coffee |
ende-0.5.21 | components/indefinido/indemma/master/src/lib/record/dirtyable.coffee |