Skip to content
Snippets Groups Projects
Commit b4f3da9b authored by damjan's avatar damjan
Browse files

[FEATURE] Version selector

parent d7a9db13
No related branches found
No related tags found
No related merge requests found
......@@ -31,9 +31,9 @@ class TsrefController extends \TYPO3\Flow\Mvc\Controller\ActionController {
* The action which fetches the data for typoScript reference page, and displays the page.
*
* @param int $typeId
* @return void
* @param string $typo3Version
*/
public function indexAction($typeId = NULL) {
public function indexAction($typeId = NULL, $typo3Version = TsrefRestService::TYPO3_DEFAULT_VERSION) {
if ($typeId !== NULL) {
$selectedType = $this->tsrefRestService->getAttributeById($typeId);
$properties = $this->tsrefRestService->getPropertiesByParentId($typeId);
......@@ -47,7 +47,7 @@ class TsrefController extends \TYPO3\Flow\Mvc\Controller\ActionController {
}
}
$this->prepareTypeMenu($typeId);
$this->prepareTypeMenu($typeId, $typo3Version);
}
/**
......@@ -55,24 +55,33 @@ class TsrefController extends \TYPO3\Flow\Mvc\Controller\ActionController {
*
* @param Attribute $theType
* @param boolean $editForm
* @param string $typo3Version
* @throws \TYPO3\Flow\Mvc\Exception\ForwardException
* @return void
*/
public function submitTypeAction(Attribute $theType, $editForm) {
public function submitTypeAction(
Attribute $theType, $editForm, $typo3Version = TsrefRestService::TYPO3_DEFAULT_VERSION
) {
if ($editForm) {
$result = $this->tsrefRestService->editAttribute($theType);
} else {
$result = $this->tsrefRestService->addNewAttribute($theType);
}
// TODO: Return error message. Or success message.
$this->forward('index', 'tsref', 'SGalinski.TypoScriptReferenceFrontend', ['typeId' => $theType->getId()]);
$this->forward(
'index', 'tsref', 'SGalinski.TypoScriptReferenceFrontend',
['typeId' => $theType->getId(), 'typo3Version' => $typo3Version]
);
}
/**
* Prepares and opens the page for adding new / editing the type
*
* @param int $theTypeId
* @param string $typo3Version
* @return void
*/
public function editTypeAction($theTypeId = NULL) {
public function editTypeAction($theTypeId = NULL, $typo3Version = TsrefRestService::TYPO3_DEFAULT_VERSION) {
$theType = new Attribute();
if ($theTypeId !== NULL) {
......@@ -81,7 +90,7 @@ class TsrefController extends \TYPO3\Flow\Mvc\Controller\ActionController {
$theType->initialiseAttribute($selectedTypeAsStdClass);
}
$this->prepareTypeMenu($theTypeId);
$this->prepareTypeMenu($theTypeId, $typo3Version);
$typo3Groups = $this->tsrefRestService->getAllTypo3Groups();
$this->view->assign('typo3Groups', $typo3Groups);
......@@ -94,9 +103,14 @@ class TsrefController extends \TYPO3\Flow\Mvc\Controller\ActionController {
*
* @param Attribute $theProperty
* @param boolean $editForm
* @param string $typo3Version
* @throws \TYPO3\Flow\Mvc\Exception\ForwardException
* @return void
*/
public function submitPropertyAction(Attribute $theProperty, $editForm) {
public function submitPropertyAction(
Attribute $theProperty, $editForm,
$typo3Version = TsrefRestService::TYPO3_DEFAULT_VERSION
) {
if ($editForm) {
$result = $this->tsrefRestService->editAttribute($theProperty);
} else {
......@@ -104,7 +118,8 @@ class TsrefController extends \TYPO3\Flow\Mvc\Controller\ActionController {
}
// TODO: Return error message. Or success message.
$this->forward(
'index', 'tsref', 'SGalinski.TypoScriptReferenceFrontend', ['typeId' => $theProperty->getParent()]
'index', 'tsref', 'SGalinski.TypoScriptReferenceFrontend',
['typeId' => $theProperty->getParent(), 'typo3Version' => $typo3Version]
);
}
......@@ -113,8 +128,12 @@ class TsrefController extends \TYPO3\Flow\Mvc\Controller\ActionController {
*
* @param int $parentTypeId
* @param int $thePropertyId
* @param string $typo3Version
* @return void
*/
public function editPropertyAction($parentTypeId, $thePropertyId = NULL) {
public function editPropertyAction(
$parentTypeId, $thePropertyId = NULL, $typo3Version = TsrefRestService::TYPO3_DEFAULT_VERSION
) {
$theProperty = new Attribute();
if ($thePropertyId !== NULL) {
......@@ -124,7 +143,7 @@ class TsrefController extends \TYPO3\Flow\Mvc\Controller\ActionController {
}
$theProperty->setParent($parentTypeId);
$this->prepareTypeMenu($parentTypeId);
$this->prepareTypeMenu($parentTypeId, $typo3Version);
$typo3Groups = $this->tsrefRestService->getAllTypo3Groups();
$this->view->assign('typo3Groups', $typo3Groups);
......@@ -140,25 +159,54 @@ class TsrefController extends \TYPO3\Flow\Mvc\Controller\ActionController {
*
* @param int $attributeId
* @param int $parentTypeId
* @param string $typo3Version
* @throws \TYPO3\Flow\Mvc\Exception\ForwardException
* @return void
*/
public function deleteAttributeAction($attributeId, $parentTypeId = NULL) {
public function deleteAttributeAction(
$attributeId, $parentTypeId = NULL, $typo3Version = TsrefRestService::TYPO3_DEFAULT_VERSION
) {
$result = $this->tsrefRestService->patchAttribute($attributeId, ['deleted' => TRUE]);
// TODO: Return error message. Or success message.
$this->forward(
'index', 'tsref', 'SGalinski.TypoScriptReferenceFrontend', ['typeId' => $parentTypeId]
'index', 'tsref', 'SGalinski.TypoScriptReferenceFrontend',
['typeId' => $parentTypeId, 'typo3Version' => $typo3Version]
);
}
/**
* Submits typo3 version to be used in filtering.
*
* @param string $typo3Version
* @throws \TYPO3\Flow\Mvc\Exception\ForwardException
* @return void
*/
public function submitTypo3VersionAction($typo3Version) {
$this->redirect(
'index', 'tsref', 'SGalinski.TypoScriptReferenceFrontend', ['typo3Version' => $typo3Version]
);
}
/**
* Sets view variables needed for type menu.
*
* @param $theTypeId
* @param int $theTypeId
* @param string $selectedTypo3Version
* @return void
*/
protected function prepareTypeMenu($theTypeId) {
$types = $this->tsrefRestService->getTypes();
protected function prepareTypeMenu($theTypeId, $selectedTypo3Version) {
$typo3VersionFilter = $selectedTypo3Version;
if ($selectedTypo3Version === 'All') {
$typo3VersionFilter = NULL;
}
$types = $this->tsrefRestService->getTypes(TRUE, $typo3VersionFilter);
$typo3Versions = $this->tsrefRestService->getTypo3Versions();
$associativeTypes = Conversion::toAssociativeIdNamesArray($types);
$this->view->assign('types', $associativeTypes);
$this->view->assign('selectedTypeId', $theTypeId);
$this->view->assign('typo3Versions', $typo3Versions);
$this->view->assign('selectedTypo3Version', $selectedTypo3Version);
}
}
\ No newline at end of file
......@@ -273,4 +273,25 @@ class TsrefRestService {
Attribute::PAGE_GROUP => 'Page group',
];
}
/**
* Returns associative array of available typo3 versions.
*
* @return array
*/
public function getTypo3Versions() {
return [
self::TYPO3_DEFAULT_VERSION => 'Current',
'1.0' => '1.0',
'2.0' => '2.0',
'3.0' => '3.0',
'4.0' => '4.0',
'5.0' => '5.0',
'6.0' => '6.0',
'6.2' => '6.2',
'7.0' => '7.0',
'7.4' => '7.4',
'All' => 'All',
];
}
}
\ No newline at end of file
<div class="col-sm-3 col-md-2 sidebar">
<f:form package="SGalinski.TypoScriptReferenceFrontend" controller="tsref" action="submitTypo3Version"
class="form-inline">
<div class="form-group">
<label for="typo3Version" class="col-sm-2 control-label">TYPO3 version</label>
<div class="col-sm-10">
<f:form.select name="typo3Version" value="{selectedTypo3Version}" options="{typo3Versions}" id="typo3Version" class="form-control" />
</div>
</div>
<div class="actions">
<nav class="form-navigation">
<f:form.submit value="Submit" class="btn btn-lg btn-primary" />
</nav>
</div>
</f:form>
<div class="add-type-link">
<f:link.action package="SGalinski.TypoScriptReferenceFrontend" controller="tsref" action="editType"
arguments="{theTypeId: NULL}">
arguments="{theTypeId: NULL, typo3Version: selectedTypo3Version}">
[add type]
</f:link.action>
</div>
......@@ -9,7 +27,7 @@
<f:for each="{types}" as="typeName" key="typeId">
<li class="{f:if(condition: '{selectedTypeId} == {typeId}', then: 'active')}">
<f:link.action package="SGalinski.TypoScriptReferenceFrontend" controller="tsref" action="index"
arguments="{typeId: typeId}">
arguments="{typeId: typeId, typo3Version: selectedTypo3Version}">
{typeName}
<f:if condition="{selectedTypeId} == {typeId}">
<span class="sr-only">(current)</span>
......
......@@ -23,7 +23,7 @@
</h1>
<f:form package="SGalinski.TypoScriptReferenceFrontend" controller="tsref" action="submitProperty"
object="{theProperty}" objectName="theProperty" arguments="{editForm: '{editForm}'}" class="form-horizontal">
object="{theProperty}" objectName="theProperty" arguments="{editForm: '{editForm}', typo3Version: selectedTypo3Version}" class="form-horizontal">
<f:form.hidden property="id" />
<f:form.hidden property="parent" />
<f:form.hidden property="isType" value="FALSE" />
......
......@@ -23,7 +23,7 @@
</h1>
<f:form package="SGalinski.TypoScriptReferenceFrontend" controller="tsref" action="submitType"
object="{theType}" objectName="theType" arguments="{editForm: '{editForm}'}" class="form-horizontal">
object="{theType}" objectName="theType" arguments="{editForm: '{editForm}', typo3Version: selectedTypo3Version}" class="form-horizontal">
<f:form.hidden property="id" />
<f:form.hidden property="isType" value="TRUE" />
......
......@@ -16,12 +16,12 @@
<div class="right-side-link">
[
<f:link.action package="SGalinski.TypoScriptReferenceFrontend" controller="tsref" action="editType"
arguments="{theTypeId: selectedType.id}">
arguments="{theTypeId: selectedType.id, typo3Version: selectedTypo3Version}">
edit type
</f:link.action>
|
<f:link.action package="SGalinski.TypoScriptReferenceFrontend" controller="tsref" action="deleteAttribute"
arguments="{attributeId: selectedType.id}">
arguments="{attributeId: selectedType.id, typo3Version: selectedTypo3Version}">
delete type
</f:link.action>
]
......@@ -44,7 +44,7 @@
<f:if condition="{selectedType.parent_id}">
<f:then>
<f:link.action package="SGalinski.TypoScriptReferenceFrontend" controller="tsref" action="index"
arguments="{typeId: selectedType.parent_id}">
arguments="{typeId: selectedType.parent_id, typo3Version: selectedTypo3Version}">
{superType.name}
</f:link.action>
</f:then>
......@@ -57,7 +57,7 @@
<td class="table-left-col"><h4>Properties</h4></td>
<td class="table-right-col">
<f:link.action package="SGalinski.TypoScriptReferenceFrontend" controller="tsref" action="editProperty"
arguments="{parentTypeId: selectedType.id, thePropertyId: NULL}" class="right-side-link">
arguments="{parentTypeId: selectedType.id, thePropertyId: NULL, typo3Version: selectedTypo3Version}" class="right-side-link">
[add property]
</f:link.action>
<br>
......@@ -67,12 +67,12 @@
<div class="right-side-link">
[
<f:link.action package="SGalinski.TypoScriptReferenceFrontend" controller="tsref" action="editProperty"
arguments="{parentTypeId: selectedType.id, thePropertyId: propertyIterator.property.id}">
arguments="{parentTypeId: selectedType.id, thePropertyId: propertyIterator.property.id, typo3Version: selectedTypo3Version}">
edit property
</f:link.action>
|
<f:link.action package="SGalinski.TypoScriptReferenceFrontend" controller="tsref" action="deleteAttribute"
arguments="{ attributeId: propertyIterator.property.id, parentTypeId: selectedType.id}">
arguments="{ attributeId: propertyIterator.property.id, parentTypeId: selectedType.id, typo3Version: selectedTypo3Version}">
delete property
</f:link.action>
]
......@@ -96,7 +96,7 @@
<td class="table-left-col"><h4>Type</h4></td>
<td class="table-right-col">
<f:link.action package="SGalinski.TypoScriptReferenceFrontend" controller="tsref" action="index"
arguments="{typeId: propertyIterator.property.type_id}">
arguments="{typeId: propertyIterator.property.type_id, typo3Version: selectedTypo3Version}">
{propertyIterator.type_name}
</f:link.action>
</td>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment