ember-cli-simple-store
Advanced tools
Comparing version 0.9.0 to 0.9.1
@@ -33,9 +33,9 @@ import Ember from "ember"; | ||
if (arguments.length === 2) { | ||
if (!this.get("isDirty")) { | ||
if (!this.get("isDirty") && !this.get("isPrimed")) { | ||
var oldState = clone(this); | ||
this.set("_oldState", oldState); | ||
} | ||
var primed = value === "" && !data[key]; | ||
var primed = value === "" && data[key] === undefined; | ||
if(!primed) { | ||
this.set("isDirty", true); | ||
this.set("isPrimed", true); | ||
dirty["%@:isDirty".fmt(key)] = true; | ||
@@ -68,3 +68,3 @@ data[key] = value; | ||
_reset: function() { | ||
this.set("isDirty", false); | ||
this.set("isPrimed", false); | ||
this.set("_dirty", {}); | ||
@@ -74,3 +74,4 @@ }, | ||
var self = this; | ||
attrs(this).forEach(function(attrName) { | ||
var attributes = attrs(this); | ||
attributes.forEach(function(attrName) { | ||
var dynamicKey = "%@IsDirty".fmt(attrName); | ||
@@ -82,5 +83,16 @@ Ember.defineProperty(self, dynamicKey, Ember.computed(function() { | ||
var dirtyKey = "%@:isDirty".fmt(attrName); | ||
return original === current ? undefined : dirty[dirtyKey]; | ||
var dirtyCheck = (original === current) || (original === undefined && current === ""); | ||
return dirtyCheck ? undefined : dirty[dirtyKey]; | ||
}).property("_dirty", "" + attrName)); | ||
}); | ||
var modelIsDirtyAttrs = []; | ||
attributes.forEach(function(attr) { | ||
modelIsDirtyAttrs.push(attr + "IsDirty"); | ||
}); | ||
Ember.defineProperty(this, "isDirty", Ember.computed(function() { | ||
var modelAttrs = modelIsDirtyAttrs.filter(function(attr){ | ||
return self.get(attr) === true; | ||
}); | ||
return modelAttrs.length > 0; | ||
}).property("" + modelIsDirtyAttrs)); | ||
} | ||
@@ -87,0 +99,0 @@ }); |
{ | ||
"name": "ember-cli-simple-store", | ||
"version": "0.9.0", | ||
"version": "0.9.1", | ||
"description": "ember-cli addon that provides a simple identity map for ember.js web applications", | ||
@@ -5,0 +5,0 @@ "directories": { |
# ember-cli-simple-store | ||
[![Build Status][]](https://travis-ci.org/toranb/ember-cli-simple-store) | ||
[![Downloads](https://img.shields.io/npm/dm/ember-cli-simple-store.svg)](https://www.npmjs.com/package/ember-cli-simple-store) | ||
[![Score](http://emberobserver.com/badges/ember-cli-simple-store.svg)](http://emberobserver.com/addons/ember-cli-simple-store) | ||
@@ -5,0 +7,0 @@ ## Description |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17039
21
11
220
232
1