| Línea 208... | Línea 208... | 
          
            | 208 |                 return;
 | 208 |                 return;
 | 
          
            | 209 |             });
 | 209 |             });
 | 
          
            | 210 |         }
 | 210 |         }
 | 
          
            | 211 |     });
 | 211 |     });
 | 
          
            | Línea 212... | Línea 212... | 
          
            | 212 |  
 | 212 |  
 | 
          
            | 213 |     // Initialize sortable list to handle active conditions moving (note JQuery dependency, see MDL-72293 for resolution).
 | 213 |     // Initialize sortable list to handle active conditions moving.
 | 
          
            | 214 |     var activeConditionsSortableList = new SortableList(`${reportSelectors.regions.activeConditions}`,
 | 214 |     const activeConditionsSelector = reportSelectors.regions.activeConditions;
 | 
          
            | 215 |         {isHorizontal: false});
 | 215 |     const activeConditionsSortableList = new SortableList(activeConditionsSelector, {isHorizontal: false});
 | 
          
            | Línea 216... | Línea 216... | 
          
            | 216 |     activeConditionsSortableList.getElementName = element => Promise.resolve(element.data('conditionName'));
 | 216 |     activeConditionsSortableList.getElementName = element => Promise.resolve(element.data('conditionName'));
 | 
          
            | - |   | 217 |  
 | 
          
            | 217 |  
 | 218 |     document.addEventListener(SortableList.EVENTS.elementDrop, event => {
 | 
          
            | 218 |     $(document).on(SortableList.EVENTS.DROP, reportSelectors.regions.activeCondition, (event, info) => {
 | 219 |         const reportOrderCondition = event.target.closest(`${activeConditionsSelector} ${reportSelectors.regions.activeCondition}`);
 | 
          
            | - |   | 220 |         if (reportOrderCondition && event.detail.positionChanged) {
 | 
          
            | 219 |         if (info.positionChanged) {
 | 221 |             const pendingPromise = new Pending('core_reportbuilder/conditions:reorder');
 | 
          
            | 220 |             const pendingPromise = new Pending('core_reportbuilder/conditions:reorder');
 | - |   | 
          
            | 221 |             const reportElement = event.target.closest(reportSelectors.regions.report);
 | 222 |  
 | 
          
            | Línea 222... | Línea 223... | 
          
            | 222 |             const conditionId = info.element.data('conditionId');
 | 223 |             const reportElement = reportOrderCondition.closest(reportSelectors.regions.report);
 | 
          
            | 223 |             const conditionPosition = info.element.data('conditionPosition');
 | 224 |             const {conditionId, conditionPosition, conditionName} = reportOrderCondition.dataset;
 | 
          
            | - |   | 225 |  
 | 
          
            | 224 |  
 | 226 |             // Select target position, if moving to the end then count number of element siblings.
 | 
          
            | 225 |             // Select target position, if moving to the end then count number of element siblings.
 | 227 |             let targetConditionPosition = event.detail.targetNextElement.data('conditionPosition')
 | 
          
            | 226 |             let targetConditionPosition = info.targetNextElement.data('conditionPosition') || info.element.siblings().length + 2;
 | 228 |                 || event.detail.element.siblings().length + 2;
 | 
          
            | Línea 227... | Línea 229... | 
          
            | 227 |             if (targetConditionPosition > conditionPosition) {
 | 229 |             if (targetConditionPosition > conditionPosition) {
 | 
          
            | 228 |                 targetConditionPosition--;
 | 230 |                 targetConditionPosition--;
 | 
          
            | 229 |             }
 | 231 |             }
 | 
          
            | 230 |  
 | 232 |  
 | 
          
            | 231 |             // Re-order condition, giving drop event transition time to finish.
 | 233 |             // Re-order condition, giving drop event transition time to finish.
 | 
          
            | 232 |             const reorderPromise = reorderCondition(reportElement.dataset.reportId, conditionId, targetConditionPosition);
 | 234 |             const reorderPromise = reorderCondition(reportElement.dataset.reportId, conditionId, targetConditionPosition);
 | 
          
            | 233 |             Promise.all([reorderPromise, new Promise(resolve => setTimeout(resolve, 1000))])
 | 235 |             Promise.all([reorderPromise, new Promise(resolve => setTimeout(resolve, 1000))])
 | 
          
            | 234 |                 .then(([data]) => reloadSettingsConditionsRegion(reportElement, data))
 | 236 |                 .then(([data]) => reloadSettingsConditionsRegion(reportElement, data))
 | 
          
            | 235 |                 .then(() => getString('conditionmoved', 'core_reportbuilder', info.element.data('conditionName')))
 | 237 |                 .then(() => getString('conditionmoved', 'core_reportbuilder', conditionName))
 | 
          
            | 236 |                 .then(addToast)
 | 238 |                 .then(addToast)
 |