Skip to content

Commit

Permalink
Merge pull request #21 from OnroerendErfgoed/develop
Browse files Browse the repository at this point in the history
release 1.1.1
  • Loading branch information
cedrikv authored Mar 4, 2021
2 parents 04d6b07 + f8f4759 commit 0b989b1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 59 deletions.
78 changes: 21 additions & 57 deletions CrabZoomer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@ define([
'dojo/promise/all',
'dojo/dom-attr',
'dojo/dom-construct',
'dojo/store/Memory',
'dijit/_WidgetBase',
'dijit/_TemplatedMixin',
'dijit/_WidgetsInTemplateMixin',
'dijit/form/ComboBox',
'./utils/DomUtils'
], function (
declare,
Expand All @@ -20,14 +17,11 @@ define([
all,
domAttr,
domConstruct,
Memory,
_WidgetBase,
_TemplatedMixin,
_WidgetsInTemplateMixin,
ComboBox,
domUtils
) {
return declare([_WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin], {
return declare([_WidgetBase, _TemplatedMixin], {

templateString: '' +
'<div data-dojo-attach-point="containerNode" class="widget-pane">' +
Expand Down Expand Up @@ -67,12 +61,10 @@ define([
disabled: false,
baseUrl: null,
alleGewesten: null,
_nummerFilteringSelect: null,

postCreate: function () {
// console.debug('CrabZoomer::postCreate', this.alleGewesten);
this.inherited(arguments);
this._createNumberSelect();
},

startup: function () {
Expand Down Expand Up @@ -115,7 +107,7 @@ define([
domAttr.remove(this.provinceSelect, 'disabled');
domAttr.remove(this.municipalitySelect, 'disabled');
domAttr.remove(this.streetSelect, 'disabled');
this._nummerFilteringSelect.set('disabled', false);
domAttr.remove(this.numberSelect, 'disabled');
},

disable: function () {
Expand All @@ -127,20 +119,7 @@ define([
domAttr.set(this.provinceSelect, 'disabled', true);
domAttr.set(this.municipalitySelect, 'disabled', true);
domAttr.set(this.streetSelect, 'disabled', true);
this._nummerFilteringSelect.set('disabled', true);
},

_createNumberSelect: function() {
this._nummerFilteringSelect = new ComboBox({
store: new Memory(),
hasDownArrow: true,
placeHolder: 'Kies een huisnummer',
searchAttr: 'label',
autoComplete: false,
required: false,
disabled: true,
'class': 'placeholder-input'
}, this.numberSelect);
domAttr.set(this.numberSelect, 'disabled', true);
},

_gewestChange: function () {
Expand Down Expand Up @@ -283,18 +262,19 @@ define([
}
domAttr.remove(this.municipalitySelect, 'disabled');
domAttr.remove(this.streetSelect, 'disabled');
this._nummerFilteringSelect.set('disabled', false);
domAttr.remove(this.numberSelect, 'disabled');

var location = this.value;
if (location && location.housenumber && location.street && location.street.id === value) {
this._setNumber(location.housenumber);
this._setNumber(location.housenumber.id);
}
})
);
},

_numberChange: function () {
//console.debug('CrabZoomer::_numberChange');
var value = domUtils.getSelectedOption(this.numberSelect);
//console.debug('CrabZoomer::_numberChange', value);
},

_errorHandler: function (e){
Expand All @@ -316,7 +296,7 @@ define([
domAttr.remove(this.provinceSelect, 'disabled');
domAttr.remove(this.municipalitySelect, 'disabled');
domAttr.set(this.streetSelect, 'disabled', true);
this._nummerFilteringSelect.set('disabled', true);
domAttr.set(this.numberSelect, 'disabled', true);
},

_getValueAttr: function () {
Expand All @@ -335,15 +315,8 @@ define([
address.street = this._getSelectValueAsObect(this.streetSelect);
}

var houseNumberObj = this._nummerFilteringSelect.item;
if (houseNumberObj) {
address.housenumber = {
id: houseNumberObj.id,
name: houseNumberObj.label
};
}
else if (this._nummerFilteringSelect.get('value')) {
address.housenumber = {name: this._nummerFilteringSelect.get('value')};
if (domUtils.getSelectedOption(this.numberSelect)) {
address.housenumber = this._getSelectValueAsObect(this.numberSelect);
}

return address;
Expand Down Expand Up @@ -376,7 +349,7 @@ define([
//console.debug('CrabZoomer::getBbox');
var bbox = null;
var url = null;
var number = this._nummerFilteringSelect.item ? this._nummerFilteringSelect.item.id : null;
var number = domUtils.getSelectedOption(this.numberSelect);
var street = domUtils.getSelectedOption(this.streetSelect);
var municipality = domUtils.getSelectedOption(this.municipalitySelect);

Expand Down Expand Up @@ -449,12 +422,14 @@ define([
domUtils.setSelectedOptions(this.streetSelect, ['']);
},

_fillNumberSelect: function (nummers) {
// console.debug('CrabZoomer::_fillNumberSelect', nummers);
if (nummers) {
this._nummerFilteringSelect.set('store', new Memory({data: nummers}));
}
this._nummerFilteringSelect.reset();
_fillNumberSelect: function (data) {
//console.debug('CrabZoomer::_fillNumberSelect', data);
domUtils.addSelectOptions(this.numberSelect, {
data: data,
idProperty: 'id',
labelProperty: 'label',
placeholder: 'Kies een huisnummer'
});
},

_setRegion: function (value) {
Expand Down Expand Up @@ -482,19 +457,8 @@ define([
},

_setNumber: function (value) {
// console.debug('CrabZoomer::_setNumber', value);
if (!value) {
this._nummerFilteringSelect.reset();
return;
}

if (value.id) {
var huisnummerObj = this._nummerFilteringSelect.store.get(value.id);
this._nummerFilteringSelect.set('item', huisnummerObj);
}
else if (value.name) {
this._nummerFilteringSelect.set('value', value.name);
}
//console.debug('CrabZoomer::_setNumber', value);
domUtils.setSelectedOptions(this.numberSelect, [value]);
this._numberChange();
},

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "crabpy_dojo",
"description": "A lightweight widget designed for crabpy_pyramid",
"keywords": ["JavaScript", "Dojo", "Widget", "crabpy"],
"version": "1.1.0",
"version": "1.1.1",
"repository": {
"type":"git",
"url":"https://github.com/OnroerendErfgoed/crabpy_dojo"
Expand Down
1 change: 0 additions & 1 deletion tests/widget/test_CrabpyWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ require([
label: "Set value",
onClick: function(){
crabZoomer.set('value', {"province":{"id":"10000","name":"Antwerpen"},"municipality":{"id":"44","name":"Arendonk"},"street":{"id":"12417","name":"Aartrijtstraat"},"housenumber":{"id":"537126","name":"6"}});
// crabZoomer.set('value', {"province":{"id":"10000","name":"Antwerpen"},"municipality":{"id":"44","name":"Arendonk"},"street":{"id":"12417","name":"Aartrijtstraat"},"housenumber":{"name":"66666"}});
// crabZoomer.set('value', {"municipality":{"id":"44","name":"Arendonk"},"street":{"id":"12417","name":"Aartrijtstraat"},"housenumber":{"id":"537126","name":"6"}});
// crabZoomer.set('value', {"province":{"id":"10000","name":"Antwerpen"}});
}
Expand Down

0 comments on commit 0b989b1

Please sign in to comment.