ensure the data type refs are only loaded when the tab is activated
This commit is contained in:
@@ -155,13 +155,6 @@ function DataTypeEditController($scope, $routeParams, appState, navigationServic
|
||||
eventsService.unsubscribe(evts[e]);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function init() {
|
||||
|
||||
@@ -227,7 +220,7 @@ function DataTypeEditController($scope, $routeParams, appState, navigationServic
|
||||
},
|
||||
{
|
||||
"name": values[1],
|
||||
"alias": "parameters",
|
||||
"alias": "relations",
|
||||
"icon": "icon-molecular-network",
|
||||
"view": "views/datatypes/views/datatype.relations.html"
|
||||
}
|
||||
|
||||
+30
-10
@@ -6,9 +6,11 @@
|
||||
* @description
|
||||
* The controller for the relations view of the datatype editor
|
||||
*/
|
||||
function DataTypeRelationsController($scope, $routeParams, dataTypeResource) {
|
||||
function DataTypeRelationsController($scope, $routeParams, dataTypeResource, eventsService, $timeout) {
|
||||
|
||||
var vm = this;
|
||||
var evts = [];
|
||||
var relationsLoaded = false;
|
||||
|
||||
vm.relations = {};
|
||||
vm.hasRelations = false;
|
||||
@@ -16,18 +18,36 @@ function DataTypeRelationsController($scope, $routeParams, dataTypeResource) {
|
||||
vm.view = {};
|
||||
vm.view.loading = true;
|
||||
|
||||
//we are editing so get the content item from the server
|
||||
dataTypeResource.getReferences($routeParams.id)
|
||||
.then(function (data) {
|
||||
|
||||
vm.view.loading = false;
|
||||
vm.relations = data;
|
||||
|
||||
vm.hasRelations = vm.relations.documentTypes.length > 0 || vm.relations.mediaTypes.length > 0 || vm.relations.memberTypes.length > 0;
|
||||
|
||||
/** Loads in the data type relations one time */
|
||||
function loadRelations() {
|
||||
if (!relationsLoaded) {
|
||||
relationsLoaded = true;
|
||||
dataTypeResource.getReferences($routeParams.id)
|
||||
.then(function (data) {
|
||||
vm.view.loading = false;
|
||||
vm.relations = data;
|
||||
vm.hasRelations = vm.relations.documentTypes.length > 0 || vm.relations.mediaTypes.length > 0 || vm.relations.memberTypes.length > 0;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// load data type relations when the relations tab is activated
|
||||
evts.push(eventsService.on("app.tabChange", function (event, args) {
|
||||
$timeout(function () {
|
||||
if (args.alias === "relations") {
|
||||
loadRelations();
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
//ensure to unregister from all events!
|
||||
$scope.$on('$destroy', function () {
|
||||
for (var e in evts) {
|
||||
eventsService.unsubscribe(evts[e]);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user