Skip to content

Commit

Permalink
Permet de filtrer les organismes avec le nom
Browse files Browse the repository at this point in the history
Issue: #199894
Change-Id: I989b1afe0c20da71b0e1f0e4f3db99d6a53b25a6
  • Loading branch information
Emilie Genton committed Dec 18, 2023
1 parent 2ae6d97 commit 34a3282
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ protected Predicate processFilterItem(
if ("id".equals(itemFilter.getFieldName())) {
Expression<String> cpPath = from.get("id");
predicat = cBuilder.equal(cpPath, itemFilter.getValue());
} else if ("query".equals(itemFilter.getFieldName())) {
} else if ("query".equals(itemFilter.getFieldName())
|| "nom".equals(itemFilter.getFieldName())) {
Expression<String> cpPath = from.get("nom");
predicat =
cBuilder.like(cBuilder.upper(cpPath), "%" + itemFilter.getValue().toUpperCase() + "%");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import fr.sdis83.remocra.repository.ContactRepository;
import fr.sdis83.remocra.service.OrganismeService;
import fr.sdis83.remocra.util.ExceptionUtils;
import fr.sdis83.remocra.web.message.ItemFilter;
import fr.sdis83.remocra.web.message.ItemSorting;
import fr.sdis83.remocra.web.serialize.ext.AbstractExtListSerializer;
import fr.sdis83.remocra.web.serialize.ext.AbstractExtObjectSerializer;
import fr.sdis83.remocra.web.serialize.ext.SuccessErrorExtSerializer;
Expand Down Expand Up @@ -41,11 +43,31 @@ protected OrganismeService getService() {
return service;
}

@Override
protected JSONSerializer additionnalIncludeExclude(JSONSerializer serializer) {
return serializer
.include("data.organismeParent.id", "data.organismeParent.code", "data.organismeParent.nom")
.exclude("data.zoneCompetence.geometrie", "data.organismeParent.*");
@RequestMapping(value = "", method = RequestMethod.GET, headers = "Accept=application/json")
@PreAuthorize("isAuthenticated()")
public ResponseEntity<java.lang.String> listJson(
@RequestParam(value = "page", required = false) Integer page,
final @RequestParam(value = "start", required = false) Integer start,
final @RequestParam(value = "limit", required = false) Integer limit,
@RequestParam(value = "sort", required = false) String sorts,
@RequestParam(value = "filter", required = false) String filters) {
final List<ItemSorting> sortList = ItemSorting.decodeJson(sorts);
final List<ItemFilter> itemFilterList = ItemFilter.decodeJson(filters);
return new AbstractExtListSerializer<Organisme>("Organisme retrieved.") {

@Override
protected JSONSerializer additionnalIncludeExclude(JSONSerializer serializer) {
return serializer
.include(
"data.organismeParent.id", "data.organismeParent.code", "data.organismeParent.nom")
.exclude("data.zoneCompetence.geometrie", "data.organismeParent.*", "");
}

@Override
protected List<Organisme> getRecords() {
return getService().find(start, limit, sortList, itemFilterList);
}
}.serialize();
}

@RequestMapping(value = "", method = RequestMethod.POST, headers = "Accept=application/json")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,37 @@ Ext.define('Sdis.Remocra.features.admin.typereference.OrganismeGrid', {
uniqueConstraints: ['code'],
modelType: 'Sdis.Remocra.model.Organisme',
store: null, // créé à la construction
plugins: [
Sdis.Remocra.widget.WidgetFactory.createRoweditingPluginCfg(false),
Ext.create('Ext.ux.grid.plugin.HeaderFilters')
],

constructor: function(config) {
config = config || {};
var deferredApplyFilter = Ext.Function.createBuffered(function() {
this.headerFilterPlugin.applyFilters();
}, 600, this);

// Ajout des définitions des colonnes si elles ne sont pas déjà définies
var typeRefGridCols = Sdis.Remocra.features.admin.typereference.TypeReferenceGrid.columns;
Ext.applyIf(config, {
columns: [
typeRefGridCols.code,
typeRefGridCols.nom,
{
header : 'Nom',
dataIndex : 'nom',
menuDisabled : true,
flex: 5,
filterable: true,
filter: {
xtype: 'textfield',
hideTrigger: true,
listeners: {
change: deferredApplyFilter
}
},
editor: {xtype: 'textfield'}
},
this.statics().columns.emailContact,
{
header: 'Type Organisme',
Expand Down
4 changes: 2 additions & 2 deletions remocra/src/main/webapp/js/app/remocra/store/Organisme.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ Ext.define('Sdis.Remocra.store.Organisme', {
remoteFilter: true,
pageSize: 20,

autoLoad : false,
autoSync: false
autoLoad : true,
autoSync: true
});

0 comments on commit 34a3282

Please sign in to comment.