Commit db0d3f9b by Kalyani Kashikar Committed by Suma Shivaprasad

ATLAS-793 Business Catalog Delete / ATLAS-845 : Atlas UI to delete terms using API

parent 86494ffd
...@@ -37,6 +37,14 @@ define(['require', ...@@ -37,6 +37,14 @@ define(['require',
toString: function() { toString: function() {
return this.get('name'); return this.get('name');
}, },
deleteTerm: function(termURL, options) {
var url = Globals.baseURL + termURL;
options = _.extend({
contentType: 'application/json',
dataType: 'json'
}, options);
return this.constructor.nonCrudOperation.call(this, url, 'DELETE', options);
}
}, {}); }, {});
return VCatalog; return VCatalog;
}); });
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
<form name="tagDefinitionform" class="css-form" onsubmit="return false;"> <form name="tagDefinitionform" class="css-form" onsubmit="return false;">
<!-- <h4 style="margin-bottom:30px">Add Term</h4> --> <!-- <h4 style="margin-bottom:30px">Add Term</h4> -->
<div class="form-group"> <div class="form-group">
<input class="form-control" data-id="termName" placeholder="Add subterm"> <input class="form-control" data-id="termName" placeholder="Add subterm" autofocus>
</div> </div>
<div class="form-group"> <div class="form-group">
<textarea class="form-control" data-id="termDetail" placeholder="Description"></textarea> <textarea class="form-control" data-id="termDetail" placeholder="Description"></textarea>
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
<div class="row row-margin-bottom"> <div class="row row-margin-bottom">
<div class="col-sm-12"> <div class="col-sm-12">
<div class="form-group"> <div class="form-group">
<input type="text" class="form-control row-margin-top" name="name" data-id="attributeId" placeholder="Attribute name" required="" value={{name}}> <input type="text" class="form-control row-margin-top" name="name" data-id="attributeId" autofocus placeholder="Attribute name" required="" value={{name}}>
</div> </div>
</div> </div>
</div> </div>
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
<form name="tagDefinitionform" class="css-form"> <form name="tagDefinitionform" class="css-form">
<!-- <h4 style="margin-bottom:30px"></h4> --> <!-- <h4 style="margin-bottom:30px"></h4> -->
<div class="form-group"> <div class="form-group">
<input class="form-control row-margin-bottom" data-id="tagName" placeholder="Name(required)"> <input class="form-control row-margin-bottom" data-id="tagName" placeholder="Name(required)" autofocus>
</input> </input>
<input class="form-control row-margin-bottom" data-id="description" placeholder="Description"> <input class="form-control row-margin-bottom" data-id="description" placeholder="Description">
</input> </input>
......
...@@ -101,8 +101,7 @@ define(['require', ...@@ -101,8 +101,7 @@ define(['require',
content: response.responseJSON.message content: response.responseJSON.message
}); });
} }
this.$('.taxanomyloader').hide(); this.hideLoader();
this.$('.contentLoading').hide();
}, this); }, this);
this.listenTo(this.parentCollection, 'error', function(model, response) { this.listenTo(this.parentCollection, 'error', function(model, response) {
if (response && response.responseJSON && response.responseJSON.message) { if (response && response.responseJSON && response.responseJSON.message) {
...@@ -110,8 +109,7 @@ define(['require', ...@@ -110,8 +109,7 @@ define(['require',
content: response.responseJSON.message content: response.responseJSON.message
}); });
} }
this.$('.taxanomyloader').hide(); this.hideLoader();
this.$('.contentLoading').hide();
}, this); }, this);
}, },
onRender: function() { onRender: function() {
...@@ -153,7 +151,6 @@ define(['require', ...@@ -153,7 +151,6 @@ define(['require',
} }
}, },
changeArrowState: function(e) { changeArrowState: function(e) {
var scope = this.$('[data-id="expandArrow"]'); var scope = this.$('[data-id="expandArrow"]');
if (e) { if (e) {
scope = $(e.currentTarget); scope = $(e.currentTarget);
...@@ -174,8 +171,6 @@ define(['require', ...@@ -174,8 +171,6 @@ define(['require',
this.ui.childList.show(); this.ui.childList.show();
} }
} }
}, },
fetchCollection: function(url, isParent) { fetchCollection: function(url, isParent) {
if (url) { if (url) {
...@@ -189,8 +184,7 @@ define(['require', ...@@ -189,8 +184,7 @@ define(['require',
} }
} }
this.$('.taxanomyloader').show(); this.showLoader();
this.$('.contentLoading').show();
if (isParent) { if (isParent) {
this.parentCollection.url = this.url; this.parentCollection.url = this.url;
this.parentCollection.fullCollection.reset(undefined, { silent: true }); this.parentCollection.fullCollection.reset(undefined, { silent: true });
...@@ -201,6 +195,14 @@ define(['require', ...@@ -201,6 +195,14 @@ define(['require',
this.childCollection.fetch({ reset: true }); this.childCollection.fetch({ reset: true });
} }
}, },
showLoader() {
this.$('.taxonomyTree').find('li.active .tools .taxanomyloader').show();
this.$('.contentLoading').show();
},
hideLoader() {
this.$('.taxanomyloader').hide();
this.$('.contentLoading').hide();
},
forwardClick: function(e, forward, url) { forwardClick: function(e, forward, url) {
var hrefUrl = ""; var hrefUrl = "";
if (e) { if (e) {
...@@ -296,21 +298,22 @@ define(['require', ...@@ -296,21 +298,22 @@ define(['require',
this.$('.taxonomyTree').find('a[data-href="' + this.refresh + '"]').parent().addClass('active'); this.$('.taxonomyTree').find('a[data-href="' + this.refresh + '"]').parent().addClass('active');
this.refresh = undefined; this.refresh = undefined;
} }
this.$('.taxanomyloader').hide(); this.hideLoader();
this.$('.contentLoading').hide();
this.$('.termPopover').popover({ this.$('.termPopover').popover({
placement: 'bottom', placement: 'bottom',
html: true, html: true,
trigger: 'manual', trigger: 'manual',
container: 'body', container: 'body',
content: function() { content: function() {
return "<ul class='termPopoverList'>" + var li = "<li class='listTerm' ><i class='fa fa-search'></i> <a href='javascript:void(0)' data-fn='onSearchTerm'>Search Assets</a></li>" +
"<li class='listTerm' ><i class='fa fa-search'></i> <a href='javascript:void(0)' data-fn='onSearchTerm'>Search Assets</a></li>" + "<li class='listTerm'><i class='fa fa-plus'></i> <a href='javascript:void(0)' data-fn='onAddTerm'>Add Subterm</a></li>";
"<li class='listTerm'><i class='fa fa-plus'></i> <a href='javascript:void(0)' data-fn='onAddTerm'>Add Subterm</a></li>" + /* "<li class='listTerm' ><i class='fa fa-arrow-right'></i> <a href='javascript:void(0)' data-fn='moveTerm'>Move Term</a></li>" +
/* "<li class='listTerm' ><i class='fa fa-arrow-right'></i> <a href='javascript:void(0)' data-fn='moveTerm'>Move Term</a></li>" + "<li class='listTerm' ><i class='fa fa-edit'></i> <a href='javascript:void(0)' data-fn='onEditTerm'>Edit Term</a></li>" +*/
"<li class='listTerm' ><i class='fa fa-edit'></i> <a href='javascript:void(0)' data-fn='onEditTerm'>Edit Term</a></li>" + var termDataURL = Utils.getUrlState.getQueryUrl().hash.split("terms");
"<li class='listTerm'><i class='fa fa-trash'></i> <a href='javascript:void(0)' data-fn='deleteTerm'>Delete Term</a></li>" +*/ if (termDataURL.length > 1) {
"</ul>"; li += "<li class='listTerm'><i class='fa fa-trash'></i> <a href='javascript:void(0)' data-fn='deleteTerm'>Delete Term</a></li>"
}
return "<ul class='termPopoverList'>" + li + "</ul>";
} }
}); });
this.$('.termPopover').off('click').on('click', function(e) { this.$('.termPopover').off('click').on('click', function(e) {
...@@ -338,9 +341,18 @@ define(['require', ...@@ -338,9 +341,18 @@ define(['require',
allowCancel: true, allowCancel: true,
okText: 'Create', okText: 'Create',
}).open(); }).open();
modal.$el.find('button.ok').attr('disabled', true);
modal.on('ok', function() { modal.on('ok', function() {
that.saveAddTerm(view); that.saveAddTerm(view);
}); });
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() { view.on('closeModal', function() {
modal.trigger('cancel'); modal.trigger('cancel');
}); });
...@@ -351,6 +363,7 @@ define(['require', ...@@ -351,6 +363,7 @@ define(['require',
var that = this; var that = this;
var url = view.url; var url = view.url;
view.model.url = url + "/terms/" + view.ui.termName.val(); view.model.url = url + "/terms/" + view.ui.termName.val();
this.showLoader();
view.model.set({ description: view.ui.termDetail.val() }).save(null, { view.model.set({ description: view.ui.termDetail.val() }).save(null, {
success: function(model, response) { success: function(model, response) {
that.create = true; that.create = true;
...@@ -363,30 +376,54 @@ define(['require', ...@@ -363,30 +376,54 @@ define(['require',
}, },
error: function(model, response) { error: function(model, response) {
Utils.notifyError({ Utils.notifyError({
content: response.responseJSON.message content: "Term " + view.ui.termName.val() + " could not be Created"
}); });
},
complete: function() {
that.hideLoader();
} }
}); });
}, },
deleteTerm: function(e) { deleteTerm: function(e) {
var tagName = this.$('.taxonomyTree').find('li.active').find("a").text(), var termName = this.$('.taxonomyTree').find('li.active a').data("name"),
that = this, that = this,
modal = CommonViewFunction.deleteTagModel(tagName); modal = CommonViewFunction.deleteTagModel(termName);
modal.on('ok', function() { modal.on('ok', function() {
that.deleteTagData(e); that.deleteTermData(e);
}); });
modal.on('closeModal', function() { modal.on('closeModal', function() {
modal.trigger('cancel'); modal.trigger('cancel');
}); });
}, },
deleteTagData: function(e) { deleteTermData: function(e) {
var that = this, var that = this;
tagName = this.$('.taxonomyTree').find('li.active').find("a").text(), this.showLoader();
guid = $(e.target).data("guid"); require(['models/VCatalog'], function(VCatalog) {
CommonViewFunction.deleteTag({ var termModel = new VCatalog(),
'tagName': tagName, url = that.$('.taxonomyTree').find('li.active a').data('href');
'guid': guid, var termName = that.$('.taxonomyTree').find('li.active a').text();
'collection': that.parentCollection termModel.deleteTerm(url, {
beforeSend: function() {},
success: function(data) {
Utils.notifySuccess({
content: "Term " + termName + " has been deleted successfully"
});
var termURL = url.split("/").slice(0, -2).join("/");
that.forwardClick(undefined, true, termURL);
},
error: function(error, data, status) {
var message = "Term " + termName + " could not be deleted";
if (data.error) {
message = data.error;
}
Utils.notifyError({
content: message
});
},
complete: function() {
that.hideLoader();
}
});
}); });
}, },
moveTerm: function() { moveTerm: function() {
...@@ -415,6 +452,7 @@ define(['require', ...@@ -415,6 +452,7 @@ define(['require',
}); });
}, },
onSearchTerm: function() { onSearchTerm: function() {
this.showLoader();
Utils.setUrl({ Utils.setUrl({
url: '#!/search/searchResult', url: '#!/search/searchResult',
urlParams: { urlParams: {
...@@ -452,7 +490,6 @@ define(['require', ...@@ -452,7 +490,6 @@ define(['require',
this.taxanomy.fetch({ reset: true }); this.taxanomy.fetch({ reset: true });
}, },
searchResult: function() { searchResult: function() {
var that = this; var that = this;
_.each(this.taxanomy.models, function(model, key) { _.each(this.taxanomy.models, function(model, key) {
var name = model.get('name'); var name = model.get('name');
...@@ -479,7 +516,7 @@ define(['require', ...@@ -479,7 +516,7 @@ define(['require',
this.refresh = this.$('.taxonomyTree').find('.active a').data('href'); this.refresh = this.$('.taxonomyTree').find('.active a').data('href');
this.fetchCollection(this.url); this.fetchCollection(this.url);
this.changeArrowState(); this.changeArrowState();
}, }
}); });
return BusinessCatalogLayoutView; return BusinessCatalogLayoutView;
}); });
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