GlossaryLayoutView.js 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  1. define([ "require", "backbone", "hbs!tmpl/glossary/GlossaryLayoutView_tmpl", "utils/Utils", "utils/Messages", "utils/Globals", "utils/CommonViewFunction", "jstree" ], function(require, Backbone, GlossaryLayoutViewTmpl, Utils, Messages, Globals, CommonViewFunction) {
  2. "use strict";
  3. var GlossaryLayoutView = Backbone.Marionette.LayoutView.extend({
  4. _viewName: "GlossaryLayoutView",
  5. template: GlossaryLayoutViewTmpl,
  6. regions: {},
  7. templateHelpers: function() {
  8. return {
  9. isAssignView: this.isAssignView,
  10. isAssignAttributeRelationView: this.isAssignAttributeRelationView
  11. };
  12. },
  13. ui: {
  14. createGlossary: "[data-id='createGlossary']",
  15. refreshGlossary: "[data-id='refreshGlossary']",
  16. searchTerm: "[data-id='searchTerm']",
  17. searchCategory: "[data-id='searchCategory']",
  18. glossaryView: 'input[name="glossaryView"]',
  19. termTree: "[data-id='termTree']",
  20. categoryTree: "[data-id='categoryTree']"
  21. },
  22. events: function() {
  23. var events = {};
  24. return events["change " + this.ui.glossaryView] = "glossaryViewToggle", events["click " + this.ui.createGlossary] = function(e) {
  25. var that = this;
  26. e && $(e.currentTarget).attr("disabled", "true"), CommonViewFunction.createEditGlossaryCategoryTerm({
  27. isGlossaryView: !0,
  28. collection: this.glossaryCollection,
  29. callback: function() {
  30. that.ui.createGlossary.removeAttr("disabled"), that.getGlossary();
  31. },
  32. onModalClose: function() {
  33. that.ui.createGlossary.removeAttr("disabled");
  34. }
  35. });
  36. }, events["click " + this.ui.refreshGlossary] = "getGlossary", events["keyup " + this.ui.searchTerm] = function() {
  37. this.ui.termTree.jstree("search", this.ui.searchTerm.val());
  38. }, events["keyup " + this.ui.searchCategory] = function() {
  39. this.ui.categoryTree.jstree("search", this.ui.searchCategory.val());
  40. }, events;
  41. },
  42. initialize: function(options) {
  43. _.extend(this, _.pick(options, "associatedTerms", "guid", "value", "glossaryCollection", "glossary", "isAssignTermView", "isAssignCategoryView", "isAssignEntityView", "isAssignAttributeRelationView")),
  44. this.viewType = "term", this.isAssignView = this.isAssignTermView || this.isAssignCategoryView || this.isAssignEntityView || this.isAssignAttributeRelationView,
  45. this.bindEvents(), this.query = {
  46. term: {},
  47. category: {}
  48. }, Utils.getUrlState.isGlossaryTab() && this.value && this.value.viewType && (this.viewType = this.value.viewType,
  49. this.query[this.viewType] = _.extend({}, this.value, {
  50. guid: this.guid
  51. }));
  52. },
  53. bindEvents: function() {
  54. var that = this;
  55. this.listenTo(this.glossaryCollection.fullCollection, "reset add change", function(skip) {
  56. this.generateTree(), this.setValues();
  57. }, this), this.listenTo(this.glossaryCollection, "update:details", function(options) {
  58. var isGlossaryUpdate = options.isGlossaryUpdate;
  59. if (isGlossaryUpdate) this.ui.termTree.jstree(!0).refresh && this.ui.termTree.jstree(!0).refresh(),
  60. this.ui.categoryTree.jstree(!0).refresh && this.ui.categoryTree.jstree(!0).refresh(); else {
  61. var $tree = this.ui["term" == this.viewType ? "termTree" : "categoryTree"];
  62. $tree.jstree(!0).refresh && ($tree.jstree(!0).refresh(), this.setValues({
  63. trigger: !1
  64. }));
  65. }
  66. }, this), this.isAssignView || $("body").on("click", ".termPopoverOptions li, .categoryPopoverOptions li", function(e) {
  67. that.$(".termPopover,.categoryPopover").popover("hide"), that[$(this).find("a").data("fn")](e);
  68. });
  69. },
  70. onRender: function() {
  71. this.isAssignCategoryView && (this.$(".category-view").show(), this.$(".term-view").hide()),
  72. this.isAssignView && this.glossaryCollection.fullCollection.length ? (this.generateTree(),
  73. this.disableNodesList = this.getDisableNodes()) : this.getGlossary();
  74. },
  75. setValues: function(options) {
  76. "category" == this.viewType ? this.ui.glossaryView.prop("checked") || this.ui.glossaryView.prop("checked", !0).trigger("change", options) : this.ui.glossaryView.prop("checked") && this.ui.glossaryView.prop("checked", !1).trigger("change", options);
  77. },
  78. glossaryViewToggle: function(e, options) {
  79. var that = this;
  80. e.currentTarget.checked ? (this.$(".category-view").show(), this.$(".term-view").hide(),
  81. this.viewType = "category") : (this.$(".term-view").show(), this.$(".category-view").hide(),
  82. this.viewType = "term");
  83. var setDefaultSelector = function() {
  84. if (that.value) {
  85. var model = null;
  86. model = that.value.gId ? that.glossaryCollection.fullCollection.get(that.value.gId) : that.glossaryCollection.fullCollection.first(),
  87. model = model.toJSON ? model.toJSON() : model, that.glossary.selectedItem = {
  88. type: "Glossary",
  89. guid: model.guid,
  90. id: model.guid,
  91. model: model,
  92. text: model.name,
  93. gType: "glossary"
  94. };
  95. }
  96. };
  97. if (Utils.getUrlState.isGlossaryTab()) {
  98. var obj = this.query[this.viewType], $tree = this.ui["term" == this.viewType ? "termTree" : "categoryTree"];
  99. if (obj.guid) {
  100. var node = $tree.jstree(!0).get_node(obj.guid);
  101. node && (this.glossary.selectedItem = node.original, $tree.jstree("activate_node", obj.guid));
  102. } else setDefaultSelector(), $tree.jstree("activate_node", that.glossary.selectedItem.guid);
  103. this.query[this.viewType] = _.extend(obj, _.pick(this.glossary.selectedItem, "model", "guid", "gType", "type"), {
  104. viewType: this.viewType,
  105. isNodeNotFoundAtLoad: this.query[this.viewType].isNodeNotFoundAtLoad
  106. });
  107. var url = _.isEmpty(this.glossary.selectedItem) ? "#!/glossary" : "#!/glossary/" + this.glossary.selectedItem.guid;
  108. Utils.setUrl({
  109. url: url,
  110. urlParams: _.extend({}, _.omit(obj, "guid", "model", "type", "isNodeNotFoundAtLoad")),
  111. mergeBrowserUrl: !1,
  112. trigger: !(options && !_.isUndefined(options.trigger)) || options.trigger,
  113. updateTabState: !0
  114. });
  115. }
  116. },
  117. getGlossary: function() {
  118. this.glossaryCollection.fetch({
  119. reset: !0
  120. });
  121. },
  122. generateCategoryData: function(options) {
  123. return _.map(options.data, function(obj) {
  124. return {
  125. text: _.escape(obj.displayText),
  126. icon: "fa fa-files-o",
  127. guid: obj.categoryGuid,
  128. id: obj.categoryGuid,
  129. glossaryId: options.node.glossaryId,
  130. glossaryName: options.node.glossaryName,
  131. model: obj,
  132. type: "GlossaryCategory",
  133. gType: "category",
  134. children: !0
  135. };
  136. });
  137. },
  138. getCategory: function(options) {
  139. var that = this;
  140. this.glossaryCollection.getCategory({
  141. guid: options.node.guid,
  142. related: !0,
  143. ajaxOptions: {
  144. success: function(data) {
  145. data && data.children ? options.callback(that.generateCategoryData(_.extend({}, {
  146. data: data.children
  147. }, options))) : options.callback([]);
  148. },
  149. cust_error: function() {
  150. options.callback([]);
  151. }
  152. }
  153. });
  154. },
  155. generateData: function(opt) {
  156. var that = this, associatedTerms = (that.guid, that.associatedTerms), type = opt.type;
  157. opt.type == this.viewType && (this.query[opt.type].isNodeNotFoundAtLoad = !0);
  158. var getSelectedState = function(options) {
  159. var objGuid = options.objGuid, node = options.node, index = options.index;
  160. if (that.isAssignView) return {
  161. opened: !0
  162. };
  163. if (that.guid) {
  164. if (that.guid == objGuid) return that.query[that.viewType].isNodeNotFoundAtLoad = !1,
  165. that.glossary.selectedItem = node, that.query[that.viewType].model = node.model,
  166. that.query[that.viewType].type = node.type, {
  167. opened: !0,
  168. selected: !0
  169. };
  170. } else {
  171. that.query[that.viewType].isNodeNotFoundAtLoad = !1;
  172. var selectedItem = {
  173. type: "Glossary",
  174. gType: "glossary",
  175. model: that.glossaryCollection.fullCollection.first().toJSON()
  176. };
  177. if (selectedItem.text = selectedItem.model.name, selectedItem.guid = selectedItem.model.guid,
  178. 0 == index && selectedItem.guid == objGuid) return that.glossary.selectedItem = selectedItem,
  179. that.query[that.viewType].model = selectedItem.model, that.query[that.viewType].type = selectedItem.type,
  180. {
  181. opened: !0,
  182. selected: !0
  183. };
  184. }
  185. };
  186. return this.glossaryCollection.fullCollection.map(function(model, i) {
  187. var obj = model.toJSON(), parent = {
  188. text: _.escape(obj.name),
  189. icon: "fa fa-folder-o",
  190. guid: obj.guid,
  191. id: obj.guid,
  192. model: obj,
  193. type: obj.typeName ? obj.typeName : "Glossary",
  194. gType: "glossary",
  195. children: []
  196. };
  197. return parent.state = getSelectedState({
  198. index: i,
  199. node: parent,
  200. objGuid: obj.guid
  201. }), "category" == type && obj.categories && _.each(obj.categories, function(category) {
  202. if (!category.parentCategoryGuid) {
  203. var typeName = category.typeName || "GlossaryCategory", guid = category.categoryGuid, categoryObj = {
  204. text: _.escape(category.displayText),
  205. type: typeName,
  206. gType: "category",
  207. guid: guid,
  208. id: guid,
  209. parent: obj,
  210. glossaryId: obj.guid,
  211. glossaryName: obj.name,
  212. model: category,
  213. children: !0,
  214. icon: "fa fa-files-o"
  215. };
  216. categoryObj.state = getSelectedState({
  217. index: i,
  218. node: categoryObj,
  219. objGuid: guid
  220. }), parent.children.push(categoryObj);
  221. }
  222. }), "term" == type && obj.terms && _.each(obj.terms, function(term) {
  223. if (associatedTerms) {
  224. var associatedTermFound = _.find(associatedTerms, function(obj, index) {
  225. if ((obj.termGuid ? obj.termGuid : obj.guid) == term.termGuid) return obj;
  226. });
  227. if (associatedTermFound) return;
  228. }
  229. var typeName = term.typeName || "GlossaryTerm", guid = term.termGuid, termObj = {
  230. text: _.escape(term.displayText),
  231. type: typeName,
  232. gType: "term",
  233. guid: guid,
  234. id: guid,
  235. parent: obj,
  236. glossaryName: obj.name,
  237. glossaryId: obj.guid,
  238. model: term,
  239. icon: "fa fa-file-o"
  240. };
  241. termObj.state = getSelectedState({
  242. index: i,
  243. node: termObj,
  244. objGuid: guid
  245. }), parent.children.push(termObj);
  246. }), parent;
  247. });
  248. },
  249. manualRender: function(options) {
  250. if (_.extend(this, _.omit(options, "isTrigger")), this.value && this.value.viewType && (this.viewType = this.value.viewType),
  251. this.guid && this.value && (this.value.fromView && this.value.fromView || this.value.updateView)) {
  252. var $tree = this.ui["term" == this.viewType ? "termTree" : "categoryTree"], node = $tree.jstree(!0).get_node(this.guid);
  253. node && ($tree.jstree("activate_node", this.guid, {
  254. skipTrigger: !0
  255. }), delete this.value.fromView, delete this.value.updateView, this.glossary.selectedItem = node.original,
  256. this.query[this.viewType] = _.extend({}, _.pick(this.glossary.selectedItem, "model", "guid", "gType", "type"), {
  257. viewType: this.viewType
  258. }), Utils.setUrl({
  259. url: "#!/glossary/" + this.guid,
  260. urlParams: this.value,
  261. mergeBrowserUrl: !1,
  262. trigger: !1,
  263. updateTabState: !0
  264. }), this.glossaryCollection.trigger("update:details", {
  265. isGlossaryUpdate: "glossary" == this.value.gType
  266. }));
  267. } else this.setValues();
  268. options.isTrigger && this.triggerUrl();
  269. },
  270. getDisableNodes: function() {
  271. var disableNodesSelection = [];
  272. if (this.options && this.options.isAssignAttributeRelationView) {
  273. var disableTerms = this.options.termData && this.options.selectedTermAttribute ? this.options.termData[this.options.selectedTermAttribute] : null;
  274. disableNodesSelection = _.map(disableTerms, function(obj) {
  275. return obj.termGuid;
  276. }), disableNodesSelection.push(this.options.termData.guid);
  277. }
  278. return disableNodesSelection;
  279. },
  280. generateTree: function() {
  281. var $termTree = this.ui.termTree, $categoryTree = this.ui.categoryTree, that = this, getTreeConfig = (that.guid,
  282. function(options) {
  283. return {
  284. plugins: [ "search", "themes", "core", "wholerow", "sort", "conditionalselect" ],
  285. conditionalselect: function(node) {
  286. var obj = node && node.original && node.original.type;
  287. if (obj) {
  288. if (that.isAssignView) {
  289. var isDisableNode = !1;
  290. return that.disableNodesList && (isDisableNode = that.disableNodesList.indexOf(node.original.guid) > -1),
  291. "Glossary" != obj && !isDisableNode;
  292. }
  293. return "NoAction" != obj;
  294. }
  295. },
  296. search: {
  297. show_only_matches: !0
  298. },
  299. core: {
  300. data: function(node, cb) {
  301. "#" === node.id ? cb(that.generateData(options)) : that.getCategory({
  302. node: node.original,
  303. callback: cb
  304. });
  305. },
  306. themes: {
  307. name: that.isAssignView ? "default" : "default-dark",
  308. dots: !0
  309. }
  310. }
  311. };
  312. }), treeLoaded = function(options) {
  313. if (1 == that.query[options.type].isNodeNotFoundAtLoad) {
  314. var id = that.glossary.selectedItem.guid;
  315. options.$el.jstree("activate_node", id);
  316. }
  317. }, createAction = function(options) {
  318. var $el = options.el, type = options.type, popoverClassName = "term" == type ? "termPopover" : "categoryPopover";
  319. if (!that.isAssignView) {
  320. var wholerowEl = $el.find("li[role='treeitem'] > .jstree-wholerow:not(:has(>div.tools))");
  321. wholerowEl.append('<div class="tools"><i class="fa fa-ellipsis-h ' + popoverClassName + '"></i></div>'),
  322. "term" == type ? that.createTermAction() : "category" == type && that.createCategoryAction();
  323. }
  324. }, initializeTree = function(options) {
  325. var $el = options.el, type = options.type;
  326. $el.jstree(getTreeConfig({
  327. type: type
  328. })).on("load_node.jstree", function(e, data) {
  329. createAction(_.extend({}, options, data));
  330. }).on("open_node.jstree", function(e, data) {
  331. createAction(_.extend({}, options, data));
  332. }).on("select_node.jstree", function(e, data) {
  333. if (that.isAssignView) that.glossary.selectedItem = data.node.original, that.glossaryCollection.trigger("node_selected"); else {
  334. var popoverClassName = "term" == type ? ".termPopover" : ".categoryPopover", currentClickedPopoverEl = "";
  335. if (data.event && (currentClickedPopoverEl = $(data.event.currentTarget).parent().hasClass("jstree-leaf") ? $(data.event.currentTarget).parent().find(popoverClassName) : $(data.event.currentTarget).parent().find(">div " + popoverClassName),
  336. $(popoverClassName).not(currentClickedPopoverEl).popover("hide")), 1 == that.query[type].isNodeNotFoundAtLoad) that.query[type].isNodeNotFoundAtLoad = !1; else if (type == that.viewType) {
  337. if (data && data.event && data.event.skipTrigger) return;
  338. that.glossary.selectedItem.guid !== data.node.original.guid && (that.glossary.selectedItem = data.node.original,
  339. that.triggerUrl());
  340. }
  341. }
  342. }).on("search.jstree", function(e, data) {
  343. createAction(_.extend({}, options, data));
  344. }).on("clear_search.jstree", function(e, data) {
  345. createAction(_.extend({}, options, data));
  346. }).bind("loaded.jstree", function(e, data) {
  347. 1 == that.query[type].isNodeNotFoundAtLoad && treeLoaded({
  348. $el: $el,
  349. type: type
  350. });
  351. });
  352. }, initializeTermTree = function() {
  353. $termTree.data("jstree") ? ($(".termPopover").popover("destroy"), $termTree.jstree(!0).refresh()) : initializeTree({
  354. el: $termTree,
  355. type: "term"
  356. });
  357. }, initializeCategoryTree = function() {
  358. $categoryTree.data("jstree") ? ($(".categoryPopover").popover("destroy"), $categoryTree.jstree(!0).refresh()) : initializeTree({
  359. el: $categoryTree,
  360. type: "category"
  361. });
  362. };
  363. this.isAssignView ? this.isAssignTermView || this.isAssignEntityView || this.isAssignAttributeRelationView ? initializeTermTree() : this.isAssignCategoryView && initializeCategoryTree() : (initializeTermTree(),
  364. initializeCategoryTree()), Utils.getUrlState.isGlossaryTab() && this.triggerUrl(),
  365. this.glossaryCollection.trigger("render:done");
  366. },
  367. createTermAction: function() {
  368. var that = this;
  369. Utils.generatePopover({
  370. el: this.$(".termPopover"),
  371. contentClass: "termPopoverOptions",
  372. popoverOptions: {
  373. content: function() {
  374. var node = that.query[that.viewType], liString = "";
  375. return liString = "Glossary" == node.type ? "<li data-type=" + node.type + " class='listTerm'><i class='fa fa-plus'></i> <a href='javascript:void(0)' data-fn='createSubNode'>Create Term</a></li><li data-type=" + node.type + " class='listTerm'><i class='fa fa-trash-o'></i><a href='javascript:void(0)' data-fn='deleteNode'>删除术语表</a></li>" : "<li data-type=" + node.type + " class='listTerm'><i class='fa fa-trash-o'></i><a href='javascript:void(0)' data-fn='deleteNode'>Delete Term</a></li>",
  376. "<ul>" + liString + "</ul>";
  377. }
  378. }
  379. });
  380. },
  381. createCategoryAction: function() {
  382. var that = this;
  383. Utils.generatePopover({
  384. el: this.$(".categoryPopover"),
  385. contentClass: "categoryPopoverOptions",
  386. popoverOptions: {
  387. content: function() {
  388. var node = that.query[that.viewType], liString = "";
  389. return liString = "Glossary" == node.type ? "<li data-type=" + node.type + " class='listTerm'><i class='fa fa-plus'></i> <a href='javascript:void(0)' data-fn='createSubNode'>Create Category</a></li><li data-type=" + node.type + " class='listTerm'><i class='fa fa-trash-o'></i><a href='javascript:void(0)' data-fn='deleteNode'>删除术语表</a></li>" : "<li data-type=" + node.type + " class='listTerm'><i class='fa fa-plus'></i> <a href='javascript:void(0)' data-fn='createSubNode'>Create Sub-Category</a></li><li data-type=" + node.type + " class='listTerm'><i class='fa fa-trash-o'></i><a href='javascript:void(0)' data-fn='deleteNode'>Delete Category</a></li>",
  390. "<ul>" + liString + "</ul>";
  391. }
  392. }
  393. });
  394. },
  395. createSubNode: function(opt) {
  396. var that = this, type = this.glossary.selectedItem.type;
  397. "Glossary" != type && "GlossaryCategory" != type || "category" != this.viewType ? CommonViewFunction.createEditGlossaryCategoryTerm({
  398. isTermView: !0,
  399. callback: function() {
  400. that.getGlossary();
  401. },
  402. collection: that.glossaryCollection,
  403. node: this.glossary.selectedItem
  404. }) : CommonViewFunction.createEditGlossaryCategoryTerm({
  405. isCategoryView: !0,
  406. collection: that.glossaryCollection,
  407. callback: function() {
  408. "glossary" == that.value.gType ? that.getGlossary() : that.ui.categoryTree.jstree(!0).refresh();
  409. },
  410. node: this.glossary.selectedItem
  411. });
  412. },
  413. deleteNode: function(opt) {
  414. var that = this, messageType = "", type = this.glossary.selectedItem.type, guid = this.glossary.selectedItem.guid, gId = this.glossary.selectedItem.glossaryId, options = {
  415. success: function(rModel, response) {
  416. gId || (gId = guid);
  417. var glossary = that.glossaryCollection.fullCollection.get(gId);
  418. that.value && ("term" == that.value.gType ? glossary.set("terms", _.reject(glossary.get("terms"), function(obj) {
  419. return obj.termGuid == guid;
  420. }), {
  421. silent: !0
  422. }) : "category" == that.value.gType ? glossary.set("categories", _.reject(glossary.get("categories"), function(obj) {
  423. return obj.categoryGuid == guid;
  424. }), {
  425. silent: !0
  426. }) : (glossary = that.glossaryCollection.fullCollection.first(), gId = glossary ? glossary.get("guid") : null)),
  427. Utils.notifySuccess({
  428. content: messageType + Messages.getAbbreviationMsg(!1, "deleteSuccessMessage")
  429. });
  430. var url = gId ? "#!/glossary/" + gId : "#!/glossary";
  431. null == gId && (that.glossary.selectedItem = {}, that.value = null, that.query = {
  432. term: {},
  433. category: {}
  434. }, that.ui.categoryTree.jstree(!0).refresh(), that.ui.termTree.jstree(!0).refresh()),
  435. Utils.setUrl({
  436. url: url,
  437. mergeBrowserUrl: !1,
  438. trigger: !0,
  439. urlParams: gId ? _.extend({}, that.value, {
  440. gType: "glossary",
  441. updateView: !0,
  442. gId: null
  443. }) : null,
  444. updateTabState: !0
  445. });
  446. }
  447. }, notifyObj = {
  448. modal: !0,
  449. ok: function(argument) {
  450. "Glossary" == type ? that.glossaryCollection.fullCollection.get(guid).destroy(options, {
  451. silent: !0,
  452. reset: !1
  453. }) : "GlossaryCategory" == type ? new that.glossaryCollection.model().deleteCategory(guid, options) : "GlossaryTerm" == type && new that.glossaryCollection.model().deleteTerm(guid, options);
  454. },
  455. cancel: function(argument) {}
  456. };
  457. "Glossary" == type ? messageType = "Glossary" : "GlossaryCategory" == type ? messageType = "Category" : "GlossaryTerm" == type && (messageType = "Term"),
  458. notifyObj.text = "Are you sure you want to delete the " + messageType, Utils.notifyConfirm(notifyObj);
  459. },
  460. triggerUrl: function(options) {
  461. if (!this.isAssignView) {
  462. var selectedItem = this.glossary.selectedItem;
  463. if (this.glossaryCollection.length && (_.isEmpty(selectedItem) || this.query[this.viewType].isNodeNotFoundAtLoad)) {
  464. var model = selectedItem.model;
  465. model && !_.isUndefined(model.parentCategory || model.parentCategoryGuid) && (selectedItem = {
  466. model: this.glossaryCollection.first().toJSON()
  467. }, selectedItem.guid = selectedItem.model.guid, selectedItem.type = "Glossary",
  468. selectedItem.gType = "glossary", selectedItem.text = model.name, this.glossary.selectedItem = selectedItem,
  469. this.query[this.viewType].model = selectedItem.model, this.query[this.viewType].gType = "glossary",
  470. this.query[this.viewType].type = "Glossary", delete this.query[this.viewType].gId);
  471. }
  472. if (!_.isEmpty(selectedItem) && (Utils.getUrlState.isGlossaryTab() || Utils.getUrlState.isDetailPage())) {
  473. var obj = {};
  474. selectedItem.glossaryId ? obj.gId = selectedItem.glossaryId : "Glossary" == selectedItem.type && (obj.gId = selectedItem.guid),
  475. this.query[this.viewType] = _.extend(obj, _.omit(this.value, "gId"), _.pick(this.glossary.selectedItem, "model", "type", "gType", "guid"), {
  476. viewType: this.viewType,
  477. isNodeNotFoundAtLoad: this.query[this.viewType].isNodeNotFoundAtLoad
  478. }), Utils.setUrl({
  479. url: "#!/glossary/" + obj.guid,
  480. mergeBrowserUrl: !1,
  481. trigger: !0,
  482. urlParams: _.omit(obj, "model", "guid", "type", "isNodeNotFoundAtLoad"),
  483. updateTabState: !0
  484. });
  485. }
  486. }
  487. }
  488. });
  489. return GlossaryLayoutView;
  490. });