Commit 43c134dd by kevalbhatt

ATLAS-3634:Betal UI: Add refresh button for basic search / Advance Search

parent 58a58956
......@@ -131,16 +131,20 @@ define(['require',
dropdownWithSearch.prototype.render = function() {
// Copy and modify default search render method
var $rendered = Dropdown.prototype.render.call(this);
var $rendered = Dropdown.prototype.render.call(this),
dropdownCssClass = this.options.get("dropdownCssClass")
if (dropdownCssClass) {
$rendered.addClass(dropdownCssClass);
}
// Add ability for a placeholder in the search box
var placeholder = this.options.get("placeholderForSearch") || "";
var $search = $(
'<span class="select2-search select2-search--dropdown"><div class="row">' +
'<div class="col-md-10"><input class="select2-search__field" placeholder="' + placeholder + '" type="search"' +
'<span class="select2-search select2-search--dropdown"><div class="clearfix">' +
'<div class="col-md-10 no-padding" style="width: calc(100% - 30px);"><input class="select2-search__field" placeholder="' + placeholder + '" type="search"' +
' tabindex="-1" autocomplete="off" autocorrect="off" autocapitalize="off"' +
' spellcheck="false" role="textbox" /></div>' +
'<div class="col-md-2"><button type="button" style="margin-left: -20px" class="btn btn-action btn-sm filter " title="Type Filter"><i class="fa fa-filter"></i></button></div>' +
'<div class="col-md-2 no-padding" style="width: 30px;"><button type="button" style="padding: 3px 6px;margin: 0px 4px;" class="btn btn-action btn-sm filter " title="Type Filter"><i class="fa fa-filter"></i></button></div>' +
'</div></span>'
);
if (!this.options.options.getFilterBox) {
......
......@@ -203,12 +203,7 @@ define(['require',
});
}
});
if (this.multiSelectEntity.length > 0) {
this.$('.multiSelectTag,.multiSelectTerm').show();
} else {
this.$('.multiSelectTag,.multiSelectTerm').hide();
}
this.updateMultiSelect();
});
this.listenTo(this.searchCollection, "error", function(model, response) {
this.hideLoader({ type: 'error' });
......@@ -339,6 +334,13 @@ define(['require',
updateTabState: true
}, options));
},
updateMultiSelect: function() {
if (this.multiSelectEntity.length > 0) {
this.$('.multiSelectTag,.multiSelectTerm').show();
} else {
this.$('.multiSelectTag,.multiSelectTerm').hide();
}
},
updateColumnList: function(updatedList) {
if (updatedList) {
var listOfColumns = [];
......@@ -388,13 +390,13 @@ define(['require',
if (that.isDestroyed) {
return;
}
that.ui.gotoPage.val('');
that.ui.gotoPage.parent().removeClass('has-error');
that.ui.gotoPagebtn.prop("disabled", true);
Globals.searchApiCallRef = undefined;
var isFirstPage = that.offset === 0,
dataLength = 0,
goToPage = that.ui.gotoPage.val();
that.ui.gotoPage.val('');
that.ui.gotoPage.parent().removeClass('has-error');
that.ui.gotoPagebtn.prop("disabled", true);
if (!(that.ui.pageRecordText instanceof jQuery)) {
return;
}
......@@ -414,6 +416,7 @@ define(['require',
pageNumber = goToPage;
that.offset = (that.activePage - 1) * that.limit;
} else {
that.finalPage = that.activePage;
that.ui.nextData.attr('disabled', true);
that.offset = that.offset - that.limit;
}
......@@ -475,6 +478,9 @@ define(['require',
that.ui.activePage.attr('title', "Page " + that.activePage);
that.ui.activePage.text(that.activePage);
that.renderTableLayoutView();
that.multiSelectEntity = [];
that.updateMultiSelect();
if (dataLength > 0) {
that.$('.searchTable').removeClass('noData')
}
......@@ -523,6 +529,7 @@ define(['require',
Globals.searchApiCallRef = this.searchCollection.fetch(apiObj);
}
} else {
_.extend(this.searchCollection.queryParams, { 'limit': this.limit, 'offset': this.offset });
if (isPostMethod) {
apiObj['data'] = _.extend(checkBoxValue, filterObj, _.pick(this.searchCollection.queryParams, 'query', 'excludeDeletedEntities', 'limit', 'offset', 'typeName', 'classification', 'termName'));
Globals.searchApiCallRef = this.searchCollection.getBasicRearchResult(apiObj);
......@@ -1214,6 +1221,13 @@ define(['require',
var that = this;
var goToPage = parseInt(this.ui.gotoPage.val());
if (!(_.isNaN(goToPage) || goToPage <= -1)) {
if (this.finalPage && this.finalPage < goToPage) {
Utils.notifyInfo({
html: true,
content: Messages.search.noRecordForPage + '<b>' + Utils.getNumberSuffix({ number: goToPage, sup: true }) + '</b> page'
});
return;
}
this.offset = (goToPage - 1) * this.limit;
if (this.offset <= -1) {
this.offset = 0;
......
......@@ -276,7 +276,7 @@ define(['require',
return '<li class="parent-node" data-id="tags">' +
'<div><div class="tools"><i class="fa fa-ellipsis-h tagPopover"></i></div>' +
(hasChild ? '<i class="fa toggleArrow fa-angle-right" data-id="expandArrow" data-name="' + name + '"></i>' : '') +
'<a href="#!/tag/tagAttribute/' + name + '?viewType=' + (isTree ? 'tree' : 'flat') + '" data-name="' + name + '">' + name + '</a></div>' +
'<a href="#!/tag/tagAttribute/' + name + '?viewType=' + (isTree ? 'tree' : 'flat') + '&searchType=basic" data-name="' + name + '">' + name + '</a></div>' +
(isTree && hasChild ? '<ul class="child hide">' + that.generateTree({ 'data': options.children, 'isTree': isTree }) + '</ul>' : '') + '</li>';
};
if (isTree) {
......
......@@ -494,4 +494,10 @@ div.columnmanager-dropdown-container {
.table-hover>tbody>tr:hover {
background-color: #fafafa;
}
.input-group {
.form-control {
z-index: 1;
}
}
\ No newline at end of file
......@@ -398,18 +398,22 @@ hr.hr-filter {
height: 100%;
width: 100%;
opacity: 0.5;
z-index: 1;
z-index: 2;
background: white;
}
.searchResultContainer {
z-index: 1;
}
.attributeResultContainer {
&.overlay {
z-index: 2;
z-index: 3;
}
.attribute-filter-container {
position: absolute;
z-index: 1;
z-index: 3;
left: 21px;
width: 75%;
right: 0;
......
......@@ -26,6 +26,7 @@
</div>
</div>
<div class="col-sm-12 attributeResultContainer form-group">
<button title="Refresh Search Result" class="btn-action btn-sm" data-id="refreshSearchResult" data-original-title="Refresh Search Result"><i class="fa fa-refresh"></i></button>
<button class="btn-action btn-sm attribute-filter-text" data-id='attrFilter'> <i class="fa fa-angle-right"></i> Filters</button>
<button class='btn-action btn-sm' data-id='clearQuerySearch'>Clear</button>
<div class="attribute-filter-container hide">
......
......@@ -212,16 +212,20 @@ define(['require',
dropdownWithSearch.prototype.render = function() {
// Copy and modify default search render method
var $rendered = Dropdown.prototype.render.call(this);
var $rendered = Dropdown.prototype.render.call(this),
dropdownCssClass = this.options.get("dropdownCssClass")
if (dropdownCssClass) {
$rendered.addClass(dropdownCssClass);
}
// Add ability for a placeholder in the search box
var placeholder = this.options.get("placeholderForSearch") || "";
var $search = $(
'<span class="select2-search select2-search--dropdown"><div class="row">' +
'<div class="col-md-10"><input class="select2-search__field" placeholder="' + placeholder + '" type="search"' +
'<span class="select2-search select2-search--dropdown"><div class="clearfix">' +
'<div class="col-md-10 no-padding" style="width: calc(100% - 30px);"><input class="select2-search__field" placeholder="' + placeholder + '" type="search"' +
' tabindex="-1" autocomplete="off" autocorrect="off" autocapitalize="off"' +
' spellcheck="false" role="textbox" /></div>' +
'<div class="col-md-2"><button type="button" style="margin-left: -20px" class="btn btn-action btn-sm filter " title="Type Filter"><i class="fa fa-filter"></i></button></div>' +
'<div class="col-md-2 no-padding" style="width: 30px;"><button type="button" style="padding: 3px 6px;margin: 0px 4px;" class="btn btn-action btn-sm filter " title="Type Filter"><i class="fa fa-filter"></i></button></div>' +
'</div></span>'
);
if (!this.options.options.getFilterBox) {
......
......@@ -88,9 +88,7 @@ define(["require",
var that = this;
$("body").on("click", function(e) {
if (!that.isDestroyed && that.$(e.target).data("id") !== "detailSearch") {
if ($(e.target).hasClass("modal") || $(e.target).parents(".modal-backdrop").length != 0 || $(e.target).parents(".modal").length != 0) {
// console.log("modal");
} else if ($(e.target).parents(".searchLayoutView").length === 0 && that.ui.searchLayoutView.hasClass("open")) {
if ($(e.target).parents(".searchLayoutView").length === 0 && that.ui.searchLayoutView.hasClass("open")) {
that.ui.searchLayoutView.removeClass("open");
}
}
......
......@@ -48,7 +48,8 @@ define(["require", "backbone", "utils/Globals", "hbs!tmpl/search/SearchDefaultLa
entityName: ".entityName",
classificationName: ".classificationName",
createNewEntity: '[data-id="createNewEntity"]',
clearQuerySearch: "[data-id='clearQuerySearch']"
clearQuerySearch: "[data-id='clearQuerySearch']",
refreshSearchQuery: "[data-id='refreshSearchResult']"
},
/** ui events hash */
events: function() {
......@@ -65,6 +66,10 @@ define(["require", "backbone", "utils/Globals", "hbs!tmpl/search/SearchDefaultLa
this.$('.attribute-filter-container, .attr-filter-overlay').toggleClass('hide');
};
events["click " + this.ui.refreshSearchQuery] = function(e) {
this.options.searchVent.trigger('search:refresh');
};
events["click " + this.ui.attrApply] = function(e) {
that.okAttrFilterButton(e);
};
......@@ -360,7 +365,7 @@ define(["require", "backbone", "utils/Globals", "hbs!tmpl/search/SearchDefaultLa
if (_.has(obj, "condition")) {
return that.getIdFromRuleObj(obj);
} else {
if (obj && obj.data && obj.data.entityType === "namespace") {
if ((obj && obj.data && obj.data.entityType === "namespace") || obj.id.indexOf(".") > -1) {
return col.add("namespace");
} else {
return col.add(obj.id);
......@@ -377,7 +382,7 @@ define(["require", "backbone", "utils/Globals", "hbs!tmpl/search/SearchDefaultLa
if (!this.options.searchTableColumns[this.options.value.type]) {
this.options.searchTableColumns[this.options.value.type] = ["selected", "name", "description", "typeName", "owner", "tag", "term"];
}
this.options.searchTableColumns[this.options.value.type] = _.sortBy(_.union(this.options.searchTableColumns[this.options.value.type], this.getIdFromRuleObj(rule)));
this.options.searchTableColumns[this.options.value.type] = _.sortBy(_.union(_.without(this.options.searchTableColumns[this.options.value.type], "namespace"), this.getIdFromRuleObj(rule)));
}
},
renderQueryBuilder: function(obj, rQueryBuilder) {
......
......@@ -487,6 +487,7 @@ define(['require',
placeholder: "Select Type",
dropdownAdapter: $.fn.select2.amd.require("ServiceTypeFilterDropdownAdapter"),
allowClear: true,
dropdownCssClass: "searchLayoutView",
getFilterBox: this.getFilterBox.bind(this),
onFilterSubmit: function(options) {
that.filterTypeSelected = options.filterVal;
......
......@@ -209,12 +209,7 @@ define(['require',
});
}
});
if (this.multiSelectEntity.length > 0) {
this.$('.multiSelectTag,.multiSelectTerm').show();
} else {
this.$('.multiSelectTag,.multiSelectTerm').hide();
}
this.updateMultiSelect();
});
this.listenTo(this.searchCollection, "error", function(model, response) {
this.hideLoader({ type: 'error' });
......@@ -348,6 +343,13 @@ define(['require',
updateTabState: true
}, options));
},
updateMultiSelect: function() {
if (this.multiSelectEntity.length > 0) {
this.$('.multiSelectTag,.multiSelectTerm').show();
} else {
this.$('.multiSelectTag,.multiSelectTerm').hide();
}
},
updateColumnList: function(updatedList) {
if (updatedList) {
var listOfColumns = [];
......@@ -363,7 +365,7 @@ define(['require',
this.searchTableColumns[this.value.type] = listOfColumns.length ? listOfColumns : null;
}
} else if (this.value && this.value.type && this.searchTableColumns && this.value.attributes) {
this.searchTableColumns[this.value.type] = this.value.attributes.split(",");
this.searchTableColumns[this.value.type] = this.value.entityFilters ? this.value.attributes.split(",") : this.value.attributes.replace("namespace,", "").split(",");
}
},
fetchCollection: function(value, options) {
......@@ -397,13 +399,13 @@ define(['require',
if (that.isDestroyed) {
return;
}
that.ui.gotoPage.val('');
that.ui.gotoPage.parent().removeClass('has-error');
that.ui.gotoPagebtn.prop("disabled", true);
Globals.searchApiCallRef = undefined;
var isFirstPage = that.offset === 0,
dataLength = 0,
goToPage = that.ui.gotoPage.val();
that.ui.gotoPage.val('');
that.ui.gotoPage.parent().removeClass('has-error');
that.ui.gotoPagebtn.prop("disabled", true);
if (!(that.ui.pageRecordText instanceof jQuery)) {
return;
}
......@@ -423,6 +425,7 @@ define(['require',
pageNumber = goToPage;
that.offset = (that.activePage - 1) * that.limit;
} else {
that.finalPage = that.activePage;
that.ui.nextData.attr('disabled', true);
that.offset = that.offset - that.limit;
}
......@@ -484,6 +487,8 @@ define(['require',
that.ui.activePage.attr('title', "Page " + that.activePage);
that.ui.activePage.text(that.activePage);
that.renderTableLayoutView();
that.multiSelectEntity = [];
that.updateMultiSelect();
if (dataLength > 0) {
that.$('.searchTable').removeClass('noData')
......@@ -536,6 +541,7 @@ define(['require',
Globals.searchApiCallRef = this.searchCollection.fetch(apiObj);
}
} else {
_.extend(this.searchCollection.queryParams, { 'limit': this.limit, 'offset': this.offset });
if (isPostMethod) {
apiObj['data'] = _.extend(checkBoxValue, filterObj, _.pick(this.searchCollection.queryParams, 'query', 'excludeDeletedEntities', 'limit', 'offset', 'typeName', 'classification', 'termName'));
Globals.searchApiCallRef = this.searchCollection.getBasicRearchResult(apiObj);
......@@ -794,6 +800,7 @@ define(['require',
editable: false,
resizeable: true,
orderable: true,
alwaysVisible: true, //Backgrid.ColumnManager.js -> render() to hide the name in dropdownlist
renderable: _.contains(columnToShow, 'namespace'),
formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
fromRaw: function(rawValue, model) {
......@@ -1271,6 +1278,13 @@ define(['require',
var that = this;
var goToPage = parseInt(this.ui.gotoPage.val());
if (!(_.isNaN(goToPage) || goToPage <= -1)) {
if (this.finalPage && this.finalPage < goToPage) {
Utils.notifyInfo({
html: true,
content: Messages.search.noRecordForPage + '<b>' + Utils.getNumberSuffix({ number: goToPage, sup: true }) + '</b> page'
});
return;
}
this.offset = (goToPage - 1) * this.limit;
if (this.offset <= -1) {
this.offset = 0;
......
......@@ -67,7 +67,7 @@ define(['require',
} else {
this.modal = modal = new Modal({
titleHtml: true,
title: '<span>' + (this.selectedModel && this.rename ? 'Rename' : 'Save/Save As..') + (this.isBasic ? " Basic" : " Advanced") + ' Custom Filter</span>',
title: '<span>' + (this.selectedModel && this.rename ? 'Rename' : 'Save') + (this.isBasic ? " Basic" : " Advanced") + ' Custom Filter</span>',
content: this,
cancelText: "Cancel",
okCloses: false,
......@@ -112,7 +112,7 @@ define(['require',
that.ui.saveAsName.append(options);
that.ui.saveAsName.val("");
that.ui.saveAsName.select2({
placeholder: "Save/Save As.. filter",
placeholder: "Enter filter name ",
allowClear: false,
tags: true,
multiple: false,
......@@ -121,9 +121,9 @@ define(['require',
return state.text;
}
if (!state.element) {
return $("<span><span class='option-title-light'>Save:</span> <strong> " + _.escape(state.text) + "</strong></span>");
return $("<span><span class='option-title-light'>New:</span> <strong>" + _.escape(state.text) + "</strong></span>");
} else {
return $("<span><span class='option-title-light'>Save As:</span> <strong>" + _.escape(state.text) + "</strong></span>");
return $("<span><span class='option-title-light'>Update:</span> <strong>" + _.escape(state.text) + "</strong></span>");
}
}
}).on("change", function() {
......
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