Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search omschrijving 93 #94

Merged
merged 3 commits into from
Apr 26, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions test/widget/test_ActorWidget.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
require([
'actorwidget/widgets/ActorWidget',
'dojo/store/Observable',
'actorwidget/test/util/JsonRestCors',
'dojo/store/JsonRest',
'dojo/domReady!'
], function (
ActorWidget,
Observable,
JsonRestCors
JsonRest
) {
//var baseUrl= "http://localhost:6565/";
var baseUrl= "https://dev-actoren.onroerenderfgoed.be";
var ssoToken = 'AQIC5wM2LY4SfcxBiA0_fpFhmsmyCzZ5fa2CXq8TmNS-3ow.*AAJTSQACMDIAAlNLABEyNjUwMjMxNjk0MjkyNDM2OQACUzEAAjAx*';
var ssoToken = 'AQIC5wM2LY4SfczcF5xbKlqhnzOrPre7au1326YcUxOUZ1o.*AAJTSQACMDIAAlNLABMyODczNTM0ODU4ODYwMTUyNDMwAAJTMQACMDM.*';

var actorWijStore = new Observable(new JsonRestCors({
var actorWijStore = new Observable(new JsonRest({
target: baseUrl + '/actoren/wij/',
sortParam: 'sort',
idProperty: 'id',
Expand All @@ -23,7 +23,7 @@ require([
}
}));

var actorStore = new Observable(new JsonRestCors({
var actorStore = new Observable(new JsonRest({
target: baseUrl + '/actoren/',
sortParam: 'sort',
idProperty: 'id',
Expand Down
47 changes: 28 additions & 19 deletions views/ActorSearchView.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,22 @@ define([
Selection,
StoreAdapter
) {

var delay = (function(){
var timer = 0;
return function(callback, ms){
clearTimeout (timer);
timer = setTimeout(callback, ms);
};
})();

return declare([_WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin], {

templateString: template,
baseClass: 'actor-widget',
widgetsInTemplate: true,
actorStore: null,
baseUrl: null,
_previousSearchValue:'',
actorWidget: null,
actorController: null,
_store: 'all',
Expand Down Expand Up @@ -214,29 +222,29 @@ define([
*/
_filterGrid: function (evt) {
evt.preventDefault();
this.removeSort();

var newValue = evt.target.value;
if (this._timeoutId) {
clearTimeout(this._timeoutId);
this._timeoutId = null;
}
this._timeoutId = setTimeout(lang.hitch(this, function () {
if (newValue != this._previousSearchValue) {
this._previousSearchValue = newValue;
if (newValue === '') {
this._grid.set("collection", new StoreAdapter({objectStore: this.actorController.actorStore}));
}
else {
this._grid.set("collection", new StoreAdapter({objectStore: this.actorController.actorStore}).filter({"naam": newValue}));
}
var newValue = evt.target.value;
var scope = this;
delay(function() {
scope.removeSort();
if (newValue === '') {
scope._grid.set({
collection: new StoreAdapter({objectStore: scope.actorController.actorStore})
});
}
else {
scope._grid.set({
collection: new StoreAdapter({objectStore: scope.actorController.actorStore}).filter({'omschrijving': newValue})
});
}
}, 300));
}, 250 );


},

/**
* Het grid zal actoren filteren worden op meegegeven query
* @param {object} query bv {naam: 'testpersoon'}
* @param {object} filter bv {omschrijving: 'testpersoon'}
*/
advSearchFilterGrid: function(filter) {
this.removeSort();
Expand All @@ -255,7 +263,8 @@ define([
* Functie om sort parameter te verwijderen bij grid, belangrijk bij zoeken in elastic search
*/
removeSort: function() {
this._grid.set('sort', "");
this._grid.set('collection', '');
this._grid.set('sort', '');
},

/**
Expand Down