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