Merge pull request '2325 - Search address' (#308) from 2325-address_searchbar into dev
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
Reviewed-by: Bernat Exposito <bernat@verdnatura.es>
This commit is contained in:
commit
e335775cdb
|
@ -1,7 +1,7 @@
|
|||
<form ng-submit="$ctrl.onSubmit()">
|
||||
<vn-textfield
|
||||
class="dense standout"
|
||||
placeholder="{{::'Search by' | translate: {module: $ctrl.baseState} }}"
|
||||
placeholder="{{::$ctrl.placeholder | translate}}"
|
||||
ng-model="$ctrl.searchString">
|
||||
<prepend>
|
||||
<vn-icon
|
||||
|
|
|
@ -21,6 +21,7 @@ export default class Searchbar extends Component {
|
|||
constructor($element, $) {
|
||||
super($element, $);
|
||||
this.searchState = '.';
|
||||
this.placeholder = 'Search';
|
||||
this.autoState = true;
|
||||
|
||||
this.deregisterCallback = this.$transitions.onSuccess(
|
||||
|
@ -35,6 +36,9 @@ export default class Searchbar extends Component {
|
|||
}
|
||||
|
||||
this.searchState = `${this.baseState}.index`;
|
||||
this.placeholder = this.$translate.instant('Search by', {
|
||||
module: this.baseState
|
||||
});
|
||||
}
|
||||
|
||||
this.fetchStateFilter(this.autoLoad);
|
||||
|
@ -293,7 +297,8 @@ ngModule.vnComponent('vnSearchbar', {
|
|||
stateParams: '&?',
|
||||
model: '<?',
|
||||
exprBuilder: '&?',
|
||||
fetchParams: '&?'
|
||||
fetchParams: '&?',
|
||||
placeholder: '@?'
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -6,6 +6,15 @@
|
|||
data="$ctrl.addresses"
|
||||
auto-load="true">
|
||||
</vn-crud-model>
|
||||
<vn-portal slot="topbar">
|
||||
<vn-searchbar
|
||||
placeholder="Search by address"
|
||||
info="You can search by address id or name"
|
||||
model="model"
|
||||
expr-builder="$ctrl.exprBuilder(param, value)"
|
||||
auto-state="false">
|
||||
</vn-searchbar>
|
||||
</vn-portal>
|
||||
<vn-data-viewer
|
||||
model="model"
|
||||
class="vn-w-md">
|
||||
|
@ -35,7 +44,7 @@
|
|||
</vn-none>
|
||||
<vn-one
|
||||
style="overflow: hidden; min-width: 14em;">
|
||||
<div class="ellipsize"><b>{{::address.nickname}}</b></div>
|
||||
<div class="ellipsize"><b>{{::address.nickname}} - #{{::address.id}}</b></div>
|
||||
<div class="ellipsize" name="street">{{::address.street}}</div>
|
||||
<div class="ellipsize">{{::address.city}}, {{::address.province.name}}</div>
|
||||
<div class="ellipsize">
|
||||
|
|
|
@ -68,6 +68,15 @@ class Controller extends Section {
|
|||
return this.isDefaultAddress(b) - this.isDefaultAddress(a);
|
||||
});
|
||||
}
|
||||
|
||||
exprBuilder(param, value) {
|
||||
switch (param) {
|
||||
case 'search':
|
||||
return /^\d+$/.test(value)
|
||||
? {id: value}
|
||||
: {nickname: {like: `%${value}%`}};
|
||||
}
|
||||
}
|
||||
}
|
||||
Controller.$inject = ['$element', '$scope'];
|
||||
|
||||
|
|
|
@ -67,5 +67,19 @@ describe('Client', () => {
|
|||
expect(controller.addresses[0].id).toEqual(123);
|
||||
});
|
||||
});
|
||||
|
||||
describe('exprBuilder()', () => {
|
||||
it('should return a filter based on a search by id', () => {
|
||||
const filter = controller.exprBuilder('search', '123');
|
||||
|
||||
expect(filter).toEqual({id: '123'});
|
||||
});
|
||||
|
||||
it('should return a filter based on a search by name', () => {
|
||||
const filter = controller.exprBuilder('search', 'Bruce Wayne');
|
||||
|
||||
expect(filter).toEqual({nickname: {like: '%Bruce Wayne%'}});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
# Index
|
||||
Set as default: Establecer como predeterminado
|
||||
Active first to set as default: Active primero para marcar como predeterminado
|
||||
Search by address: Buscar por consignatario
|
||||
You can search by address id or name: Puedes buscar por el id o nombre del consignatario
|
||||
# Edit
|
||||
Enabled: Activo
|
||||
Is equalizated: Recargo de equivalencia
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
</vn-crud-model>
|
||||
<vn-portal slot="topbar">
|
||||
<vn-searchbar
|
||||
placeholder="Search by weekly ticket"
|
||||
info="Search weekly ticket by id or client id"
|
||||
auto-state="false"
|
||||
model="model">
|
||||
|
|
|
@ -3,3 +3,4 @@ Weekly tickets: Tickets programados
|
|||
You are going to delete this weekly ticket: Vas a eliminar este ticket programado
|
||||
This ticket will be removed from weekly tickets! Continue anyway?: Este ticket se eliminará de tickets programados! ¿Continuar de todas formas?
|
||||
Search weekly ticket by id or client id: Busca tickets programados por el identificador o el identificador del cliente
|
||||
Search by weekly ticket: Buscar por tickets programados
|
Loading…
Reference in New Issue