diff --git a/Classes/Controller/BackendController.php b/Classes/Controller/BackendController.php index 6720edb4fb69d3b925832901580c8f424d3affc1..4969af58fe2280e4767a987eac4fe2f7df9f9aea 100644 --- a/Classes/Controller/BackendController.php +++ b/Classes/Controller/BackendController.php @@ -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()); diff --git a/Classes/Domain/Model/Base.php b/Classes/Domain/Model/Base.php deleted file mode 100644 index fb4ced6584d8f57e707b5a00e1c1bc2fd8d90563..0000000000000000000000000000000000000000 --- a/Classes/Domain/Model/Base.php +++ /dev/null @@ -1,139 +0,0 @@ -<?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\Domain\Model\FileReference; -use TYPO3\CMS\Extbase\DomainObject\AbstractEntity; -use TYPO3\CMS\Extbase\Persistence\Generic\LazyLoadingProxy; - -/** - * The base model - */ -class Base extends AbstractEntity { - /** - * @var string - */ - protected $textField = ''; - - /** - * @lazy - * @var \TYPO3\CMS\Extbase\Domain\Model\FileReference - */ - protected $image = ''; - - /** - * @var string - */ - protected $textArea = ''; - - /** - * @var string - */ - protected $textAreaWithRte = ''; - - /** - * @var boolean - */ - protected $checkbox = FALSE; - - /** - * @return string - */ - public function getTextField() { - return $this->textField; - } - - /** - * @param string $textField - * @return void - */ - public function setTextField($textField) { - $this->textField = $textField; - } - - /** - * @return FileReference - */ - public function getImage() { - if ($this->image instanceof LazyLoadingProxy) { - $this->image->_loadRealInstance(); - } - return $this->image; - } - - /** - * @param FileReference $image - * @return void - */ - public function setImage(FileReference $image) { - $this->image = $image; - } - - /** - * @return string - */ - public function getTextArea() { - return $this->textArea; - } - - /** - * @param string $textArea - * @return void - */ - public function setTextArea($textArea) { - $this->textArea = $textArea; - } - - /** - * @return string - */ - public function getTextAreaWithRte() { - return $this->textAreaWithRte; - } - - /** - * @param string $textAreaWithRte - * @return void - */ - public function setTextAreaWithRte($textAreaWithRte) { - $this->textAreaWithRte = $textAreaWithRte; - } - - /** - * @return bool - */ - public function getCheckbox() { - return $this->checkbox; - } - - /** - * @param bool $checkbox - * @return void - */ - public function setCheckbox($checkbox) { - $this->checkbox = ($checkbox == TRUE); - } -} diff --git a/Classes/Domain/Model/Contact.php b/Classes/Domain/Model/Contact.php new file mode 100644 index 0000000000000000000000000000000000000000..a162e7dced8a72bcc17b4d6a6c43d2916e29b7fe --- /dev/null +++ b/Classes/Domain/Model/Contact.php @@ -0,0 +1,167 @@ +<?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 Contact model + */ +class Contact extends AbstractEntity { + /** + * @var string $firstName + */ + protected $firstName = ''; + + /** + * @var string $lastName + */ + protected $lastName = ''; + + /** + * @var string $company + */ + protected $company = ''; + + /** + * @var string $city + */ + protected $city = ''; + + /** + * @var string $zip + */ + protected $zip = ''; + + /** + * @var string $email + */ + protected $email = ''; + + /** + * @var string $phone + */ + protected $phone = ''; + + /** + * @return string + */ + public function getFirstName() { + return $this->firstName; + } + + /** + * @param string $firstName + */ + public function setFirstName(string $firstName) { + $this->firstName = $firstName; + } + + /** + * @return string + */ + public function getLastName() { + return $this->lastName; + } + + /** + * @param string $lastName + */ + public function setLastName(string $lastName) { + $this->lastName = $lastName; + } + + /** + * @return string + */ + public function getCompany() { + return $this->company; + } + + /** + * @param string $company + */ + public function setCompany(string $company) { + $this->company = $company; + } + + /** + * @return string + */ + public function getCity() { + return $this->city; + } + + /** + * @param string $city + */ + public function setCity(string $city) { + $this->city = $city; + } + + /** + * @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 getPhone() { + return $this->phone; + } + + /** + * @param string $phone + */ + public function setPhone(string $phone) { + $this->phone = $phone; + } +} diff --git a/Classes/Domain/Model/Job.php b/Classes/Domain/Model/Job.php new file mode 100644 index 0000000000000000000000000000000000000000..3ee4b8c46c0407b00bec4d1a13b2d7f1420073c7 --- /dev/null +++ b/Classes/Domain/Model/Job.php @@ -0,0 +1,166 @@ +<?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; + } +} diff --git a/Classes/Domain/Model/Location.php b/Classes/Domain/Model/Location.php new file mode 100644 index 0000000000000000000000000000000000000000..cde55b37fe6987d7420e48b26a17e02d04f54f98 --- /dev/null +++ b/Classes/Domain/Model/Location.php @@ -0,0 +1,91 @@ +<?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; + } +} diff --git a/Resources/Private/Backend/Layouts/Default.html b/Resources/Private/Backend/Layouts/Default.html index e98061c284eae143c3a2331dd7004dcfff0e029c..05547be59351dc1b135bbf578e2502e1fba049c2 100644 --- a/Resources/Private/Backend/Layouts/Default.html +++ b/Resources/Private/Backend/Layouts/Default.html @@ -1,7 +1,7 @@ {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\')}', diff --git a/Resources/Private/Backend/Partials/Filter.html b/Resources/Private/Backend/Partials/Filter.html new file mode 100644 index 0000000000000000000000000000000000000000..30f5c912eed362d8291b54b008995faedc6f6c62 --- /dev/null +++ b/Resources/Private/Backend/Partials/Filter.html @@ -0,0 +1,45 @@ +<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 diff --git a/Resources/Private/Backend/Partials/JobList.html b/Resources/Private/Backend/Partials/JobList.html new file mode 100644 index 0000000000000000000000000000000000000000..5e5383469378181292a28ca9d7c2ee1ba9402429 --- /dev/null +++ b/Resources/Private/Backend/Partials/JobList.html @@ -0,0 +1,23 @@ +<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 diff --git a/Resources/Private/Templates/Backend/Index.html b/Resources/Private/Templates/Backend/Index.html index 876a0630a58edbc21370185810a58e281da783ae..7de009eae7443b98992e467bc7d5608330d61894 100644 --- a/Resources/Private/Templates/Backend/Index.html +++ b/Resources/Private/Templates/Backend/Index.html @@ -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>