Repository: incubator-atlas
Updated Branches:
  refs/heads/master db0d3f9b7 -> 9e23fdc1b


ATLAS-857 : Atlas UI: Default taxonomy object creation


Project: http://git-wip-us.apache.org/repos/asf/incubator-atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-atlas/commit/9e23fdc1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-atlas/tree/9e23fdc1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-atlas/diff/9e23fdc1

Branch: refs/heads/master
Commit: 9e23fdc1bf456c049c66cddf1b8035d99044afd9
Parents: db0d3f9
Author: Keval Bhatt <[email protected]>
Authored: Fri Jun 3 13:51:17 2016 +0530
Committer: Suma Shivaprasad <[email protected]>
Committed: Fri Jun 3 12:59:54 2016 -0700

----------------------------------------------------------------------
 .../BusinessCatalogLayoutView.js                | 67 +++++++++++++++++++-
 1 file changed, 66 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/9e23fdc1/dashboardv2/public/js/views/business_catalog/BusinessCatalogLayoutView.js
----------------------------------------------------------------------
diff --git 
a/dashboardv2/public/js/views/business_catalog/BusinessCatalogLayoutView.js 
b/dashboardv2/public/js/views/business_catalog/BusinessCatalogLayoutView.js
index 53511e6..3e88b6d 100644
--- a/dashboardv2/public/js/views/business_catalog/BusinessCatalogLayoutView.js
+++ b/dashboardv2/public/js/views/business_catalog/BusinessCatalogLayoutView.js
@@ -83,7 +83,13 @@ define(['require',
                 var that = this;
                 this.listenTo(this.parentCollection, 'reset', function() {
                     this.dblClick = false;
-                    this.generateTree(true);
+                    if (this.parentCollection.fullCollection.models.length) {
+                        this.generateTree(true);
+                    } else {
+                        if (Utils.getUrlState.isTaxonomyTab()) {
+                            this.createDefaultTaxonomy();
+                        }
+                    }
                 }, this);
                 this.listenTo(this.childCollection, 'reset', function() {
                     this.dblClick = false;
@@ -516,6 +522,65 @@ define(['require',
                 this.refresh = this.$('.taxonomyTree').find('.active 
a').data('href');
                 this.fetchCollection(this.url);
                 this.changeArrowState();
+            },
+            createDefaultTaxonomy: function() {
+                var that = this;
+                require([
+                    'views/business_catalog/AddTermLayoutView',
+                    'modules/Modal'
+                ], function(AddTermLayoutView, Modal) {
+                    var view = new AddTermLayoutView({
+                        url: "/api/atlas/v1/taxonomies",
+                        model: new that.parentCollection.model()
+                    });
+                    var modal = new Modal({
+                        title: 'Default taxonomy',
+                        content: view,
+                        okCloses: true,
+                        showFooter: true,
+                        allowCancel: true,
+                        okText: 'Create',
+                    }).open();
+                    modal.$el.find('button.ok').attr('disabled', true);
+                    modal.on('ok', function() {
+                        that.saveDefaultTaxonomy(view);
+                    });
+                    view.ui.termName.attr("placeholder", "Default taxonomy 
name");
+                    view.ui.termName.on('keyup', function() {
+                        if (this.value.indexOf(' ') >= 0) {
+                            modal.$el.find('button.ok').prop('disabled', true);
+                        } else {
+                            modal.$el.find('button.ok').prop('disabled', 
false);
+                        }
+
+                    });
+                    view.on('closeModal', function() {
+                        modal.trigger('cancel');
+                    });
+                });
+            },
+            saveDefaultTaxonomy: function(view) {
+                var that = this;
+                var url = view.url;
+                view.model.url = url + "/" + view.ui.termName.val();
+                this.showLoader();
+                view.model.set({ description: view.ui.termDetail.val() 
}).save(null, {
+                    success: function(model, response) {
+                        that.fetchCollection(view.model.url, true);
+                        that.forwardClick(undefined, undefined, 
view.model.url);
+                        Utils.notifySuccess({
+                            content: "Default taxonomy" + 
view.ui.termName.val() + " Created successfully"
+                        });
+                    },
+                    error: function(error, data, status) {
+                        Utils.notifyError({
+                            content: "Default taxonomy " + 
view.ui.termName.val() + " could not be Created"
+                        });
+                    },
+                    complete: function() {
+                        that.hideLoader();
+                    }
+                });
             }
         });
     return BusinessCatalogLayoutView;

Reply via email to