fixes references issue
This commit is contained in:
@@ -10,7 +10,7 @@ class Note extends Item {
|
|||||||
if(!this.content.title) {
|
if(!this.content.title) {
|
||||||
this.content.title = "";
|
this.content.title = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!this.content.text) {
|
if(!this.content.text) {
|
||||||
this.content.text = "";
|
this.content.text = "";
|
||||||
}
|
}
|
||||||
@@ -31,15 +31,12 @@ class Note extends Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get hasOnePublicTag() {
|
get hasOnePublicTag() {
|
||||||
var hasPublicTag = false;
|
for (var tag of this.tags) {
|
||||||
this.tags.forEach(function(tag){
|
|
||||||
if(tag.isPublic()) {
|
if(tag.isPublic()) {
|
||||||
hasPublicTag = true;
|
return true
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
return false;
|
||||||
return hasPublicTag;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
toJSON() {
|
toJSON() {
|
||||||
|
|||||||
@@ -443,7 +443,7 @@ angular.module('app.frontend')
|
|||||||
|
|
||||||
this.loadLocalItemsAndUser = function() {
|
this.loadLocalItemsAndUser = function() {
|
||||||
var user = {};
|
var user = {};
|
||||||
var items = JSON.parse(localStorage.getItem('items'));
|
var items = JSON.parse(localStorage.getItem('items')) || [];
|
||||||
items = modelManager.mapResponseItemsToLocalModels(items);
|
items = modelManager.mapResponseItemsToLocalModels(items);
|
||||||
Item.sortItemsByDate(items);
|
Item.sortItemsByDate(items);
|
||||||
user.items = items;
|
user.items = items;
|
||||||
|
|||||||
@@ -16,6 +16,40 @@ class ItemManager {
|
|||||||
this._items = _.uniq(this.items.concat(items));
|
this._items = _.uniq(this.items.concat(items));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mapResponseItemsToLocalModels(items) {
|
||||||
|
var models = []
|
||||||
|
for (var json_obj of items) {
|
||||||
|
var item = this.findItem(json_obj["uuid"]);
|
||||||
|
if(json_obj["deleted"] == true) {
|
||||||
|
if(item) {
|
||||||
|
this.deleteItem(item)
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(item) {
|
||||||
|
_.merge(item, json_obj);
|
||||||
|
} else {
|
||||||
|
item = this.createItem(json_obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
models.push(item)
|
||||||
|
}
|
||||||
|
this.addItems(models)
|
||||||
|
this.resolveReferences()
|
||||||
|
return models;
|
||||||
|
}
|
||||||
|
|
||||||
|
createItem(json_obj) {
|
||||||
|
if(json_obj.content_type == "Note") {
|
||||||
|
return new Note(json_obj);
|
||||||
|
} else if(json_obj.content_type == "Tag") {
|
||||||
|
return new Tag(json_obj);
|
||||||
|
} else {
|
||||||
|
return new Item(json_obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
resolveReferences() {
|
resolveReferences() {
|
||||||
this.items.forEach(function(item){
|
this.items.forEach(function(item){
|
||||||
// build out references, safely handle broken references
|
// build out references, safely handle broken references
|
||||||
|
|||||||
@@ -7,45 +7,9 @@ class ModelManager extends ItemManager {
|
|||||||
this.dirtyItems = [];
|
this.dirtyItems = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
// get items() {
|
resolveReferences() {
|
||||||
// return super.items()
|
super.resolveReferences()
|
||||||
// }
|
|
||||||
|
|
||||||
mapResponseItemsToLocalModels(items) {
|
|
||||||
var models = []
|
|
||||||
for (var json_obj of items) {
|
|
||||||
var item = this.findItem(json_obj["uuid"]);
|
|
||||||
if(json_obj["deleted"] == true) {
|
|
||||||
if(item) {
|
|
||||||
this.deleteItem(item)
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(item) {
|
|
||||||
_.merge(item, json_obj);
|
|
||||||
} else {
|
|
||||||
item = this.createItem(json_obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
models.push(item)
|
|
||||||
}
|
|
||||||
this.addItems(models)
|
|
||||||
return models;
|
|
||||||
}
|
|
||||||
|
|
||||||
createItem(json_obj) {
|
|
||||||
if(json_obj.content_type == "Note") {
|
|
||||||
return new Note(json_obj);
|
|
||||||
} else if(json_obj.content_type == "Tag") {
|
|
||||||
return new Tag(json_obj);
|
|
||||||
} else {
|
|
||||||
return new Item(json_obj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
addItems(items) {
|
|
||||||
super.addItems(items)
|
|
||||||
this.notes = this.itemsForContentType("Note");
|
this.notes = this.itemsForContentType("Note");
|
||||||
this.notes.forEach(function(note){
|
this.notes.forEach(function(note){
|
||||||
note.updateReferencesLocalMapping();
|
note.updateReferencesLocalMapping();
|
||||||
|
|||||||
@@ -32,23 +32,6 @@
|
|||||||
<%= javascript_include_tag "compiled.js", debug: true %>
|
<%= javascript_include_tag "compiled.js", debug: true %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= javascript_include_tag "compiled.min.js", debug: false %>
|
<%= javascript_include_tag "compiled.min.js", debug: false %>
|
||||||
|
|
||||||
<!-- Piwik -->
|
|
||||||
<script type="text/javascript">
|
|
||||||
var _paq = _paq || [];
|
|
||||||
_paq.push(['trackPageView']);
|
|
||||||
_paq.push(['enableLinkTracking']);
|
|
||||||
(function() {
|
|
||||||
var u="//dash.neeto.io/";
|
|
||||||
_paq.push(['setTrackerUrl', u+'piwik.php']);
|
|
||||||
_paq.push(['setSiteId', '1']);
|
|
||||||
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
|
|
||||||
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
|
|
||||||
})();
|
|
||||||
</script>
|
|
||||||
<noscript><p><img src="//dash.neeto.io/piwik.php?idsite=1" style="border:0;" alt="" /></p></noscript>
|
|
||||||
<!-- End Piwik Code -->
|
|
||||||
|
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= stylesheet_link_tag "app", media: "all", debug: false %>
|
<%= stylesheet_link_tag "app", media: "all", debug: false %>
|
||||||
|
|
||||||
|
|||||||
183
vendor/assets/javascripts/transpiled.js
vendored
183
vendor/assets/javascripts/transpiled.js
vendored
@@ -1419,15 +1419,34 @@ var Note = function (_Item) {
|
|||||||
}, {
|
}, {
|
||||||
key: 'hasOnePublicTag',
|
key: 'hasOnePublicTag',
|
||||||
get: function get() {
|
get: function get() {
|
||||||
var hasPublicTag = false;
|
var _iteratorNormalCompletion = true;
|
||||||
this.tags.forEach(function (tag) {
|
var _didIteratorError = false;
|
||||||
if (tag.isPublic()) {
|
var _iteratorError = undefined;
|
||||||
hasPublicTag = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return hasPublicTag;
|
try {
|
||||||
|
for (var _iterator = this.tags[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
||||||
|
var tag = _step.value;
|
||||||
|
|
||||||
|
if (tag.isPublic()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
_didIteratorError = true;
|
||||||
|
_iteratorError = err;
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
if (!_iteratorNormalCompletion && _iterator.return) {
|
||||||
|
_iterator.return();
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
if (_didIteratorError) {
|
||||||
|
throw _iteratorError;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
key: 'content_type',
|
key: 'content_type',
|
||||||
@@ -1921,7 +1940,7 @@ var User = function User(json_obj) {
|
|||||||
|
|
||||||
this.loadLocalItemsAndUser = function () {
|
this.loadLocalItemsAndUser = function () {
|
||||||
var user = {};
|
var user = {};
|
||||||
var items = JSON.parse(localStorage.getItem('items'));
|
var items = JSON.parse(localStorage.getItem('items')) || [];
|
||||||
items = modelManager.mapResponseItemsToLocalModels(items);
|
items = modelManager.mapResponseItemsToLocalModels(items);
|
||||||
Item.sortItemsByDate(items);
|
Item.sortItemsByDate(items);
|
||||||
user.items = items;
|
user.items = items;
|
||||||
@@ -2005,13 +2024,13 @@ var User = function User(json_obj) {
|
|||||||
|
|
||||||
this.decryptItems = function (items) {
|
this.decryptItems = function (items) {
|
||||||
var masterKey = this.retrieveMk();
|
var masterKey = this.retrieveMk();
|
||||||
var _iteratorNormalCompletion = true;
|
var _iteratorNormalCompletion2 = true;
|
||||||
var _didIteratorError = false;
|
var _didIteratorError2 = false;
|
||||||
var _iteratorError = undefined;
|
var _iteratorError2 = undefined;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (var _iterator = items[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
for (var _iterator2 = items[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
||||||
var item = _step.value;
|
var item = _step2.value;
|
||||||
|
|
||||||
if (item.deleted == true) {
|
if (item.deleted == true) {
|
||||||
continue;
|
continue;
|
||||||
@@ -2026,16 +2045,16 @@ var User = function User(json_obj) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
_didIteratorError = true;
|
_didIteratorError2 = true;
|
||||||
_iteratorError = err;
|
_iteratorError2 = err;
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
if (!_iteratorNormalCompletion && _iterator.return) {
|
if (!_iteratorNormalCompletion2 && _iterator2.return) {
|
||||||
_iterator.return();
|
_iterator2.return();
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
if (_didIteratorError) {
|
if (_didIteratorError2) {
|
||||||
throw _iteratorError;
|
throw _iteratorError2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2426,6 +2445,64 @@ var ItemManager = function () {
|
|||||||
value: function addItems(items) {
|
value: function addItems(items) {
|
||||||
this._items = _.uniq(this.items.concat(items));
|
this._items = _.uniq(this.items.concat(items));
|
||||||
}
|
}
|
||||||
|
}, {
|
||||||
|
key: 'mapResponseItemsToLocalModels',
|
||||||
|
value: function mapResponseItemsToLocalModels(items) {
|
||||||
|
var models = [];
|
||||||
|
var _iteratorNormalCompletion3 = true;
|
||||||
|
var _didIteratorError3 = false;
|
||||||
|
var _iteratorError3 = undefined;
|
||||||
|
|
||||||
|
try {
|
||||||
|
for (var _iterator3 = items[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
|
||||||
|
var json_obj = _step3.value;
|
||||||
|
|
||||||
|
var item = this.findItem(json_obj["uuid"]);
|
||||||
|
if (json_obj["deleted"] == true) {
|
||||||
|
if (item) {
|
||||||
|
this.deleteItem(item);
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item) {
|
||||||
|
_.merge(item, json_obj);
|
||||||
|
} else {
|
||||||
|
item = this.createItem(json_obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
models.push(item);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
_didIteratorError3 = true;
|
||||||
|
_iteratorError3 = err;
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
if (!_iteratorNormalCompletion3 && _iterator3.return) {
|
||||||
|
_iterator3.return();
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
if (_didIteratorError3) {
|
||||||
|
throw _iteratorError3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.addItems(models);
|
||||||
|
this.resolveReferences();
|
||||||
|
return models;
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
key: 'createItem',
|
||||||
|
value: function createItem(json_obj) {
|
||||||
|
if (json_obj.content_type == "Note") {
|
||||||
|
return new Note(json_obj);
|
||||||
|
} else if (json_obj.content_type == "Tag") {
|
||||||
|
return new Tag(json_obj);
|
||||||
|
} else {
|
||||||
|
return new Item(json_obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
}, {
|
}, {
|
||||||
key: 'resolveReferences',
|
key: 'resolveReferences',
|
||||||
value: function resolveReferences() {
|
value: function resolveReferences() {
|
||||||
@@ -2529,71 +2606,11 @@ var ModelManager = function (_ItemManager) {
|
|||||||
return _this5;
|
return _this5;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get items() {
|
|
||||||
// return super.items()
|
|
||||||
// }
|
|
||||||
|
|
||||||
_createClass(ModelManager, [{
|
_createClass(ModelManager, [{
|
||||||
key: 'mapResponseItemsToLocalModels',
|
key: 'resolveReferences',
|
||||||
value: function mapResponseItemsToLocalModels(items) {
|
value: function resolveReferences() {
|
||||||
var models = [];
|
_get(ModelManager.prototype.__proto__ || Object.getPrototypeOf(ModelManager.prototype), 'resolveReferences', this).call(this);
|
||||||
var _iteratorNormalCompletion2 = true;
|
|
||||||
var _didIteratorError2 = false;
|
|
||||||
var _iteratorError2 = undefined;
|
|
||||||
|
|
||||||
try {
|
|
||||||
for (var _iterator2 = items[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
|
||||||
var json_obj = _step2.value;
|
|
||||||
|
|
||||||
var item = this.findItem(json_obj["uuid"]);
|
|
||||||
if (json_obj["deleted"] == true) {
|
|
||||||
if (item) {
|
|
||||||
this.deleteItem(item);
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (item) {
|
|
||||||
_.merge(item, json_obj);
|
|
||||||
} else {
|
|
||||||
item = this.createItem(json_obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
models.push(item);
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
_didIteratorError2 = true;
|
|
||||||
_iteratorError2 = err;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
if (!_iteratorNormalCompletion2 && _iterator2.return) {
|
|
||||||
_iterator2.return();
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
if (_didIteratorError2) {
|
|
||||||
throw _iteratorError2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.addItems(models);
|
|
||||||
return models;
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
key: 'createItem',
|
|
||||||
value: function createItem(json_obj) {
|
|
||||||
if (json_obj.content_type == "Note") {
|
|
||||||
return new Note(json_obj);
|
|
||||||
} else if (json_obj.content_type == "Tag") {
|
|
||||||
return new Tag(json_obj);
|
|
||||||
} else {
|
|
||||||
return new Item(json_obj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
key: 'addItems',
|
|
||||||
value: function addItems(items) {
|
|
||||||
_get(ModelManager.prototype.__proto__ || Object.getPrototypeOf(ModelManager.prototype), 'addItems', this).call(this, items);
|
|
||||||
this.notes = this.itemsForContentType("Note");
|
this.notes = this.itemsForContentType("Note");
|
||||||
this.notes.forEach(function (note) {
|
this.notes.forEach(function (note) {
|
||||||
note.updateReferencesLocalMapping();
|
note.updateReferencesLocalMapping();
|
||||||
|
|||||||
2
vendor/assets/javascripts/transpiled.js.map
vendored
2
vendor/assets/javascripts/transpiled.js.map
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user