From afa87040a31299cdc99a953046d9101de664cd98 Mon Sep 17 00:00:00 2001 From: Stefan Hanauska Date: Wed, 21 Feb 2024 15:34:01 +0100 Subject: [PATCH] Fix --- amd/build/column.min.js | 2 +- amd/build/column.min.js.map | 2 +- amd/src/column.js | 4 +++- lib.php | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/amd/build/column.min.js b/amd/build/column.min.js index 21f96fc8..d8621b68 100644 --- a/amd/build/column.min.js +++ b/amd/build/column.min.js @@ -1,3 +1,3 @@ -define("mod_kanban/column",["exports","core/reactive","mod_kanban/selectors","mod_kanban/capabilities","mod_kanban/exporter","core/notification","core/str","core_form/modalform","mod_kanban/kanbancomponent","core/log"],(function(_exports,_reactive,_selectors,_capabilities,_exporter,_notification,Str,_modalform,_kanbancomponent,_log){function _getRequireWildcardCache(nodeInterop){if("function"!=typeof WeakMap)return null;var cacheBabelInterop=new WeakMap,cacheNodeInterop=new WeakMap;return(_getRequireWildcardCache=function(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop})(nodeInterop)}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_selectors=_interopRequireDefault(_selectors),_capabilities=_interopRequireDefault(_capabilities),_exporter=_interopRequireDefault(_exporter),Str=function(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule)return obj;if(null===obj||"object"!=typeof obj&&"function"!=typeof obj)return{default:obj};var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj))return cache.get(obj);var newObj={},hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj)if("default"!==key&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;desc&&(desc.get||desc.set)?Object.defineProperty(newObj,key,desc):newObj[key]=obj[key]}newObj.default=obj,cache&&cache.set(obj,newObj);return newObj}(Str),_modalform=_interopRequireDefault(_modalform),_kanbancomponent=_interopRequireDefault(_kanbancomponent),_log=_interopRequireDefault(_log);class _default extends _kanbancomponent.default{static init(target){return new this({element:document.getElementById(target)})}create(){this.id=this.element.dataset.id}getWatchers(){return[{watch:"columns[".concat(this.id,"]:updated"),handler:this._columnUpdated},{watch:"columns[".concat(this.id,"]:deleted"),handler:this._columnDeleted},{watch:"cards:created",handler:this._cardCreated}]}stateReady(state){this.addEventListener(this.getElement(_selectors.default.DELETECOLUMN,this.id),"click",this._removeConfirm),this.addEventListener(this.getElement(_selectors.default.ADDCARDFIRST),"click",this._addCard),this.addEventListener(this.getElement(_selectors.default.ADDCOLUMN,this.id),"click",this._addColumn),this.addEventListener(this.getElement(_selectors.default.LOCKCOLUMN,this.id),"click",this._lockColumn),this.addEventListener(this.getElement(_selectors.default.UNLOCKCOLUMN,this.id),"click",this._unlockColumn),this.addEventListener(this.getElement(_selectors.default.EDITDETAILS,this.id),"click",this._editDetails),this.addEventListener(this.getElement(_selectors.default.SHOWHIDDEN),"click",this._showHidden),this.addEventListener(this.getElement(_selectors.default.HIDEHIDDEN),"click",this._hideHidden),this.draggable=!1,this.dragdrop=new _reactive.DragDrop(this),this.checkDragging(state),this.boardid=state.board.id,this.cmid=state.common.id}_removeConfirm(event){Str.get_strings([{key:"deletecolumn",component:"mod_kanban"},{key:"deletecolumnconfirm",component:"mod_kanban"},{key:"delete",component:"core"}]).then((strings=>(0,_notification.saveCancel)(strings[0],strings[1],strings[2],(()=>{this._removeColumn(event)})))).catch((error=>_log.default.debug(error)))}destroy(){void 0!==this.dragdrop&&this.dragdrop.unregister()}getDraggableData(){return{id:this.id,type:"column"}}checkDragging(state){void 0===state&&(state=this.reactive.stateManager.state),state.capabilities.get(_capabilities.default.MANAGECOLUMNS).value&&0==state.columns.get(this.id).locked?this.dragdrop.setDraggable(!0):this.dragdrop.setDraggable(!1)}validateDropData(dropdata){let type=null==dropdata?void 0:dropdata.type;return"card"==type||"column"==type}drop(dropdata,event){if("card"==dropdata.type){let cards=this.getElements(_selectors.default.CARD),aftercard=0;for(let i=0;i{e.classList.remove("mod_kanban_insert")}))}_addColumn(event){document.activeElement.blur();let target=event.target.closest(_selectors.default.ADDCOLUMN),data=Object.assign({},target.dataset);this.reactive.dispatch("addColumn",data.id)}async _cardCreated(_ref){let{element:element}=_ref;if(element.kanban_column==this.id){let data=JSON.parse(JSON.stringify(element));Object.assign(data,_exporter.default.exportCapabilities(this.reactive.state));let placeholder=document.createElement("li");placeholder.setAttribute("data-id",data.id);let node=this.getElement(_selectors.default.COLUMNINNER,this.id);node.appendChild(placeholder);const newelement=(await this.renderComponent(placeholder,"mod_kanban/card",data)).getElement();node.replaceChild(newelement,placeholder)}}_addCard(event){document.activeElement.blur();let target=event.target.closest(_selectors.default.ADDCARD),data=Object.assign({},target.dataset);this.reactive.dispatch("addCard",data.columnid,0)}_columnUpdated(_ref2){let{element:element}=_ref2;const el=this.getElement(_selectors.default.COLUMNINNER,this.id);if(void 0!==element.sequence){let sequence=element.sequence.split(",");[...el.children].forEach((node=>{node.classList.contains("mod_kanban_card")&&!sequence.includes(node.dataset.id)&&el.removeChild(node)})),[...el.children].sort(((a,b)=>sequence.indexOf(a.dataset.id)>sequence.indexOf(b.dataset.id)?1:-1)).forEach((node=>el.appendChild(node)))}if(void 0!==element.locked&&(this.toggleClass(0!=element.locked,"mod_kanban_locked_column"),0!=element.locked?this.getElement(_selectors.default.INPLACEEDITABLE).removeAttribute("data-inplaceeditable"):this.getElement(_selectors.default.INPLACEEDITABLE).setAttribute("data-inplaceeditable","1")),void 0!==element.title&&(this.getElement(_selectors.default.INPLACEEDITABLE).setAttribute("data-value",element.title),this.getElement(_selectors.default.INPLACEEDITABLE).querySelector("a").innerHTML=element.title),void 0!==element.options){let options=JSON.parse(element.options);this.toggleClass(options.autohide,"mod_kanban_autohide")}this.checkDragging()}_columnDeleted(){this.destroy()}_removeColumn(event){let target=event.target.closest(_selectors.default.DELETECOLUMN),data=Object.assign({},target.dataset);this.reactive.dispatch("deleteColumn",data.id)}_lockColumn(event){let target=event.target.closest(_selectors.default.LOCKCOLUMN),data=Object.assign({},target.dataset);this.reactive.dispatch("lockColumn",data.id)}_unlockColumn(event){let target=event.target.closest(_selectors.default.UNLOCKCOLUMN),data=Object.assign({},target.dataset);this.reactive.dispatch("unlockColumn",data.id)}_editDetails(event){event.preventDefault();const modalForm=new _modalform.default({formClass:"mod_kanban\\form\\edit_column_form",args:{id:this.id,boardid:this.boardid,cmid:this.cmid},modalConfig:{title:(0,Str.get_string)("editcolumn","mod_kanban")},returnFocus:this.getElement()});this.addEventListener(modalForm,modalForm.events.FORM_SUBMITTED,this._updateColumn),modalForm.show()}_updateColumn(event){this.reactive.dispatch("processUpdates",event.detail)}_showHidden(){this.getElement().classList.add("mod_kanban_show_hidden")}_hideHidden(){this.getElement().classList.remove("mod_kanban_show_hidden")}}return _exports.default=_default,_exports.default})); +define("mod_kanban/column",["exports","core/reactive","mod_kanban/selectors","mod_kanban/capabilities","mod_kanban/exporter","core/notification","core/str","core_form/modalform","mod_kanban/kanbancomponent","core/log"],(function(_exports,_reactive,_selectors,_capabilities,_exporter,_notification,Str,_modalform,_kanbancomponent,_log){function _getRequireWildcardCache(nodeInterop){if("function"!=typeof WeakMap)return null;var cacheBabelInterop=new WeakMap,cacheNodeInterop=new WeakMap;return(_getRequireWildcardCache=function(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop})(nodeInterop)}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_selectors=_interopRequireDefault(_selectors),_capabilities=_interopRequireDefault(_capabilities),_exporter=_interopRequireDefault(_exporter),Str=function(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule)return obj;if(null===obj||"object"!=typeof obj&&"function"!=typeof obj)return{default:obj};var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj))return cache.get(obj);var newObj={},hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj)if("default"!==key&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;desc&&(desc.get||desc.set)?Object.defineProperty(newObj,key,desc):newObj[key]=obj[key]}newObj.default=obj,cache&&cache.set(obj,newObj);return newObj}(Str),_modalform=_interopRequireDefault(_modalform),_kanbancomponent=_interopRequireDefault(_kanbancomponent),_log=_interopRequireDefault(_log);class _default extends _kanbancomponent.default{static init(target){return new this({element:document.getElementById(target)})}create(){this.id=this.element.dataset.id}getWatchers(){return[{watch:"columns[".concat(this.id,"]:updated"),handler:this._columnUpdated},{watch:"columns[".concat(this.id,"]:deleted"),handler:this._columnDeleted},{watch:"cards:created",handler:this._cardCreated}]}stateReady(state){this.addEventListener(this.getElement(_selectors.default.DELETECOLUMN,this.id),"click",this._removeConfirm),this.addEventListener(this.getElement(_selectors.default.ADDCARDFIRST),"click",this._addCard),this.addEventListener(this.getElement(_selectors.default.ADDCOLUMN,this.id),"click",this._addColumn),this.addEventListener(this.getElement(_selectors.default.LOCKCOLUMN,this.id),"click",this._lockColumn),this.addEventListener(this.getElement(_selectors.default.UNLOCKCOLUMN,this.id),"click",this._unlockColumn),this.addEventListener(this.getElement(_selectors.default.EDITDETAILS,this.id),"click",this._editDetails),this.addEventListener(this.getElement(_selectors.default.SHOWHIDDEN),"click",this._showHidden),this.addEventListener(this.getElement(_selectors.default.HIDEHIDDEN),"click",this._hideHidden),this.draggable=!1,this.dragdrop=new _reactive.DragDrop(this),this.checkDragging(state),this.boardid=state.board.id,this.cmid=state.common.id}_removeConfirm(event){Str.get_strings([{key:"deletecolumn",component:"mod_kanban"},{key:"deletecolumnconfirm",component:"mod_kanban"},{key:"delete",component:"core"}]).then((strings=>(0,_notification.saveCancel)(strings[0],strings[1],strings[2],(()=>{this._removeColumn(event)})))).catch((error=>_log.default.debug(error)))}destroy(){void 0!==this.dragdrop&&this.dragdrop.unregister()}getDraggableData(){return{id:this.id,type:"column"}}checkDragging(state){void 0===state&&(state=this.reactive.stateManager.state),state.capabilities.get(_capabilities.default.MANAGECOLUMNS).value&&0==state.columns.get(this.id).locked?this.dragdrop.setDraggable(!0):this.dragdrop.setDraggable(!1)}validateDropData(dropdata){let type=null==dropdata?void 0:dropdata.type;return"card"==type||"column"==type}drop(dropdata,event){if("card"==dropdata.type){let cards=this.getElements(_selectors.default.CARD),aftercard=0;for(let i=0;i{e.classList.remove("mod_kanban_insert")}))}_addColumn(event){document.activeElement.blur();let target=event.target.closest(_selectors.default.ADDCOLUMN),data=Object.assign({},target.dataset);this.reactive.dispatch("addColumn",data.id)}async _cardCreated(_ref){let{element:element}=_ref;if(element.kanban_column==this.id){let data=JSON.parse(JSON.stringify(element));Object.assign(data,_exporter.default.exportCapabilities(this.reactive.state));let placeholder=document.createElement("li");placeholder.setAttribute("data-id",data.id);let node=this.getElement(_selectors.default.COLUMNINNER,this.id);node.appendChild(placeholder);const newelement=(await this.renderComponent(placeholder,"mod_kanban/card",data)).getElement();node.replaceChild(newelement,placeholder)}}_addCard(event){document.activeElement.blur();let target=event.target.closest(_selectors.default.ADDCARD),data=Object.assign({},target.dataset);this.reactive.dispatch("addCard",data.columnid,0)}_columnUpdated(_ref2){let{element:element}=_ref2;const el=this.getElement(_selectors.default.COLUMNINNER,this.id);if(void 0!==element.sequence){let sequence=element.sequence.split(",");[...el.children].forEach((node=>{node.classList.contains("mod_kanban_card")&&!sequence.includes(node.dataset.id)&&el.removeChild(node)})),[...el.children].sort(((a,b)=>sequence.indexOf(a.dataset.id)>sequence.indexOf(b.dataset.id)?1:-1)).forEach((node=>el.appendChild(node)))}if(void 0!==element.locked&&(this.toggleClass(0!=element.locked,"mod_kanban_locked_column"),0!=element.locked?this.getElement(_selectors.default.INPLACEEDITABLE).removeAttribute("data-inplaceeditable"):this.getElement(_selectors.default.INPLACEEDITABLE).setAttribute("data-inplaceeditable","1")),void 0!==element.title){let titlehelper=document.createElement("textarea");titlehelper.innerHTML=element.title,this.getElement(_selectors.default.INPLACEEDITABLE).setAttribute("data-value",titlehelper.value),this.getElement(_selectors.default.INPLACEEDITABLE).querySelector("a").innerHTML=element.title}if(void 0!==element.options){let options=JSON.parse(element.options);this.toggleClass(options.autohide,"mod_kanban_autohide")}this.checkDragging()}_columnDeleted(){this.destroy()}_removeColumn(event){let target=event.target.closest(_selectors.default.DELETECOLUMN),data=Object.assign({},target.dataset);this.reactive.dispatch("deleteColumn",data.id)}_lockColumn(event){let target=event.target.closest(_selectors.default.LOCKCOLUMN),data=Object.assign({},target.dataset);this.reactive.dispatch("lockColumn",data.id)}_unlockColumn(event){let target=event.target.closest(_selectors.default.UNLOCKCOLUMN),data=Object.assign({},target.dataset);this.reactive.dispatch("unlockColumn",data.id)}_editDetails(event){event.preventDefault();const modalForm=new _modalform.default({formClass:"mod_kanban\\form\\edit_column_form",args:{id:this.id,boardid:this.boardid,cmid:this.cmid},modalConfig:{title:(0,Str.get_string)("editcolumn","mod_kanban")},returnFocus:this.getElement()});this.addEventListener(modalForm,modalForm.events.FORM_SUBMITTED,this._updateColumn),modalForm.show()}_updateColumn(event){this.reactive.dispatch("processUpdates",event.detail)}_showHidden(){this.getElement().classList.add("mod_kanban_show_hidden")}_hideHidden(){this.getElement().classList.remove("mod_kanban_show_hidden")}}return _exports.default=_default,_exports.default})); //# sourceMappingURL=column.min.js.map \ No newline at end of file diff --git a/amd/build/column.min.js.map b/amd/build/column.min.js.map index 9954ce14..cabdff53 100644 --- a/amd/build/column.min.js.map +++ b/amd/build/column.min.js.map @@ -1 +1 @@ -{"version":3,"file":"column.min.js","sources":["../src/column.js"],"sourcesContent":["import {DragDrop} from 'core/reactive';\nimport selectors from 'mod_kanban/selectors';\nimport capabilities from 'mod_kanban/capabilities';\nimport exporter from 'mod_kanban/exporter';\nimport {saveCancel} from 'core/notification';\nimport * as Str from 'core/str';\nimport {get_string as getString} from 'core/str';\nimport ModalForm from 'core_form/modalform';\nimport KanbanComponent from 'mod_kanban/kanbancomponent';\nimport Log from \"core/log\";\n\n/**\n * Component representing a column in a kanban board.\n */\nexport default class extends KanbanComponent {\n /**\n * Function to initialize component, called by mustache template.\n * @param {*} target The id of the HTMLElement to attach to\n * @returns {BaseComponent} New component attached to the HTMLElement represented by target\n */\n static init(target) {\n let element = document.getElementById(target);\n return new this({\n element: element,\n });\n }\n\n /**\n * Called after the component was created.\n */\n create() {\n this.id = this.element.dataset.id;\n }\n\n /**\n * Watchers for this component.\n * @returns {array}\n */\n getWatchers() {\n return [\n {watch: `columns[${this.id}]:updated`, handler: this._columnUpdated},\n {watch: `columns[${this.id}]:deleted`, handler: this._columnDeleted},\n {watch: `cards:created`, handler: this._cardCreated}\n ];\n }\n\n /**\n * Called once when state is ready, attaching event listeners and initializing drag and drop.\n * @param {object} state\n */\n stateReady(state) {\n this.addEventListener(\n this.getElement(selectors.DELETECOLUMN, this.id),\n 'click',\n this._removeConfirm\n );\n this.addEventListener(\n this.getElement(selectors.ADDCARDFIRST),\n 'click',\n this._addCard\n );\n this.addEventListener(\n this.getElement(selectors.ADDCOLUMN, this.id),\n 'click',\n this._addColumn\n );\n this.addEventListener(\n this.getElement(selectors.LOCKCOLUMN, this.id),\n 'click',\n this._lockColumn\n );\n this.addEventListener(\n this.getElement(selectors.UNLOCKCOLUMN, this.id),\n 'click',\n this._unlockColumn\n );\n this.addEventListener(\n this.getElement(selectors.EDITDETAILS, this.id),\n 'click',\n this._editDetails\n );\n this.addEventListener(\n this.getElement(selectors.SHOWHIDDEN),\n 'click',\n this._showHidden\n );\n this.addEventListener(\n this.getElement(selectors.HIDEHIDDEN),\n 'click',\n this._hideHidden\n );\n this.draggable = false;\n this.dragdrop = new DragDrop(this);\n this.checkDragging(state);\n this.boardid = state.board.id;\n this.cmid = state.common.id;\n }\n\n /**\n * Display confirmation modal for deleting a card.\n * @param {*} event\n */\n _removeConfirm(event) {\n Str.get_strings([\n {key: 'deletecolumn', component: 'mod_kanban'},\n {key: 'deletecolumnconfirm', component: 'mod_kanban'},\n {key: 'delete', component: 'core'},\n ]).then((strings) => {\n return saveCancel(\n strings[0],\n strings[1],\n strings[2],\n () => {\n this._removeColumn(event);\n }\n );\n }).catch((error) => Log.debug(error));\n }\n\n /**\n * Remove all subcomponents dependencies.\n */\n destroy() {\n if (this.dragdrop !== undefined) {\n this.dragdrop.unregister();\n }\n }\n\n /**\n * Get the draggable data of this component.\n *\n * @returns {Object} the draggable data.\n */\n getDraggableData() {\n return {id: this.id, type: 'column'};\n }\n\n /**\n * Conditionally enable / disable dragging.\n * @param {*} state\n */\n checkDragging(state) {\n if (state === undefined) {\n state = this.reactive.stateManager.state;\n }\n\n if (state.capabilities.get(capabilities.MANAGECOLUMNS).value && state.columns.get(this.id).locked == 0) {\n this.dragdrop.setDraggable(true);\n } else {\n this.dragdrop.setDraggable(false);\n }\n }\n\n /**\n * Validate draggable data. This component accepts cards and columns.\n * @param {object} dropdata\n * @returns {boolean} if the data is valid for this drop-zone.\n */\n validateDropData(dropdata) {\n let type = dropdata?.type;\n return type == 'card' || type == 'column';\n }\n\n /**\n * Executed when a valid dropdata is dropped over the drop-zone.\n * @param {object} dropdata\n * @param {object} event\n */\n drop(dropdata, event) {\n if (dropdata.type == 'card') {\n let cards = this.getElements(selectors.CARD);\n let aftercard = 0;\n for (let i = 0; i < cards.length; i++) {\n if (cards[i].offsetTop + cards[i].clientHeight / 2 <= event.layerY) {\n aftercard = cards[i].dataset.id;\n }\n }\n this.reactive.dispatch('moveCard', dropdata.id, this.id, aftercard);\n }\n if (dropdata.type == 'column') {\n if (dropdata.id != this.id) {\n this.reactive.dispatch('moveColumn', dropdata.id, this.id);\n }\n }\n }\n\n /**\n * Show some visual hints to the user.\n * @param {object} dropdata\n * @param {object} event\n */\n showDropZone(dropdata, event) {\n if (dropdata.type == 'card') {\n let cards = this.getElements(selectors.CARD);\n let aftercard = 0;\n for (let i = 0; i < cards.length; i++) {\n if (cards[i].offsetTop + cards[i].clientHeight / 2 <= event.layerY) {\n aftercard = cards[i].dataset.id;\n }\n }\n if (aftercard == 0) {\n this.getElement(selectors.ADDCARDCONTAINER).classList.add('mod_kanban_insert');\n } else {\n this.getElement(selectors.ADDCARDCONTAINER, aftercard).classList.add('mod_kanban_insert');\n }\n }\n if (dropdata.type == 'column') {\n this.getElement(selectors.ADDCOLUMNCONTAINER).classList.add('mod_kanban_insert');\n }\n }\n\n /**\n * Remove visual hints to the user.\n */\n hideDropZone() {\n this.getElement(selectors.ADDCOLUMNCONTAINER).classList.remove('mod_kanban_insert');\n this.getElements(selectors.ADDCARDCONTAINER).forEach((e) => {\n e.classList.remove('mod_kanban_insert');\n });\n }\n\n /**\n * Dispatch event to add a column after this column.\n * @param {*} event\n */\n _addColumn(event) {\n document.activeElement.blur();\n let target = event.target.closest(selectors.ADDCOLUMN);\n let data = Object.assign({}, target.dataset);\n this.reactive.dispatch('addColumn', data.id);\n }\n\n /**\n * Called when a card was created in this column.\n * @param {*} param0\n */\n async _cardCreated({element}) {\n if (element.kanban_column == this.id) {\n let data = JSON.parse(JSON.stringify(element));\n Object.assign(data, exporter.exportCapabilities(this.reactive.state));\n let placeholder = document.createElement('li');\n placeholder.setAttribute('data-id', data.id);\n let node = this.getElement(selectors.COLUMNINNER, this.id);\n node.appendChild(placeholder);\n const newcomponent = await this.renderComponent(placeholder, 'mod_kanban/card', data);\n const newelement = newcomponent.getElement();\n node.replaceChild(newelement, placeholder);\n }\n }\n\n /**\n * Dispatch event to add a card in this column.\n * @param {*} event\n */\n _addCard(event) {\n document.activeElement.blur();\n let target = event.target.closest(selectors.ADDCARD);\n let data = Object.assign({}, target.dataset);\n this.reactive.dispatch('addCard', data.columnid, 0);\n }\n\n /**\n * Called when column is updated.\n * @param {*} param0\n */\n _columnUpdated({element}) {\n const el = this.getElement(selectors.COLUMNINNER, this.id);\n if (element.sequence !== undefined) {\n let sequence = element.sequence.split(',');\n // Remove all cards from frontend that are no longer present in the database.\n [...el.children]\n .forEach((node) => {\n if (node.classList.contains('mod_kanban_card') && !sequence.includes(node.dataset.id)) {\n el.removeChild(node);\n }\n });\n // Reorder cards according to sequence from the database.\n [...el.children]\n .sort((a, b) => sequence.indexOf(a.dataset.id) > sequence.indexOf(b.dataset.id) ? 1 : -1)\n .forEach(node => el.appendChild(node));\n }\n if (element.locked !== undefined) {\n this.toggleClass(element.locked != 0, 'mod_kanban_locked_column');\n // Inplace editing of the column title is disabled if the column is locked.\n if (element.locked != 0) {\n this.getElement(selectors.INPLACEEDITABLE).removeAttribute('data-inplaceeditable');\n } else {\n this.getElement(selectors.INPLACEEDITABLE).setAttribute('data-inplaceeditable', '1');\n }\n }\n // Update data for inplace editing if title was updated (this is important if title was modified by another user).\n if (element.title !== undefined) {\n this.getElement(selectors.INPLACEEDITABLE).setAttribute('data-value', element.title);\n this.getElement(selectors.INPLACEEDITABLE).querySelector('a').innerHTML = element.title;\n }\n // Only autohide option is relevant for the frontend for now. autoclose option is handled by the backend.\n if (element.options !== undefined) {\n let options = JSON.parse(element.options);\n this.toggleClass(options.autohide, 'mod_kanban_autohide');\n }\n // Enable/disable dragging (e.g. if column is locked).\n this.checkDragging();\n }\n\n /**\n * Called when this column is deleted.\n */\n _columnDeleted() {\n this.destroy();\n }\n\n /**\n * Dispatch event to remove this column.\n * @param {*} event\n */\n _removeColumn(event) {\n let target = event.target.closest(selectors.DELETECOLUMN);\n let data = Object.assign({}, target.dataset);\n this.reactive.dispatch('deleteColumn', data.id);\n }\n\n /**\n * Dispatch event to lock this column.\n * @param {*} event\n */\n _lockColumn(event) {\n let target = event.target.closest(selectors.LOCKCOLUMN);\n let data = Object.assign({}, target.dataset);\n this.reactive.dispatch('lockColumn', data.id);\n }\n\n /**\n * Dispatch event to unlock this column.\n * @param {*} event\n */\n _unlockColumn(event) {\n let target = event.target.closest(selectors.UNLOCKCOLUMN);\n let data = Object.assign({}, target.dataset);\n this.reactive.dispatch('unlockColumn', data.id);\n }\n\n /**\n * Show modal form to edit column details.\n * @param {*} event\n */\n _editDetails(event) {\n event.preventDefault();\n\n const modalForm = new ModalForm({\n formClass: \"mod_kanban\\\\form\\\\edit_column_form\",\n args: {\n id: this.id,\n boardid: this.boardid,\n cmid: this.cmid\n },\n modalConfig: {title: getString('editcolumn', 'mod_kanban')},\n returnFocus: this.getElement(),\n });\n this.addEventListener(modalForm, modalForm.events.FORM_SUBMITTED, this._updateColumn);\n modalForm.show();\n }\n\n /**\n * Dispatch an event to update column data from the detail modal.\n * @param {*} event\n */\n _updateColumn(event) {\n this.reactive.dispatch('processUpdates', event.detail);\n }\n\n /**\n * Show hidden cards.\n */\n _showHidden() {\n this.getElement().classList.add('mod_kanban_show_hidden');\n }\n\n /**\n * Hide hidden cards.\n */\n _hideHidden() {\n this.getElement().classList.remove('mod_kanban_show_hidden');\n }\n}\n"],"names":["KanbanComponent","target","this","element","document","getElementById","create","id","dataset","getWatchers","watch","handler","_columnUpdated","_columnDeleted","_cardCreated","stateReady","state","addEventListener","getElement","selectors","DELETECOLUMN","_removeConfirm","ADDCARDFIRST","_addCard","ADDCOLUMN","_addColumn","LOCKCOLUMN","_lockColumn","UNLOCKCOLUMN","_unlockColumn","EDITDETAILS","_editDetails","SHOWHIDDEN","_showHidden","HIDEHIDDEN","_hideHidden","draggable","dragdrop","DragDrop","checkDragging","boardid","board","cmid","common","event","Str","get_strings","key","component","then","strings","_removeColumn","catch","error","Log","debug","destroy","undefined","unregister","getDraggableData","type","reactive","stateManager","capabilities","get","MANAGECOLUMNS","value","columns","locked","setDraggable","validateDropData","dropdata","drop","cards","getElements","CARD","aftercard","i","length","offsetTop","clientHeight","layerY","dispatch","showDropZone","ADDCARDCONTAINER","classList","add","ADDCOLUMNCONTAINER","hideDropZone","remove","forEach","e","activeElement","blur","closest","data","Object","assign","kanban_column","JSON","parse","stringify","exporter","exportCapabilities","placeholder","createElement","setAttribute","node","COLUMNINNER","appendChild","newelement","renderComponent","replaceChild","ADDCARD","columnid","el","sequence","split","children","contains","includes","removeChild","sort","a","b","indexOf","toggleClass","INPLACEEDITABLE","removeAttribute","title","querySelector","innerHTML","options","autohide","preventDefault","modalForm","ModalForm","formClass","args","modalConfig","returnFocus","events","FORM_SUBMITTED","_updateColumn","show","detail"],"mappings":"ysDAc6BA,qCAMbC,eAED,IAAIC,KAAK,CACZC,QAFUC,SAASC,eAAeJ,UAS1CK,cACSC,GAAKL,KAAKC,QAAQK,QAAQD,GAOnCE,oBACW,CACH,CAACC,wBAAkBR,KAAKK,gBAAeI,QAAST,KAAKU,gBACrD,CAACF,wBAAkBR,KAAKK,gBAAeI,QAAST,KAAKW,gBACrD,CAACH,sBAAwBC,QAAST,KAAKY,eAQ/CC,WAAWC,YACFC,iBACDf,KAAKgB,WAAWC,mBAAUC,aAAclB,KAAKK,IAC7C,QACAL,KAAKmB,qBAEJJ,iBACDf,KAAKgB,WAAWC,mBAAUG,cAC1B,QACApB,KAAKqB,eAEJN,iBACDf,KAAKgB,WAAWC,mBAAUK,UAAWtB,KAAKK,IAC1C,QACAL,KAAKuB,iBAEJR,iBACDf,KAAKgB,WAAWC,mBAAUO,WAAYxB,KAAKK,IAC3C,QACAL,KAAKyB,kBAEJV,iBACDf,KAAKgB,WAAWC,mBAAUS,aAAc1B,KAAKK,IAC7C,QACAL,KAAK2B,oBAEJZ,iBACDf,KAAKgB,WAAWC,mBAAUW,YAAa5B,KAAKK,IAC5C,QACAL,KAAK6B,mBAEJd,iBACDf,KAAKgB,WAAWC,mBAAUa,YAC1B,QACA9B,KAAK+B,kBAEJhB,iBACDf,KAAKgB,WAAWC,mBAAUe,YAC1B,QACAhC,KAAKiC,kBAEJC,WAAY,OACZC,SAAW,IAAIC,mBAASpC,WACxBqC,cAAcvB,YACdwB,QAAUxB,MAAMyB,MAAMlC,QACtBmC,KAAO1B,MAAM2B,OAAOpC,GAO7Bc,eAAeuB,OACXC,IAAIC,YAAY,CACZ,CAACC,IAAK,eAAgBC,UAAW,cACjC,CAACD,IAAK,sBAAuBC,UAAW,cACxC,CAACD,IAAK,SAAUC,UA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U,CAC5BC,UAAW,qCACXC,KAAM,CACFnI,GAAIL,KAAKK,GACTiC,QAAStC,KAAKsC,QACdE,KAAMxC,KAAKwC,MAEfiG,YAAa,CAACV,OAAO,kBAAU,aAAc,eAC7CW,YAAa1I,KAAKgB,oBAEjBD,iBAAiBsH,UAAWA,UAAUM,OAAOC,eAAgB5I,KAAK6I,eACvER,UAAUS,OAOdD,cAAcnG,YACLiB,SAASqB,SAAS,iBAAkBtC,MAAMqG,QAMnDhH,mBACSf,aAAamE,UAAUC,IAAI,0BAMpCnD,mBACSjB,aAAamE,UAAUI,OAAO"} \ No newline at end of file +{"version":3,"file":"column.min.js","sources":["../src/column.js"],"sourcesContent":["import {DragDrop} from 'core/reactive';\nimport selectors from 'mod_kanban/selectors';\nimport capabilities from 'mod_kanban/capabilities';\nimport exporter from 'mod_kanban/exporter';\nimport {saveCancel} from 'core/notification';\nimport * as Str from 'core/str';\nimport {get_string as getString} from 'core/str';\nimport ModalForm from 'core_form/modalform';\nimport KanbanComponent from 'mod_kanban/kanbancomponent';\nimport Log from \"core/log\";\n\n/**\n * Component representing a column in a kanban board.\n */\nexport default class extends KanbanComponent {\n /**\n * Function to initialize component, called by mustache template.\n * @param {*} target The id of the HTMLElement to attach to\n * @returns {BaseComponent} New component attached to the HTMLElement represented by target\n */\n static init(target) {\n let element = document.getElementById(target);\n return new this({\n element: element,\n });\n }\n\n /**\n * Called after the component was created.\n */\n create() {\n this.id = this.element.dataset.id;\n }\n\n /**\n * Watchers for this component.\n * @returns {array}\n */\n getWatchers() {\n return [\n {watch: `columns[${this.id}]:updated`, handler: this._columnUpdated},\n {watch: `columns[${this.id}]:deleted`, handler: this._columnDeleted},\n {watch: `cards:created`, handler: this._cardCreated}\n ];\n }\n\n /**\n * Called once when state is ready, attaching event listeners and initializing drag and drop.\n * @param {object} state\n */\n stateReady(state) {\n this.addEventListener(\n this.getElement(selectors.DELETECOLUMN, this.id),\n 'click',\n this._removeConfirm\n );\n this.addEventListener(\n this.getElement(selectors.ADDCARDFIRST),\n 'click',\n this._addCard\n );\n this.addEventListener(\n this.getElement(selectors.ADDCOLUMN, this.id),\n 'click',\n this._addColumn\n );\n this.addEventListener(\n this.getElement(selectors.LOCKCOLUMN, this.id),\n 'click',\n this._lockColumn\n );\n this.addEventListener(\n this.getElement(selectors.UNLOCKCOLUMN, this.id),\n 'click',\n this._unlockColumn\n );\n this.addEventListener(\n this.getElement(selectors.EDITDETAILS, this.id),\n 'click',\n this._editDetails\n );\n this.addEventListener(\n this.getElement(selectors.SHOWHIDDEN),\n 'click',\n this._showHidden\n );\n this.addEventListener(\n this.getElement(selectors.HIDEHIDDEN),\n 'click',\n this._hideHidden\n );\n this.draggable = false;\n this.dragdrop = new DragDrop(this);\n this.checkDragging(state);\n this.boardid = state.board.id;\n this.cmid = state.common.id;\n }\n\n /**\n * Display confirmation modal for deleting a card.\n * @param {*} event\n */\n _removeConfirm(event) {\n Str.get_strings([\n {key: 'deletecolumn', component: 'mod_kanban'},\n {key: 'deletecolumnconfirm', component: 'mod_kanban'},\n {key: 'delete', component: 'core'},\n ]).then((strings) => {\n return saveCancel(\n strings[0],\n strings[1],\n strings[2],\n () => {\n this._removeColumn(event);\n }\n );\n }).catch((error) => Log.debug(error));\n }\n\n /**\n * Remove all subcomponents dependencies.\n */\n destroy() {\n if (this.dragdrop !== undefined) {\n this.dragdrop.unregister();\n }\n }\n\n /**\n * Get the draggable data of this component.\n *\n * @returns {Object} the draggable data.\n */\n getDraggableData() {\n return {id: this.id, type: 'column'};\n }\n\n /**\n * Conditionally enable / disable dragging.\n * @param {*} state\n */\n checkDragging(state) {\n if (state === undefined) {\n state = this.reactive.stateManager.state;\n }\n\n if (state.capabilities.get(capabilities.MANAGECOLUMNS).value && state.columns.get(this.id).locked == 0) {\n this.dragdrop.setDraggable(true);\n } else {\n this.dragdrop.setDraggable(false);\n }\n }\n\n /**\n * Validate draggable data. This component accepts cards and columns.\n * @param {object} dropdata\n * @returns {boolean} if the data is valid for this drop-zone.\n */\n validateDropData(dropdata) {\n let type = dropdata?.type;\n return type == 'card' || type == 'column';\n }\n\n /**\n * Executed when a valid dropdata is dropped over the drop-zone.\n * @param {object} dropdata\n * @param {object} event\n */\n drop(dropdata, event) {\n if (dropdata.type == 'card') {\n let cards = this.getElements(selectors.CARD);\n let aftercard = 0;\n for (let i = 0; i < cards.length; i++) {\n if (cards[i].offsetTop + cards[i].clientHeight / 2 <= event.layerY) {\n aftercard = cards[i].dataset.id;\n }\n }\n this.reactive.dispatch('moveCard', dropdata.id, this.id, aftercard);\n }\n if (dropdata.type == 'column') {\n if (dropdata.id != this.id) {\n this.reactive.dispatch('moveColumn', dropdata.id, this.id);\n }\n }\n }\n\n /**\n * Show some visual hints to the user.\n * @param {object} dropdata\n * @param {object} event\n */\n showDropZone(dropdata, event) {\n if (dropdata.type == 'card') {\n let cards = this.getElements(selectors.CARD);\n let aftercard = 0;\n for (let i = 0; i < cards.length; i++) {\n if (cards[i].offsetTop + cards[i].clientHeight / 2 <= event.layerY) {\n aftercard = cards[i].dataset.id;\n }\n }\n if (aftercard == 0) {\n this.getElement(selectors.ADDCARDCONTAINER).classList.add('mod_kanban_insert');\n } else {\n this.getElement(selectors.ADDCARDCONTAINER, aftercard).classList.add('mod_kanban_insert');\n }\n }\n if (dropdata.type == 'column') {\n this.getElement(selectors.ADDCOLUMNCONTAINER).classList.add('mod_kanban_insert');\n }\n }\n\n /**\n * Remove visual hints to the user.\n */\n hideDropZone() {\n this.getElement(selectors.ADDCOLUMNCONTAINER).classList.remove('mod_kanban_insert');\n this.getElements(selectors.ADDCARDCONTAINER).forEach((e) => {\n e.classList.remove('mod_kanban_insert');\n });\n }\n\n /**\n * Dispatch event to add a column after this column.\n * @param {*} event\n */\n _addColumn(event) {\n document.activeElement.blur();\n let target = event.target.closest(selectors.ADDCOLUMN);\n let data = Object.assign({}, target.dataset);\n this.reactive.dispatch('addColumn', data.id);\n }\n\n /**\n * Called when a card was created in this column.\n * @param {*} param0\n */\n async _cardCreated({element}) {\n if (element.kanban_column == this.id) {\n let data = JSON.parse(JSON.stringify(element));\n Object.assign(data, exporter.exportCapabilities(this.reactive.state));\n let placeholder = document.createElement('li');\n placeholder.setAttribute('data-id', data.id);\n let node = this.getElement(selectors.COLUMNINNER, this.id);\n node.appendChild(placeholder);\n const newcomponent = await this.renderComponent(placeholder, 'mod_kanban/card', data);\n const newelement = newcomponent.getElement();\n node.replaceChild(newelement, placeholder);\n }\n }\n\n /**\n * Dispatch event to add a card in this column.\n * @param {*} event\n */\n _addCard(event) {\n document.activeElement.blur();\n let target = event.target.closest(selectors.ADDCARD);\n let data = Object.assign({}, target.dataset);\n this.reactive.dispatch('addCard', data.columnid, 0);\n }\n\n /**\n * Called when column is updated.\n * @param {*} param0\n */\n _columnUpdated({element}) {\n const el = this.getElement(selectors.COLUMNINNER, this.id);\n if (element.sequence !== undefined) {\n let sequence = element.sequence.split(',');\n // Remove all cards from frontend that are no longer present in the database.\n [...el.children]\n .forEach((node) => {\n if (node.classList.contains('mod_kanban_card') && !sequence.includes(node.dataset.id)) {\n el.removeChild(node);\n }\n });\n // Reorder cards according to sequence from the database.\n [...el.children]\n .sort((a, b) => sequence.indexOf(a.dataset.id) > sequence.indexOf(b.dataset.id) ? 1 : -1)\n .forEach(node => el.appendChild(node));\n }\n if (element.locked !== undefined) {\n this.toggleClass(element.locked != 0, 'mod_kanban_locked_column');\n // Inplace editing of the column title is disabled if the column is locked.\n if (element.locked != 0) {\n this.getElement(selectors.INPLACEEDITABLE).removeAttribute('data-inplaceeditable');\n } else {\n this.getElement(selectors.INPLACEEDITABLE).setAttribute('data-inplaceeditable', '1');\n }\n }\n // Update data for inplace editing if title was updated (this is important if title was modified by another user).\n if (element.title !== undefined) {\n let titlehelper = document.createElement('textarea');\n titlehelper.innerHTML = element.title;\n this.getElement(selectors.INPLACEEDITABLE).setAttribute('data-value', titlehelper.value);\n this.getElement(selectors.INPLACEEDITABLE).querySelector('a').innerHTML = element.title;\n }\n // Only autohide option is relevant for the frontend for now. autoclose option is handled by the backend.\n if (element.options !== undefined) {\n let options = JSON.parse(element.options);\n this.toggleClass(options.autohide, 'mod_kanban_autohide');\n }\n // Enable/disable dragging (e.g. if column is locked).\n this.checkDragging();\n }\n\n /**\n * Called when this column is deleted.\n */\n _columnDeleted() {\n this.destroy();\n }\n\n /**\n * Dispatch event to remove this column.\n * @param {*} event\n */\n _removeColumn(event) {\n let target = event.target.closest(selectors.DELETECOLUMN);\n let data = Object.assign({}, target.dataset);\n this.reactive.dispatch('deleteColumn', data.id);\n }\n\n /**\n * Dispatch event to lock this column.\n * @param {*} event\n */\n _lockColumn(event) {\n let target = event.target.closest(selectors.LOCKCOLUMN);\n let data = Object.assign({}, target.dataset);\n this.reactive.dispatch('lockColumn', data.id);\n }\n\n /**\n * Dispatch event to unlock this column.\n * @param {*} event\n */\n _unlockColumn(event) {\n let target = event.target.closest(selectors.UNLOCKCOLUMN);\n let data = Object.assign({}, target.dataset);\n this.reactive.dispatch('unlockColumn', data.id);\n }\n\n /**\n * Show modal form to edit column details.\n * @param {*} event\n */\n _editDetails(event) {\n event.preventDefault();\n\n const modalForm = new ModalForm({\n formClass: \"mod_kanban\\\\form\\\\edit_column_form\",\n args: {\n id: this.id,\n boardid: this.boardid,\n cmid: this.cmid\n },\n modalConfig: {title: getString('editcolumn', 'mod_kanban')},\n returnFocus: this.getElement(),\n });\n this.addEventListener(modalForm, modalForm.events.FORM_SUBMITTED, this._updateColumn);\n modalForm.show();\n }\n\n /**\n * Dispatch an event to update column data from the detail modal.\n * @param {*} event\n */\n _updateColumn(event) {\n this.reactive.dispatch('processUpdates', event.detail);\n }\n\n /**\n * Show hidden cards.\n */\n _showHidden() {\n this.getElement().classList.add('mod_kanban_show_hidden');\n }\n\n /**\n * Hide hidden cards.\n */\n _hideHidden() {\n this.getElement().classList.remove('mod_kanban_show_hidden');\n }\n}\n"],"names":["KanbanComponent","target","this","element","document","getElementById","create","id","dataset","getWatchers","watch","handler","_columnUpdated","_columnDeleted","_cardCreated","stateReady","state","addEventListener","getElement","selectors","DELETECOLUMN","_removeConfirm","ADDCARDFIRST","_addCard","ADDCOLUMN","_addColumn","LOCKCOLUMN","_lockColumn","UNLOCKCOLUMN","_unlockColumn","EDITDETAILS","_editDetails","SHOWHIDDEN","_showHidden","HIDEHIDDEN","_hideHidden","draggable","dragdrop","DragDrop","checkDragging","boardid","board","cmid","common","event","Str","get_strings","key","component","then","strings","_removeColumn","catch","error","Log","debug","destroy","undefined","unregister","getDraggableData","type","reactive","stateManager","capabilities","get","MANAGECOLUMNS","value","columns","locked","setDraggable","validateDropData","dropdata","drop","cards","getElements","CARD","aftercard","i","length","offsetTop","clientHeight","layerY","dispatch","showDropZone","ADDCARDCONTAINER","classList","add","ADDCOLUMNCONTAINER","hideDropZone","remove","forEach","e","activeElement","blur","closest","data","Object","assign","kanban_column","JSON","parse","stringify","exporter","exportCapabilities","placeholder","createElement","setAttribute","node","COLUMNINNER","appendChild","newelement","renderComponent","replaceChild","ADDCARD","columnid","el","sequence","split","children","contains","includes","removeChild","sort","a","b","indexOf","toggleClass","INPLACEEDITABLE","removeAttribute","title","titlehelper","innerHTML","querySelector","options","autohide","preventDefault","modalForm","ModalForm","formClass","args","modalConfig","returnFocus","events","FORM_SUBMITTED","_updateColumn","show","detail"],"mappings":"ysDAc6BA,qCAMbC,eAED,IAAIC,KAAK,CACZC,QAFUC,SAASC,eAAeJ,UAS1CK,cACSC,GAAKL,KAAKC,QAAQK,QAAQD,GAOnCE,oBACW,CACH,CAACC,wBAAkBR,KAAKK,gBAAeI,QAAST,KAAKU,gBACrD,CAACF,wBAAkBR,KAAKK,gBAAeI,QAAST,KAAKW,gBACrD,CAACH,sBAAwBC,QAAST,KAAKY,eAQ/CC,WAAWC,YACFC,iBACDf,KAAKgB,WAAWC,mBAAUC,aAAclB,KAAKK,IAC7C,QACAL,KAAKmB,qBAEJJ,iBACDf,KAAKgB,WAAWC,mBAAUG,cAC1B,QACApB,KAAKqB,eAEJN,i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C,mBAAU4G,iBAAiBrB,aAAa,aAAcwB,YAAYhE,YAC7EhD,WAAWC,mBAAU4G,iBAAiBK,cAAc,KAAKD,UAAYhI,QAAQ8H,cAG9DxE,IAApBtD,QAAQkI,QAAuB,KAC3BA,QAAUlC,KAAKC,MAAMjG,QAAQkI,cAC5BP,YAAYO,QAAQC,SAAU,4BAGlC/F,gBAMT1B,sBACS2C,UAOTL,cAAcP,WACN3C,OAAS2C,MAAM3C,OAAO6F,QAAQ3E,mBAAUC,cACxC2E,KAAOC,OAAOC,OAAO,GAAIhG,OAAOO,cAC/BqD,SAASqB,SAAS,eAAgBa,KAAKxF,IAOhDoB,YAAYiB,WACJ3C,OAAS2C,MAAM3C,OAAO6F,QAAQ3E,mBAAUO,YACxCqE,KAAOC,OAAOC,OAAO,GAAIhG,OAAOO,cAC/BqD,SAASqB,SAAS,aAAca,KAAKxF,IAO9CsB,cAAce,WACN3C,OAAS2C,MAAM3C,OAAO6F,QAAQ3E,mBAAUS,cACxCmE,KAAOC,OAAOC,OAAO,GAAIhG,OAAOO,cAC/BqD,SAASqB,SAAS,eAAgBa,KAAKxF,IAOhDwB,aAAaa,OACTA,MAAM2F,uBAEAC,UAAY,IAAIC,mBAAU,CAC5BC,UAAW,qCACXC,KAAM,CACFpI,GAAIL,KAAKK,GACTiC,QAAStC,KAAKsC,QACdE,KAAMxC,KAAKwC,MAEfkG,YAAa,CAACX,OAAO,kBAAU,aAAc,eAC7CY,YAAa3I,KAAKgB,oBAEjBD,iBAAiBuH,UAAWA,UAAUM,OAAOC,eAAgB7I,KAAK8I,eACvER,UAAUS,OAOdD,cAAcpG,YACLiB,SAASqB,SAAS,iBAAkBtC,MAAMsG,QAMnDjH,mBACSf,aAAamE,UAAUC,IAAI,0BAMpCnD,mBACSjB,aAAamE,UAAUI,OAAO"} \ No newline at end of file diff --git a/amd/src/column.js b/amd/src/column.js index 6ff84c58..5a06eca2 100644 --- a/amd/src/column.js +++ b/amd/src/column.js @@ -290,7 +290,9 @@ export default class extends KanbanComponent { } // Update data for inplace editing if title was updated (this is important if title was modified by another user). if (element.title !== undefined) { - this.getElement(selectors.INPLACEEDITABLE).setAttribute('data-value', element.title); + let titlehelper = document.createElement('textarea'); + titlehelper.innerHTML = element.title; + this.getElement(selectors.INPLACEEDITABLE).setAttribute('data-value', titlehelper.value); this.getElement(selectors.INPLACEEDITABLE).querySelector('a').innerHTML = element.title; } // Only autohide option is relevant for the frontend for now. autoclose option is handled by the backend. diff --git a/lib.php b/lib.php index 55087871..0877e5dd 100644 --- a/lib.php +++ b/lib.php @@ -167,7 +167,7 @@ function kanban_inplace_editable($itemtype, $itemid, $newvalue) { $boardmanager->update_column($itemid, ['title' => $newvalue]); } - return new \core\output\inplace_editable('mod_kanban', $itemtype, $itemid, true, s($newvalue), s($newvalue), null, ''); + return new \core\output\inplace_editable('mod_kanban', $itemtype, $itemid, true, s($newvalue), $newvalue, null, ''); } /**