diff --git a/frontend/client/src/controller.js b/frontend/client/src/controller.js
index 4400c57b59..5d236d86d9 100644
--- a/frontend/client/src/controller.js
+++ b/frontend/client/src/controller.js
@@ -126,6 +126,26 @@ Espo.define('controller', [], function () {
return key in this.params;
},
+ getStoredMainView: function (key) {
+ return this.get('storedMainView-' + key);
+ },
+
+ hasStoredMainView: function (key) {
+ return this.has('storedMainView-' + key);
+ },
+
+ clearStoredMainView: function (key) {
+ var view = this.getStoredMainView(key);
+ if (view) {
+ view.remove();
+ }
+ this.unset('storedMainView-' + key);
+ },
+
+ storeMainView: function (key, view) {
+ this.set('storedMainView-' + key, view);
+ },
+
checkAccess: function (action) {
return true;
},
@@ -216,7 +236,7 @@ Espo.define('controller', [], function () {
var process = function (main) {
if (useStored) {
- this.set('storedView-' + storedKey, main);
+ this.storeMainView(storedKey, main);
}
main.once('render', function () {
main.updatePageTitle();
@@ -225,7 +245,8 @@ Espo.define('controller', [], function () {
if (master.currentViewKey) {
this.set('storedScrollTop-' + master.currentViewKey, $(window).scrollTop());
- if (this.has('storedView-' + master.currentViewKey)) {
+ if (this.hasStoredMainView(master.currentViewKey)) {
+ master.nestedViews['main'].undelegateEvents();
delete master.nestedViews['main'];
}
}
@@ -247,8 +268,9 @@ Espo.define('controller', [], function () {
}
}.bind(this);
if (useStored) {
- if (this.has('storedView-' + storedKey)) {
- process(this.get('storedView-' + storedKey));
+ if (this.hasStoredMainView(storedKey)) {
+ var main = this.getStoredMainView(storedKey);
+ process(main);
return;
}
}
diff --git a/frontend/client/src/controllers/record.js b/frontend/client/src/controllers/record.js
index 3658e600d1..ddd073a6a1 100644
--- a/frontend/client/src/controllers/record.js
+++ b/frontend/client/src/controllers/record.js
@@ -71,10 +71,9 @@ Espo.define('controllers/record', 'controller', function (Dep) {
var key = this.name + 'List';
if (!isReturn) {
- var stored = this.get('storedView-' + key);
+ var stored = this.getStoredMainView(key);
if (stored) {
- stored.remove();
- this.unset('storedView-' + key);
+ this.clearStoredMainView(key);
}
}
@@ -83,7 +82,7 @@ Espo.define('controllers/record', 'controller', function (Dep) {
scope: this.name,
collection: collection
}, null, isReturn, key);
- }.bind(this), null, isReturn);
+ }, this, false);
},
beforeView: function () {
@@ -147,6 +146,11 @@ Espo.define('controllers/record', 'controller', function (Dep) {
model.set(options.attributes);
}
+ model.on('sync', function () {
+ var key = this.name + 'List';
+ this.clearStoredMainView(key);
+ }, this);
+
this.main(this.getViewName('edit'), o);
});
},
@@ -231,14 +235,6 @@ Espo.define('controllers/record', 'controller', function (Dep) {
if (usePreviouslyFetched) {
if (collectionName in this.collectionMap) {
var collection = this.collectionMap[collectionName];// = this.collectionMap[collectionName].clone();
- /*var maxSize = this.getConfig().get('recordsPerPage');
- if (collection.length > maxSize) {
- var k = collection.length - maxSize;
- while (k) {
- collection.pop();
- k--;
- }
- }*/
callback.call(context, collection);
return;
}
diff --git a/frontend/client/src/views/detail.js b/frontend/client/src/views/detail.js
index 15c0b04cfe..9ac71cefd3 100644
--- a/frontend/client/src/views/detail.js
+++ b/frontend/client/src/views/detail.js
@@ -193,13 +193,6 @@ Espo.define('views/detail', 'views/main', function (Dep) {
selectBoolFilterLists: [],
- actionNavigateToRoot: function () {
- this.getRouter().dispatch(this.scope, '', {
- isReturn: true
- });
- this.getRouter().navigate('#' + this.scope, {trigger: false});
- },
-
actionCreateRelated: function (data) {
var link = data.link;
var scope = this.model.defs['links'][link].entity;
diff --git a/frontend/client/src/views/edit.js b/frontend/client/src/views/edit.js
index 609daefb96..872e2e96a5 100644
--- a/frontend/client/src/views/edit.js
+++ b/frontend/client/src/views/edit.js
@@ -57,7 +57,7 @@ Espo.define('views/edit', 'views/main', function (Dep) {
if (this.options.noHeaderLinks) {
arr.push(this.getLanguage().translate(this.model.name, 'scopeNamesPlural'));
} else {
- arr.push('' + this.getLanguage().translate(this.model.name, 'scopeNamesPlural') + '');
+ arr.push('' + this.getLanguage().translate(this.model.name, 'scopeNamesPlural') + '');
}
if (this.model.isNew()) {
@@ -67,7 +67,7 @@ Espo.define('views/edit', 'views/main', function (Dep) {
if (this.options.noHeaderLinks) {
arr.push(name);
} else {
- arr.push('' + name + '');
+ arr.push('' + name + '');
}
}
return this.buildHeaderHtml(arr);
diff --git a/frontend/client/src/views/main.js b/frontend/client/src/views/main.js
index 8c852771f4..41cd6cf6e2 100644
--- a/frontend/client/src/views/main.js
+++ b/frontend/client/src/views/main.js
@@ -130,7 +130,17 @@ Espo.define('views/main', 'view', function (Dep) {
if (this.isRendered()) {
this.getView('header').render();
}
+ },
+
+ actionNavigateToRoot: function (data, e) {
+ e.stopPropagation();
+ var options = {
+ isReturn: true
+ };
+ this.getRouter().dispatch(this.scope, null, options);
+ this.getRouter().navigate('#' + this.scope, {trigger: false});
}
+
});
});
diff --git a/frontend/client/src/views/record/detail.js b/frontend/client/src/views/record/detail.js
index 4cc893e673..6a01d3bedf 100644
--- a/frontend/client/src/views/record/detail.js
+++ b/frontend/client/src/views/record/detail.js
@@ -693,9 +693,6 @@ Espo.define('Views.Record.Detail', 'Views.Record.Base', function (Dep) {
return;
}
this.getRouter().navigate(url, {trigger: true});
- },
-
- createField: function () {
}
});