fix list view return

This commit is contained in:
yuri
2015-09-04 11:36:19 +03:00
parent 118025f646
commit d6ef8e1b33
6 changed files with 46 additions and 28 deletions
+26 -4
View File
@@ -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;
}
}
+8 -12
View File
@@ -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;
}
-7
View File
@@ -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;
+2 -2
View File
@@ -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('<a href="#' + this.model.name + '">' + this.getLanguage().translate(this.model.name, 'scopeNamesPlural') + '</a>');
arr.push('<a href="#' + this.model.name + '" class="action" data-action="navigateToRoot">' + this.getLanguage().translate(this.model.name, 'scopeNamesPlural') + '</a>');
}
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('<a href="#' + this.model.name + '/view/' + this.model.id + '">' + name + '</a>');
arr.push('<a href="#' + this.model.name + '/view/' + this.model.id + '" class="action" data-action="navigateToRoot">' + name + '</a>');
}
}
return this.buildHeaderHtml(arr);
+10
View File
@@ -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});
}
});
});
@@ -693,9 +693,6 @@ Espo.define('Views.Record.Detail', 'Views.Record.Base', function (Dep) {
return;
}
this.getRouter().navigate(url, {trigger: true});
},
createField: function () {
}
});