ATLAS-1812: On browser refresh if, tag is doesn't exist, then URL should update with the first tag.
Signed-off-by: Madhan Neethiraj <madhan@apache.org>
diff --git a/dashboardv2/public/js/router/Router.js b/dashboardv2/public/js/router/Router.js
index 6bec26d..f1250e7 100644
--- a/dashboardv2/public/js/router/Router.js
+++ b/dashboardv2/public/js/router/Router.js
@@ -181,8 +181,19 @@
'views/business_catalog/SideNavLayoutView',
'views/tag/TagDetailLayoutView',
], function(Header, BusinessCatalogLayoutView, SideNavLayoutView, TagDetailLayoutView) {
+ var paramObj = Utils.getUrlState.getQueryParams(),
+ url = Utils.getUrlState.getQueryUrl().queyParams[0];
App.rNHeader.show(new Header());
if (!App.rSideNav.currentView) {
+ if (paramObj && paramObj.dlttag) {
+ Utils.setUrl({
+ url: url,
+ trigger: false,
+ updateTabState: function() {
+ return { tagUrl: this.url, stateChanged: true };
+ }
+ });
+ }
App.rSideNav.show(new SideNavLayoutView(
_.extend({
'tag': tagName,
@@ -190,11 +201,24 @@
}, that.preFetchedCollectionLists)
));
} else {
+ if (paramObj && paramObj.dlttag) {
+ Utils.setUrl({
+ url: url,
+ trigger: false,
+ updateTabState: function() {
+ return { tagUrl: this.url, stateChanged: true };
+ }
+ });
+ }
App.rSideNav.currentView.RTagLayoutView.currentView.manualRender(tagName);
App.rSideNav.currentView.selectTab();
}
-
if (tagName) {
+ // updating paramObj to check for new queryparam.
+ paramObj = Utils.getUrlState.getQueryParams();
+ if (paramObj && paramObj.dlttag) {
+ return false;
+ }
App.rNContent.show(new TagDetailLayoutView(
_.extend({
'tag': tagName,
diff --git a/dashboardv2/public/js/views/business_catalog/SideNavLayoutView.js b/dashboardv2/public/js/views/business_catalog/SideNavLayoutView.js
index 8c67d11..af18540 100644
--- a/dashboardv2/public/js/views/business_catalog/SideNavLayoutView.js
+++ b/dashboardv2/public/js/views/business_catalog/SideNavLayoutView.js
@@ -74,7 +74,6 @@
}
},
onRender: function() {
- this.bindEvent();
this.renderTagLayoutView();
this.renderSearchLayoutView();
if (Globals.taxonomy) {
@@ -83,7 +82,6 @@
this.selectTab();
},
- bindEvent: function() {},
rendeBusinessCatalogLayoutView: function() {
var that = this;
require(['views/business_catalog/BusinessCatalogLayoutView'], function(BusinessCatalogLayoutView) {
diff --git a/dashboardv2/public/js/views/entity/CreateEntityLayoutView.js b/dashboardv2/public/js/views/entity/CreateEntityLayoutView.js
index 44dd898..12edab6 100644
--- a/dashboardv2/public/js/views/entity/CreateEntityLayoutView.js
+++ b/dashboardv2/public/js/views/entity/CreateEntityLayoutView.js
@@ -583,7 +583,11 @@
that.callback();
} else {
if (model.mutatedEntities && model.mutatedEntities.CREATE && _.isArray(model.mutatedEntities.CREATE) && model.mutatedEntities.CREATE[0] && model.mutatedEntities.CREATE[0].guid) {
- that.setUrl('#!/detailPage/' + (model.mutatedEntities.CREATE[0].guid), true);
+ Utils.setUrl({
+ url: '#!/detailPage/' + (model.mutatedEntities.CREATE[0].guid),
+ mergeBrowserUrl: false,
+ trigger: true
+ });
}
}
},
@@ -599,16 +603,6 @@
that.hideLoader();
}
},
- setUrl: function(url, create) {
- Utils.setUrl({
- url: url,
- mergeBrowserUrl: false,
- trigger: true,
- updateTabState: function() {
- return { tagUrl: this.url, stateChanged: true };
- }
- });
- },
showLoader: function() {
this.$('.entityLoader').show();
this.$('.entityInputData').hide();
diff --git a/dashboardv2/public/js/views/schema/SchemaLayoutView.js b/dashboardv2/public/js/views/schema/SchemaLayoutView.js
index d069c44..6f9b6e3 100644
--- a/dashboardv2/public/js/views/schema/SchemaLayoutView.js
+++ b/dashboardv2/public/js/views/schema/SchemaLayoutView.js
@@ -246,7 +246,7 @@
});
});
},
- getSchemaTableColumns: function(deleteEnity) {
+ getSchemaTableColumns: function() {
var that = this,
col = {
Check: {
diff --git a/dashboardv2/public/js/views/search/SearchResultLayoutView.js b/dashboardv2/public/js/views/search/SearchResultLayoutView.js
index 50e4a54..cf751e8 100644
--- a/dashboardv2/public/js/views/search/SearchResultLayoutView.js
+++ b/dashboardv2/public/js/views/search/SearchResultLayoutView.js
@@ -126,7 +126,7 @@
* @constructs
*/
initialize: function(options) {
- _.extend(this, _.pick(options, 'value', 'initialView', 'entityDefCollection', 'typeHeaders', 'searchVent', 'enumDefCollection'));
+ _.extend(this, _.pick(options, 'value', 'initialView', 'entityDefCollection', 'typeHeaders', 'searchVent', 'enumDefCollection', 'tagCollection'));
var pagination = "";
this.entityModel = new VEntity();
this.searchCollection = new VSearchList();
diff --git a/dashboardv2/public/js/views/tag/TagDetailLayoutView.js b/dashboardv2/public/js/views/tag/TagDetailLayoutView.js
index 5007427..3bb27c3 100644
--- a/dashboardv2/public/js/views/tag/TagDetailLayoutView.js
+++ b/dashboardv2/public/js/views/tag/TagDetailLayoutView.js
@@ -44,7 +44,7 @@
* @constructs
*/
initialize: function(options) {
- _.extend(this, _.pick(options, 'tag', 'collection', 'entityDefCollection', 'typeHeaders'));
+ _.extend(this, _.pick(options, 'tag', 'collection', 'entityDefCollection', 'typeHeaders', 'enumDefCollection'));
},
bindEvents: function() {},
onRender: function() {
@@ -58,20 +58,26 @@
'tag': that.tag,
'searchType': 'basic'
};
- that.RSearchResultLayoutView.show(new SearchResultLayoutView({
- value: value,
- entityDefCollection: that.entityDefCollection,
- typeHeaders: that.typeHeaders
- }));
+ if (that.RSearchResultLayoutView) {
+ that.RSearchResultLayoutView.show(new SearchResultLayoutView({
+ value: value,
+ entityDefCollection: that.entityDefCollection,
+ typeHeaders: that.typeHeaders,
+ tagCollection: that.collection,
+ enumDefCollection: that.enumDefCollection
+ }));
+ }
});
},
renderTagAttributeCompositeView: function() {
var that = this;
require(['views/tag/TagAttributeDetailLayoutView'], function(TagAttributeDetailLayoutView) {
- that.RTagAttributeDetailLayoutView.show(new TagAttributeDetailLayoutView({
- tag: that.tag,
- collection: that.collection
- }));
+ if (that.RTagAttributeDetailLayoutView) {
+ that.RTagAttributeDetailLayoutView.show(new TagAttributeDetailLayoutView({
+ tag: that.tag,
+ collection: that.collection
+ }));
+ }
});
}
});
diff --git a/dashboardv2/public/js/views/tag/TagLayoutView.js b/dashboardv2/public/js/views/tag/TagLayoutView.js
index ae7c594..a5b5665 100644
--- a/dashboardv2/public/js/views/tag/TagLayoutView.js
+++ b/dashboardv2/public/js/views/tag/TagLayoutView.js
@@ -97,30 +97,40 @@
}
},
setValues: function(manual) {
+ var $firstEl = this.ui.tagsParent.find('li a') ? this.ui.tagsParent.find('li a').first() : null;
if (Utils.getUrlState.isTagTab()) {
if (!this.tag) {
this.selectFirst = false;
this.ui.tagsParent.find('li').first().addClass('active');
- if (this.ui.tagsParent.find('li a').first().length) {
+ if ($firstEl && $firstEl.length) {
+ url: $firstEl.attr("href"),
Utils.setUrl({
- url: this.ui.tagsParent.find('li a').first().attr("href"),
+ url: $firstEl.attr("href"),
mergeBrowserUrl: false,
- trigger: true,
updateTabState: function() {
return { tagUrl: this.url, stateChanged: true };
}
});
}
} else {
+ var presentTag = this.collection.fullCollection.findWhere({ name: this.tag }),
+ url = Utils.getUrlState.getQueryUrl().hash,
+ tag = this.tag,
+ query = null;
+ if (!presentTag) {
+ tag = $firstEl.data('name');
+ url = $firstEl && $firstEl.length ? $firstEl.attr("href") : '#!/tag';
+ query = $firstEl && $firstEl.length ? { dlttag: true } : null
+ }
Utils.setUrl({
- url: Utils.getUrlState.getQueryUrl().hash,
+ url: url,
+ urlParams: query,
updateTabState: function() {
return { tagUrl: this.url, stateChanged: true };
}
});
- var tag = Utils.getUrlState.getLastValue();
- if (this.tag) {
- tag = this.tag;
+ if (!presentTag) {
+ return false;
}
this.ui.tagsParent.find('li').removeClass('active');
var target = this.ui.tagsParent.find('li').filter(function() {
@@ -399,26 +409,14 @@
Utils.notifySuccess({
content: "Tag " + that.tagName + Messages.deleteSuccessMessage
});
+ // if deleted tag is prviously searched then remove that tag url from save state of tab.
var searchUrl = Globals.saveApplicationState.tabState.searchUrl;
var urlObj = Utils.getUrlState.getQueryParams(searchUrl);
if (urlObj && urlObj.tag && urlObj.tag === that.tagName) {
Globals.saveApplicationState.tabState.searchUrl = "#!/search";
}
- that.ui.tagsParent.find('li.active').removeClass('active');
- if (that.tagDeleteData.prev().length === 0) {
- that.tagDeleteData.next().addClass('active');
- } else {
- that.tagDeleteData.prev().addClass('active');
- }
- Utils.setUrl({
- url: that.ui.tagsParent.find('li.active').find("a").attr("href"),
- mergeBrowserUrl: false,
- trigger: true,
- updateTabState: function() {
- return { tagUrl: that.url, stateChanged: true };
- }
- });
that.collection.remove(deleteTagData);
+ // to update tag list of search tab fetch typeHeaders.
that.typeHeaders.fetch({ reset: true });
}
});