-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: show Controller Info in elements registry (#230)
Now when we select a view from the Elements Registry tab we can inspect some information about the controller of the given XML View. The information that we provide is the name of the given controller and its relative path to the given XML view.
- Loading branch information
1 parent
a4f597b
commit a93c5ce
Showing
9 changed files
with
205 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
|
||
'use strict'; | ||
const NOCONTROLLERMESSAGE = 'Select a \'sap.ui.core.mvc.XMLView\' to see its Controller content. Click to filter on XMLViews'; | ||
const CONTROLLERNAME = 'Name:'; | ||
const CONTROLLERPATH = 'Relative Path:'; | ||
/** | ||
* @param {string} containerId - id of the DOM container | ||
* @constructor | ||
*/ | ||
function ControllerDetailView(containerId) { | ||
this.oContainer = document.getElementById(containerId); | ||
this.oEditorDOM = document.createElement('div'); | ||
this.oEditorDOM.id = 'controllerEditor'; | ||
this.oEditorDOM.classList.toggle('hidden', true); | ||
this.oContainer.appendChild(this.oEditorDOM); | ||
|
||
this.oNamePlaceholderDOM = document.createElement('div'); | ||
this.oNamePlaceholderDOM.classList.add('longTextReduce'); | ||
this.oNamePlaceholderDOM.onclick = this._selectAllText; | ||
this.oPathPlaceholderDOM = document.createElement('div'); | ||
this.oPathPlaceholderDOM.classList.add('longTextReduce'); | ||
this.oPathPlaceholderDOM.onclick = this._selectAllText; | ||
this.oNameDOM = document.createElement('div'); | ||
this.oNameDOM.classList.add('firstColAlignment'); | ||
this.oNameDOM.innerText = CONTROLLERNAME; | ||
this.oPathDOM = document.createElement('div'); | ||
this.oPathDOM.classList.add('firstColAlignment'); | ||
this.oPathDOM.innerText = CONTROLLERPATH; | ||
this.oEditorDOM.appendChild(this.oNameDOM); | ||
this.oEditorDOM.appendChild(this.oNamePlaceholderDOM); | ||
this.oEditorDOM.appendChild(this.oPathDOM); | ||
this.oEditorDOM.appendChild(this.oPathPlaceholderDOM); | ||
|
||
this.oEditorAltDOM = document.createElement('div'); | ||
this.oEditorAltDOM.classList.add('editorAlt'); | ||
this.oEditorAltDOM.classList.toggle('hidden', false); | ||
this.oEditorAltMessageDOM = document.createElement('div'); | ||
this.oEditorAltMessageDOM.innerText = NOCONTROLLERMESSAGE; | ||
|
||
this.oEditorAltMessageDOM.addEventListener('click', function() { | ||
var searchField = document.getElementById('elementsRegistrySearch'); | ||
var filterCheckbox = document.getElementById('elementsRegistryCheckbox'); | ||
searchField.value = 'sap.ui.core.mvc.XMLView'; | ||
if (!filterCheckbox.checked) { | ||
filterCheckbox.click(); | ||
} | ||
return false; | ||
}); | ||
this.oContainer.appendChild(this.oEditorAltDOM); | ||
this.oEditorAltDOM.appendChild(this.oEditorAltMessageDOM); | ||
} | ||
|
||
/** | ||
* Updates data. | ||
* @param {Object} data - object structure as JSON | ||
*/ | ||
ControllerDetailView.prototype.update = function (controllerInfo) { | ||
|
||
var bIsDataValid = !!(controllerInfo.sControllerName && controllerInfo.sControllerRelPath); | ||
|
||
this.oEditorDOM.classList.toggle('hidden', !bIsDataValid); | ||
this.oEditorAltDOM.classList.toggle('hidden', bIsDataValid); | ||
|
||
if (bIsDataValid) { | ||
this.oNamePlaceholderDOM.innerText = controllerInfo.sControllerName; | ||
this.oPathPlaceholderDOM.innerText = controllerInfo.sControllerRelPath; | ||
} | ||
}; | ||
|
||
ControllerDetailView.prototype._selectAllText = function (oEvent) { | ||
var range = document.createRange(); | ||
range.selectNode(oEvent.target); | ||
window.getSelection().removeAllRanges(); | ||
window.getSelection().addRange(range); | ||
}; | ||
|
||
|
||
module.exports = ControllerDetailView; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
xml-view { | ||
height: 100%; | ||
} | ||
|
||
#elements-registry-control-controller { | ||
.editorAlt { | ||
display: flex; | ||
div { | ||
cursor: pointer; | ||
} | ||
} | ||
|
||
div.hidden { | ||
display: none !important; | ||
} | ||
|
||
.editorAlt { | ||
position: absolute; | ||
top: .5rem; | ||
left: .5rem; | ||
right: .5rem; | ||
bottom: .5rem; | ||
height: auto; | ||
} | ||
|
||
.firstColAlignment { | ||
text-align: end; | ||
} | ||
|
||
.longTextReduce { | ||
text-overflow: ellipsis; | ||
white-space: nowrap; | ||
overflow: hidden; | ||
} | ||
|
||
#controllerEditor{ | ||
display: grid; | ||
grid-template-columns: 25% auto; | ||
gap: .5rem; | ||
padding: .5rem; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters