{"version":3,"file":"dndsectionitem.min.js","sources":["https:\/\/www.alsg.org\/home\/course\/format\/amd\/src\/local\/courseeditor\/dndsectionitem.js"],"sourcesContent":["\/\/ This file is part of Moodle - http:\/\/moodle.org\/\n\/\/\n\/\/ Moodle is free software: you can redistribute it and\/or modify\n\/\/ it under the terms of the GNU General Public License as published by\n\/\/ the Free Software Foundation, either version 3 of the License, or\n\/\/ (at your option) any later version.\n\/\/\n\/\/ Moodle is distributed in the hope that it will be useful,\n\/\/ but WITHOUT ANY WARRANTY; without even the implied warranty of\n\/\/ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\/\/ GNU General Public License for more details.\n\/\/\n\/\/ You should have received a copy of the GNU General Public License\n\/\/ along with Moodle. If not, see .\n\n\/**\n * Course index section title draggable component.\n *\n * This component is used to control specific course section interactions like drag and drop\n * in both course index and course content.\n *\n * @module core_courseformat\/local\/courseeditor\/dndsectionitem\n * @class core_courseformat\/local\/courseeditor\/dndsectionitem\n * @copyright 2021 Ferran Recio \n * @license http:\/\/www.gnu.org\/copyleft\/gpl.html GNU GPL v3 or later\n *\/\n\nimport {BaseComponent, DragDrop} from 'core\/reactive';\n\nexport default class extends BaseComponent {\n\n \/**\n * Initial state ready method.\n *\n * @param {number} sectionid the section id\n * @param {Object} state the initial state\n * @param {Element} fullregion the complete section region to mark as dragged\n *\/\n configDragDrop(sectionid, state, fullregion) {\n\n this.id = sectionid;\n if (this.section === undefined) {\n this.section = state.section.get(this.id);\n }\n if (this.course === undefined) {\n this.course = state.course;\n }\n\n \/\/ Prevent topic zero from being draggable.\n if (this.section.number > 0) {\n this.getDraggableData = this._getDraggableData;\n }\n\n this.fullregion = fullregion;\n\n \/\/ Drag and drop is only available for components compatible course formats.\n if (this.reactive.isEditing && this.reactive.supportComponents) {\n \/\/ Init the dropzone.\n this.dragdrop = new DragDrop(this);\n \/\/ Save dropzone classes.\n this.classes = this.dragdrop.getClasses();\n }\n }\n\n \/**\n * Remove all subcomponents dependencies.\n *\/\n destroy() {\n if (this.dragdrop !== undefined) {\n this.dragdrop.unregister();\n }\n }\n\n \/\/ Drag and drop methods.\n\n \/**\n * The element drop start hook.\n *\n * @param {Object} dropdata the dropdata\n *\/\n dragStart(dropdata) {\n this.reactive.dispatch('sectionDrag', [dropdata.id], true);\n }\n\n \/**\n * The element end start hook.\n *\n * @param {Object} dropdata the dropdata\n *\/\n dragEnd(dropdata) {\n this.reactive.dispatch('sectionDrag', [dropdata.id], false);\n }\n\n \/**\n * Get the draggable data of this component.\n *\n * @returns {Object} exported course module drop data\n *\/\n _getDraggableData() {\n const exporter = this.reactive.getExporter();\n return exporter.sectionDraggableData(this.reactive.state, this.id);\n }\n\n \/**\n * Validate if the drop data can be dropped over the component.\n *\n * @param {Object} dropdata the exported drop data.\n * @returns {boolean}\n *\/\n validateDropData(dropdata) {\n \/\/ Course module validation.\n if (dropdata?.type === 'cm') {\n \/\/ The first section element is already there so we can ignore it.\n const firstcmid = this.section?.cmlist[0];\n return dropdata.id !== firstcmid;\n }\n return false;\n }\n\n \/**\n * Display the component dropzone.\n *\/\n showDropZone() {\n this.element.classList.add(this.classes.DROPZONE);\n }\n\n \/**\n * Hide the component dropzone.\n *\/\n hideDropZone() {\n this.element.classList.remove(this.classes.DROPZONE);\n }\n\n \/**\n * Drop event handler.\n *\n * @param {Object} dropdata the accepted drop data\n *\/\n drop(dropdata) {\n \/\/ Call the move mutation.\n if (dropdata.type == 'cm') {\n this.reactive.dispatch('cmMove', [dropdata.id], this.id, this.section?.cmlist[0]);\n }\n }\n}\n"],"names":["BaseComponent","configDragDrop","sectionid","state","fullregion","id","undefined","this","section","get","course","number","getDraggableData","_getDraggableData","reactive","isEditing","supportComponents","dragdrop","DragDrop","classes","getClasses","destroy","unregister","dragStart","dropdata","dispatch","dragEnd","getExporter","sectionDraggableData","validateDropData","type","firstcmid","_this$section","cmlist","showDropZone","element","classList","add","DROPZONE","hideDropZone","remove","drop","_this$section2"],"mappings":";;;;;;;;;;;;uBA6B6BA,wBASzBC,eAAeC,UAAWC,MAAOC,iBAExBC,GAAKH,eACWI,IAAjBC,KAAKC,eACAA,QAAUL,MAAMK,QAAQC,IAAIF,KAAKF,UAEtBC,IAAhBC,KAAKG,cACAA,OAASP,MAAMO,QAIpBH,KAAKC,QAAQG,OAAS,SACjBC,iBAAmBL,KAAKM,wBAG5BT,WAAaA,WAGdG,KAAKO,SAASC,WAAaR,KAAKO,SAASE,yBAEpCC,SAAW,IAAIC,mBAASX,WAExBY,QAAUZ,KAAKU,SAASG,cAOrCC,eAC0Bf,IAAlBC,KAAKU,eACAA,SAASK,aAWtBC,UAAUC,eACDV,SAASW,SAAS,cAAe,CAACD,SAASnB,KAAK,GAQzDqB,QAAQF,eACCV,SAASW,SAAS,cAAe,CAACD,SAASnB,KAAK,GAQzDQ,2BACqBN,KAAKO,SAASa,cACfC,qBAAqBrB,KAAKO,SAASX,MAAOI,KAAKF,IASnEwB,iBAAiBL,aAEU,QAAnBA,MAAAA,gBAAAA,SAAUM,MAAe,yBAEnBC,gCAAYxB,KAAKC,wCAALwB,cAAcC,OAAO,UAChCT,SAASnB,KAAO0B,iBAEpB,EAMXG,oBACSC,QAAQC,UAAUC,IAAI9B,KAAKY,QAAQmB,UAM5CC,oBACSJ,QAAQC,UAAUI,OAAOjC,KAAKY,QAAQmB,UAQ\/CG,KAAKjB,6BAEoB,MAAjBA,SAASM,WACJhB,SAASW,SAAS,SAAU,CAACD,SAASnB,IAAKE,KAAKF,0BAAIE,KAAKC,yCAALkC,eAAcT,OAAO"}