Author: bleny Date: 2014-05-20 14:14:21 +0200 (Tue, 20 May 2014) New Revision: 1971 Url: http://forge.codelutin.com/projects/wao/repository/revisions/1971 Log: fix filter refreshing selected option after applying filters Modified: trunk/wao-web/src/main/webapp/wao.css trunk/wao-web/src/main/webapp/wao.js Modified: trunk/wao-web/src/main/webapp/wao.css =================================================================== --- trunk/wao-web/src/main/webapp/wao.css 2014-05-19 14:53:37 UTC (rev 1970) +++ trunk/wao-web/src/main/webapp/wao.css 2014-05-20 12:14:21 UTC (rev 1971) @@ -391,6 +391,11 @@ margin-right: 30px; } + .selected-options-container ul { + list-style-type: none; + margin: 0; + } + /** * Les boutons */ Modified: trunk/wao-web/src/main/webapp/wao.js =================================================================== --- trunk/wao-web/src/main/webapp/wao.js 2014-05-19 14:53:37 UTC (rev 1970) +++ trunk/wao-web/src/main/webapp/wao.js 2014-05-20 12:14:21 UTC (rev 1971) @@ -334,11 +334,12 @@ var selectedOptions = []; var filterValues = WAO.getNestedPropertyValue(this.filterMapping.filterName, filter); if (filterValues) { + this.updateOptions(); + // XXX brendan 19/05/14 on a pas encore le label, ce sera mis à jour par le updateOptions $.each(filterValues, function (index, filterValue) { selectedOptions.push({ value: filterValue, - // TODO brendan 16/05/14 get label - label: filterValue, + label: '' }); }); } @@ -409,7 +410,6 @@ this.$openButton.hide(); this.$selectContainer.show(); if (this.useSelect2) { -// this.$select.hide(); this.$select.select2(); } }; @@ -425,7 +425,6 @@ this.lockSelection = function () { if (this.useSelect2) { - //this.$select.select2('destroy'); this.$select.select2('readonly', true); } else { this.$select.attr('readonly', 'readonly'); @@ -434,11 +433,6 @@ this.unlockSelection = function () { if (this.useSelect2) { - var val = []; - $.each(this.model.selectedOptions, function (index, selectedOption) { - val.push(selectedOption.value); - }); - this.$select.val(val).trigger('change'); this.$select.select2('readonly', false); this.$select.select2('open'); } else { @@ -452,6 +446,14 @@ var optionHtml = '<option value="' + option.value + '">' + option.label + '</option>'; self.$select.append(optionHtml); }); + if (this.useSelect2) { + var val = []; + $.each(this.model.selectedOptions, function (index, selectedOption) { + val.push(selectedOption.value); + }); + this.$select.val(val).trigger('change'); + } + this.updateSelectedOptions(); this.unlockSelection(); };