Commit 62451d62 by kevalbhatt

ATLAS-3793:- UI: Entity detail page improvement for label, user-define properties, BM panel

parent 2dd41162
...@@ -143,9 +143,9 @@ ...@@ -143,9 +143,9 @@
.panel-default.custom-panel>.panel-actions { .panel-default.custom-panel>.panel-actions {
float: right; float: right;
margin-top: 15px; margin-top: 15px;
margin-right: 10px;
button { button {
margin-right: 10px;
margin-top: -4px; margin-top: -4px;
} }
} }
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
--> -->
<div class="panel panel-default custom-panel expand_collapse_panel-icon"> <div class="panel panel-default custom-panel expand_collapse_panel-icon">
<div class="panel-heading" data-toggle="collapse" href="#businessMetadataCollapse" aria-expanded="false" style="width: 70%;"> <div class="panel-heading main-parent collapsed" data-toggle="collapse" href="#businessMetadataCollapse" aria-expanded="false" style="width: 70%;">
<h4 class="panel-title"> <h4 class="panel-title">
<a>Business Metadata</a> <a>Business Metadata</a>
</h4> </h4>
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
<div class="panel-group" id="accordion"> <div class="panel-group" id="accordion">
<div class="panel panel-default custom-panel expand_collapse_panel-icon" data-id="userDefineLabel"> <div class="panel panel-default custom-panel expand_collapse_panel-icon" data-id="userDefineLabel">
{{#ifCond labels.length "===" 0}} {{#ifCond labels.length "===" 0}}
<div class="panel-heading collapsed" data-toggle="collapse" href={{div_1.anchor}} aria-expanded="false" style="width: 70%"> <div class="panel-heading collapsed" data-toggle="collapse" href={{div_1.anchor}} {{#ifCond swapItem "===" true}} aria-expanded="true" {{else}} aria-expanded="false" {{/ifCond}} style="width: 70%">
<h4 class="panel-title"> <h4 class="panel-title">
<a>Labels </a> <a>Labels </a>
</h4> </h4>
...@@ -38,12 +38,13 @@ ...@@ -38,12 +38,13 @@
{{#ifCond readOnlyEntity "===" false}} {{#ifCond readOnlyEntity "===" false}}
<div class="panel-actions"> <div class="panel-actions">
{{#ifCond swapItem "!==" true}} {{#ifCond swapItem "!==" true}}
<button class="btn btn-action btn-sm" data-id="addLabels" {{#ifCond labels.length "===" 0}} data-original-title="Add User-Defined Labels" {{else}} data-original-title="Edit User-Defined Labels" {{/ifCond}}> <button class="btn btn-action btn-sm" data-id="addLabels">
{{#ifCond labels.length "===" 0}} Add {{else}} Edit {{/ifCond}} {{#ifCond labels.length "===" 0}} Add {{else}} Edit {{/ifCond}}
</button> </button>
{{/ifCond}} {{/ifCond}}
{{#ifCond saveLabels "===" true}} {{#ifCond saveLabels "===" true}}
<button class="btn btn-action btn-sm" data-id="saveLabels" data-original-title="Save User-Defined Labels">Save</button> <button class="btn btn-action btn-sm" data-id="saveLabels">Save</button>
<button class="btn btn-action btn-sm" data-id="cancel">Cancel</button>
{{/ifCond}} {{/ifCond}}
</div> </div>
{{/ifCond}} {{/ifCond}}
...@@ -56,9 +57,7 @@ ...@@ -56,9 +57,7 @@
<select class="form-control" data-id="addLabelOptions" multiple="multiple"></select> <select class="form-control" data-id="addLabelOptions" multiple="multiple"></select>
{{else}} {{else}}
<div class="badge-container"> <div class="badge-container">
{{#each labels}} No labels have been created yet. To add a labels, click <a href="javascript:void(0)" data-id="addLabels">here</a>
<label class="btn btn-action btn-sm btn-blue no-pointer">{{this}}</label>
{{/each}}
</div> </div>
{{/ifCond}} {{/ifCond}}
</div> </div>
......
...@@ -41,7 +41,9 @@ ...@@ -41,7 +41,9 @@
<p class="errorMsg" data-id="charSupportMsg"></p> <p class="errorMsg" data-id="charSupportMsg"></p>
</td> </td>
</tr> </tr>
{{#if allValueRemovedUpdate}}
All properties has been removed. To add a property, click <a href="javascript:void(0)" data-id="addItem">here</a>{{else}}
{{#ifCond items.length "===" 0}} {{#ifCond items.length "===" 0}}
No properties have been created yet. To add a property, click <a href="javascript:void(0)" data-id="addItem">here</a> No properties have been created yet. To add a property, click <a href="javascript:void(0)" data-id="addItem">here</a>
{{/ifCond}} {{/ifCond}}{{/if}}
</table> </table>
\ No newline at end of file
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
<div class="panel-group" id="accordion"> <div class="panel-group" id="accordion">
<div class="panel panel-default custom-panel expand_collapse_panel-icon" data-id="userDefine"> <div class="panel panel-default custom-panel expand_collapse_panel-icon" data-id="userDefine">
{{#ifCond customAttibutes.length "===" 0}} {{#ifCond customAttibutes.length "===" 0}}
<div class="panel-heading collapsed" data-toggle="collapse" href={{divId_1.anchor}} aria-expanded="false" style="width: 70%"> <div class="panel-heading collapsed" data-toggle="collapse" href={{divId_1.anchor}} {{#ifCond swapItem "===" true}} aria-expanded="true" {{else}} aria-expanded="false" {{/ifCond}} style="width: 70%">
<h4 class="panel-title"> <h4 class="panel-title">
<a>User-defined properties </a> <a>User-defined properties </a>
</h4> </h4>
...@@ -38,12 +38,13 @@ ...@@ -38,12 +38,13 @@
{{#ifCond readOnlyEntity "===" false}} {{#ifCond readOnlyEntity "===" false}}
<div class="panel-actions"> <div class="panel-actions">
{{#ifCond swapItem "!==" true}} {{#ifCond swapItem "!==" true}}
<button class="btn btn-action btn-sm" data-id="addAttr" {{#ifCond customAttibutes.length "===" 0}} data-original-title="Add User-defined properties" {{else}} data-original-title="Edit User-defined properties" {{/ifCond}}> <button class="btn btn-action btn-sm" data-id="addAttr">
{{#ifCond customAttibutes.length "===" 0}} Add {{else}} Edit {{/ifCond}} {{#ifCond customAttibutes.length "===" 0}} Add {{else}} Edit {{/ifCond}}
</button> </button>
{{/ifCond}} {{/ifCond}}
{{#ifCond saveAttrItems "===" true}} {{#ifCond saveAttrItems "===" true}}
<button class="btn btn-action btn-sm" data-id="saveAttrItems" data-original-title="Save User-defined properties">Save</button> <button class="btn btn-action btn-sm" data-id="saveAttrItems">Save</button>
<button class="btn btn-action btn-sm" data-id="cancel">Cancel</button>
{{/ifCond}} {{/ifCond}}
</div> </div>
{{/ifCond}} {{/ifCond}}
...@@ -55,22 +56,7 @@ ...@@ -55,22 +56,7 @@
{{#ifCond swapItem "===" true}} {{#ifCond swapItem "===" true}}
<div id="r_entityUserDefinedItemView"></div> <div id="r_entityUserDefinedItemView"></div>
{{else}} {{else}}
<div class="entity-detail-table"> No properties have been created yet. To add a property, click <a href="javascript:void(0)" data-id="addItem">here</a>
<table class="table">
<tbody>
{{#each customAttibutes}}
<tr>
<td>
<div class="scroll-y">{{key}}</div>
</div>
</td>
<td>
<div class="scroll-y">{{value}}</div>
</td>
</tr>
{{/each}}
</tbody>
</table>
</div> </div>
{{/ifCond}} {{/ifCond}}
</div> </div>
......
...@@ -111,15 +111,15 @@ define([ ...@@ -111,15 +111,15 @@ define([
this.panelOpenClose(); this.panelOpenClose();
}, },
panelOpenClose: function() { panelOpenClose: function() {
var collection = this.editMode ? this.collection : this.actualCollection; var collection = this.editMode ? this.collection : this.actualCollection,
headingEl = this.$el.find(".panel-heading.main-parent");
if (collection && collection.length === 0) { if (collection && collection.length === 0) {
this.$el.find(".panel-heading").addClass("collapsed").attr('aria-expanded',false);
this.$el.find(".panel-collapse.collapse").removeClass("in");
this.ui.addBusinessMetadata.text("Add"); this.ui.addBusinessMetadata.text("Add");
} else { } else {
this.ui.addBusinessMetadata.text("Edit"); this.ui.addBusinessMetadata.text("Edit");
this.$el.find(".panel-heading").removeClass("collapsed").attr('aria-expanded',true); if (headingEl.hasClass("collapsed")) {
this.$el.find(".panel-collapse.collapse").addClass("in"); headingEl.click();
}
} }
}, },
validate: function() { validate: function() {
...@@ -164,12 +164,14 @@ define([ ...@@ -164,12 +164,14 @@ define([
type: "POST", type: "POST",
success: function(data) { success: function(data) {
Utils.notifySuccess({ Utils.notifySuccess({
content: "One or more Business Metadada attributes" + Messages.getAbbreviationMsg(false, 'editSuccessMessage') content: "One or more Business Metadada attributes" + Messages.getAbbreviationMsg(true, 'editSuccessMessage')
}); });
that.entity.businessAttributes = data; that.entity.businessAttributes = data;
this.editMode = false; that.ui.businessMetadataTree.html("");
that.editMode = false;
that.fetchCollection(); that.fetchCollection();
that.onCancel(); that.onCancel();
}, },
complete: function(model, response) { complete: function(model, response) {
//that.hideLoader(); //that.hideLoader();
...@@ -239,7 +241,11 @@ define([ ...@@ -239,7 +241,11 @@ define([
}); });
li += that.associateAttributePanel(obj, attrLi); li += that.associateAttributePanel(obj, attrLi);
}); });
this.ui.businessMetadataTree.html(li); var html = li;
if (html === "") {
html = '<div class="col-md-12"> No business metadata have been created yet. To add a business metadata, click <a href="javascript:void(0)" data-id="addBusinessMetadata">here</a></div>';
}
this.ui.businessMetadataTree.html(html);
}, },
associateAttributePanel: function(obj, tableBody) { associateAttributePanel: function(obj, tableBody) {
return '<div class="panel panel-default custom-panel expand_collapse_panel-icon no-border business-metadata-detail-attr">' + return '<div class="panel panel-default custom-panel expand_collapse_panel-icon no-border business-metadata-detail-attr">' +
...@@ -252,7 +258,11 @@ define([ ...@@ -252,7 +258,11 @@ define([
'</div></div>'; '</div></div>';
}, },
onRender: function() { onRender: function() {
this.panelOpenClose(); if (this.actualCollection && this.actualCollection.length) {
this.$el.find(".panel-heading.main-parent").removeClass("collapsed").attr("aria-expanded", "true");
this.$el.find("#businessMetadataCollapse").addClass("in").removeAttr("style");
this.ui.addBusinessMetadata.text("Edit");
}
this.renderBusinessMetadata(); this.renderBusinessMetadata();
} }
}); });
......
...@@ -44,13 +44,15 @@ define(['require', ...@@ -44,13 +44,15 @@ define(['require',
ui: { ui: {
addLabelOptions: "[data-id='addLabelOptions']", addLabelOptions: "[data-id='addLabelOptions']",
addLabels: "[data-id='addLabels']", addLabels: "[data-id='addLabels']",
saveLabels: "[data-id='saveLabels']" saveLabels: "[data-id='saveLabels']",
cancel: "[data-id='cancel']"
}, },
events: function() { events: function() {
var events = {}; var events = {};
events["change " + this.ui.addLabelOptions] = 'onChangeLabelChange'; events["change " + this.ui.addLabelOptions] = 'onChangeLabelChange';
events["click " + this.ui.addLabels] = 'handleBtnClick'; events["click " + this.ui.addLabels] = 'handleBtnClick';
events["click " + this.ui.saveLabels] = 'saveUserDefinedLabels'; events["click " + this.ui.saveLabels] = 'saveUserDefinedLabels';
events["click " + this.ui.cancel] = 'onCancelClick';
return events; return events;
}, },
initialize: function(options) { initialize: function(options) {
...@@ -140,6 +142,12 @@ define(['require', ...@@ -140,6 +142,12 @@ define(['require',
} }
this.render(); this.render();
}, },
onCancelClick: function() {
this.labels = this.entityModel.get("labels") || [];
this.swapItem = false;
this.saveLabels = false;
this.render();
},
saveUserDefinedLabels: function() { saveUserDefinedLabels: function() {
var that = this; var that = this;
var entityJson = that.entityModel.toJSON(); var entityJson = that.entityModel.toJSON();
......
...@@ -29,7 +29,8 @@ define(['require', ...@@ -29,7 +29,8 @@ define(['require',
templateHelpers: function() { templateHelpers: function() {
return { return {
items: this.items items: this.items,
allValueRemovedUpdate: this.allValueRemovedUpdate
}; };
}, },
...@@ -62,11 +63,13 @@ define(['require', ...@@ -62,11 +63,13 @@ define(['require',
if (options.items.length === 0) { if (options.items.length === 0) {
this.items = [{ key: "", value: "" }]; this.items = [{ key: "", value: "" }];
} else { } else {
this.items = options.items; this.items = $.extend(true, [], options.items);
} }
this.updateParentButtonState = options.updateButtonState;
}, },
onRender: function() {}, onRender: function() {},
onAddItemClick: function(e) { onAddItemClick: function(e) {
this.allValueRemovedUpdate = false;
var el = e.currentTarget; var el = e.currentTarget;
this.items.splice(parseInt(el.dataset.index) + 1, 0, { key: "", value: "" }); this.items.splice(parseInt(el.dataset.index) + 1, 0, { key: "", value: "" });
this.render(); this.render();
...@@ -74,7 +77,16 @@ define(['require', ...@@ -74,7 +77,16 @@ define(['require',
onDeleteItemClick: function(e) { onDeleteItemClick: function(e) {
var el = e.currentTarget; var el = e.currentTarget;
this.items.splice(el.dataset.index, 1); this.items.splice(el.dataset.index, 1);
this.render(); this.allValueRemovedUpdate = false;
if (this.items.length === 0) {
var updated = this.updateParentButtonState();
if (updated === false) {
this.allValueRemovedUpdate = true;
this.render();
}
} else {
this.render();
}
}, },
onItemKeyChange: function(e) { onItemKeyChange: function(e) {
var el = e.currentTarget; var el = e.currentTarget;
......
...@@ -42,14 +42,16 @@ define(['require', ...@@ -42,14 +42,16 @@ define(['require',
}, },
ui: { ui: {
addAttr: "[data-id='addAttr']", addAttr: "[data-id='addAttr']",
editAttr: "[data-id='editAttr']", saveAttrItems: "[data-id='saveAttrItems']",
saveAttrItems: "[data-id='saveAttrItems']" cancel: "[data-id='cancel']",
addItem: "[data-id='addItem']"
}, },
events: function() { events: function() {
var events = {}; var events = {};
events["click " + this.ui.addAttr] = 'onAddAttrClick'; events["click " + this.ui.addAttr] = 'onAddAttrClick';
events["click " + this.ui.editAttr] = 'onEditAttrClick'; events["click " + this.ui.addItem] = 'onAddAttrClick';
events["click " + this.ui.saveAttrItems] = 'onEditAttrClick'; events["click " + this.ui.saveAttrItems] = 'onEditAttrClick';
events["click " + this.ui.cancel] = 'onCancelClick';
return events; return events;
}, },
initialize: function(options) { initialize: function(options) {
...@@ -66,9 +68,8 @@ define(['require', ...@@ -66,9 +68,8 @@ define(['require',
onRender: function() {}, onRender: function() {},
renderEntityUserDefinedItems: function() { renderEntityUserDefinedItems: function() {
var that = this; var that = this;
require(['views/entity/EntityUserDefineItemView'], function(EntityUserDefineItemView) { require(['views/entity/EntityUserDefineItemView'], function(EntityUserDefineItemView) {
that.itemView = new EntityUserDefineItemView({ items: that.customAttibutes }); that.itemView = new EntityUserDefineItemView({ items: that.customAttibutes, updateButtonState: that.updateButtonState.bind(that) });
that.REntityUserDefinedItemView.show(that.itemView); that.REntityUserDefinedItemView.show(that.itemView);
}); });
}, },
...@@ -106,6 +107,21 @@ define(['require', ...@@ -106,6 +107,21 @@ define(['require',
this.initialCall = this.customAttibutes.length > 0 ? false : true; this.initialCall = this.customAttibutes.length > 0 ? false : true;
this.setAttributeModal(this.itemView); this.setAttributeModal(this.itemView);
}, },
updateButtonState: function() {
if (this.customAttibutes.length === 0) {
this.swapItem = false;
this.saveAttrItems = false;
this.render();
} else {
return false;
}
},
onCancelClick: function() {
this.initialCall = false;
this.swapItem = false;
this.saveAttrItems = false;
this.render();
},
structureAttributes: function(list) { structureAttributes: function(list) {
var obj = {} var obj = {}
list.map(function(o) { list.map(function(o) {
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
--> -->
<div class="panel panel-default custom-panel expand_collapse_panel-icon"> <div class="panel panel-default custom-panel expand_collapse_panel-icon">
<div class="panel-heading" data-toggle="collapse" href="#businessMetadataCollapse" aria-expanded="false" style="width: 70%;"> <div class="panel-heading main-parent collapsed" data-toggle="collapse" href="#businessMetadataCollapse" aria-expanded="false" style="width: 70%;">
<h4 class="panel-title"> <h4 class="panel-title">
<a>Business Metadata</a> <a>Business Metadata</a>
</h4> </h4>
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
<div class="panel-group" id="accordion"> <div class="panel-group" id="accordion">
<div class="panel panel-default custom-panel expand_collapse_panel-icon" data-id="userDefineLabel"> <div class="panel panel-default custom-panel expand_collapse_panel-icon" data-id="userDefineLabel">
{{#ifCond labels.length "===" 0}} {{#ifCond labels.length "===" 0}}
<div class="panel-heading collapsed" data-toggle="collapse" href={{div_1.anchor}} aria-expanded="false" style="width: 70%"> <div class="panel-heading collapsed" data-toggle="collapse" href={{div_1.anchor}} {{#ifCond swapItem "===" true}} aria-expanded="true" {{else}} aria-expanded="false" {{/ifCond}} style="width: 70%">
<h4 class="panel-title"> <h4 class="panel-title">
<a>Labels </a> <a>Labels </a>
</h4> </h4>
...@@ -38,12 +38,13 @@ ...@@ -38,12 +38,13 @@
{{#ifCond readOnlyEntity "===" false}} {{#ifCond readOnlyEntity "===" false}}
<div class="panel-actions"> <div class="panel-actions">
{{#ifCond swapItem "!==" true}} {{#ifCond swapItem "!==" true}}
<button class="btn btn-action btn-sm" data-id="addLabels" {{#ifCond labels.length "===" 0}} data-original-title="Add User-Defined Labels" {{else}} data-original-title="Edit User-Defined Labels" {{/ifCond}}> <button class="btn btn-action btn-sm" data-id="addLabels">
{{#ifCond labels.length "===" 0}} Add {{else}} Edit {{/ifCond}} {{#ifCond labels.length "===" 0}} Add {{else}} Edit {{/ifCond}}
</button> </button>
{{/ifCond}} {{/ifCond}}
{{#ifCond saveLabels "===" true}} {{#ifCond saveLabels "===" true}}
<button class="btn btn-action btn-sm" data-id="saveLabels" data-original-title="Save User-Defined Labels">Save</button> <button class="btn btn-action btn-sm" data-id="saveLabels">Save</button>
<button class="btn btn-action btn-sm" data-id="cancel">Cancel</button>
{{/ifCond}} {{/ifCond}}
</div> </div>
{{/ifCond}} {{/ifCond}}
...@@ -56,9 +57,7 @@ ...@@ -56,9 +57,7 @@
<select class="form-control" data-id="addLabelOptions" multiple="multiple"></select> <select class="form-control" data-id="addLabelOptions" multiple="multiple"></select>
{{else}} {{else}}
<div class="badge-container"> <div class="badge-container">
{{#each labels}} No labels have been created yet. To add a labels, click <a href="javascript:void(0)" data-id="addLabels">here</a>
<label class="btn btn-action btn-sm btn-blue no-pointer">{{this}}</label>
{{/each}}
</div> </div>
{{/ifCond}} {{/ifCond}}
</div> </div>
......
...@@ -41,7 +41,9 @@ ...@@ -41,7 +41,9 @@
<p class="errorMsg" data-id="charSupportMsg"></p> <p class="errorMsg" data-id="charSupportMsg"></p>
</td> </td>
</tr> </tr>
{{#if allValueRemovedUpdate}}
All properties has been removed. To add a property, click <a href="javascript:void(0)" data-id="addItem">here</a>{{else}}
{{#ifCond items.length "===" 0}} {{#ifCond items.length "===" 0}}
No properties have been created yet. To add a property, click <a href="javascript:void(0)" data-id="addItem">here</a> No properties have been created yet. To add a property, click <a href="javascript:void(0)" data-id="addItem">here</a>
{{/ifCond}} {{/ifCond}}{{/if}}
</table> </table>
\ No newline at end of file
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
<div class="panel-group" id="accordion"> <div class="panel-group" id="accordion">
<div class="panel panel-default custom-panel expand_collapse_panel-icon" data-id="userDefine"> <div class="panel panel-default custom-panel expand_collapse_panel-icon" data-id="userDefine">
{{#ifCond customAttibutes.length "===" 0}} {{#ifCond customAttibutes.length "===" 0}}
<div class="panel-heading collapsed" data-toggle="collapse" href={{divId_1.anchor}} aria-expanded="false" style="width: 70%"> <div class="panel-heading collapsed" data-toggle="collapse" href={{divId_1.anchor}} {{#ifCond swapItem "===" true}} aria-expanded="true" {{else}} aria-expanded="false" {{/ifCond}} style="width: 70%">
<h4 class="panel-title"> <h4 class="panel-title">
<a>User-defined properties </a> <a>User-defined properties </a>
</h4> </h4>
...@@ -38,12 +38,13 @@ ...@@ -38,12 +38,13 @@
{{#ifCond readOnlyEntity "===" false}} {{#ifCond readOnlyEntity "===" false}}
<div class="panel-actions"> <div class="panel-actions">
{{#ifCond swapItem "!==" true}} {{#ifCond swapItem "!==" true}}
<button class="btn btn-action btn-sm" data-id="addAttr" {{#ifCond customAttibutes.length "===" 0}} data-original-title="Add User-defined properties" {{else}} data-original-title="Edit User-defined properties" {{/ifCond}}> <button class="btn btn-action btn-sm" data-id="addAttr">
{{#ifCond customAttibutes.length "===" 0}} Add {{else}} Edit {{/ifCond}} {{#ifCond customAttibutes.length "===" 0}} Add {{else}} Edit {{/ifCond}}
</button> </button>
{{/ifCond}} {{/ifCond}}
{{#ifCond saveAttrItems "===" true}} {{#ifCond saveAttrItems "===" true}}
<button class="btn btn-action btn-sm" data-id="saveAttrItems" data-original-title="Save User-defined properties">Save</button> <button class="btn btn-action btn-sm" data-id="saveAttrItems">Save</button>
<button class="btn btn-action btn-sm" data-id="cancel">Cancel</button>
{{/ifCond}} {{/ifCond}}
</div> </div>
{{/ifCond}} {{/ifCond}}
...@@ -55,22 +56,7 @@ ...@@ -55,22 +56,7 @@
{{#ifCond swapItem "===" true}} {{#ifCond swapItem "===" true}}
<div id="r_entityUserDefinedItemView"></div> <div id="r_entityUserDefinedItemView"></div>
{{else}} {{else}}
<div class="entity-detail-table"> No properties have been created yet. To add a property, click <a href="javascript:void(0)" data-id="addItem">here</a>
<table class="table">
<tbody>
{{#each customAttibutes}}
<tr>
<td>
<div class="scroll-y">{{key}}</div>
</div>
</td>
<td>
<div class="scroll-y">{{value}}</div>
</td>
</tr>
{{/each}}
</tbody>
</table>
</div> </div>
{{/ifCond}} {{/ifCond}}
</div> </div>
......
...@@ -240,10 +240,12 @@ define(['require', 'utils/Globals', 'pnotify', 'utils/Messages', 'utils/Enums', ...@@ -240,10 +240,12 @@ define(['require', 'utils/Globals', 'pnotify', 'utils/Messages', 'utils/Enums',
} }
Utils.defaultErrorHandler = function(model, error, options) { Utils.defaultErrorHandler = function(model, error, options) {
var skipDefaultError = null, var skipDefaultError = null,
defaultErrorMessage = null; defaultErrorMessage = null,
isHtml = null;
if (options) { if (options) {
skipDefaultError = options.skipDefaultError; skipDefaultError = options.skipDefaultError;
defaultErrorMessage = options.defaultErrorMessage; defaultErrorMessage = options.defaultErrorMessage;
isHtml = options.isHtml;
} }
var redirectToLoginPage = function() { var redirectToLoginPage = function() {
Utils.localStorage.setValue("last_ui_load", "v2"); Utils.localStorage.setValue("last_ui_load", "v2");
...@@ -266,13 +268,13 @@ define(['require', 'utils/Globals', 'pnotify', 'utils/Messages', 'utils/Enums', ...@@ -266,13 +268,13 @@ define(['require', 'utils/Globals', 'pnotify', 'utils/Messages', 'utils/Enums',
}); });
} }
} else if (skipDefaultError !== true) { } else if (skipDefaultError !== true) {
Utils.serverErrorHandler(error, defaultErrorMessage); Utils.serverErrorHandler(error, defaultErrorMessage, isHtml);
} }
} else if (skipDefaultError !== true) { } else if (skipDefaultError !== true) {
Utils.serverErrorHandler(error, defaultErrorMessage); Utils.serverErrorHandler(error, defaultErrorMessage);
} }
}; };
Utils.serverErrorHandler = function(response, defaultErrorMessage) { Utils.serverErrorHandler = function(response, defaultErrorMessage, isHtml) {
var responseJSON = response ? response.responseJSON : response, var responseJSON = response ? response.responseJSON : response,
message = defaultErrorMessage ? defaultErrorMessage : Messages.defaultErrorMessage message = defaultErrorMessage ? defaultErrorMessage : Messages.defaultErrorMessage
if (response && responseJSON) { if (response && responseJSON) {
...@@ -281,6 +283,7 @@ define(['require', 'utils/Globals', 'pnotify', 'utils/Messages', 'utils/Enums', ...@@ -281,6 +283,7 @@ define(['require', 'utils/Globals', 'pnotify', 'utils/Messages', 'utils/Enums',
var existingError = $(".ui-pnotify-container.alert-danger .ui-pnotify-text").text(); var existingError = $(".ui-pnotify-container.alert-danger .ui-pnotify-text").text();
if (existingError !== message) { if (existingError !== message) {
Utils.notifyError({ Utils.notifyError({
html:isHtml,
content: message content: message
}); });
} }
......
...@@ -111,15 +111,15 @@ define([ ...@@ -111,15 +111,15 @@ define([
this.panelOpenClose(); this.panelOpenClose();
}, },
panelOpenClose: function() { panelOpenClose: function() {
var collection = this.editMode ? this.collection : this.actualCollection; var collection = this.editMode ? this.collection : this.actualCollection,
headingEl = this.$el.find(".panel-heading.main-parent");
if (collection && collection.length === 0) { if (collection && collection.length === 0) {
this.$el.find(".panel-heading").addClass("collapsed");
this.$el.find(".panel-collapse.collapse").removeClass("in");
this.ui.addBusinessMetadata.text("Add"); this.ui.addBusinessMetadata.text("Add");
} else { } else {
this.ui.addBusinessMetadata.text("Edit"); this.ui.addBusinessMetadata.text("Edit");
this.$el.find(".panel-heading").removeClass("collapsed"); if (headingEl.hasClass("collapsed")) {
this.$el.find(".panel-collapse.collapse").addClass("in"); headingEl.click();
}
} }
}, },
validate: function() { validate: function() {
...@@ -164,12 +164,14 @@ define([ ...@@ -164,12 +164,14 @@ define([
type: "POST", type: "POST",
success: function(data) { success: function(data) {
Utils.notifySuccess({ Utils.notifySuccess({
content: "One or more Business Metadada attributes" + Messages.getAbbreviationMsg(false, 'editSuccessMessage') content: "One or more Business Metadada attributes" + Messages.getAbbreviationMsg(true, 'editSuccessMessage')
}); });
that.entity.businessAttributes = data; that.entity.businessAttributes = data;
this.editMode = false; that.ui.businessMetadataTree.html("");
that.editMode = false;
that.fetchCollection(); that.fetchCollection();
that.onCancel(); that.onCancel();
}, },
complete: function(model, response) { complete: function(model, response) {
//that.hideLoader(); //that.hideLoader();
...@@ -239,7 +241,11 @@ define([ ...@@ -239,7 +241,11 @@ define([
}); });
li += that.associateAttributePanel(obj, attrLi); li += that.associateAttributePanel(obj, attrLi);
}); });
this.ui.businessMetadataTree.html(li); var html = li;
if (html === "") {
html = '<div class="col-md-12"> No business metadata have been created yet. To add a business metadata, click <a href="javascript:void(0)" data-id="addBusinessMetadata">here</a></div>';
}
this.ui.businessMetadataTree.html(html);
}, },
associateAttributePanel: function(obj, tableBody) { associateAttributePanel: function(obj, tableBody) {
return '<div class="panel panel-default custom-panel expand_collapse_panel-icon no-border business-metadata-detail-attr">' + return '<div class="panel panel-default custom-panel expand_collapse_panel-icon no-border business-metadata-detail-attr">' +
...@@ -252,7 +258,11 @@ define([ ...@@ -252,7 +258,11 @@ define([
'</div></div>'; '</div></div>';
}, },
onRender: function() { onRender: function() {
this.panelOpenClose(); if (this.actualCollection && this.actualCollection.length) {
this.$el.find(".panel-heading.main-parent").removeClass("collapsed").attr("aria-expanded", "true");
this.$el.find("#businessMetadataCollapse").addClass("in").removeAttr("style");
this.ui.addBusinessMetadata.text("Edit");
}
this.renderBusinessMetadata(); this.renderBusinessMetadata();
} }
}); });
......
...@@ -44,13 +44,15 @@ define(['require', ...@@ -44,13 +44,15 @@ define(['require',
ui: { ui: {
addLabelOptions: "[data-id='addLabelOptions']", addLabelOptions: "[data-id='addLabelOptions']",
addLabels: "[data-id='addLabels']", addLabels: "[data-id='addLabels']",
saveLabels: "[data-id='saveLabels']" saveLabels: "[data-id='saveLabels']",
cancel: "[data-id='cancel']"
}, },
events: function() { events: function() {
var events = {}; var events = {};
events["change " + this.ui.addLabelOptions] = 'onChangeLabelChange'; events["change " + this.ui.addLabelOptions] = 'onChangeLabelChange';
events["click " + this.ui.addLabels] = 'handleBtnClick'; events["click " + this.ui.addLabels] = 'handleBtnClick';
events["click " + this.ui.saveLabels] = 'saveUserDefinedLabels'; events["click " + this.ui.saveLabels] = 'saveUserDefinedLabels';
events["click " + this.ui.cancel] = 'onCancelClick';
return events; return events;
}, },
initialize: function(options) { initialize: function(options) {
...@@ -140,6 +142,12 @@ define(['require', ...@@ -140,6 +142,12 @@ define(['require',
} }
this.render(); this.render();
}, },
onCancelClick: function() {
this.labels = this.entityModel.get("labels") || [];
this.swapItem = false;
this.saveLabels = false;
this.render();
},
saveUserDefinedLabels: function() { saveUserDefinedLabels: function() {
var that = this; var that = this;
var entityJson = that.entityModel.toJSON(); var entityJson = that.entityModel.toJSON();
......
...@@ -29,7 +29,8 @@ define(['require', ...@@ -29,7 +29,8 @@ define(['require',
templateHelpers: function() { templateHelpers: function() {
return { return {
items: this.items items: this.items,
allValueRemovedUpdate: this.allValueRemovedUpdate
}; };
}, },
...@@ -62,11 +63,13 @@ define(['require', ...@@ -62,11 +63,13 @@ define(['require',
if (options.items.length === 0) { if (options.items.length === 0) {
this.items = [{ key: "", value: "" }]; this.items = [{ key: "", value: "" }];
} else { } else {
this.items = options.items; this.items = $.extend(true, [], options.items);
} }
this.updateParentButtonState = options.updateButtonState;
}, },
onRender: function() {}, onRender: function() {},
onAddItemClick: function(e) { onAddItemClick: function(e) {
this.allValueRemovedUpdate = false;
var el = e.currentTarget; var el = e.currentTarget;
this.items.splice(parseInt(el.dataset.index) + 1, 0, { key: "", value: "" }); this.items.splice(parseInt(el.dataset.index) + 1, 0, { key: "", value: "" });
this.render(); this.render();
...@@ -74,7 +77,16 @@ define(['require', ...@@ -74,7 +77,16 @@ define(['require',
onDeleteItemClick: function(e) { onDeleteItemClick: function(e) {
var el = e.currentTarget; var el = e.currentTarget;
this.items.splice(el.dataset.index, 1); this.items.splice(el.dataset.index, 1);
this.render(); this.allValueRemovedUpdate = false;
if (this.items.length === 0) {
var updated = this.updateParentButtonState();
if (updated === false) {
this.allValueRemovedUpdate = true;
this.render();
}
} else {
this.render();
}
}, },
onItemKeyChange: function(e) { onItemKeyChange: function(e) {
var el = e.currentTarget; var el = e.currentTarget;
......
...@@ -42,14 +42,16 @@ define(['require', ...@@ -42,14 +42,16 @@ define(['require',
}, },
ui: { ui: {
addAttr: "[data-id='addAttr']", addAttr: "[data-id='addAttr']",
editAttr: "[data-id='editAttr']", saveAttrItems: "[data-id='saveAttrItems']",
saveAttrItems: "[data-id='saveAttrItems']" cancel: "[data-id='cancel']",
addItem: "[data-id='addItem']"
}, },
events: function() { events: function() {
var events = {}; var events = {};
events["click " + this.ui.addAttr] = 'onAddAttrClick'; events["click " + this.ui.addAttr] = 'onAddAttrClick';
events["click " + this.ui.editAttr] = 'onEditAttrClick'; events["click " + this.ui.addItem] = 'onAddAttrClick';
events["click " + this.ui.saveAttrItems] = 'onEditAttrClick'; events["click " + this.ui.saveAttrItems] = 'onEditAttrClick';
events["click " + this.ui.cancel] = 'onCancelClick';
return events; return events;
}, },
initialize: function(options) { initialize: function(options) {
...@@ -66,9 +68,8 @@ define(['require', ...@@ -66,9 +68,8 @@ define(['require',
onRender: function() {}, onRender: function() {},
renderEntityUserDefinedItems: function() { renderEntityUserDefinedItems: function() {
var that = this; var that = this;
require(['views/entity/EntityUserDefineItemView'], function(EntityUserDefineItemView) { require(['views/entity/EntityUserDefineItemView'], function(EntityUserDefineItemView) {
that.itemView = new EntityUserDefineItemView({ items: that.customAttibutes }); that.itemView = new EntityUserDefineItemView({ items: that.customAttibutes, updateButtonState: that.updateButtonState.bind(that) });
that.REntityUserDefinedItemView.show(that.itemView); that.REntityUserDefinedItemView.show(that.itemView);
}); });
}, },
...@@ -106,6 +107,21 @@ define(['require', ...@@ -106,6 +107,21 @@ define(['require',
this.initialCall = this.customAttibutes.length > 0 ? false : true; this.initialCall = this.customAttibutes.length > 0 ? false : true;
this.setAttributeModal(this.itemView); this.setAttributeModal(this.itemView);
}, },
updateButtonState: function() {
if (this.customAttibutes.length === 0) {
this.swapItem = false;
this.saveAttrItems = false;
this.render();
} else {
return false;
}
},
onCancelClick: function() {
this.initialCall = false;
this.swapItem = false;
this.saveAttrItems = false;
this.render();
},
structureAttributes: function(list) { structureAttributes: function(list) {
var obj = {} var obj = {}
list.map(function(o) { list.map(function(o) {
......
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