Commit 138bc6f1 by kevalbhatt Committed by Madhan Neethiraj

ATLAS-1812: On browser refresh if, tag is doesn't exist, then URL should update with the first tag.

parent f0f7fe2c
...@@ -181,8 +181,19 @@ define([ ...@@ -181,8 +181,19 @@ define([
'views/business_catalog/SideNavLayoutView', 'views/business_catalog/SideNavLayoutView',
'views/tag/TagDetailLayoutView', 'views/tag/TagDetailLayoutView',
], function(Header, BusinessCatalogLayoutView, SideNavLayoutView, TagDetailLayoutView) { ], function(Header, BusinessCatalogLayoutView, SideNavLayoutView, TagDetailLayoutView) {
var paramObj = Utils.getUrlState.getQueryParams(),
url = Utils.getUrlState.getQueryUrl().queyParams[0];
App.rNHeader.show(new Header()); App.rNHeader.show(new Header());
if (!App.rSideNav.currentView) { 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( App.rSideNav.show(new SideNavLayoutView(
_.extend({ _.extend({
'tag': tagName, 'tag': tagName,
...@@ -190,11 +201,24 @@ define([ ...@@ -190,11 +201,24 @@ define([
}, that.preFetchedCollectionLists) }, that.preFetchedCollectionLists)
)); ));
} else { } 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.RTagLayoutView.currentView.manualRender(tagName);
App.rSideNav.currentView.selectTab(); App.rSideNav.currentView.selectTab();
} }
if (tagName) { if (tagName) {
// updating paramObj to check for new queryparam.
paramObj = Utils.getUrlState.getQueryParams();
if (paramObj && paramObj.dlttag) {
return false;
}
App.rNContent.show(new TagDetailLayoutView( App.rNContent.show(new TagDetailLayoutView(
_.extend({ _.extend({
'tag': tagName, 'tag': tagName,
......
...@@ -74,7 +74,6 @@ define(['require', ...@@ -74,7 +74,6 @@ define(['require',
} }
}, },
onRender: function() { onRender: function() {
this.bindEvent();
this.renderTagLayoutView(); this.renderTagLayoutView();
this.renderSearchLayoutView(); this.renderSearchLayoutView();
if (Globals.taxonomy) { if (Globals.taxonomy) {
...@@ -83,7 +82,6 @@ define(['require', ...@@ -83,7 +82,6 @@ define(['require',
this.selectTab(); this.selectTab();
}, },
bindEvent: function() {},
rendeBusinessCatalogLayoutView: function() { rendeBusinessCatalogLayoutView: function() {
var that = this; var that = this;
require(['views/business_catalog/BusinessCatalogLayoutView'], function(BusinessCatalogLayoutView) { require(['views/business_catalog/BusinessCatalogLayoutView'], function(BusinessCatalogLayoutView) {
......
...@@ -583,7 +583,11 @@ define(['require', ...@@ -583,7 +583,11 @@ define(['require',
that.callback(); that.callback();
} else { } else {
if (model.mutatedEntities && model.mutatedEntities.CREATE && _.isArray(model.mutatedEntities.CREATE) && model.mutatedEntities.CREATE[0] && model.mutatedEntities.CREATE[0].guid) { 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 @@ define(['require', ...@@ -599,16 +603,6 @@ define(['require',
that.hideLoader(); that.hideLoader();
} }
}, },
setUrl: function(url, create) {
Utils.setUrl({
url: url,
mergeBrowserUrl: false,
trigger: true,
updateTabState: function() {
return { tagUrl: this.url, stateChanged: true };
}
});
},
showLoader: function() { showLoader: function() {
this.$('.entityLoader').show(); this.$('.entityLoader').show();
this.$('.entityInputData').hide(); this.$('.entityInputData').hide();
......
...@@ -246,7 +246,7 @@ define(['require', ...@@ -246,7 +246,7 @@ define(['require',
}); });
}); });
}, },
getSchemaTableColumns: function(deleteEnity) { getSchemaTableColumns: function() {
var that = this, var that = this,
col = { col = {
Check: { Check: {
......
...@@ -126,7 +126,7 @@ define(['require', ...@@ -126,7 +126,7 @@ define(['require',
* @constructs * @constructs
*/ */
initialize: function(options) { 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 = ""; var pagination = "";
this.entityModel = new VEntity(); this.entityModel = new VEntity();
this.searchCollection = new VSearchList(); this.searchCollection = new VSearchList();
......
...@@ -44,7 +44,7 @@ define(['require', ...@@ -44,7 +44,7 @@ define(['require',
* @constructs * @constructs
*/ */
initialize: function(options) { initialize: function(options) {
_.extend(this, _.pick(options, 'tag', 'collection', 'entityDefCollection', 'typeHeaders')); _.extend(this, _.pick(options, 'tag', 'collection', 'entityDefCollection', 'typeHeaders', 'enumDefCollection'));
}, },
bindEvents: function() {}, bindEvents: function() {},
onRender: function() { onRender: function() {
...@@ -58,20 +58,26 @@ define(['require', ...@@ -58,20 +58,26 @@ define(['require',
'tag': that.tag, 'tag': that.tag,
'searchType': 'basic' 'searchType': 'basic'
}; };
that.RSearchResultLayoutView.show(new SearchResultLayoutView({ if (that.RSearchResultLayoutView) {
value: value, that.RSearchResultLayoutView.show(new SearchResultLayoutView({
entityDefCollection: that.entityDefCollection, value: value,
typeHeaders: that.typeHeaders entityDefCollection: that.entityDefCollection,
})); typeHeaders: that.typeHeaders,
tagCollection: that.collection,
enumDefCollection: that.enumDefCollection
}));
}
}); });
}, },
renderTagAttributeCompositeView: function() { renderTagAttributeCompositeView: function() {
var that = this; var that = this;
require(['views/tag/TagAttributeDetailLayoutView'], function(TagAttributeDetailLayoutView) { require(['views/tag/TagAttributeDetailLayoutView'], function(TagAttributeDetailLayoutView) {
that.RTagAttributeDetailLayoutView.show(new TagAttributeDetailLayoutView({ if (that.RTagAttributeDetailLayoutView) {
tag: that.tag, that.RTagAttributeDetailLayoutView.show(new TagAttributeDetailLayoutView({
collection: that.collection tag: that.tag,
})); collection: that.collection
}));
}
}); });
} }
}); });
......
...@@ -97,30 +97,40 @@ define(['require', ...@@ -97,30 +97,40 @@ define(['require',
} }
}, },
setValues: function(manual) { setValues: function(manual) {
var $firstEl = this.ui.tagsParent.find('li a') ? this.ui.tagsParent.find('li a').first() : null;
if (Utils.getUrlState.isTagTab()) { if (Utils.getUrlState.isTagTab()) {
if (!this.tag) { if (!this.tag) {
this.selectFirst = false; this.selectFirst = false;
this.ui.tagsParent.find('li').first().addClass('active'); 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({ Utils.setUrl({
url: this.ui.tagsParent.find('li a').first().attr("href"), url: $firstEl.attr("href"),
mergeBrowserUrl: false, mergeBrowserUrl: false,
trigger: true,
updateTabState: function() { updateTabState: function() {
return { tagUrl: this.url, stateChanged: true }; return { tagUrl: this.url, stateChanged: true };
} }
}); });
} }
} else { } 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({ Utils.setUrl({
url: Utils.getUrlState.getQueryUrl().hash, url: url,
urlParams: query,
updateTabState: function() { updateTabState: function() {
return { tagUrl: this.url, stateChanged: true }; return { tagUrl: this.url, stateChanged: true };
} }
}); });
var tag = Utils.getUrlState.getLastValue(); if (!presentTag) {
if (this.tag) { return false;
tag = this.tag;
} }
this.ui.tagsParent.find('li').removeClass('active'); this.ui.tagsParent.find('li').removeClass('active');
var target = this.ui.tagsParent.find('li').filter(function() { var target = this.ui.tagsParent.find('li').filter(function() {
...@@ -399,26 +409,14 @@ define(['require', ...@@ -399,26 +409,14 @@ define(['require',
Utils.notifySuccess({ Utils.notifySuccess({
content: "Tag " + that.tagName + Messages.deleteSuccessMessage 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 searchUrl = Globals.saveApplicationState.tabState.searchUrl;
var urlObj = Utils.getUrlState.getQueryParams(searchUrl); var urlObj = Utils.getUrlState.getQueryParams(searchUrl);
if (urlObj && urlObj.tag && urlObj.tag === that.tagName) { if (urlObj && urlObj.tag && urlObj.tag === that.tagName) {
Globals.saveApplicationState.tabState.searchUrl = "#!/search"; 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); that.collection.remove(deleteTagData);
// to update tag list of search tab fetch typeHeaders.
that.typeHeaders.fetch({ reset: true }); that.typeHeaders.fetch({ reset: true });
} }
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment