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

[FEATURE] EditType form (IN PROGRESS)

parent bbce6055
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,7 @@ namespace SGalinski\TypoScriptReferenceFrontend\Controller;
* *
* */
use SGalinski\TypoScriptReferenceFrontend\Domain\Model\Attribute;
use SGalinski\TypoScriptReferenceFrontend\Service\TsrefRestService;
use TYPO3\Flow\Annotations as Flow;
......@@ -38,6 +39,7 @@ class TsrefController extends \TYPO3\Flow\Mvc\Controller\ActionController {
$this->view->assign('properties', $properties);
$this->view->assign('selectedType', $selectedType);
// If the type extends a type (superType), the superType name is being fetched among other fields
if (isset($selectedType->parent_id)) {
$superType = $this->tsrefRestService->getAttributeById($selectedType->parent_id);
$this->view->assign('superType', $superType);
......@@ -47,4 +49,36 @@ class TsrefController extends \TYPO3\Flow\Mvc\Controller\ActionController {
$types = $this->tsrefRestService->getTypes();
$this->view->assign('types', $types);
}
/**
* Adds a new type.
*
* @param Attribute $theType
* @return void
*/
public function submitNewTypeAction(Attribute $theType) {
}
/**
* Prepares and opens the page for adding new / editing the type
* @param int $theTypeId
*/
public function editTypeAction($theTypeId = NULL) {
$theType = new Attribute();
if ($theTypeId !== NULL) {
// Edit type
$selectedTypeAsStdClass = $this->tsrefRestService->getAttributeById($theTypeId);
$theType->initialiseAttribute($selectedTypeAsStdClass);
$this->view->assign('selectedType', $selectedTypeAsStdClass);
} else {
// Add new type
}
$types = $this->tsrefRestService->getTypes();
$this->view->assign('types', $types);
$this->view->assign('theType', $theType);
}
}
\ No newline at end of file
......@@ -84,6 +84,13 @@ class Attribute {
*/
private $deleted = FALSE;
/**
* @param int $id
*/
public function setId($id) {
$this->id = $id;
}
/**
* Get id
*
......@@ -363,4 +370,69 @@ class Attribute {
}
return $attributeArray;
}
/**
* Initialises the attribute from the stdClass argument.
*
* @param \stdClass $attribute
*/
public function initialiseAttribute(\stdClass $attribute) {
if (isset($attribute->id)) {
$this->id = $attribute->id;
} else {
$this->id = NULL;
}
if (isset($attribute->name)) {
$this->name = $attribute->name;
} else {
$this->name = NULL;
}
if (isset($attribute->description)) {
$this->description = $attribute->description;
} else {
$this->name = NULL;
}
if (isset($attribute->default)) {
$this->default = $attribute->default;
} else {
$this->name = NULL;
}
if (isset($attribute->minVersion)) {
$this->minVersion = $attribute->minVersion;
} else {
$this->minVersion = NULL;
}
if (isset($attribute->maxVersion)) {
$this->maxVersion = $attribute->maxVersion;
} else {
$this->maxVersion = NULL;
}
if (isset($attribute->parent)) {
$this->parent = new Attribute();
$this->parent->setId($attribute->parent);
} else {
$this->parent = NULL;
}
if (isset($attribute->type)) {
$this->type = new Attribute();
$this->type->setId($attribute->type);
} else {
$this->type = NULL;
}
if (isset($attribute->typo3Group)) {
$this->typo3Group = $attribute->typo3Group;
} else {
$this->typo3Group = NULL;
}
if (isset($attribute->deleted)) {
$this->deleted = $attribute->deleted;
} else {
$this->deleted = NULL;
}
if (isset($attribute->isType)) {
$this->isType = $attribute->isType;
} else {
$this->isType = NULL;
}
}
}
<f:layout name="Default" />
<f:section name="Javascripts"></f:section>
<f:section name="Title">TypoScript reference</f:section>
<f:section name="Content">
<f:render partial="ResourcesInclusion" arguments="{_all}" />
<div class="container-fluid">
<div class="row">
<f:render partial="NavigationSidebar" arguments="{_all}" />
<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:then>
Edit type: {theType.name}
</f:then>
<f:else>
Add new type
</f:else>
</f:if>
</h1>
<f:debug title="theType.name">{theType.name}</f:debug>
<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>
<f:form.submit value="Submit" />
</f:form>
</div>
</div>
</div>
</div>
</f:section>
\ No newline at end of file
......@@ -13,6 +13,11 @@
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
<h1 class="page-header">{selectedType.name}</h1>
<f:link.action package="SGalinski.TypoScriptReferenceFrontend" controller="tsref" action="editType"
arguments="{theTypeId: selectedType.id}">
Edit type
</f:link.action>
<p>
{selectedType.description}
</p>
......
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