Skip to content

Commit 8aa0d81

Browse files
committed
new feature: saved search
1 parent 5b9833a commit 8aa0d81

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

src/main/celerio/angularjs/assets/js/entity/EntityController.e.vm.js

+9
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ scope.pagination = {};
6060
scope.totalElementsPerPage = 20;
6161
scope.busy = false;
6262

63+
// saved search
64+
scope.savedSearch = {};
65+
6366
// checkbox in the grid header
6467
scope.selectAll = false;
6568

@@ -156,6 +159,12 @@ scope.clear = function () {
156159
scope.data = [];
157160
};
158161

162+
/** clear saved search */
163+
scope.clearSavedSearch = function () {
164+
log.info("call method clearSavedSearch inside ${entity.model.type}Controller");
165+
scope.savedSearch = {};
166+
};
167+
159168
/** Shows search aside */
160169
scope.searchItem = function() {
161170
log.info("searchItem: ");

src/main/celerio/angularjs/assets/tpl/apps/entitySearch.e.vm.html

+9-9
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,20 @@
88
<div class="aside-dialog">
99
<div class="aside-body bs-sidebar">
1010

11-
<form class="form-floating" novalidate="novalidate" ng-submit="startSearch(item)">
11+
<form class="form-floating" novalidate="novalidate" ng-submit="startSearch(savedSearch)">
1212
<fieldset>
13-
<legend><span ng-bind-html="item.icon"></span> {{cmd}} {{settings.singular}} search</legend>
13+
<legend><span ng-bind-html="savedSearch.icon"></span> {{cmd}} {{settings.singular}} search</legend>
1414

1515
#foreach ($attribute in $entity.nonCpkAttributes.list)
1616
#if (!$attribute.isInPk() && !$attribute.isInFk())
1717
<div class="form-group filled">
1818
<label class="control-label">$attribute.varUp</label>
1919
#if ($attribute.type == "BigDecimal" || $attribute.type == "Integer" || $attribute.type == "BigInteger")
20-
<input type="text" class="form-control" ng-model="item.${attribute.var}" ng-disabled="!item.editing">
20+
<input type="text" class="form-control" ng-model="savedSearch.${attribute.var}">
2121
#elseif ($attribute.type == "String")
22-
<input type="text" class="form-control" ng-model="item.${attribute.var}" ng-disabled="!item.editing">
22+
<input type="text" class="form-control" ng-model="savedSearch.${attribute.var}">
2323
#elseif ($attribute.type == "Date")
24-
<input type="text" class="form-control" ng-model="item.${attribute.var}" data-autoclose="1" placeholder="{{ '${attribute.name}' | translate }}"
25-
bs-datepicker ng-disabled="!item.editing">
24+
<input type="text" class="form-control" ng-model="savedSearch.${attribute.var}" data-autoclose="1" placeholder="{{ '${attribute.name}' | translate }}" bs-datepicker>
2625
#else
2726
<p>Type [$attribute.type] not implemented yet !!!!</p>
2827
#end
@@ -33,7 +32,7 @@
3332
#if ($attribute.getXToOneRelation().isManyToOne())
3433
<div class="form-group filled">
3534
<label class="control-label">${attribute.getEntityIPointTo().name}</label>
36-
<ui-select ng-model="item.${attribute.var}" theme="select2" title="Choose an $attribute.getEntityIPointTo().name.toLowerCase()" search-enabled="false" ng-disabled="!item.editing">
35+
<ui-select ng-model="savedSearch.${attribute.var}" theme="select2" title="Choose an $attribute.getEntityIPointTo().name.toLowerCase()" search-enabled="false">
3736
<ui-select-match placeholder="Choose an $attribute.getEntityIPointTo().name.toLowerCase()">{{${dollar}select.selected.name}}</ui-select-match>
3837
<ui-select-choices repeat="item in ${attribute.getEntityIPointTo().name.toLowerCase()}s | filter: ${dollar}select.search">
3938
<div ng-bind-html="item.name | highlight: ${dollar}select.search"></div>
@@ -51,18 +50,19 @@
5150
#end
5251

5352
<div class="form-group">
53+
<button type="button" ng-click="clearSavedSearch()" class="btn btn-lg btn-primary">{{ 'CLEAR' | translate }}</button>
5454
<button type="submit" class="btn btn-lg btn-primary">{{ 'SEARCH' | translate }}</button>
5555
</div>
5656

5757
</fieldset>
5858
</form>
5959

60-
<form class="form-floating" novalidate="novalidate" ng-submit="startElasticSearch(item)">
60+
<form class="form-floating" novalidate="novalidate" ng-submit="startElasticSearch(savedSearch)">
6161
<fieldset>
6262

6363
<div class="form-group filled">
6464
<label class="control-label">{{ 'QUERY' | translate }}</label>
65-
<input type="text" class="form-control" ng-model="item.query" required>
65+
<input type="text" class="form-control" ng-model="savedSearch.query" required>
6666
</div>
6767

6868
<div class="form-group">

0 commit comments

Comments
 (0)