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

[FEATURE] Edit/add type form

parent 76758bb1
No related branches found
No related tags found
No related merge requests found
......@@ -9,6 +9,7 @@ namespace SGalinski\TypoScriptReferenceFrontend\Controller;
use SGalinski\TypoScriptReferenceFrontend\Domain\Model\Attribute;
use SGalinski\TypoScriptReferenceFrontend\Service\TsrefRestService;
use SGalinski\TypoScriptReferenceFrontend\Utilities\Conversion;
use TYPO3\Flow\Annotations as Flow;
class TsrefController extends \TYPO3\Flow\Mvc\Controller\ActionController {
......@@ -54,10 +55,16 @@ class TsrefController extends \TYPO3\Flow\Mvc\Controller\ActionController {
* Adds a new type.
*
* @param Attribute $theType
* @param boolean $editForm
* @return void
*/
public function submitNewTypeAction(Attribute $theType) {
public function submitTypeAction(Attribute $theType, $editForm) {
if ($editForm) {
//TODO: Call edit service method
} else {
$this->tsrefRestService->addNewAttribute($theType);
}
$this->forward('index', 'tsref', 'SGalinski.TypoScriptReferenceFrontend');
}
/**
......@@ -78,7 +85,13 @@ class TsrefController extends \TYPO3\Flow\Mvc\Controller\ActionController {
}
$types = $this->tsrefRestService->getTypes();
$associativeTypes = Conversion::toAssociativeIdNamesArray($types);
$typo3Groups = $this->tsrefRestService->getAllTypo3Groups();
$this->view->assign('typo3Groups', $typo3Groups);
$this->view->assign('associativeTypes', $associativeTypes); // TODO: Use this array also for rendering menu.
$this->view->assign('types', $types);
$this->view->assign('theType', $theType);
$this->view->assign('editForm', $theTypeId !== NULL);
}
}
\ No newline at end of file
......@@ -127,10 +127,10 @@ class TsrefRestService {
}
/**
* Gets all type attributes by $typo3Version and $typo3Group from RESOURCE_URL
* Gets attribute by id.
*
* @param int $attributeId
* @return mixed
* @return \stdClass
*/
public function getAttributeById($attributeId) {
$attributeJson = $this->getAttributeByIdJson($attributeId);
......@@ -192,4 +192,17 @@ class TsrefRestService {
return $output;
}
/**
* Returns associative array of all typo3 groups.
*
* @return array
*/
public function getAllTypo3Groups() {
return [
Attribute::NORMAL_GROUP => 'Normal group',
Attribute::USER_GROUP => 'User group',
Attribute::PAGE_GROUP => 'Page group',
];
}
}
\ No newline at end of file
......@@ -12,7 +12,7 @@
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
<h1 class="page-header">
<f:if condition="{theType.id}">
<f:if condition="{editForm}">
<f:then>
Edit type: {theType.name}
</f:then>
......@@ -22,19 +22,66 @@
</f:if>
</h1>
<f:debug title="theType.name">{theType.name}</f:debug>
<f:form package="SGalinski.TypoScriptReferenceFrontend" controller="tsref" action="submitType"
object="{theType}" objectName="theType" arguments="{editForm: '{editForm}'}" class="form-horizontal">
<f:form.hidden property="id" />
<f:form.hidden property="isType" value="TRUE" />
<f:form action="submitNewType" object="{theType}" objectName="theType">
{theType.name}
<f:form.textfield property="name" id="name" />
{name}
<f:debug title="name">{name}</f:debug>
<div class="form-group">
<label for="name" class="col-sm-2 control-label required">Name</label>
<div class="col-sm-10">
<f:form.textfield property="name" id="name" required="TRUE" class="form-control" />
</div>
</div>
<f:form.submit value="Submit" />
<div class="form-group">
<label for="description" class="col-sm-2 control-label">Description</label>
<div class="col-sm-10">
<f:form.textarea property="description" id="description" class="form-control" />
</div>
</div>
<div class="form-group">
<label for="minVersion" class="col-sm-2 control-label">MinVersion</label>
<div class="col-sm-10">
<f:form.textfield property="minVersion" id="minVersion" class="form-control" />
</div>
</div>
<div class="form-group">
<label for="maxVersion" class="col-sm-2 control-label">MaxVersion</label>
<div class="col-sm-10">
<f:form.textfield property="maxVersion" id="maxVersion" class="form-control" />
</div>
</div>
<div class="form-group">
<label for="typo3Group" class="col-sm-2 control-label">Typo3Group</label>
<div class="col-sm-10">
<f:form.select property="typo3Group" options="{typo3Groups}" id="typo3Group" class="form-control" />
</div>
</div>
<div class="form-group">
<label for="extends" class="col-sm-2 control-label">Extends</label>
<div class="col-sm-10">
<f:form.select property="parent" options="{associativeTypes}" id="extends" 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>
</div>
</div>
</div>
</f:section>
\ No newline at end of file
......@@ -17,6 +17,11 @@
arguments="{theTypeId: selectedType.id}">
Edit type
</f:link.action>
|
<f:link.action package="SGalinski.TypoScriptReferenceFrontend" controller="tsref" action="editType"
arguments="{theTypeId: NULL, editForm: FALSE}">
Add type
</f:link.action>
<p>
{selectedType.description}
......
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