r1952 - in trunk/wao-web/src/main/webapp: . WEB-INF/content/obsmer
Author: bleny Date: 2014-05-16 17:23:46 +0200 (Fri, 16 May 2014) New Revision: 1952 Url: http://forge.codelutin.com/projects/wao/repository/revisions/1952 Log: fix filter (un)locking Modified: trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/sampling-plan.jsp trunk/wao-web/src/main/webapp/wao.js Modified: trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/sampling-plan.jsp =================================================================== --- trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/sampling-plan.jsp 2014-05-16 14:12:49 UTC (rev 1951) +++ trunk/wao-web/src/main/webapp/WEB-INF/content/obsmer/sampling-plan.jsp 2014-05-16 15:23:46 UTC (rev 1952) @@ -36,7 +36,24 @@ // sampleRowsFilterController.init(); var filterMappings = [ + <s:if test="authenticatedWaoUser.authorizedToViewOtherCompanies"> + { + filterName: 'companyIds', + filterLabel: "<s:text name="wao.ui.entity.Company"/>", + filterValuesField: 'companies', + }, + </s:if> { + filterName: 'programNames', + filterLabel: "<s:text name="wao.ui.field.SampleRow.programName"/>", + filterValuesField: 'programNames', + }, + { + filterName: 'sampleRowCodes', + filterLabel: "<s:text name="wao.ui.field.SampleRow.code"/>", + filterValuesField: 'sampleRowCodes', + }, + { filterName: 'fishingZoneFacadeNames', filterLabel: "<s:text name="wao.ui.field.FishingZone.facadeName"/>", filterValuesField: 'fishingZoneFacadeNames', Modified: trunk/wao-web/src/main/webapp/wao.js =================================================================== --- trunk/wao-web/src/main/webapp/wao.js 2014-05-16 14:12:49 UTC (rev 1951) +++ trunk/wao-web/src/main/webapp/wao.js 2014-05-16 15:23:46 UTC (rev 1952) @@ -217,9 +217,20 @@ this.filterValuesUrl = filterValuesUrl; this.updateOptions = function (oneFilterModel) { - var filter = $.extend({}, self.filter); + +// var filter = $.extend({}, self.filter); +// // on lance la recherche mais on ne prend pas en compte le critère qu'on est en train de modifier comme un filtre +// delete filter[oneFilterModel.filterMapping.filterName]; +// delete filter['filled']; +// +// var data = {}; +// $.each(filter, function (key,value) { +// data['filter.' + key] = value; +// }); + + var filter = WAO.toData($('.filters-form')); // on lance la recherche mais on ne prend pas en compte le critère qu'on est en train de modifier comme un filtre - delete filter[oneFilterModel.filterMapping.filterName]; + delete filter['filter.' + oneFilterModel.filterMapping.filterName]; var successCallback = function (data) { var options = WAO.getNestedPropertyValue(oneFilterModel.filterMapping.filterValuesField, data.filterValues); @@ -346,12 +357,16 @@ var self = this; this.model = oneFilterModel; + this.useSelect2 = true; this.init = function () { var html = '<div class="control-group">' + ' <label class="control-label">' + ' ' + this.model.filterMapping.filterLabel + + ' <button type="button" class="btn btn-link open-button">' + + ' <i class="fa fa-edit"></i>' + + ' </button>' + ' </label>' + ' <div class="controls">' + ' <span class="selected-options-container"></span>' @@ -362,9 +377,6 @@ + ' <i class="fa fa-check"></i>' + ' </button>' + ' </span>' - + ' <button type="button" class="btn btn-link open-button">' - + ' <i class="fa fa-edit"></i>' - + ' </button>' + ' </div>' + '</div>' ; @@ -373,7 +385,6 @@ this.$selectContainer = this.$container.find('.select-container'); this.$select = this.$container.find('select'); - this.$select.select2(); this.$selectedOptionsContainer = this.$container.find('.selected-options-container'); @@ -397,20 +408,50 @@ this.$selectedOptionsContainer.hide(); this.$openButton.hide(); this.$selectContainer.show(); + if (this.useSelect2) { +// this.$select.hide(); + this.$select.select2(); + } }; this.hide = function () { + if (this.useSelect2) { + this.$select.select2('destroy'); + } this.$selectedOptionsContainer.show(); this.$openButton.show(); this.$selectContainer.hide(); }; + this.lockSelection = function () { + if (this.useSelect2) { + //this.$select.select2('destroy'); + this.$select.select2('readonly', true); + } else { + this.$select.attr('readonly', 'readonly'); + } + }; + + this.unlockSelection = function () { + if (this.useSelect2) { + var val = []; + $.each(this.model.selectedOptions, function (index, selectedOption) { + val.push(selectedOption.value); + }); + this.$select.select2('readonly', false); + this.$select.val(val).select2('open'); + } else { + this.$select.removeAttr('readonly'); + } + }; + this.updateOptions = function () { self.$select.empty(); $.each(this.model.options, function (index, option) { var optionHtml = '<option value="' + option.value + '">' + option.label + '</option>'; self.$select.append(optionHtml); }); + this.unlockSelection(); }; this.updateSelectedOptions = function () { @@ -465,6 +506,7 @@ this.open = function () { this.model.updateOptions(); this.view.show(); + this.view.lockSelection(); } this.close = function () {
participants (1)
-
bleny@users.forge.codelutin.com