Skip to content

Commit

Permalink
[TASK] Improve "Active Typoscript" view
Browse files Browse the repository at this point in the history
The module receives a similar treatment as
"Active PageTsConfig", namely client side
search and client side expand state persisting.

This simplifies server side a bit, which is
cleaned up. We're also avoiding the naming
'object browser' in file names and other places
in favor of 'active'. A series of minor bug
fixes is applied along the way.

Resolves: #99782
Related: #99747
Releases: main
Change-Id: Ibaef3123b3e6df316ef5e633582077fd0e702be0
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/77650
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Nikita Hovratov <nikita.h@live.de>
Tested-by: core-ci <typo3@b13.com>
Tested-by: Stefan Bürk <stefan@buerk.tech>
Reviewed-by: Nikita Hovratov <nikita.h@live.de>
  • Loading branch information
lolli42 committed Feb 1, 2023
1 parent a947ed0 commit c8ecb1e
Show file tree
Hide file tree
Showing 39 changed files with 602 additions and 988 deletions.
2 changes: 1 addition & 1 deletion Build/Sources/Sass/module/_tstemplate.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
}
}

.tstemplate-tsobjectbrowser-content {
.tstemplate-active-content {
overflow-x: auto;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,23 +104,29 @@ export class CollapseStatePersister {
if (id === '' || !this.shallRecoverState(element)) {
return;
}
const collapsible = BootstrapCollapse.getOrCreateInstance(element, {
toggle: false
});
const storeExpandedState = (element.dataset.persistCollapseStateIfState ?? 'shown') === 'shown';
const storeHiddenState = (element.dataset.persistCollapseStateIfState ?? 'hidden') === 'hidden';
const isExpanded = element.classList.contains('show');
if (storeExpandedState === true) {
if (currentStates[id] === true) {
collapsible.show();
if (!isExpanded) {
BootstrapCollapse.getOrCreateInstance(element, { toggle: false }).show();
}
} else {
collapsible.hide();
if (isExpanded) {
BootstrapCollapse.getOrCreateInstance(element, { toggle: false }).hide();
}
}
}
if (storeHiddenState === true) {
if (currentStates[id] === false) {
collapsible.hide();
if (isExpanded) {
BootstrapCollapse.getOrCreateInstance(element, { toggle: false }).hide();
}
} else {
collapsible.show();
if (!isExpanded) {
BootstrapCollapse.getOrCreateInstance(element, { toggle: false }).show();
}
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,10 @@ class CollapseStateSearch {

constructor() {
DocumentService.ready().then(() => {
const treeContainers: NodeListOf<HTMLElement>|null = document.querySelectorAll('.t3js-collapse-states-search-tree');
if (treeContainers === null) {
this.treeContainers = document.querySelectorAll('.t3js-collapse-states-search-tree');
if (this.treeContainers.length === 0) {
return;
}
this.treeContainers = treeContainers;
this.numberOfSearchMatchesContainer = document.querySelectorAll('.t3js-collapse-states-search-numberOfSearchMatches');
this.searchField = document.querySelector(this.searchValueSelector);
this.searchForm = this.searchField.closest('form');
Expand Down Expand Up @@ -126,11 +125,15 @@ class CollapseStateSearch {

const allNodes = Array.from(treeContainer.querySelectorAll('.collapse')) as HTMLElement[];
for (let node of allNodes) {
const collapsible = BootstrapCollapse.getOrCreateInstance(node, { toggle: false });
const isExpanded = node.classList.contains('show');
if (matchingCollapsibleIds.has(node.id)) {
collapsible.show();
if (!isExpanded) {
BootstrapCollapse.getOrCreateInstance(node, { toggle: false }).show();
}
} else {
collapsible.hide();
if (isExpanded) {
BootstrapCollapse.getOrCreateInstance(node, { toggle: false }).hide();
}
}
}

Expand Down
39 changes: 0 additions & 39 deletions Build/Sources/TypeScript/tstemplate/typo-script-object-browser.ts

This file was deleted.

2 changes: 1 addition & 1 deletion typo3/sysext/backend/Resources/Public/Css/backend.css

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 0 additions & 33 deletions typo3/sysext/core/Classes/TypoScript/AST/Node/AbstractNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ abstract class AbstractNode implements NodeInterface
* @var array<string, ChildNodeInterface>
*/
protected array $children = [];
private bool $expanded = false;
private ?TokenStreamInterface $originalValueTokenStream = null;
private bool $searchMatchInName = false;
private bool $searchMatchInValue = false;
private array $comments = [];

/**
Expand Down Expand Up @@ -173,36 +170,6 @@ public function getOriginalValueTokenStream(): ?TokenStreamInterface
return $this->originalValueTokenStream;
}

public function setExpanded(bool $expanded): void
{
$this->expanded = $expanded;
}

public function isExpanded(): bool
{
return $this->expanded;
}

public function setSearchMatchInName(): void
{
$this->searchMatchInName = true;
}

public function hasSearchMatchInName(): bool
{
return $this->searchMatchInName;
}

public function setSearchMatchInValue(): void
{
$this->searchMatchInValue = true;
}

public function hasSearchMatchInValue(): bool
{
return $this->searchMatchInValue;
}

public function addComment(TokenStreamInterface $tokenStream): void
{
$this->comments[] = $tokenStream;
Expand Down
15 changes: 0 additions & 15 deletions typo3/sysext/core/Classes/TypoScript/AST/Node/NodeInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,21 +89,6 @@ public function getPreviousValue(): ?string;
public function setOriginalValueTokenStream(?TokenStreamInterface $tokenStream): void;
public function getOriginalValueTokenStream(): ?TokenStreamInterface;

/**
* Helper methods mostly for backend object browser to declare a node expanded or not,
* and to query expand / collapsed state.
*/
public function setExpanded(bool $expanded): void;
public function isExpanded(): bool;

/**
* Helper methods mostly for backend object browser to declare a node matched a search value.
*/
public function setSearchMatchInName(): void;
public function hasSearchMatchInName(): bool;
public function setSearchMatchInValue(): void;
public function hasSearchMatchInValue(): bool;

/**
* Helper methods to attach TypoScript tokens to a node.
* This is used in ext:tstemplate "Constant Editor" and "Object Browser" and handled
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -486,12 +486,12 @@ private function parseCustomCategoryAndSubCategories(TokenStreamInterface $comme

public function visit(RootNode $rootNode, NodeInterface $node, CurrentObjectPath $currentObjectPath, int $currentDepth): void
{
// dummy to fulfill interface
// Implement interface
}

public function visitAfterChildren(RootNode $rootNode, NodeInterface $node, CurrentObjectPath $currentObjectPath, int $currentDepth): void
{
// dummy to fulfill interface
// Implement interface
}

private function getLanguageService(): LanguageService
Expand Down
Loading

0 comments on commit c8ecb1e

Please sign in to comment.