|
| 1 | + |
| 2 | +'use strict'; |
| 3 | +const NOCONTROLLERMESSAGE = 'Select a \'sap.ui.core.mvc.XMLView\' to see its Controller content. Click to filter on XMLViews'; |
| 4 | +const CONTROLLERNAME = 'Name:'; |
| 5 | +const CONTROLLERPATH = 'Relative Path:'; |
| 6 | +/** |
| 7 | + * @param {string} containerId - id of the DOM container |
| 8 | + * @constructor |
| 9 | + */ |
| 10 | +function ControllerDetailView(containerId) { |
| 11 | + this.oContainer = document.getElementById(containerId); |
| 12 | + this.oEditorDOM = document.createElement('div'); |
| 13 | + this.oEditorDOM.id = 'controllerEditor'; |
| 14 | + this.oEditorDOM.classList.toggle('hidden', true); |
| 15 | + this.oContainer.appendChild(this.oEditorDOM); |
| 16 | + |
| 17 | + this.oNamePlaceholderDOM = document.createElement('div'); |
| 18 | + this.oNamePlaceholderDOM.classList.add('longTextReduce'); |
| 19 | + this.oNamePlaceholderDOM.onclick = this._selectAllText; |
| 20 | + this.oPathPlaceholderDOM = document.createElement('div'); |
| 21 | + this.oPathPlaceholderDOM.classList.add('longTextReduce'); |
| 22 | + this.oPathPlaceholderDOM.onclick = this._selectAllText; |
| 23 | + this.oNameDOM = document.createElement('div'); |
| 24 | + this.oNameDOM.classList.add('firstColAlignment'); |
| 25 | + this.oNameDOM.innerText = CONTROLLERNAME; |
| 26 | + this.oPathDOM = document.createElement('div'); |
| 27 | + this.oPathDOM.classList.add('firstColAlignment'); |
| 28 | + this.oPathDOM.innerText = CONTROLLERPATH; |
| 29 | + this.oEditorDOM.appendChild(this.oNameDOM); |
| 30 | + this.oEditorDOM.appendChild(this.oNamePlaceholderDOM); |
| 31 | + this.oEditorDOM.appendChild(this.oPathDOM); |
| 32 | + this.oEditorDOM.appendChild(this.oPathPlaceholderDOM); |
| 33 | + |
| 34 | + this.oEditorAltDOM = document.createElement('div'); |
| 35 | + this.oEditorAltDOM.classList.add('editorAlt'); |
| 36 | + this.oEditorAltDOM.classList.toggle('hidden', false); |
| 37 | + this.oEditorAltMessageDOM = document.createElement('div'); |
| 38 | + this.oEditorAltMessageDOM.innerText = NOCONTROLLERMESSAGE; |
| 39 | + |
| 40 | + this.oEditorAltMessageDOM.addEventListener('click', function() { |
| 41 | + var searchField = document.getElementById('elementsRegistrySearch'); |
| 42 | + var filterCheckbox = document.getElementById('elementsRegistryCheckbox'); |
| 43 | + searchField.value = 'sap.ui.core.mvc.XMLView'; |
| 44 | + if (!filterCheckbox.checked) { |
| 45 | + filterCheckbox.click(); |
| 46 | + } |
| 47 | + return false; |
| 48 | + }); |
| 49 | + this.oContainer.appendChild(this.oEditorAltDOM); |
| 50 | + this.oEditorAltDOM.appendChild(this.oEditorAltMessageDOM); |
| 51 | +} |
| 52 | + |
| 53 | +/** |
| 54 | + * Updates data. |
| 55 | + * @param {Object} data - object structure as JSON |
| 56 | + */ |
| 57 | +ControllerDetailView.prototype.update = function (controllerInfo) { |
| 58 | + |
| 59 | + var bIsDataValid = !!(controllerInfo.sControllerName && controllerInfo.sControllerRelPath); |
| 60 | + |
| 61 | + this.oEditorDOM.classList.toggle('hidden', !bIsDataValid); |
| 62 | + this.oEditorAltDOM.classList.toggle('hidden', bIsDataValid); |
| 63 | + |
| 64 | + if (bIsDataValid) { |
| 65 | + this.oNamePlaceholderDOM.innerText = controllerInfo.sControllerName; |
| 66 | + this.oPathPlaceholderDOM.innerText = controllerInfo.sControllerRelPath; |
| 67 | + } |
| 68 | +}; |
| 69 | + |
| 70 | +ControllerDetailView.prototype._selectAllText = function (oEvent) { |
| 71 | + var range = document.createRange(); |
| 72 | + range.selectNode(oEvent.target); |
| 73 | + window.getSelection().removeAllRanges(); |
| 74 | + window.getSelection().addRange(range); |
| 75 | +}; |
| 76 | + |
| 77 | + |
| 78 | +module.exports = ControllerDetailView; |
0 commit comments