Commit 7f03fc8e by kalyani Committed by Madhan Neethiraj

ATLAS-1718: UI update to support enum-type attributes for tags

parent ceea868d
...@@ -14,7 +14,10 @@ ...@@ -14,7 +14,10 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
--> -->
<div class="row row-margin-bottom"> <div class="fontLoader" style="margin-top:-10px">
<i class="fa fa-refresh fa-spin-custom"></i>
</div>
<div class="row row-margin-bottom hide">
<div class="col-sm-12"> <div class="col-sm-12">
<div class="clearfix"> <div class="clearfix">
<button type="button" class="btn btn-success btn-sm pull-right" data-id="attributeData"><i class="fa fa-plus"></i> Add New Attribute</button> <button type="button" class="btn btn-success btn-sm pull-right" data-id="attributeData"><i class="fa fa-plus"></i> Add New Attribute</button>
......
...@@ -14,7 +14,10 @@ ...@@ -14,7 +14,10 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
--> -->
<form name="tagDefinitionform" class="css-form" data-id="createTagForm"> <div class="fontLoader" style="margin-top:-10px">
<i class="fa fa-refresh fa-spin-custom"></i>
</div>
<form name="tagDefinitionform" class="css-form hide" data-id="createTagForm">
<div class="form-group"> <div class="form-group">
{{#if create}} {{#if create}}
<input class="form-control row-margin-bottom" data-id="tagName" placeholder="Name(required)" autofocus> <input class="form-control row-margin-bottom" data-id="tagName" placeholder="Name(required)" autofocus>
......
...@@ -20,8 +20,10 @@ define(['require', ...@@ -20,8 +20,10 @@ define(['require',
'backbone', 'backbone',
'hbs!tmpl/tag/AddTagAttributeView_tmpl', 'hbs!tmpl/tag/AddTagAttributeView_tmpl',
'views/tag/TagAttributeItemView', 'views/tag/TagAttributeItemView',
'utils/UrlLinks',
'collection/VTagList'
], function(require, Backbone, AddTagAttributeView_tmpl, TagAttributeItemView) { ], function(require, Backbone, AddTagAttributeView_tmpl, TagAttributeItemView, UrlLinks, VTagList) {
'use strict'; 'use strict';
return Backbone.Marionette.CompositeView.extend( return Backbone.Marionette.CompositeView.extend(
...@@ -61,13 +63,25 @@ define(['require', ...@@ -61,13 +63,25 @@ define(['require',
initialize: function(options) { initialize: function(options) {
// this.parentView = options.parentView; // this.parentView = options.parentView;
this.collection = new Backbone.Collection(); this.collection = new Backbone.Collection();
this.collectionAttribute(); this.typeEnum = new VTagList();
this.typeEnum.url = UrlLinks.typedefsUrl().defs;
this.typeEnum.modelAttrName = "enumDefs";
}, },
onRender: function() { onRender: function() {
var that = this;
this.$('.fontLoader').show();
this.ui.addAttributeDiv.find('.closeInput').hide(); this.ui.addAttributeDiv.find('.closeInput').hide();
if (!('placeholder' in HTMLInputElement.prototype)) { if (!('placeholder' in HTMLInputElement.prototype)) {
this.ui.addAttributeDiv.find('input,textarea').placeholder(); this.ui.addAttributeDiv.find('input,textarea').placeholder();
} }
that.typeEnum.fetch({
reset: true,
complete: function(model, response) {
that.collectionAttribute();
that.$('.fontLoader').hide();
that.$('.hide').removeClass('hide');
}
});
}, },
bindEvents: function() {}, bindEvents: function() {},
collectionAttribute: function() { collectionAttribute: function() {
...@@ -81,6 +95,7 @@ define(['require', ...@@ -81,6 +95,7 @@ define(['require',
"isUnique": false, "isUnique": false,
"isIndexable": false "isIndexable": false
})); }));
}, },
onClickAddAttriBtn: function() { onClickAddAttriBtn: function() {
if (this.ui.addAttributeDiv.find("input").length > 0) { if (this.ui.addAttributeDiv.find("input").length > 0) {
......
...@@ -21,8 +21,10 @@ define(['require', ...@@ -21,8 +21,10 @@ define(['require',
'hbs!tmpl/tag/createTagLayoutView_tmpl', 'hbs!tmpl/tag/createTagLayoutView_tmpl',
'utils/Utils', 'utils/Utils',
'views/tag/TagAttributeItemView', 'views/tag/TagAttributeItemView',
'collection/VTagList',
'utils/UrlLinks',
'platform' 'platform'
], function(require, Backbone, CreateTagLayoutViewTmpl, Utils, TagAttributeItemView, platform) { ], function(require, Backbone, CreateTagLayoutViewTmpl, Utils, TagAttributeItemView, VTagList, UrlLinks, platform) {
var CreateTagLayoutView = Backbone.Marionette.CompositeView.extend( var CreateTagLayoutView = Backbone.Marionette.CompositeView.extend(
/** @lends CreateTagLayoutView */ /** @lends CreateTagLayoutView */
...@@ -81,9 +83,14 @@ define(['require', ...@@ -81,9 +83,14 @@ define(['require',
this.create = true; this.create = true;
} }
this.collection = new Backbone.Collection(); this.collection = new Backbone.Collection();
this.typeEnum = new VTagList();
this.typeEnum.url = UrlLinks.typedefsUrl().defs;
this.typeEnum.modelAttrName = "enumDefs";
}, },
bindEvents: function() {}, bindEvents: function() {},
onRender: function() { onRender: function() {
var that = this;
this.$('.fontLoader').show();
if (this.create) { if (this.create) {
this.tagCollectionList(); this.tagCollectionList();
} else { } else {
...@@ -92,6 +99,12 @@ define(['require', ...@@ -92,6 +99,12 @@ define(['require',
if (!('placeholder' in HTMLInputElement.prototype)) { if (!('placeholder' in HTMLInputElement.prototype)) {
this.ui.createTagForm.find('input,textarea').placeholder(); this.ui.createTagForm.find('input,textarea').placeholder();
} }
that.typeEnum.fetch({
reset: true,
complete: function(model, response) {
that.hideLoader();
}
});
}, },
tagCollectionList: function() { tagCollectionList: function() {
var str = '', var str = '',
...@@ -114,6 +127,10 @@ define(['require', ...@@ -114,6 +127,10 @@ define(['require',
}); });
} }
}, },
hideLoader: function() {
this.$('.fontLoader').hide();
this.$('.hide').removeClass('hide');
},
collectionAttribute: function() { collectionAttribute: function() {
this.collection.add(new Backbone.Model({ this.collection.add(new Backbone.Model({
"name": "", "name": "",
...@@ -131,6 +148,7 @@ define(['require', ...@@ -131,6 +148,7 @@ define(['require',
if (!('placeholder' in HTMLInputElement.prototype)) { if (!('placeholder' in HTMLInputElement.prototype)) {
this.ui.addAttributeDiv.find('input,textarea').placeholder(); this.ui.addAttributeDiv.find('input,textarea').placeholder();
} }
} }
}); });
return CreateTagLayoutView; return CreateTagLayoutView;
......
...@@ -35,7 +35,7 @@ define(['require', ...@@ -35,7 +35,7 @@ define(['require',
ui: { ui: {
attributeInput: "[data-id='attributeInput']", attributeInput: "[data-id='attributeInput']",
close: "[data-id='close']", close: "[data-id='close']",
dataTypeSelector: "[data-id='dataTypeSelector']", dataTypeSelector: "[data-id='dataTypeSelector']"
}, },
/** ui events hash */ /** ui events hash */
events: function() { events: function() {
...@@ -56,11 +56,14 @@ define(['require', ...@@ -56,11 +56,14 @@ define(['require',
*/ */
initialize: function(options) { initialize: function(options) {
this.parentView = options.parentView; this.parentView = options.parentView;
}, },
onRender: function() { onRender: function() {
var that = this;
_.each(this.parentView.typeEnum.models, function(objValue) {
that.ui.dataTypeSelector.append("<option>" + objValue.attributes.name + "</option>");
});
}, },
bindEvents: function() {},
onCloseButton: function() { onCloseButton: function() {
if (this.parentView.collection.models.length > 0) { if (this.parentView.collection.models.length > 0) {
this.model.destroy(); this.model.destroy();
......
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