Commit 8baade24 by kevalbhatt

ATLAS-3685 :- UI Bulk import Business Metadata attribute assignment to entities

parent c5464da3
......@@ -427,7 +427,7 @@ span.tree-tooltip {
}
}
.glossary-dropdown {
.tree-droupdown {
left: -190px !important;
span a {
......
......@@ -14,4 +14,4 @@
* See the License for the specific language governing permissions and
* limitations under the License.
-->
<form action={{importUrl}} id="importGlossary" class="dropzone single-file-center"></form>
\ No newline at end of file
<form id="importGlossary" class="dropzone single-file-center"></form>
\ No newline at end of file
......@@ -25,8 +25,6 @@
<button type="button" class="typeRefresh drop-down-menu-view" data-id="createBusinessMetadata" title="Open Business Metadata">
<i class="fa fa-external-link"></i>
</button>
</ul>
</button>
</div>
</div>
<div id="businessMetadataTree" class="panel-collapse collapse jstree-with-action in">
......
......@@ -29,11 +29,16 @@
<div class=" btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fa fa-ellipsis-v"></i>
</div>
<ul class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<ul class="dropdown-menu tree-droupdown" aria-labelledby="dropdownMenuButton">
<li data-id="groupOrFlatTreeView" data-type="entity"> <i class="fa fa-list-ul"></i><span>Show flat tree</span>
</li>
<li data-id="downloadBusinessMetadata"><i class="fa fa-download"></i> <span><a href="{{importTmplUrl}}"><span>Download Import template</span></a></span>
</li>
<li data-id="importBusinessMetadata"> <i class="fa fa-upload"></i><a href="javascript:void(0)"><span>Import Business Metadata</span></a>
</li>
</ul>
</button>
</button>
</div>
</div>
<div id="c_entity" class="panel-collapse collapse jstree-with-action in">
......
......@@ -27,7 +27,7 @@
<div class=" btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fa fa-ellipsis-v"></i>
</div>
<ul class="dropdown-menu glossary-dropdown" aria-labelledby="dropdownMenuButton">
<ul class="dropdown-menu tree-droupdown" aria-labelledby="dropdownMenuButton">
<li data-id="createGlossary" data-type="term"> <i class="fa fa-plus"></i><span>Create Glossary</span>
</li>
<li data-id="downloadTemplate" data-type="term"><i class="fa fa-download"></i> <span><a href="{{importTmplUrl}}"><span>Download Import template</span></a></span>
......
......@@ -191,6 +191,12 @@ define(['require', 'utils/Enums', 'utils/Utils', 'underscore'], function(require
glossaryImportUrl: function() {
return this.glossaryApiUrl() + '/import';
},
businessMetadataImportTempUrl: function() {
return this.entitiesApiUrl() + '/businessmetadata/import/template';
},
businessMetadataImportUrl: function() {
return this.entitiesApiUrl() + '/businessmetadata/import';
},
categoryApiUrl: function(options) {
var guid = options && options.guid,
list = options && options.list,
......
......@@ -19,25 +19,19 @@
define([
"require",
"backbone",
"hbs!tmpl/glossary/ImportGlossaryLayoutView_tmpl",
"hbs!tmpl/import/ImportLayoutView_tmpl",
"modules/Modal",
'utils/CommonViewFunction',
"utils/Utils",
"utils/UrlLinks",
"dropzone"
], function(require, Backbone, ImportGlossaryLayoutViewTmpl, Modal, CommonViewFunction, Utils, UrlLinks, dropzone) {
var ImportGlossaryLayoutView = Backbone.Marionette.LayoutView.extend(
/** @lends ImportGlossaryLayoutView */
], function(require, Backbone, ImportLayoutViewTmpl, Modal, CommonViewFunction, Utils, UrlLinks, dropzone) {
var ImportLayoutView = Backbone.Marionette.LayoutView.extend(
/** @lends ImportLayoutView */
{
_viewName: "ImportGlossaryLayoutView",
_viewName: "ImportLayoutView",
template: ImportGlossaryLayoutViewTmpl,
templateHelpers: function() {
return {
importUrl: UrlLinks.glossaryImportUrl()
};
},
template: ImportLayoutViewTmpl,
/** Layout sub regions */
regions: {},
......@@ -50,14 +44,14 @@ define([
return events;
},
/**
* intialize a new ImportGlossaryLayoutView Layout
* intialize a new ImportLayoutView Layout
* @constructs
*/
initialize: function(options) {
_.extend(this, _.pick(options, "callback"));
_.extend(this, _.pick(options, "callback", "isGlossary"));
var that = this;
this.modal = new Modal({
title: "Import Glossary",
title: this.isGlossary ? "Import Glossary" : "Import Business Metadata",
content: this,
cancelText: "Cancel",
okText: "upload",
......@@ -88,7 +82,7 @@ define([
var headers = {};
headers[CommonViewFunction.restCsrfCustomHeader] = '""';
this.$("#importGlossary").dropzone({
url: UrlLinks.glossaryImportUrl(),
url: that.isGlossary ? UrlLinks.glossaryImportUrl() : UrlLinks.businessMetadataImportUrl(),
clickable: true,
acceptedFiles: ".csv,.xls,.xlsx",
autoProcessQueue: false,
......@@ -108,11 +102,19 @@ define([
this.addFile(file);
},
success: function(file, response) {
that.modal.trigger("cancel");
Utils.notifySuccess({
content: "File: " + file.name + " added successfully"
});
that.callback();
if (response.successImportInfoList.length && response.failedImportInfoList.length === 0) {
that.modal.trigger("cancel");
Utils.notifySuccess({
content: "File: " + file.name + " imported successfully"
});
} else if (response.failedImportInfoList.length) {
Utils.notifyError({
content: response.failedImportInfoList[0].remarks
});
}
if (that.callback) {
that.callback();
}
},
error: function(file, response, responseObj) {
Utils.defaultErrorHandler(null, responseObj, { defaultErrorMessage: (response.errorMessage) || response });
......@@ -124,5 +126,5 @@ define([
}
}
);
return ImportGlossaryLayoutView;
return ImportLayoutView;
});
\ No newline at end of file
......@@ -43,11 +43,14 @@ define([
// Show/hide empty values in tree
showEmptyServiceType: '[data-id="showEmptyServiceType"]',
entityTreeLoader: '[data-id="entityTreeLoader"]'
entityTreeLoader: '[data-id="entityTreeLoader"]',
importBusinessMetadata: "[data-id='importBusinessMetadata']",
downloadBusinessMetadata: "[data-id='downloadBusinessMetadata']"
},
templateHelpers: function() {
return {
apiBaseUrl: UrlLinks.apiBaseUrl
apiBaseUrl: UrlLinks.apiBaseUrl,
importTmplUrl: UrlLinks.businessMetadataImportTempUrl()
};
},
events: function() {
......@@ -79,6 +82,13 @@ define([
that.ui[type + "SearchTree"].jstree(true).destroy();
that.renderEntityTree();
};
events["click " + this.ui.importBusinessMetadata] = function(e) {
e.stopPropagation();
that.onClickImportBusinessMetadata();
};
events["click " + this.ui.downloadBusinessMetadata] = function(e) {
e.stopPropagation();
};
return events;
},
......@@ -558,7 +568,14 @@ define([
renderTree();
}
});
},
onClickImportBusinessMetadata: function() {
var that = this;
require([
'views/import/ImportLayoutView'
], function(ImportLayoutView) {
var view = new ImportLayoutView({});
});
}
});
return EntityTreeLayoutview;
......
......@@ -711,12 +711,13 @@ define([
onClickImportGlossary: function() {
var that = this;
require([
'views/glossary/ImportGlossaryLayoutView'
], function(ImportGlossaryLayoutView) {
var view = new ImportGlossaryLayoutView({
'views/import/ImportLayoutView'
], function(ImportLayoutView) {
var view = new ImportLayoutView({
callback: function() {
that.refresh();
}
},
isGlossary: true
});
});
}
......
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