You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by ma...@apache.org on 2018/04/16 21:31:10 UTC
[2/4] atlas git commit: ATLAS-2562: UI for Glossary
http://git-wip-us.apache.org/repos/asf/atlas/blob/3709842a/dashboardv2/public/js/views/glossary/GlossaryDetailLayoutView.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/views/glossary/GlossaryDetailLayoutView.js b/dashboardv2/public/js/views/glossary/GlossaryDetailLayoutView.js
new file mode 100644
index 0000000..2ba3c45
--- /dev/null
+++ b/dashboardv2/public/js/views/glossary/GlossaryDetailLayoutView.js
@@ -0,0 +1,294 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+define(['require',
+ 'backbone',
+ 'hbs!tmpl/glossary/GlossaryDetailLayoutView_tmpl',
+ 'utils/Utils',
+ 'utils/Messages',
+ 'utils/Globals',
+ 'utils/CommonViewFunction'
+], function(require, Backbone, GlossaryDetailLayoutViewTmpl, Utils, Messages, Globals, CommonViewFunction) {
+ 'use strict';
+
+ var GlossaryDetailLayoutView = Backbone.Marionette.LayoutView.extend(
+ /** @lends GlossaryDetailLayoutView */
+ {
+ _viewName: 'GlossaryDetailLayoutView',
+
+ template: GlossaryDetailLayoutViewTmpl,
+
+ /** Layout sub regions */
+ regions: {
+ RSearchResultLayoutView: "#r_searchResultLayoutView",
+ },
+ templateHelpers: function() {
+ return {
+ isTermView: this.isTermView,
+ isCategoryView: this.isCategoryView
+ };
+ },
+
+ /** ui selector cache */
+ ui: {
+ details: "[data-id='details']",
+ editButton: "[data-id='editButton']",
+ title: "[data-id='title']",
+ shortDescription: "[data-id='shortDescription']",
+ longDescription: "[data-id='longDescription']",
+ categoryList: "[data-id='categoryList']",
+ removeCategory: "[data-id='removeCategory']",
+ categoryClick: "[data-id='categoryClick']",
+ addCategory: "[data-id='addCategory']",
+ termList: "[data-id='termList']",
+ removeTerm: "[data-id='removeTerm']",
+ termClick: "[data-id='termClick']",
+ addTerm: "[data-id='addTerm']"
+ },
+ /** ui events hash */
+ events: function() {
+ var events = {};
+ events["click " + this.ui.categoryClick] = function(e) {
+ if (e.target.nodeName.toLocaleLowerCase() == "i") {
+ this.onClickRemoveAssociationBtn(e);
+ } else {
+ var guid = $(e.currentTarget).data('guid'),
+ categoryObj = _.find(this.data.categories, { "categoryGuid": guid });
+ this.glossary.selectedItem = { "type": "GlossaryCategory", "guid": guid, "model": categoryObj };
+ Utils.setUrl({
+ url: '#!/glossary/' + guid,
+ mergeBrowserUrl: false,
+ urlParams: { gType: "category" },
+ trigger: true,
+ updateTabState: true
+ });
+ }
+ };
+ events["click " + this.ui.termClick] = function(e) {
+ if (e.target.nodeName.toLocaleLowerCase() == "i") {
+ this.onClickRemoveAssociationBtn(e);
+ } else {
+ var guid = $(e.currentTarget).data('guid'),
+ termObj = _.find(this.data.terms, { "termGuid": guid });
+ this.glossary.selectedItem = { "type": "GlossaryTerm", "guid": guid, "model": termObj };
+ Utils.setUrl({
+ url: '#!/glossary/' + guid,
+ mergeBrowserUrl: false,
+ urlParams: { gType: "term" },
+ trigger: true,
+ updateTabState: true
+ });
+ }
+ };
+ events["click " + this.ui.editButton] = function(e) {
+ var that = this,
+ model = this.glossaryCollection.fullCollection.get(this.guid);
+ if (this.isGlossaryView) {
+ CommonViewFunction.createEditGlossaryCategoryTerm({
+ "model": model,
+ "isGlossaryView": this.isGlossaryView,
+ "collection": this.glossaryCollection,
+ "callback": function(newModel) {
+ that.data = newModel;
+ model.set(newModel);
+ that.renderDetails(that.data);
+ //that.glossaryCollection.trigger("update:details");
+ }
+ });
+ } else {
+ CommonViewFunction.createEditGlossaryCategoryTerm({
+ "isTermView": this.isTermView,
+ "isCategoryView": this.isCategoryView,
+ "model": this.data,
+ "collection": this.glossaryCollection,
+ "callback": function() {
+ that.getData();
+ that.glossaryCollection.trigger("update:details");
+ }
+ });
+ }
+ };
+ events["click " + this.ui.addTerm] = 'onClickAddTermBtn';
+ events["click " + this.ui.addCategory] = 'onClickAddCategoryBtn';
+ return events;
+ },
+ /**
+ * intialize a new GlossaryDetailLayoutView Layout
+ * @constructs
+ */
+ initialize: function(options) {
+ _.extend(this, _.pick(options, 'guid', 'glossaryCollection', 'glossary', 'collection', 'typeHeaders', 'value', 'entityDefCollection', 'enumDefCollection', 'classificationDefCollection'));
+ if (this.value && this.value.gType) {
+ if (this.value.gType == "category") {
+ this.isCategoryView = true;
+ } else if (this.value.gType == "term") {
+ this.isTermView = true;
+ } else {
+ this.isGlossaryView = true;
+ }
+ }
+ },
+ onRender: function() {
+ this.getData();
+ this.bindEvents();
+ },
+ bindEvents: function() {
+ var that = this;
+ },
+ getData: function() {
+ if (this.glossaryCollection.fullCollection.length && this.isGlossaryView) {
+ this.data = this.glossaryCollection.fullCollection.get(this.guid).toJSON();
+ this.renderDetails(this.data);
+ } else {
+ Utils.showTitleLoader(this.$('.page-title .fontLoader'), this.ui.details);
+ var getApiFunctionKey = "getCategory",
+ that = this;
+ if (this.isTermView) {
+ getApiFunctionKey = "getTerm";
+ }
+ this.glossaryCollection[getApiFunctionKey]({
+ "guid": this.guid,
+ "ajaxOptions": {
+ success: function(data) {
+ if (that.isTermView) {
+ that.renderSearchResultLayoutView();
+ }
+ that.data = data;
+ that.glossary.selectedItem.model = data;
+ that.glossary.selectedItem.guid = data.guid;
+ that.renderDetails(data)
+ },
+ cust_error: function() {}
+ }
+ });
+ }
+ },
+ renderDetails: function(data) {
+ Utils.hideTitleLoader(this.$('.fontLoader'), this.ui.details);
+ this.ui.title.text(data.displayName || data.displayText || data.qualifiedName);
+ this.ui.shortDescription.text(data.shortDescription);
+ this.ui.longDescription.text(data.longDescription);
+ this.generateCategories(data.categories);
+ this.generateTerm(data.terms);
+
+ },
+ generateCategories: function(data) {
+ var that = this,
+ categories = "";
+ _.each(data, function(val) {
+ var name = _.escape(val.displayText);
+ categories += '<span data-guid="' + val.categoryGuid + '"" class="btn btn-action btn-sm btn-icon btn-blue" title=' + _.escape(name) + ' data-id="categoryClick"><span>' + name + '</span><i class="fa fa-close" data-id="removeCategory" data-type="category" title="Remove Category"></i></span>';
+ });
+ this.ui.categoryList.find("span.btn").remove();
+ this.ui.categoryList.prepend(categories);
+ },
+ generateTerm: function(data) {
+ var that = this,
+ terms = "";
+ _.each(data, function(val) {
+ var name = _.escape(val.displayText);
+ terms += '<span data-guid="' + val.termGuid + '"" class="btn btn-action btn-sm btn-icon btn-blue" title=' + _.escape(name) + ' data-id="termClick"><span>' + name + '</span><i class="fa fa-close" data-id="removeTerm" data-type="term" title="Remove Term"></i></span>';
+ });
+ this.ui.termList.find("span.btn").remove();
+ this.ui.termList.prepend(terms);
+
+ },
+ onClickAddTermBtn: function(e) {
+ var that = this;
+ require(['views/glossary/AssignTermLayoutView'], function(AssignTermLayoutView) {
+ var view = new AssignTermLayoutView({
+ categoryData: that.data,
+ isCategoryView: that.isCategoryView,
+ callback: function() {
+ that.getData();
+ },
+ glossaryCollection: that.glossaryCollection
+ });
+ view.modal.on('ok', function() {
+ that.hideLoader();
+ });
+ });
+ },
+ onClickAddCategoryBtn: function(e) {
+ var that = this;
+ require(['views/glossary/AssignTermLayoutView'], function(AssignTermLayoutView) {
+ var view = new AssignTermLayoutView({
+ termData: that.data,
+ isTermView: that.isTermView,
+ callback: function() {
+ that.getData();
+ },
+ glossaryCollection: that.glossaryCollection
+ });
+ view.modal.on('ok', function() {
+ that.hideLoader();
+ });
+ });
+ },
+ onClickRemoveAssociationBtn: function(e) {
+ var $el = $(e.currentTarget),
+ guid = $el.data('guid'),
+ name = $el.text(),
+ that = this;
+ CommonViewFunction.removeCategoryTermAssociation({
+ selectedGuid: guid,
+ model: that.data,
+ collection: that.glossaryCollection,
+ msg: "<div class='ellipsis'>Remove: " + "<b>" + _.escape(name) + "</b> assignment from" + " " + "<b>" + that.data.displayName + "?</b></div>",
+ titleMessage: Messages.glossary[that.isTermView ? "removeCategoryfromTerm" : "removeTermfromCategory"],
+ isCategoryView: that.isCategoryView,
+ isTermView: that.isTermView,
+ buttonText: "Remove",
+ showLoader: that.hideLoader.bind(that),
+ hideLoader: that.hideLoader.bind(that),
+ callback: function() {
+ that.getData();
+ }
+ });
+ },
+ showLoader: function() {
+ Utils.showTitleLoader(this.$('.page-title .fontLoader'), this.ui.details);
+ },
+ hideLoader: function() {
+ Utils.hideTitleLoader(this.$('.page-title .fontLoader'), this.ui.details);
+ },
+ renderSearchResultLayoutView: function() {
+ var that = this;
+ require(['views/search/SearchResultLayoutView'], function(SearchResultLayoutView) {
+ var value = {
+ 'tag': "PII",
+ 'searchType': 'basic'
+ };
+ if (that.RSearchResultLayoutView) {
+ that.RSearchResultLayoutView.show(new SearchResultLayoutView({
+ "value": _.extend({}, that.value, { "searchType": "basic" }),
+ "termName": that.data.qualifiedName,
+ "guid": that.guid,
+ "entityDefCollection": that.entityDefCollection,
+ "typeHeaders": that.typeHeaders,
+ "tagCollection": that.collection,
+ "enumDefCollection": that.enumDefCollection,
+ "classificationDefCollection": that.classificationDefCollection,
+ "fromView": "glossary"
+ }));
+ }
+ });
+ },
+ });
+ return GlossaryDetailLayoutView;
+});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/atlas/blob/3709842a/dashboardv2/public/js/views/glossary/GlossaryLayoutView.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/views/glossary/GlossaryLayoutView.js b/dashboardv2/public/js/views/glossary/GlossaryLayoutView.js
new file mode 100644
index 0000000..57c58c7
--- /dev/null
+++ b/dashboardv2/public/js/views/glossary/GlossaryLayoutView.js
@@ -0,0 +1,528 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+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) {
+ 'use strict';
+
+ var GlossaryLayoutView = Backbone.Marionette.LayoutView.extend(
+ /** @lends GlossaryLayoutView */
+ {
+ _viewName: 'GlossaryLayoutView',
+
+ template: GlossaryLayoutViewTmpl,
+
+ /** Layout sub regions */
+ regions: {},
+ templateHelpers: function() {
+ return {
+ isAssignView: this.isAssignView
+ };
+ },
+
+ /** ui selector cache */
+ ui: {
+ createGlossary: "[data-id='createGlossary']",
+ refreshGlossary: "[data-id='refreshGlossary']",
+ searchTerm: "[data-id='searchTerm']",
+ searchCategory: "[data-id='searchCategory']",
+ glossaryView: 'input[name="glossaryView"]',
+ termTree: "[data-id='termTree']",
+ categoryTree: "[data-id='categoryTree']"
+ },
+ /** ui events hash */
+ events: function() {
+ var events = {};
+ events["change " + this.ui.glossaryView] = 'glossaryViewToggle';
+ events["click " + this.ui.createGlossary] = function(e) {
+ var that = this;
+ if (e) {
+ $(e.currentTarget).attr("disabled", "true");
+ }
+ CommonViewFunction.createEditGlossaryCategoryTerm({
+ isGlossaryView: true,
+ collection: this.glossaryCollection,
+ callback: function() {
+ that.ui.createGlossary.removeAttr("disabled");
+ that.getGlossary();
+ },
+ onModalClose: function() {
+ that.ui.createGlossary.removeAttr("disabled");
+ }
+ })
+ };
+ events["click " + this.ui.refreshGlossary] = 'getGlossary';
+ events["keyup " + this.ui.searchTerm] = function() {
+ this.ui.termTree.jstree("search", this.ui.searchTerm.val());
+ };
+ events["keyup " + this.ui.searchCategory] = function() {
+ this.ui.categoryTree.jstree("search", this.ui.searchCategory.val());
+ };
+ return events;
+ },
+ /**
+ * intialize a new GlossaryLayoutView Layout
+ * @constructs
+ */
+ initialize: function(options) {
+ _.extend(this, _.pick(options, 'guid', 'value', 'glossaryCollection', 'glossary', 'isAssignTermView', 'isAssignCategoryView', 'isAssignEntityView'));
+ this.viewType = "term";
+ this.isAssignView = this.isAssignTermView || this.isAssignCategoryView || this.isAssignEntityView;
+ this.bindEvents();
+ this.query = {
+ term: {
+ url: null
+ },
+ category: {
+ url: null
+ }
+ };
+ },
+ bindEvents: function() {
+ var that = this;
+ this.listenTo(this.glossaryCollection.fullCollection, "reset add remove change", function() {
+ this.generateTree();
+ }, this);
+ this.listenTo(this.glossaryCollection, "update:details", function() {
+ this.getGlossary();
+ }, this);
+ $('body').on('click', '.termPopoverOptions li, .categoryPopoverOptions li', function(e) {
+ that.$('.termPopover,.categoryPopover').popover('hide');
+ that[$(this).find('a').data('fn')](e)
+ });
+ },
+ onRender: function() {
+ if (this.isAssignCategoryView) {
+ this.$('.category-view').show();
+ this.$('.term-view').hide();
+ }
+ if (this.isAssignView && this.glossaryCollection.fullCollection.length) {
+ this.generateTree();
+ } else {
+ this.getGlossary();
+ }
+ },
+ glossaryViewToggle: function(e) {
+ if (e.currentTarget.checked) {
+ this.$('.category-view').show();
+ this.$('.term-view').hide();
+ this.viewType = "category";
+ } else {
+ this.$('.term-view').show();
+ this.$('.category-view').hide();
+ this.viewType = "term";
+ }
+ if (Utils.getUrlState.isGlossaryTab()) {
+ // var name = this.query[this.viewType].url;
+ // var guid = this.glossary.selectedItem.guid;
+ // Utils.setUrl({
+ // url: '#!/glossary/' + guid,
+ // urlParams: {
+ // viewType: this.viewType,
+ // },
+ // mergeBrowserUrl: false,
+ // trigger: true,
+ // updateTabState: true
+ // });
+ }
+ },
+ getGlossary: function() {
+ this.glossaryCollection.fetch({ reset: true });
+ },
+ generateCategoryData: function(options) {
+ return _.map(options.data, function(obj) {
+ return {
+ "text": obj.displayText,
+ "icon": "fa fa-files-o",
+ "guid": obj.categoryGuid,
+ "id": obj.categoryGuid,
+ "glossaryId": options.node.glossaryId,
+ "glossaryName": options.node.glossaryName,
+ "model": obj,
+ "type": "GlossaryCategory",
+ "children": true
+ }
+ });
+ },
+ getCategory: function(options) {
+ var that = this;
+ this.glossaryCollection.getCategory({
+ "guid": options.node.guid,
+ "related": true,
+ "ajaxOptions": {
+ success: function(data) {
+ if (data && data.children) {
+ options.callback(that.generateCategoryData(_.extend({}, { "data": data.children }, options)));
+ } else {
+ options.callback([]);
+ }
+ },
+ cust_error: function() {
+ options.callback([]);
+ }
+ }
+ });
+ },
+ generateData: function(opt) {
+ var that = this,
+ type = opt.type;
+ var getSelectedState = function(options) {
+ var objGuid = options.objGuid,
+ node = options.node,
+ index = options.index;
+ if (!that.guid) {
+ var selectedItem = {
+ "type": "Glossary",
+ "model": that.glossaryCollection.first().toJSON()
+ };
+ selectedItem.text = selectedItem.model.displayName;
+ selectedItem.guid = selectedItem.model.guid;
+ if (index == 0 && selectedItem.guid == objGuid) {
+ that.glossary.selectedItem = selectedItem;
+ return {
+ 'opened': true,
+ 'selected': true
+ }
+ }
+ } else {
+ if (that.guid == objGuid) {
+ that.glossary.selectedItem = node
+ return {
+ 'opened': true,
+ 'selected': true
+ }
+ }
+ }
+ }
+ return this.glossaryCollection.fullCollection.map(function(model, i) {
+ var obj = model.toJSON(),
+ parent = {
+ "text": obj.displayName,
+ "icon": "fa fa-folder-o",
+ "guid": obj.guid,
+ "id": obj.guid,
+ "model": obj,
+ "type": obj.typeName ? obj.typeName : "Glossary",
+ "children": []
+ }
+ parent.state = getSelectedState({
+ index: i,
+ node: parent,
+ objGuid: obj.guid
+ });
+
+ if (type == "category" && obj.categories) {
+ _.each(obj.categories, function(category) {
+ if (category.parentCategoryGuid) {
+ return;
+ }
+ var type = category.typeName || "GlossaryCategory",
+ guid = category.categoryGuid,
+ categoryObj = {
+ "text": category.displayText,
+ "type": type,
+ "guid": guid,
+ "id": guid,
+ "parent": obj,
+ "glossaryId": obj.guid,
+ "glossaryName": obj.displayName,
+ "model": category,
+ "children": true,
+ "icon": "fa fa-files-o",
+ };
+ categoryObj.state = getSelectedState({
+ index: i,
+ node: categoryObj,
+ objGuid: guid
+ })
+ parent.children.push(categoryObj)
+ });
+ }
+ if (type == "term" && obj.terms) {
+ _.each(obj.terms, function(term) {
+ var type = term.typeName || "GlossaryTerm",
+ guid = term.termGuid,
+ termObj = {
+ "text": term.displayText,
+ "type": type,
+ "guid": guid,
+ "id": guid,
+ "parent": obj,
+ "glossaryName": obj.displayName,
+ "glossaryId": obj.guid,
+ "model": term,
+ "icon": "fa fa-file-o"
+ }
+ termObj.state = getSelectedState({
+ index: i,
+ node: termObj,
+ objGuid: guid
+ })
+ parent.children.push(termObj);
+ });
+ }
+ return parent;
+ });
+ },
+ manualRender: function(options) {
+ _.extend(this, options);
+ this.triggerUrl();
+ },
+ generateTree: function() {
+ var $termTree = this.ui.termTree,
+ $categoryTree = this.ui.categoryTree,
+ that = this,
+ getTreeConfig = function(options) {
+ return {
+ "plugins": ["search", "themes", "core", "wholerow", "sort", "conditionalselect"],
+ "conditionalselect": function(node) {
+ if (that.isAssignView) {
+ return node.original.type != "Glossary" ? true : false;
+ } else {
+ return node.original.type != "NoAction" ? true : false;
+ }
+ },
+ "core": {
+ "data": function(node, cb) {
+ if (node.id === "#") {
+ cb(that.generateData(options));
+ } else {
+ that.getCategory({ "node": node.original, "callback": cb });
+ }
+ },
+ "themes": {
+ "name": that.isAssignView ? "default" : "default-dark",
+ "dots": true
+ },
+ }
+ }
+ },
+ treeLoaded = function() {
+ if (that.selectFirstNodeManually) {
+ that.selectFirstNodeManually = false;
+ var id = that.glossary.selectedItem.guid;
+ $treeEl.jstree('select_node', '#' + id + '_anchor');
+ $treeEl.jstree('open_node', '#' + id + '_anchor');
+ }
+ },
+ createAction = function(options) {
+ var $el = options.el,
+ type = options.type,
+ popoverClassName = type == "term" ? "termPopover" : "categoryPopover";
+ if (!that.isAssignView) {
+ var wholerowEl = $el.find("li[role='treeitem'] > .jstree-wholerow:not(:has(>div.tools))")
+ wholerowEl.append('<div class="tools"><i class="fa fa-ellipsis-h ' + popoverClassName + '"></i></div>');
+
+ if (type == "term") {
+ that.createTermAction();
+ } else if (type == "category") {
+ that.createCategoryAction();
+ }
+ }
+ },
+ initializeTree = function(options) {
+ var $el = options.el,
+ type = options.type;
+
+ $el.jstree(getTreeConfig({
+ type: type
+ })).on("load_node.jstree", function(e, data) {
+ createAction(_.extend({}, options, data));
+ }).on("open_node.jstree", function(e, data) {
+ createAction(_.extend({}, options, data));
+ })
+ .on("select_node.jstree", function(e, data) {
+ that.glossary.selectedItem = data.node.original;
+ //$("." + popoverClassName).popover('hide');
+ that.triggerUrl();
+ }).bind('loaded.jstree', function(e, data) {
+ treeLoaded();
+ });
+ },
+ initializeTermTree = function() {
+ if ($termTree.data('jstree')) {
+ $('.termPopover').popover('destroy');
+ $termTree.jstree(true).refresh();
+ } else {
+ initializeTree({
+ el: $termTree,
+ type: "term"
+ });
+ }
+ },
+ initializeCategoryTree = function() {
+ if ($categoryTree.data('jstree')) {
+ $categoryTree.jstree(true).refresh();
+ } else {
+ initializeTree({
+ el: $categoryTree,
+ type: "category"
+ })
+ }
+ }
+ if (this.isAssignView) {
+ if (this.isAssignTermView || this.isAssignEntityView) {
+ initializeTermTree();
+ } else if (this.isAssignCategoryView) {
+ initializeCategoryTree();
+ }
+ } else {
+ initializeTermTree();
+ initializeCategoryTree();
+ }
+
+
+ if (Utils.getUrlState.isGlossaryTab()) {
+ this.triggerUrl();
+ }
+ this.glossaryCollection.trigger("render:done");
+ },
+ createTermAction: function() {
+ var that = this;
+ Utils.generatePopover({
+ el: this.$('.termPopover'),
+ contentClass: 'termPopoverOptions',
+ popoverOptions: {
+ content: function() {
+ var node = that.glossary.selectedItem,
+ liString = "";
+ if (node.type == "Glossary") {
+ liString = "<li data-type=" + node.type + " class='listTerm'><i class='fa fa-plus'></i> <a href='javascript:void(0)' data-fn='createSubNode'>Create Sub-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'>Delete Glossary</a></li>"
+ } else {
+ liString = "<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>"
+ }
+ return "<ul>" + liString + "</ul>";
+ }
+ }
+ });
+ },
+ createCategoryAction: function() {
+ var that = this;
+ Utils.generatePopover({
+ el: this.$('.categoryPopover'),
+ contentClass: 'categoryPopoverOptions',
+ popoverOptions: {
+ content: function() {
+ var node = that.glossary.selectedItem,
+ liString = "";
+ if (node.type == "Glossary") {
+ liString = "<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 Glossary</a></li>"
+ } else {
+ liString = "<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>"
+ }
+ return "<ul>" + liString + "</ul>";
+ }
+ }
+ });
+ },
+ createSubNode: function(opt) {
+ var that = this,
+ type = this.glossary.selectedItem.type;
+ if ((type == "Glossary" || type == "GlossaryCategory") && this.viewType == "category") {
+ CommonViewFunction.createEditGlossaryCategoryTerm({
+ "isCategoryView": true,
+ "collection": that.glossaryCollection,
+ "callback": function() {
+ that.getGlossary();
+ },
+ "node": this.glossary.selectedItem
+ })
+ } else {
+ CommonViewFunction.createEditGlossaryCategoryTerm({
+ "isTermView": true,
+ "callback": function() {
+ that.getGlossary();
+ },
+ "collection": that.glossaryCollection,
+ "node": this.glossary.selectedItem
+ })
+ }
+ },
+ deleteNode: function(opt) {
+ var that = this,
+ messageType = "",
+ options = {
+ success: function(rModel, response) {
+ Utils.notifySuccess({
+ content: messageType + Messages.deleteSuccessMessage
+ });
+ that.getGlossary();
+ }
+ },
+ type = this.glossary.selectedItem.type,
+ guid = this.glossary.selectedItem.guid
+ if (type == "Glossary") {
+ messageType = "Glossary";
+ this.glossaryCollection.fullCollection.get(guid).destroy(options);
+ } else if (type == "GlossaryCategory") {
+ messageType = "Category"
+ new this.glossaryCollection.model().deleteCategory(guid, options);
+ } else if (type == "GlossaryTerm") {
+ messageType = "Term";
+ new this.glossaryCollection.model().deleteTerm(guid, options);
+ }
+ },
+ triggerUrl: function() {
+ if (this.isAssignView) {
+ return;
+ }
+ var selectedItem = this.glossary.selectedItem;
+ if (this.glossaryCollection.length && _.isEmpty(selectedItem)) {
+ selectedItem = { "model": this.glossaryCollection.first().toJSON() };
+ selectedItem.guid = selectedItem.model.guid;
+ selectedItem.type = "glossary";
+ this.glossary.selectedItem = selectedItem;
+ this.selectFirstNodeManually = true;
+ }
+ if (_.isEmpty(selectedItem)) {
+ return;
+ }
+ var type = selectedItem.type;
+ if (Utils.getUrlState.isGlossaryTab() || Utils.getUrlState.isDetailPage()) {
+ var urlParams = { gType: "glossary" },
+ guid = selectedItem.guid;
+ if (type === "GlossaryTerm") {
+ urlParams.gType = "term";
+ } else if (type === "GlossaryCategory") {
+ urlParams.gType = "category";
+ }
+ if (selectedItem.glossaryId) {
+ urlParams["gId"] = selectedItem.glossaryId;
+ }
+ Utils.setUrl({
+ url: '#!/glossary/' + guid,
+ mergeBrowserUrl: false,
+ trigger: true,
+ urlParams: urlParams,
+ updateTabState: true
+ });
+ }
+ }
+ });
+ return GlossaryLayoutView;
+});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/atlas/blob/3709842a/dashboardv2/public/js/views/schema/SchemaLayoutView.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/views/schema/SchemaLayoutView.js b/dashboardv2/public/js/views/schema/SchemaLayoutView.js
index 41ec8eb..4bee673 100644
--- a/dashboardv2/public/js/views/schema/SchemaLayoutView.js
+++ b/dashboardv2/public/js/views/schema/SchemaLayoutView.js
@@ -174,12 +174,12 @@ define(['require',
that.$('.multiSelectTag').hide();
Utils.generatePopover({
el: that.$('[data-id="showMoreLess"]'),
- contentClass: 'popover-tag',
+ contentClass: 'popover-tag-term',
viewFixedPopover: true,
popoverOptions: {
container: null,
content: function() {
- return $(this).find('.popup-tag').children().clone();
+ return $(this).find('.popup-tag-term').children().clone();
}
}
});
http://git-wip-us.apache.org/repos/asf/atlas/blob/3709842a/dashboardv2/public/js/views/search/SearchResultLayoutView.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/views/search/SearchResultLayoutView.js b/dashboardv2/public/js/views/search/SearchResultLayoutView.js
index 6835f03..0318c32 100644
--- a/dashboardv2/public/js/views/search/SearchResultLayoutView.js
+++ b/dashboardv2/public/js/views/search/SearchResultLayoutView.js
@@ -51,7 +51,9 @@ define(['require',
/** ui selector cache */
ui: {
tagClick: '[data-id="tagClick"]',
+ termClick: '[data-id="termClick"]',
addTag: '[data-id="addTag"]',
+ addTerm: '[data-id="addTerm"]',
paginationDiv: '[data-id="paginationDiv"]',
previousData: "[data-id='previousData']",
nextData: "[data-id='nextData']",
@@ -94,6 +96,20 @@ define(['require',
});
}
};
+ events["click " + this.ui.termClick] = function(e) {
+ var scope = $(e.currentTarget);
+ if (e.target.nodeName.toLocaleLowerCase() == "i") {
+ this.onClickTermCross(e);
+ } else {
+ this.triggerUrl({
+ url: '#!/glossary/' + scope.find('i').data('termguid'),
+ urlParams: { gType: "term" },
+ mergeBrowserUrl: false,
+ trigger: true,
+ updateTabState: null
+ });
+ }
+ };
events["keyup " + this.ui.gotoPage] = function(e) {
var code = e.which,
goToPage = parseInt(e.currentTarget.value);
@@ -111,6 +127,7 @@ define(['require',
events["change " + this.ui.showPage] = 'changePageLimit';
events["click " + this.ui.gotoPagebtn] = 'gotoPagebtn';
events["click " + this.ui.addTag] = 'checkedValue';
+ events["click " + this.ui.addTerm] = 'onClickAddTermBtn';
events["click " + this.ui.addAssignTag] = 'checkedValue';
events["click " + this.ui.nextData] = "onClicknextData";
events["click " + this.ui.previousData] = "onClickpreviousData";
@@ -125,7 +142,7 @@ define(['require',
* @constructs
*/
initialize: function(options) {
- _.extend(this, _.pick(options, 'value', 'initialView', 'isTypeTagNotExists', 'classificationDefCollection', 'entityDefCollection', 'typeHeaders', 'searchVent', 'enumDefCollection', 'tagCollection', 'searchTableColumns', 'isDisable', 'fromView'));
+ _.extend(this, _.pick(options, 'value', 'guid', 'initialView', 'isTypeTagNotExists', 'classificationDefCollection', 'entityDefCollection', 'typeHeaders', 'searchVent', 'enumDefCollection', 'tagCollection', 'searchTableColumns', 'isDisable', 'fromView', 'glossaryCollection', 'termName'));
this.entityModel = new VEntity();
this.searchCollection = new VSearchList();
this.limit = 25;
@@ -200,7 +217,7 @@ define(['require',
this.updateColumnList(state);
var excludeDefaultColumn = [];
if (this.value && this.value.type) {
- excludeDefaultColumn = _.without(this.searchTableColumns[this.value.type], "selected", "name", "description", "typeName", "owner", "tag");
+ excludeDefaultColumn = _.without(this.searchTableColumns[this.value.type], "selected", "name", "description", "typeName", "owner", "tag", "term");
if (this.searchTableColumns[this.value.type] === null) {
this.ui.columnEmptyInfo.show();
} else {
@@ -459,7 +476,7 @@ define(['require',
if (value.searchType) {
this.searchCollection.url = UrlLinks.searchApiUrl(value.searchType);
}
- _.extend(this.searchCollection.queryParams, { 'limit': this.limit, 'offset': this.offset, 'query': _.trim(value.query), 'typeName': value.type || null, 'classification': value.tag || null });
+ _.extend(this.searchCollection.queryParams, { 'limit': this.limit, 'offset': this.offset, 'query': _.trim(value.query), 'typeName': value.type || null, 'classification': value.tag || null, 'termName': that.termName || null });
if (value.profileDBView && value.typeName && value.guid) {
var profileParam = {};
profileParam['guid'] = value.guid;
@@ -470,7 +487,7 @@ define(['require',
}
if (isPostMethod) {
this.searchCollection.filterObj = _.extend({}, filterObj);
- apiObj['data'] = _.extend(checkBoxValue, filterObj, _.pick(this.searchCollection.queryParams, 'query', 'excludeDeletedEntities', 'limit', 'offset', 'typeName', 'classification'))
+ apiObj['data'] = _.extend(checkBoxValue, filterObj, _.pick(this.searchCollection.queryParams, 'query', 'excludeDeletedEntities', 'limit', 'offset', 'typeName', 'classification', 'termName'))
Globals.searchApiCallRef = this.searchCollection.getBasicRearchResult(apiObj);
} else {
apiObj.data = null;
@@ -482,7 +499,7 @@ define(['require',
}
} else {
if (isPostMethod) {
- apiObj['data'] = _.extend(checkBoxValue, filterObj, _.pick(this.searchCollection.queryParams, 'query', 'excludeDeletedEntities', 'limit', 'offset', 'typeName', 'classification'));
+ apiObj['data'] = _.extend(checkBoxValue, filterObj, _.pick(this.searchCollection.queryParams, 'query', 'excludeDeletedEntities', 'limit', 'offset', 'typeName', 'classification', 'termName'));
Globals.searchApiCallRef = this.searchCollection.getBasicRearchResult(apiObj);
} else {
apiObj.data = null;
@@ -561,12 +578,12 @@ define(['require',
this.hideLoader();
Utils.generatePopover({
el: this.$('[data-id="showMoreLess"]'),
- contentClass: 'popover-tag',
+ contentClass: 'popover-tag-term',
viewFixedPopover: true,
popoverOptions: {
container: null,
content: function() {
- return $(this).find('.popup-tag').children().clone();
+ return $(this).find('.popup-tag-term').children().clone();
}
}
});
@@ -580,6 +597,7 @@ define(['require',
if (this.value && this.value.searchType === "basic" && this.searchTableColumns && (this.searchTableColumns[this.value.type] !== undefined)) {
columnToShow = this.searchTableColumns[this.value.type] == null ? [] : this.searchTableColumns[this.value.type];
}
+
col['Check'] = {
name: "selected",
label: "Select",
@@ -590,6 +608,7 @@ define(['require',
headerCell: "select-all"
};
+
col['name'] = {
label: this.value && this.value.profileDBView ? "Table Name" : "Name",
cell: "html",
@@ -617,6 +636,7 @@ define(['require',
}
})
};
+
col['owner'] = {
label: "Owner",
cell: "String",
@@ -634,6 +654,8 @@ define(['require',
}
})
};
+
+
if (this.value && this.value.profileDBView) {
col['createTime'] = {
label: "Date Created",
@@ -653,6 +675,7 @@ define(['require',
}
}
if (this.value && !this.value.profileDBView) {
+
col['description'] = {
label: "Description",
cell: "String",
@@ -670,6 +693,8 @@ define(['require',
}
})
};
+
+
col['typeName'] = {
label: "Type",
cell: "Html",
@@ -688,6 +713,9 @@ define(['require',
})
};
this.getTagCol({ 'col': col, 'columnToShow': columnToShow });
+ if (this.fromView != "glossary") {
+ this.getTermCol({ 'col': col, 'columnToShow': columnToShow });
+ }
if (this.value && this.value.searchType === "basic") {
var def = this.entityDefCollection.fullCollection.find({ name: this.value.type });
@@ -806,6 +834,34 @@ define(['require',
};
}
},
+ getTermCol: function(options) {
+ var that = this,
+ columnToShow = options.columnToShow,
+ col = options.col;
+ if (col) {
+ col['term'] = {
+ label: "Term",
+ cell: "Html",
+ editable: false,
+ sortable: false,
+ resizeable: true,
+ orderable: true,
+ renderable: (columnToShow ? _.contains(columnToShow, 'term') : true),
+ className: 'searchTag',
+ formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
+ fromRaw: function(rawValue, model) {
+ var obj = model.toJSON();
+ if (obj.status && Enums.entityStateReadOnly[obj.status]) {
+ return '<div class="readOnly">' + CommonViewFunction.termForTable(obj); + '</div>';
+ } else {
+ return CommonViewFunction.termForTable(obj);
+ }
+
+ }
+ })
+ };
+ }
+ },
addTagModalView: function(guid, multiple) {
var that = this;
require(['views/tag/AddTagModalView'], function(AddTagModalView) {
@@ -863,6 +919,19 @@ define(['require',
that.addTagModalView(guid);
}
},
+ onClickAddTermBtn: function(e) {
+ var that = this,
+ entityGuid = $(e.currentTarget).data("guid");
+ require(['views/glossary/AssignTermLayoutView'], function(AssignTermLayoutView) {
+ var view = new AssignTermLayoutView({
+ guid: entityGuid,
+ callback: function() {
+ that.fetchCollection();
+ },
+ glossaryCollection: that.glossaryCollection,
+ });
+ });
+ },
onClickTagCross: function(e) {
var that = this,
tagName = $(e.target).data("name"),
@@ -885,6 +954,31 @@ define(['require',
});
}
},
+ onClickTermCross: function(e) {
+ var $el = $(e.target),
+ termGuid = $el.data('termguid'),
+ guid = $el.data('guid'),
+ termName = $(e.currentTarget).text(),
+ assetname = $el.data('assetname'),
+ meanings = this.searchCollection.find({ "guid": guid }).get("meanings"),
+ that = this,
+ termObj = _.find(meanings, { termGuid: termGuid });
+ CommonViewFunction.removeCategoryTermAssociation({
+ termGuid: termGuid,
+ model: {
+ guid: guid,
+ relationshipGuid: termObj.relationGuid
+ },
+ collection: that.glossaryCollection,
+ msg: "<div class='ellipsis'>Remove: " + "<b>" + _.escape(termName) + "</b> assignment from" + " " + "<b>" + assetname + "?</b></div>",
+ titleMessage: Messages.glossary.removeTermfromEntity,
+ isEntityView: true,
+ buttonText: "Remove",
+ callback: function() {
+ that.fetchCollection();
+ }
+ });
+ },
deleteTagData: function(options) {
var that = this;
CommonViewFunction.deleteTag(_.extend({}, options, {
http://git-wip-us.apache.org/repos/asf/atlas/blob/3709842a/dashboardv2/public/js/views/site/Header.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/views/site/Header.js b/dashboardv2/public/js/views/site/Header.js
index bd58986..e96559d 100644
--- a/dashboardv2/public/js/views/site/Header.js
+++ b/dashboardv2/public/js/views/site/Header.js
@@ -36,8 +36,12 @@ define(['require',
events['click ' + this.ui.backButton] = function() {
var queryParams = Utils.getUrlState.getQueryParams(),
urlPath = "searchUrl";
- if (queryParams && queryParams.from && queryParams.from == "classification") {
- urlPath = "tagUrl";
+ if (queryParams && queryParams.from) {
+ if (queryParams.from == "classification") {
+ urlPath = "tagUrl";
+ } else if(queryParams.from == "glossary"){
+ urlPath = "glossaryUrl";
+ }
}
Utils.setUrl({
url: Globals.saveApplicationState.tabState[urlPath],
http://git-wip-us.apache.org/repos/asf/atlas/blob/3709842a/dashboardv2/public/js/views/site/SideNavLayoutView.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/views/site/SideNavLayoutView.js b/dashboardv2/public/js/views/site/SideNavLayoutView.js
index b00451b..87cf4e8 100644
--- a/dashboardv2/public/js/views/site/SideNavLayoutView.js
+++ b/dashboardv2/public/js/views/site/SideNavLayoutView.js
@@ -29,14 +29,14 @@ define(['require',
regions: {
RTagLayoutView: "#r_tagLayoutView",
- RSearchLayoutView: "#r_searchLayoutView"
+ RSearchLayoutView: "#r_searchLayoutView",
+ RGlossaryLayoutView: "#r_glossaryLayoutView"
},
ui: {
tabs: '.tabs li a',
},
templateHelpers: function() {
return {
- tabClass: this.tabClass,
apiBaseUrl: UrlLinks.apiBaseUrl
};
},
@@ -60,11 +60,14 @@ define(['require',
}
}
- if (elementName.name == "tab-tag") {
+ if (elementName.name == "tab-classification") {
urlString = tabStateUrls.tagUrl; //'#!/tag';
} else if (elementName.name == "tab-search") {
urlString = tabStateUrls.searchUrl; // '#!/search';
+ } else if (elementName.name == "tab-glossary") {
+ urlString = tabStateUrls.glossaryUrl; // '#!/glossary';
}
+
Utils.setUrl({
url: urlString,
mergeBrowserUrl: false,
@@ -75,40 +78,35 @@ define(['require',
return events;
},
initialize: function(options) {
- _.extend(this, _.pick(options, 'url', 'value', 'tag', 'selectFirst', 'classificationDefCollection', 'typeHeaders', 'searchVent', 'entityDefCollection', 'enumDefCollection', 'searchTableColumns', 'searchTableFilters'));
- this.tabClass = "tab col-sm-6";
+ this.options = options;
},
onRender: function() {
this.renderTagLayoutView();
this.renderSearchLayoutView();
+ this.renderGlossaryLayoutView();
this.selectTab();
},
renderTagLayoutView: function() {
var that = this;
require(['views/tag/TagLayoutView'], function(TagLayoutView) {
- that.RTagLayoutView.show(new TagLayoutView({
- collection: that.classificationDefCollection,
- tag: that.tag,
- value: that.value,
- enumDefCollection: that.enumDefCollection,
- typeHeaders: that.typeHeaders
- }));
+ that.RTagLayoutView.show(new TagLayoutView(
+ _.extend(that.options, {
+ "collection": that.options.classificationDefCollection
+ })
+ ));
});
},
renderSearchLayoutView: function() {
var that = this;
require(['views/search/SearchLayoutView'], function(SearchLayoutView) {
- that.RSearchLayoutView.show(new SearchLayoutView({
- value: that.value,
- searchVent: that.searchVent,
- typeHeaders: that.typeHeaders,
- entityDefCollection: that.entityDefCollection,
- enumDefCollection: that.enumDefCollection,
- classificationDefCollection: that.classificationDefCollection,
- searchTableColumns: that.searchTableColumns,
- searchTableFilters: that.searchTableFilters
- }));
+ that.RSearchLayoutView.show(new SearchLayoutView(that.options));
+ });
+ },
+ renderGlossaryLayoutView: function() {
+ var that = this;
+ require(['views/glossary/GlossaryLayoutView'], function(GlossaryLayoutView) {
+ that.RGlossaryLayoutView.show(new GlossaryLayoutView(that.options));
});
},
selectTab: function() {
@@ -121,12 +119,18 @@ define(['require',
if (Utils.getUrlState.isSearchTab() || Utils.getUrlState.isInitial()) {
activeTab({ "view": "search" });
} else if (Utils.getUrlState.isTagTab()) {
- activeTab({ "view": "tag" });
+ activeTab({ "view": "classification" });
+ } else if (Utils.getUrlState.isGlossaryTab()) {
+ activeTab({ "view": "glossary" });
} else if (Utils.getUrlState.isDetailPage()) {
var queryParams = Utils.getUrlState.getQueryParams(),
view = "search";
- if (queryParams && queryParams.from && queryParams.from == "classification") {
- view = "tag";
+ if (queryParams && queryParams.from) {
+ if (queryParams.from == "classification") {
+ view = "tag";
+ } else if (queryParams.from == "glossary") {
+ view = "glossary";
+ }
}
activeTab({ "view": view });
}