Skip to content
Snippets Groups Projects
Commit 67c68895 authored by Torsten Oppermann's avatar Torsten Oppermann
Browse files

[TASK] WIP fluid templates for be module, search/filter functions, added models & repositories

parent 27d4b84d
No related branches found
No related tags found
No related merge requests found
......@@ -26,12 +26,15 @@ namespace SGalinski\SgJobs\Controller;
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use SGalinski\SgJobs\Domain\Model\Location;
use SGalinski\SgJobs\Service\BackendService;
use TYPO3\CMS\Backend\Template\Components\DocHeaderComponent;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\VersionNumberUtility;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
use TYPO3\CMS\Extbase\Persistence\QueryResultInterface;
/**
* The backend module controller
......@@ -44,6 +47,18 @@ class BackendController extends ActionController {
*/
protected $docHeaderComponent;
/**
* @var \SGalinski\SgJobs\Domain\Repository\LocationRepository
* @inject
*/
private $locationRepository;
/**
* @var \SGalinski\SgJobs\Domain\Repository\JobRepository
* @inject
*/
private $jobRepository;
/**
* The uid of the current root page
*
......@@ -58,7 +73,6 @@ class BackendController extends ActionController {
* @return void
*/
public function indexAction(array $filters = []) {
// create doc header component
try {
$pageUid = (int) GeneralUtility::_GP('id');
......@@ -72,6 +86,25 @@ class BackendController extends ActionController {
$this->docHeaderComponent->setMetaInformation($pageInfo);
BackendService::makeButtons($this->docHeaderComponent, $this->request);
// get all jobs
/** @var ObjectStorage $jobs */
$jobs = $this->jobRepository->findJobs($this->rootPageUid, $filters);
$this->view->assign('jobs', $jobs);
// get all Locations
/** @noinspection PhpUndefinedMethodInspection */
/** @var QueryResultInterface $categories */
$locations = $this->locationRepository->findByPid($this->rootPageUid);
$locationOptions = [];
/** @var Location $location */
foreach ($locations as $location) {
$locationOptions[$location->getUid()] = $location->getCity();
}
$this->view->assign('locationOptions', $locationOptions);
debug($jobs);
debug($locationOptions);
// if we are not on a root page, display the root pages to the user
if (!$this->rootPageUid) {
$this->view->assign('rootOptions', BackendService::getRootOptions());
......
<?php
namespace SGalinski\SgJobs\Domain\Model;
/***************************************************************
......@@ -25,115 +26,142 @@ namespace SGalinski\SgJobs\Domain\Model;
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use TYPO3\CMS\Extbase\Domain\Model\FileReference;
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
use TYPO3\CMS\Extbase\Persistence\Generic\LazyLoadingProxy;
/**
* The base model
* The Contact model
*/
class Base extends AbstractEntity {
class Contact extends AbstractEntity {
/**
* @var string $firstName
*/
protected $firstName = '';
/**
* @var string $lastName
*/
protected $lastName = '';
/**
* @var string
* @var string $company
*/
protected $textField = '';
protected $company = '';
/**
* @lazy
* @var \TYPO3\CMS\Extbase\Domain\Model\FileReference
* @var string $city
*/
protected $image = '';
protected $city = '';
/**
* @var string
* @var string $zip
*/
protected $textArea = '';
protected $zip = '';
/**
* @var string
* @var string $email
*/
protected $textAreaWithRte = '';
protected $email = '';
/**
* @var boolean
* @var string $phone
*/
protected $checkbox = FALSE;
protected $phone = '';
/**
* @return string
*/
public function getTextField() {
return $this->textField;
public function getFirstName() {
return $this->firstName;
}
/**
* @param string $textField
* @return void
* @param string $firstName
*/
public function setTextField($textField) {
$this->textField = $textField;
public function setFirstName(string $firstName) {
$this->firstName = $firstName;
}
/**
* @return FileReference
* @return string
*/
public function getImage() {
if ($this->image instanceof LazyLoadingProxy) {
$this->image->_loadRealInstance();
}
return $this->image;
public function getLastName() {
return $this->lastName;
}
/**
* @param FileReference $image
* @return void
* @param string $lastName
*/
public function setImage(FileReference $image) {
$this->image = $image;
public function setLastName(string $lastName) {
$this->lastName = $lastName;
}
/**
* @return string
*/
public function getTextArea() {
return $this->textArea;
public function getCompany() {
return $this->company;
}
/**
* @param string $textArea
* @return void
* @param string $company
*/
public function setTextArea($textArea) {
$this->textArea = $textArea;
public function setCompany(string $company) {
$this->company = $company;
}
/**
* @return string
*/
public function getTextAreaWithRte() {
return $this->textAreaWithRte;
public function getCity() {
return $this->city;
}
/**
* @param string $textAreaWithRte
* @return void
* @param string $city
*/
public function setTextAreaWithRte($textAreaWithRte) {
$this->textAreaWithRte = $textAreaWithRte;
public function setCity(string $city) {
$this->city = $city;
}
/**
* @return bool
* @return string
*/
public function getZip() {
return $this->zip;
}
/**
* @param string $zip
*/
public function setZip(string $zip) {
$this->zip = $zip;
}
/**
* @return string
*/
public function getEmail() {
return $this->email;
}
/**
* @param string $email
*/
public function setEmail(string $email) {
$this->email = $email;
}
/**
* @return string
*/
public function getCheckbox() {
return $this->checkbox;
public function getPhone() {
return $this->phone;
}
/**
* @param bool $checkbox
* @return void
* @param string $phone
*/
public function setCheckbox($checkbox) {
$this->checkbox = ($checkbox == TRUE);
public function setPhone(string $phone) {
$this->phone = $phone;
}
}
<?php
namespace SGalinski\SgJobs\Domain\Model;
/***************************************************************
* Copyright notice
*
* (c) sgalinski Internet Services (https://www.sgalinski.de)
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
/**
* The Job model
*/
class Job extends AbstractEntity {
/**
* @var string $title
*/
protected $title = '';
/**
* @var string $subtitle
*/
protected $subtitle = '';
/**
* @var int $startDate
*/
protected $startDate = 0;
/**
* @var string $company
*/
protected $company = '';
/**
* @var string $title
*/
protected $description = '';
/**
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\SGalinski\SgJobs\Domain\Model\Location> $location
*/
protected $location;
/**
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\SGalinski\SgJobs\Domain\Model\Contact> $contact
*/
protected $contact;
/**
* @return string
*/
public function getTitle() {
return $this->title;
}
/**
* @param string $title
*/
public function setTitle(string $title) {
$this->title = $title;
}
/**
* @return string
*/
public function getSubtitle() {
return $this->subtitle;
}
/**
* @param string $subtitle
*/
public function setSubtitle(string $subtitle) {
$this->subtitle = $subtitle;
}
/**
* @return int
*/
public function getStartDate() {
return $this->startDate;
}
/**
* @param int $startDate
*/
public function setStartDate(int $startDate) {
$this->startDate = $startDate;
}
/**
* @return string
*/
public function getCompany() {
return $this->company;
}
/**
* @param string $company
*/
public function setCompany(string $company) {
$this->company = $company;
}
/**
* @return string
*/
public function getDescription() {
return $this->description;
}
/**
* @param string $description
*/
public function setDescription(string $description) {
$this->description = $description;
}
/**
* @return ObjectStorage
*/
public function getLocation() {
return $this->location;
}
/**
* @param ObjectStorage $location
*/
public function setLocation(ObjectStorage $location) {
$this->location = $location;
}
/**
* @return ObjectStorage
*/
public function getContact() {
return $this->contact;
}
/**
* @param ObjectStorage $contact
*/
public function setContact(ObjectStorage $contact) {
$this->contact = $contact;
}
}
<?php
namespace SGalinski\SgJobs\Domain\Model;
/***************************************************************
* Copyright notice
*
* (c) sgalinski Internet Services (https://www.sgalinski.de)
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
/**
* The Location model
*/
class Location extends AbstractEntity {
/**
* @var string $city
*/
protected $city = '';
/**
* @var string $country
*/
protected $country = '';
/**
* @var string $description
*/
protected $description = '';
/**
* @return string
*/
public function getCity() {
return $this->city;
}
/**
* @param string $city
*/
public function setCity(string $city) {
$this->city = $city;
}
/**
* @return string
*/
public function getCountry() {
return $this->country;
}
/**
* @param string $country
*/
public function setCountry(string $country) {
$this->country = $country;
}
/**
* @return string
*/
public function getDescription() {
return $this->description;
}
/**
* @param string $description
*/
public function setDescription(string $description) {
$this->description = $description;
}
}
{namespace core = TYPO3\CMS\Core\ViewHelpers}
{namespace sg=SGalinski\SgJobs\ViewHelpers}
<f:be.container enableClickMenu="TRUE" loadExtJs="TRUE"
<f:be.container enableClickMenu="FALSE" loadExtJs="FALSE"
includeRequireJsModules="{
0: 'TYPO3/CMS/Backend/AjaxDataHandler',
1: '{f:if(condition: \'{typo3Version} < 8000000 \', then: \'TYPO3/CMS/Backend/ClickMenu\', else: \'TYPO3/CMS/Backend/ContextMenu\')}',
......
<f:form action="list" controller="Route" method="post" objectName="filters" object="{filters}">
<div class="row">
<div class="col-xs-6">
<div class="form-group">
<label for="filter-locations">
<f:translate key="backend.filters.locations" />
</label>
<f:form.select class="form-control" multiple="1" size="4" property="locations" options="{locationOptions}" id="filter-locations" />
<small>
<f:format.raw><f:translate key="backend.filters.locations.description" />
</f:format.raw>
</small>
<script>
var LocationEditLinks = {};
</script>
<f:for each="{locationOptions}" key="uid" as="location">
<script>
LocationEditLinks["{uid}"] = "{sg:backend.editLink(table: 'tx_sgroutes_domain_model_location', uid: uid) -> f:format.raw()}";
</script>
</f:for>
<br />
<a href="#" class="btn btn-default" onclick="editSelectedLocation();">
<span class="t3js-icon icon icon-size-small icon-state-default icon-actions-document-new">
<span class="icon-markup">
<img src="/typo3/sysext/core/Resources/Public/Icons/T3Icons/actions/actions-document-open.svg" width="16" height="16">
</span>
</span>
<f:translate key="backend.filters.editCategory" />
</a>
</div>
</div>
<div class="col-xs-6">
<div class="form-group">
<label for="filter-search"><f:translate key="backend.filters.search" /></label>
<f:form.textfield class="form-control" property="search" id="filter-search" />
</div>
<div class="form-inline">
<f:form.button class="btn btn-success form-group pull-right" type="submit" additionalAttributes="{style: 'min-width: 150px;'}">
<f:translate key="backend.filter" />
</f:form.button>
</div>
</div>
</div>
</f:form>
\ No newline at end of file
<p>
<f:translate key="backend.message.sorting" />
</p>
<div class="panel panel-default recordlist">
<div class="table-fit">
<table data-table="tx_sgroutes_domain_model_job" class="table table-striped table-hover">
<sg:backend.widget.paginate objects="{jobs}" as="paginatedJobs" configuration="{insertAbove: 1, itemsPerPage: 20}">
<tbody>
<f:for each="{paginatedJobs}" as="job">
{sg:backend.editOnClick(table: 'tx_sgroutes_domain_model_job', uid: job.uid) -> sg:set(name: 'editOnClick')}
<tr data-uid="{job.uid}">
<td style="white-space: normal;">
<a href="#" onclick="{editOnClick}">
<span>{job.title} - {job.subtitle}</span>
</a>
</td>
</tr>
</f:for>
</tbody>
</sg:backend.widget.paginate>
</table>
</div>
</div>
\ No newline at end of file
......@@ -10,55 +10,18 @@
<f:section name="content">
<f:if condition="{rootPageUid}">
<f:then>
<f:form action="list" controller="Route" method="post" objectName="filters" object="{filters}">
<div class="row">
<div class="col-xs-6">
<div class="form-group">
<label for="filter-locations">
<f:translate key="backend.filters.locations" />
</label>
<f:form.select class="form-control" multiple="1" size="4" property="locations" options="{locationOptions}" id="filter-locations" />
<small>
<f:format.raw><f:translate key="backend.filters.locations.description" />
</f:format.raw>
</small>
<script>
var LocationEditLinks = {};
</script>
<f:for each="{locationOptions}" key="uid" as="location">
<script>
LocationEditLinks["{uid}"] = "{sg:backend.editLink(table: 'tx_sgroutes_domain_model_location', uid: uid) -> f:format.raw()}";
</script>
</f:for>
<br />
<a href="#" class="btn btn-default" onclick="editSelectedLocation();">
<span class="t3js-icon icon icon-size-small icon-state-default icon-actions-document-new">
<span class="icon-markup">
<img src="/typo3/sysext/core/Resources/Public/Icons/T3Icons/actions/actions-document-open.svg" width="16" height="16">
</span>
</span>
<f:translate key="backend.filters.editCategory" />
</a>
</div>
</div>
<div class="col-xs-6">
<div class="form-group">
<label for="filter-search"><f:translate key="backend.filters.search" /></label>
<f:form.textfield class="form-control" property="search" id="filter-search" />
</div>
<div class="form-inline">
<f:form.button class="btn btn-success form-group pull-right" type="submit" additionalAttributes="{style: 'min-width: 150px;'}">
<f:translate key="backend.filter" />
</f:form.button>
</div>
</div>
</div>
</f:form>
<f:render partial="Filter" arguments="{filters: filters, locationOptions: locationOptions}" />
<f:if condition="{jobs}">
<f:then>
<f:render partial="JobList" arguments="{jobs: jobs}" />
</f:then>
<f:else>
<p>
<f:translate key="backend.noJobsMessage" />
</p>
</f:else>
</f:if>
</f:then>
<f:else>
<f:render partial="SelectRoot" arguments="{pages: rootOptions}" />
</f:else>
......
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