|
65 | 65 | return dtoArr; |
66 | 66 | } |
67 | 67 |
|
68 | | - self.selectCheckbox = function (element, selectAll) { |
| 68 | + self.selectCheckbox = function (element, selectAll, deselectAll) { |
69 | 69 | var id = $(element).attr('id'); |
70 | 70 | var list = id.indexOf('-') > -1; |
71 | 71 |
|
|
84 | 84 | if (selectAll) { |
85 | 85 | $(element).prop('checked', true); |
86 | 86 | } |
| 87 | + else if (deselectAll) { |
| 88 | + $(element).prop('checked', false); |
| 89 | + } |
87 | 90 | else { |
88 | 91 | $(element).prop('checked', checked); |
89 | 92 | } |
90 | 93 | } |
91 | | - |
92 | | - self.postReportParameters = function () { |
| 94 | + |
| 95 | + self.postReportParameters = function (callback) { |
93 | 96 | var dtoArr = constructReportParameters(); |
94 | 97 | var dto = { |
95 | 98 | Parameters: dtoArr |
|
105 | 108 |
|
106 | 109 | let paramLists = $('.report-viewer .reportparam-list'); |
107 | 110 |
|
108 | | - $('.report-viewer .reportparameters-container').on("click", function (e) { |
109 | | - let load = false; |
| 111 | + if (callback) { |
| 112 | + callback(); |
| 113 | + } |
110 | 114 |
|
| 115 | + $('.report-viewer .reportparameters-container').on("click", function (e) { |
111 | 116 | if (e.target !== e.currentTarget) { |
112 | 117 | return; |
113 | 118 | } |
114 | 119 |
|
115 | | - $.each(paramLists, function (idx, list) { |
116 | | - let dropdownContainers = $(list).find('.reportparam-list-dropdown[class*="open"]'); |
117 | | - |
118 | | - $.each(dropdownContainers, function (idx, ele) { |
119 | | - if (!list.contains(e.target)) { |
120 | | - $(ele).removeClass('open'); |
121 | | - $(ele).css('display', 'none'); |
122 | | - load = true; |
123 | | - } |
124 | | - }); |
125 | | - }); |
126 | | - |
127 | | - if (load || paramLists.length === 0) { |
128 | | - self.postReportParameters(); |
129 | | - } |
| 120 | + self.processUserAction(); |
130 | 121 | }); |
131 | 122 |
|
132 | | - $('.report-viewer .reportparam-list-select .over-select').on("click", function () { |
133 | | - let dropdownContainer = $(this).closest('.reportparam-list').find('.reportparam-list-dropdown'); |
| 123 | + $('.report-viewer .reportparam-list-select .over-select').on("click", function (e) { |
| 124 | + e.preventDefault(); |
| 125 | + |
| 126 | + self.processUserAction(function () { |
| 127 | + let currentTarget = e.currentTarget; |
| 128 | + let dropdownContainer = $(currentTarget).closest('.reportparam-list').find('.reportparam-list-dropdown'); |
| 129 | + let dropdownOptions = $(dropdownContainer).find('.custom-checkbox'); |
134 | 130 |
|
135 | | - if (!$(dropdownContainer).is(':empty')) { |
136 | | - if ($(dropdownContainer).css('display') === 'none') { |
| 131 | + if ($(dropdownContainer).css('display') === 'none' && dropdownOptions.length > 0) { |
137 | 132 | $(dropdownContainer).addClass('open'); |
138 | 133 | $(dropdownContainer).css('display', 'block'); |
139 | 134 | } |
140 | | - else { |
141 | | - $(dropdownContainer).removeClass('open'); |
142 | | - $(dropdownContainer).css('display', 'none'); |
143 | | - } |
144 | | - } |
| 135 | + }); |
145 | 136 | }); |
146 | 137 |
|
147 | 138 | $('.report-viewer .reportparam-list-dropdown .reportparam-list-selectall').on("click", function () { |
148 | 139 | let dropdownContainer = $(this).closest('.reportparam-list').find('.reportparam-list-dropdown'); |
149 | 140 | let checkboxes = $(dropdownContainer).find('input[type="checkbox"]'); |
150 | 141 |
|
151 | 142 | $.each(checkboxes, function (idx, ele) { |
152 | | - self.selectCheckbox($(ele), true); |
| 143 | + self.selectCheckbox($(ele), true, false); |
| 144 | + }); |
| 145 | + }); |
| 146 | + |
| 147 | + $('.report-viewer .reportparam-list-dropdown .reportparam-list-deselectall').on("click", function () { |
| 148 | + let dropdownContainer = $(this).closest('.reportparam-list').find('.reportparam-list-dropdown'); |
| 149 | + let checkboxes = $(dropdownContainer).find('input[type="checkbox"]'); |
| 150 | + |
| 151 | + $.each(checkboxes, function (idx, ele) { |
| 152 | + self.selectCheckbox($(ele), false, true); |
153 | 153 | }); |
154 | 154 | }); |
155 | 155 |
|
|
159 | 159 | } |
160 | 160 | }); |
161 | 161 |
|
| 162 | + $('.report-viewer input[type="text"]').on("focus", function (event) { |
| 163 | + self.processUserAction(); |
| 164 | + }); |
| 165 | + |
162 | 166 | $('.report-viewer input[type="checkbox"]').on("change", function (event) { |
163 | | - self.selectCheckbox($(this), false); |
| 167 | + self.selectCheckbox($(this), false, false); |
164 | 168 | }); |
165 | 169 |
|
166 | 170 | $('.report-viewer #RunReportBtn').on('click', function () { |
|
171 | 175 | }); |
172 | 176 | } |
173 | 177 |
|
| 178 | + self.processUserAction = function (callback) { |
| 179 | + let paramLists = $('.report-viewer .reportparam-list'); |
| 180 | + let load = false; |
| 181 | + |
| 182 | + $.each(paramLists, function (idx, list) { |
| 183 | + let dropdownContainers = $(list).find('.reportparam-list-dropdown[class*="open"]'); |
| 184 | + |
| 185 | + $.each(dropdownContainers, function (idx, ele) { |
| 186 | + $(ele).removeClass('open'); |
| 187 | + $(ele).css('display', 'none'); |
| 188 | + load = true; |
| 189 | + }); |
| 190 | + }); |
| 191 | + |
| 192 | + if (load || paramLists.length === 0) { |
| 193 | + self.postReportParameters(callback); |
| 194 | + } else if (callback) { |
| 195 | + callback(); |
| 196 | + } |
| 197 | + }; |
| 198 | + |
174 | 199 | self.renderReport = function() { |
175 | 200 | var dtoArr = constructReportParameters(); |
176 | 201 | var dto = { |
|
0 commit comments