Commit 506ffc97 by kevalbhatt Committed by nixonrodrigues

ATLAS-3662 : UI: Business Metadata validation improvements

parent 2e69f922
......@@ -157,6 +157,7 @@ define(['require',
this.multiSelectEntity = [];
this.searchType = 'Basic Search';
this.columnOrder = null;
this.defaultColumns = ["selected", "name", "description", "typeName", "owner", "tag", "term"];
if (this.value) {
if (this.value.searchType && this.value.searchType == 'dsl') {
this.searchType = 'Advanced Search';
......@@ -221,7 +222,7 @@ define(['require',
this.updateColumnList(state);
var excludeDefaultColumn = [];
if (this.value && this.value.type) {
excludeDefaultColumn = _.without(this.searchTableColumns[this.value.type], "selected", "name", "description", "typeName", "owner", "tag", "term");
excludeDefaultColumn = _.difference(this.searchTableColumns[this.value.type], this.defaultColumns);
if (this.searchTableColumns[this.value.type] === null) {
this.ui.columnEmptyInfo.show();
} else {
......@@ -371,7 +372,7 @@ define(['require',
}
if (isPostMethod && isSearchTab) {
var excludeDefaultColumn = this.value.type && this.searchTableColumns ? _.without(this.searchTableColumns[this.value.type], "selected", "name", "description", "typeName", "owner", "tag") : null,
var excludeDefaultColumn = this.value.type && this.searchTableColumns ? _.difference(this.searchTableColumns[this.value.type], this.defaultColumns) : null,
filterObj = {
'entityFilters': entityFilters,
'tagFilters': tagFilters,
......
......@@ -276,4 +276,13 @@ pre {
margin-bottom: 5px;
margin-left: 5px;
float: left;
}
.errorValidate {
border-color: red !important;
}
.errorValidate+span .select2-selection {
border-color: red !important;
}
\ No newline at end of file
......@@ -23,7 +23,7 @@
<div class="form-group">
<label class="control-label col-sm-3 required" for="name">Name</label>
<div class="col-sm-8">
<input class="form-control attributeInput" data-id="attributeInput" placeholder="Attribute name">
<input class="form-control attributeInput require" data-id="attributeInput" placeholder="Attribute name">
</input>
</div>
</div>
......@@ -54,7 +54,7 @@
<div class="">
<label class="control-label col-sm-3 required" for="enumType">Enum Name</label>
<div class="col-sm-5">
<select class="form-control enumTypeSelector" data-id="enumTypeSelector" multiple="false">
<select class="form-control enumTypeSelector require" data-id="enumTypeSelector" multiple="false">
</select>
</div>
<div class="col-sm-3">
......@@ -75,7 +75,7 @@
<div class="stringlength-container">
<label class="control-label col-sm-3 required" for="name">Max length</label>
<div class="col-sm-8">
<input type="number" class="form-control stringLengthVal" data-id="stringLength" placeholder="Maximum length">
<input type="number" class="form-control stringLengthVal require" data-id="stringLength" placeholder="Maximum length">
</div>
</div>
</div>
......
......@@ -23,7 +23,7 @@
<label class="control-label col-sm-2 {{#if create}}required{{/if}}" for="name">Name</label>
{{#if create}}
<div class="col-sm-10">
<input class="form-control businessMetadata-name" data-id="name" placeholder="Name(required)" autofocus />
<input class="form-control businessMetadata-name require" data-id="name" placeholder="Name(required)" autofocus />
</div>
{{else}}
<span class="ellipsis-with-margin control-label text-left col-sm-10" data-id="title"></span> {{/if}}
......
......@@ -72,7 +72,6 @@ define(['require',
filterOpts: {},
paginatorOpts: {}
};
this.isFilters = null;
this.showDetails = true;
},
onRender: function() {
......
......@@ -47,33 +47,7 @@ define([
initialize: function(options) {
_.extend(this, options);
},
bindEvents: function() {
// this.listenTo(this.businessMetadataDefCollection, 'reset', function() {
// if (!this.model) {
// this.model = this.businessMetadataDefCollection.fullCollection.findWhere({ guid: this.guid });
// if (this.model) {
// this.renderTagDetail();
// } else {
// this.$('.fontLoader').hide();
// Utils.notifyError({
// content: 'Tag Not Found'
// });
// }
// }
// }, this);
// this.listenTo(this.collection, 'error', function(error, response) {
// if (response.responseJSON && response.responseJSON.error) {
// Utils.notifyError({
// content: response.responseJSON.error
// });
// } else {
// Utils.notifyError({
// content: 'Something went wrong'
// });
// }
// this.$('.fontLoader').hide();
// }, this);
},
bindEvents: function() {},
onRender: function() {
this.updateView();
},
......
......@@ -32,10 +32,7 @@ define(['require',
/** ui selector cache */
ui: {
title: '[data-id="title"]',
editBox: '[data-id="editBox"]',
saveButton: "[data-id='saveButton']",
description: '[data-id="description"]',
publishButton: '[data-id="publishButton"]',
backButton: '[data-id="backButton"]'
},
/** ui events hash */
......@@ -51,16 +48,15 @@ define(['require',
* @constructs
*/
initialize: function(options) {
_.extend(this, _.pick(options, 'guid', 'model', 'enumDefCollection', 'typeHeaders'));
_.extend(this, _.pick(options, 'model'));
},
onRender: function() {
this.renderDetail();
},
renderDetail: function() {
var that = this;
this.ui.title.html('<span>' + that.model.get('name') + '</span>');
if (that.model.get('description')) {
this.ui.description.text((that.model.get('description')));
this.ui.title.html('<span>' + this.model.get('name') + '</span>');
if (this.model.get('description')) {
this.ui.description.text((this.model.get('description')));
}
}
});
......
......@@ -19,14 +19,9 @@
define(['require',
'backbone',
'hbs!tmpl/business_metadata/BusinessMetadataTableLayoutView_tmpl',
'collection/VEntityList',
'models/VSearch',
'utils/Utils',
'utils/Messages',
'utils/Enums',
'utils/UrlLinks',
'utils/CommonViewFunction'
], function(require, Backbone, BusinessMetadataTableLayoutView_tmpl, VEntityList, VSearch, Utils, Messages, Enums, UrlLinks, CommonViewFunction) {
'utils/Messages'
], function(require, Backbone, BusinessMetadataTableLayoutView_tmpl, Utils, Messages) {
'use strict';
var BusinessMetadataTableLayoutView = Backbone.Marionette.LayoutView.extend(
......@@ -47,18 +42,12 @@ define(['require',
businessMetadataAttrPage: "[data-id='businessMetadataAttrPage']",
businessMetadataAttrPageTitle: "[data-id='businessMetadataAttrPageTitle']",
businessMetadataDetailPage: "[data-id='businessMetadataDetailPage']",
auditCreate: "[data-id='auditCreate']",
pageRecordText: "[data-id='pageRecordText']",
activePage: "[data-id='activePage']",
createBusinessMetadata: "[data-id='createBusinessMetadata']",
attributeEdit: "[data-id='attributeEdit']",
addAttribute: '[data-id="addAttribute"]',
businessMetadataAttrPageOk: '[data-id="businessMetadataAttrPageOk"]',
colManager: "[data-id='colManager']",
deleteBusinessMetadata: '[data-id="deleteBusinessMetadata"]',
businessMetadataAttrFontLoader: '.business-metadata-attr-fontLoader',
businessMetadataAttrTableOverlay: '.businessMetadata-attr-tableOverlay'
deleteBusinessMetadata: '[data-id="deleteBusinessMetadata"]'
},
/** ui events hash */
events: function() {
......@@ -80,9 +69,6 @@ define(['require',
initialize: function(options) {
_.extend(this, _.pick(options, 'guid', 'entity', 'entityName', 'attributeDefs', 'typeHeaders', 'businessMetadataDefCollection', 'entityDefCollection', 'businessMetadataAttr', 'selectedBusinessMetadata'));
this.limit = 10;
this.offset = 0;
this.pervOld = [];
this.onlyPurge = true;
this.newAttr = false;
this.commonTableOptions = {
collection: this.businessMetadataDefCollection,
......@@ -111,8 +97,6 @@ define(['require',
filterOpts: {},
paginatorOpts: {}
};
this.currPage = 1;
this.isFilters = null;
this.guid = null;
this.showDetails = true; // toggle between sttribute page and detail page
},
......@@ -225,11 +209,10 @@ define(['require',
that.toggleBusinessMetadataDetailsAttrView();
that.entityDefCollection.fetch({ silent: true });
},
tagCollection: that.businessMetadataDefCollection,
businessMetadataDefCollection: that.businessMetadataDefCollection,
enumDefCollection: enumDefCollection,
typeHeaders: typeHeaders,
isNewBusinessMetadata: isNewBusinessMetadata,
businessMetadataDefCollection: businessMetadataDefCollection
isNewBusinessMetadata: isNewBusinessMetadata
});
that.RModal.show(that.view);
});
......@@ -272,7 +255,6 @@ define(['require',
var applicableEntityTypes = '',
typeName = attrObj.typeName;
if (attrObj.options && attrObj.options.applicableEntityTypes) {
// attrEntityTypes = JSON.parse(attrObj.options.applicableEntityTypes).join(', ');
var entityTypes = JSON.parse(attrObj.options.applicableEntityTypes);
_.each(entityTypes, function(values) {
applicableEntityTypes += '<label class="btn btn-action btn-xs btn-blue no-pointer">' + values + '</label>';
......@@ -283,11 +265,11 @@ define(['require',
}
attrRow += "<tr> <td style='display:table-cell'>" + _.escape(attrObj.name) + "</td><td style='display:table-cell'>" + typeName + "</td><td style='display:table-cell'>" + applicableEntityTypes + "</td><td style='display:table-cell'> <div class='btn btn-action btn-sm' style='margin-left:0px;' data-id='attributeEdit' data-guid='" + model.get('guid') + "' data-name ='" + _.escape(attrObj.name) + "' data-action='attributeEdit' >Edit</div> </td></tr> ";
});
var purgeText = '<div class="row"><div class="col-sm-12 attr-details"><table style="padding: 50px;">' + attrTableHeading + attrRow + '</table></div></div>';
$(el).append($('<div>').html(purgeText));
var adminText = '<div class="row"><div class="col-sm-12 attr-details"><table style="padding: 50px;">' + attrTableHeading + attrRow + '</table></div></div>';
$(el).append($('<div>').html(adminText));
} else {
var purgeText = '<div class="row"><div class="col-sm-12 attr-details"><h5 class="text-center"> No attributes to show.</h5></div></div>';
$(el).append($('<div>').html(purgeText));
var adminText = '<div class="row"><div class="col-sm-12 attr-details"><h5 class="text-center"> No attributes to show.</h5></div></div>';
$(el).append($('<div>').html(adminText));
}
}
......@@ -364,7 +346,6 @@ define(['require',
formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
fromRaw: function(rawValue, model) {
return "<button type='button' data-id='addAttribute' data-guid='" + model.get('guid') + "'' title='' class='btn btn-action btn-xs ' style='margin-bottom: 10px;' data-action='createAttr' data-original-title='Add Business Metadata attribute'><i class='fa fa-plus'></i> Attributes</button>";
// "<button type='button' data-id='deleteBusinessMetadata' data-guid='" + model.get('guid') + "'' title='' class='btn btn-action btn-xs ' style='margin-bottom: 10px;' data-action='createAttr' data-original-title='Delete BusinessMetadata'><i class='fa fa-trash-o'></i> Delete</button>";
}
})
}
......@@ -386,7 +367,6 @@ define(['require',
onNotifyDeleteOk: function(data) {
var that = this,
deleteBusinessMetadataData = that.businessMetadataDefCollection.fullCollection.findWhere({ guid: that.guid });
// that.$('.position-relative .fontLoader').addClass('show');
that.$('.tableOverlay').show();
if (deleteBusinessMetadataData) {
var businessMetadataName = deleteBusinessMetadataData.get("name");
......
......@@ -15,13 +15,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
define(["require", "backbone", "hbs!tmpl/business_metadata/EnumCreateUpdateItemView_tmpl", "utils/Utils", "utils/UrlLinks", "utils/Messages"], function(
define(["require", "backbone", "hbs!tmpl/business_metadata/EnumCreateUpdateItemView_tmpl", "utils/Utils", "utils/UrlLinks"], function(
require,
Backbone,
EnumCreateUpdateItemViewTmpl,
Utils,
UrlLinks,
Messages
UrlLinks
) {
"use strict";
......@@ -81,13 +80,9 @@ define(["require", "backbone", "hbs!tmpl/business_metadata/EnumCreateUpdateItemV
* @constructs
*/
initialize: function(options) {
this.enumDefCollection = options.enumDefCollection;
this.businessMetadataDefCollection = options.businessMetadataDefCollection;
_.extend(this, _.pick(options, "businessMetadataDefCollection", "enumDefCollection"));
},
onRender: function() {
var that = this,
entitytypes = "",
enumTypes = [];
this.ui.enumValueSelectorContainer.hide();
this.bindEvents();
this.emumTypeSelectDisplay();
......@@ -107,8 +102,7 @@ define(["require", "backbone", "hbs!tmpl/business_metadata/EnumCreateUpdateItemV
var enumValues = "",
selectedValues = [],
selectedEnum = this.enumDefCollection.fullCollection.findWhere({ name: enumName }),
selectedEnumValues = selectedEnum ? selectedEnum.get("elementDefs") : null,
savedValues = [];
selectedEnumValues = selectedEnum ? selectedEnum.get("elementDefs") : null;
_.each(selectedEnumValues, function(enumVal, index) {
selectedValues.push(_.unescape(enumVal.value));
enumValues += "<option>" + enumVal.value + "</option>";
......
......@@ -163,6 +163,7 @@ define(['require',
this.multiSelectEntity = [];
this.searchType = 'Basic Search';
this.columnOrder = null;
this.defaultColumns = ["selected", "name", "description", "typeName", "owner", "tag", "term"];
if (this.value) {
if (this.value.searchType && this.value.searchType == 'dsl') {
this.searchType = 'Advanced Search';
......@@ -227,7 +228,7 @@ define(['require',
this.updateColumnList(state);
var excludeDefaultColumn = [];
if (this.value && this.value.type) {
excludeDefaultColumn = _.without(this.searchTableColumns[this.value.type], "selected", "name", "description", "typeName", "owner", "tag", "term");
excludeDefaultColumn = _.difference(this.searchTableColumns[this.value.type], this.defaultColumns);
if (this.searchTableColumns[this.value.type] === null) {
this.ui.columnEmptyInfo.show();
} else {
......@@ -380,7 +381,7 @@ define(['require',
}
if (isPostMethod && isSearchTab) {
var excludeDefaultColumn = this.value.type && this.searchTableColumns ? _.without(this.searchTableColumns[this.value.type], "selected", "name", "description", "typeName", "owner", "tag") : null,
var excludeDefaultColumn = this.value.type && this.searchTableColumns ? _.difference(this.searchTableColumns[this.value.type], this.defaultColumns) : null,
filterObj = {
'entityFilters': entityFilters,
'tagFilters': tagFilters,
......@@ -793,14 +794,14 @@ define(['require',
}
})
};
col['businessMetaData'] = {
label: "Business MetaData",
col['businessMetadata'] = {
label: "Business Metadata",
cell: "Html",
editable: false,
resizeable: true,
orderable: true,
alwaysVisible: true, //Backgrid.ColumnManager.js -> render() to hide the name in dropdownlist
renderable: _.contains(columnToShow, 'businessMetaData'),
renderable: _.contains(columnToShow, 'businessMetadata'),
formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
fromRaw: function(rawValue, model) {
var obj = model.toJSON(),
......
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