From ee79e75aa7c58a40f98b01691d573f85acc119d9 Mon Sep 17 00:00:00 2001 From: Torsten Oppermann <torsten@sgalinski.de> Date: Thu, 16 Nov 2017 18:06:10 +0100 Subject: [PATCH] [TASK] Working on filters + file upload, add alternative entry date field --- Classes/Controller/JoblistController.php | 32 ++++++- Classes/Domain/Model/Job.php | 19 ++++ .../Domain/Repository/CompanyRepository.php | 61 +++++++++++++ Classes/Domain/Repository/JobRepository.php | 42 +++++++++ .../TCA/tx_sgjobs_domain_model_job.php | 17 +++- .../Private/Backend/Layouts/Default.html | 2 +- .../Private/Language/de.locallang_db.xlf | 4 + Resources/Private/Language/locallang_db.xlf | 3 + Resources/Private/Partials/Filter.html | 2 +- Resources/Private/Partials/Job.html | 18 +++- .../Private/Templates/Joblist/Index.html | 5 +- Resources/Public/JavaScript/sgjobs.js | 12 +++ Resources/Public/Scripts/Backend.js | 88 ------------------- ext_tables.sql | 1 + 14 files changed, 208 insertions(+), 98 deletions(-) create mode 100644 Resources/Public/JavaScript/sgjobs.js delete mode 100644 Resources/Public/Scripts/Backend.js diff --git a/Classes/Controller/JoblistController.php b/Classes/Controller/JoblistController.php index 4dd7dd23..c8a65a5a 100644 --- a/Classes/Controller/JoblistController.php +++ b/Classes/Controller/JoblistController.php @@ -33,6 +33,7 @@ use TYPO3\CMS\Core\Resource\ResourceFactory; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; use TYPO3\CMS\Core\Utility\File\ExtendedFileUtility; +use TYPO3Fluid\Fluid\View\ViewInterface; /** * The joblist plugin controller @@ -65,9 +66,12 @@ class JoblistController extends ActionController { */ public function indexAction() { $pageUid = (int) GeneralUtility::_GP('id'); + $rootPageId = BackendService::getRootUidByPageUid($pageUid); + + $this->assignFilterValues($rootPageId); // get all jobs for the next root page - $jobs = $this->jobRepository->findJobs(BackendService::getRootUidByPageUid($pageUid)); + $jobs = $this->jobRepository->findJobs($rootPageId); $this->view->assign('jobs', $jobs); } @@ -106,6 +110,32 @@ class JoblistController extends ActionController { } } + /** + * @param int $rootPageId + * @param array $filterValues + */ + private function assignFilterValues($rootPageId, $filterValues = []) { + // get all countries + $countries = $this->companyRepository->getAllCountries($rootPageId); + $this->view->assign('countries', $countries); + + // get all cities + $cities = $this->companyRepository->getAllCities($rootPageId); + $this->view->assign('cities', $cities); + + // get all cities + $companies = $this->companyRepository->getAllCompanyNames($rootPageId); + $this->view->assign('companies', $companies); + + // get all areas + $areas = $this->jobRepository->getAllAreas($rootPageId); + $this->view->assign('areas', $areas); + + // get all areas + $functions = $this->jobRepository->getAllFunctions($rootPageId); + $this->view->assign('functions', $functions); + } + /** * @param array $applyData * @return array diff --git a/Classes/Domain/Model/Job.php b/Classes/Domain/Model/Job.php index c90fe88a..7428dce8 100644 --- a/Classes/Domain/Model/Job.php +++ b/Classes/Domain/Model/Job.php @@ -58,6 +58,11 @@ class Job extends AbstractEntity { */ protected $function = ''; + /** + * @var string $alternativeStartDate + */ + protected $alternativeStartDate = ''; + /** * @var int $startDate */ @@ -203,4 +208,18 @@ class Job extends AbstractEntity { public function setFunction(string $function) { $this->function = $function; } + + /** + * @return string + */ + public function getAlternativeStartDate() { + return $this->alternativeStartDate; + } + + /** + * @param string $alternativeStartDate + */ + public function setAlternativeStartDate(string $alternativeStartDate) { + $this->alternativeStartDate = $alternativeStartDate; + } } diff --git a/Classes/Domain/Repository/CompanyRepository.php b/Classes/Domain/Repository/CompanyRepository.php index e93fa2c8..a05c5eb1 100644 --- a/Classes/Domain/Repository/CompanyRepository.php +++ b/Classes/Domain/Repository/CompanyRepository.php @@ -26,6 +26,7 @@ namespace SGalinski\SgJobs\Domain\Repository; * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ +use TYPO3\CMS\Core\Database\DatabaseConnection; use TYPO3\CMS\Extbase\Persistence\Repository; /** @@ -43,4 +44,64 @@ class CompanyRepository extends Repository { $querySettings->setEnableFieldsToBeIgnored(['disabled']); $this->setDefaultQuerySettings($querySettings); } + + /** + * @param int $pageUid + * @return mixed + */ + public function getAllCountries($pageUid) { + /** @var DatabaseConnection $db */ + $db = $GLOBALS['TYPO3_DB']; + $result = $db->exec_SELECTquery( + 'country', 'tx_sgjobs_domain_model_company', 'pid = ' . $pageUid, 'country' + )->fetch_all(); + + $countryArray = []; + $countryArray[] = ''; + foreach($result as $country) { + $countryArray[] = $country[0]; + } + + return $countryArray; + } + + /** + * @param int $pageUid + * @return mixed + */ + public function getAllCities($pageUid) { + /** @var DatabaseConnection $db */ + $db = $GLOBALS['TYPO3_DB']; + $result = $db->exec_SELECTquery( + 'city', 'tx_sgjobs_domain_model_company', 'pid = ' . $pageUid, 'city' + )->fetch_all(); + + $cityArray = []; + $cityArray[] = ''; + foreach($result as $city) { + $cityArray[] = $city[0]; + } + + return $cityArray; + } + + /** + * @param int $pageUid + * @return mixed + */ + public function getAllCompanyNames($pageUid) { + /** @var DatabaseConnection $db */ + $db = $GLOBALS['TYPO3_DB']; + $result = $db->exec_SELECTquery( + 'name', 'tx_sgjobs_domain_model_company', 'pid = ' . $pageUid, 'name' + )->fetch_all(); + + $namesArray = []; + $namesArray[] = ''; + foreach($result as $name) { + $namesArray[] = $name[0]; + } + + return $namesArray; + } } diff --git a/Classes/Domain/Repository/JobRepository.php b/Classes/Domain/Repository/JobRepository.php index 20e1eaab..753f1331 100644 --- a/Classes/Domain/Repository/JobRepository.php +++ b/Classes/Domain/Repository/JobRepository.php @@ -26,6 +26,7 @@ namespace SGalinski\SgJobs\Domain\Repository; * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ +use TYPO3\CMS\Core\Database\DatabaseConnection; use TYPO3\CMS\Extbase\Persistence\QueryInterface; use TYPO3\CMS\Extbase\Persistence\Repository; @@ -98,4 +99,45 @@ class JobRepository extends Repository { return $query->execute($raw); } + + + /** + * @param int $pageUid + * @return mixed + */ + public function getAllAreas($pageUid) { + /** @var DatabaseConnection $db */ + $db = $GLOBALS['TYPO3_DB']; + $result = $db->exec_SELECTquery( + 'area', 'tx_sgjobs_domain_model_job', 'pid = ' . $pageUid, 'area' + )->fetch_all(); + + $areaArray = []; + $areaArray[] = ''; + foreach($result as $area) { + $areaArray[] = $area[0]; + } + + return $areaArray; + } + + /** + * @param int $pageUid + * @return mixed + */ + public function getAllFunctions($pageUid) { + /** @var DatabaseConnection $db */ + $db = $GLOBALS['TYPO3_DB']; + $result = $db->exec_SELECTquery( + 'function', 'tx_sgjobs_domain_model_job', 'pid = ' . $pageUid, 'function' + )->fetch_all(); + + $functionArray = []; + $functionArray[] = ''; + foreach($result as $function) { + $functionArray[] = $function[0]; + } + + return $functionArray; + } } diff --git a/Configuration/TCA/tx_sgjobs_domain_model_job.php b/Configuration/TCA/tx_sgjobs_domain_model_job.php index df9615af..91fb782d 100644 --- a/Configuration/TCA/tx_sgjobs_domain_model_job.php +++ b/Configuration/TCA/tx_sgjobs_domain_model_job.php @@ -8,7 +8,7 @@ return [ 'crdate' => 'crdate', 'cruser_id' => 'cruser_id', 'dividers2tabs' => TRUE, - 'searchFields' => 'title, start_date, company, contact, area, function', + 'searchFields' => 'title, start_date, alternative_start_date, company, contact, area, function', 'versioningWS' => 2, 'versioning_followPages' => TRUE, 'origUid' => 't3_origuid', @@ -26,12 +26,12 @@ return [ 'Resources/Public/Icons/tx_sgjobs_domain_model_job.svg' ], 'interface' => [ - 'showRecordFieldList' => 'sys_language_uid, l10n_parent, l10n_diffsource, hidden, pid, title, area, function, start_date, + 'showRecordFieldList' => 'sys_language_uid, l10n_parent, l10n_diffsource, hidden, pid, title, area, function, start_date, alternative_start_date, company, task, qualification, description, contact', ], 'types' => [ '1' => [ - 'showitem' => '--palette--;;sysLanguageAndHidden,--palette--;;pallete_title_start,,--palette--;;pallete_area_function, + 'showitem' => '--palette--;;sysLanguageAndHidden,title, --palette--;;pallete_title_start,,--palette--;;pallete_area_function, --palette--;;pallete_location_contact, description, --div--; LLL:EXT:sg_jobs/Resources/Private/Language/locallang_db.xlf:tca.qualification_tab, task, qualification, div;;richtext[*]:rte_transform[mode=ts], --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.access, starttime, endtime', ], @@ -41,7 +41,7 @@ return [ 'showitem' => 'sys_language_uid;;;;1-1-1, l10n_diffsource, hidden;;1, ', 'canNotCollapse' => 1, ], - 'pallete_title_start' => ['showitem' => 'title, start_date', 'canNotCollapse' => 1], + 'pallete_title_start' => ['showitem' => 'start_date, alternative_start_date', 'canNotCollapse' => 1], 'pallete_area_function' => ['showitem' => 'area, function', 'canNotCollapse' => 1], 'pallete_location_contact' => ['showitem' => 'company, contact', 'canNotCollapse' => 1] ], @@ -167,6 +167,15 @@ return [ ], ], ], + 'alternative_start_date' => [ + 'exclude' => 0, + 'label' => 'LLL:EXT:sg_jobs/Resources/Private/Language/locallang_db.xlf:tx_sgjobs_domain_model_job.alternative_start_date', + 'config' => [ + 'type' => 'input', + 'size' => 30, + 'eval' => 'trim' + ], + ], 'task' => [ 'exclude' => 0, 'label' => 'LLL:EXT:sg_jobs/Resources/Private/Language/locallang_db.xlf:tx_sgjobs_domain_model_job.task', diff --git a/Resources/Private/Backend/Layouts/Default.html b/Resources/Private/Backend/Layouts/Default.html index aa5a5d45..a56cc9e6 100644 --- a/Resources/Private/Backend/Layouts/Default.html +++ b/Resources/Private/Backend/Layouts/Default.html @@ -7,7 +7,7 @@ 1: '{f:if(condition: \'{typo3Version} < 8000000 \', then: \'TYPO3/CMS/Backend/ClickMenu\', else: \'TYPO3/CMS/Backend/ContextMenu\')}', 2: 'TYPO3/CMS/Backend/Tooltip'}" includeJsFiles="{ - 0: '{f:uri.resource(path: \'Scripts/Backend.js\')}' + 0: '{f:uri.resource(path: \'JavaScript/backend.js\')}' }"> <div class="module" data-module-id="" data-module-name=""> diff --git a/Resources/Private/Language/de.locallang_db.xlf b/Resources/Private/Language/de.locallang_db.xlf index 603dfd4b..720663b8 100644 --- a/Resources/Private/Language/de.locallang_db.xlf +++ b/Resources/Private/Language/de.locallang_db.xlf @@ -101,6 +101,10 @@ <source>Job offer</source> <target>Stellenanzeige</target> </trans-unit> + <trans-unit id="tx_sgjobs_domain_model_job.alternative_start_date" approved="yes"> + <source>Alternative start date</source> + <target>Alternatives Eintrittszeitpunkt</target> + </trans-unit> <trans-unit id="tx_sgjobs_domain_model_job.area" approved="yes"> <source>Area</source> <target>Bereich</target> diff --git a/Resources/Private/Language/locallang_db.xlf b/Resources/Private/Language/locallang_db.xlf index e07f8904..ae9baa3d 100644 --- a/Resources/Private/Language/locallang_db.xlf +++ b/Resources/Private/Language/locallang_db.xlf @@ -78,6 +78,9 @@ <trans-unit id="tx_sgjobs_domain_model_job"> <source>Job offer</source> </trans-unit> + <trans-unit id="tx_sgjobs_domain_model_job.alternative_start_date"> + <source>Alternative start date</source> + </trans-unit> <trans-unit id="tx_sgjobs_domain_model_job.area"> <source>Area</source> </trans-unit> diff --git a/Resources/Private/Partials/Filter.html b/Resources/Private/Partials/Filter.html index 79096ed2..94a020fb 100644 --- a/Resources/Private/Partials/Filter.html +++ b/Resources/Private/Partials/Filter.html @@ -1,6 +1,6 @@ <f:form id="sgjobs-filter" action="index" controller="Joblist" method="post" objectName="filters" object="{filters}"> <f:form.select class="sgjobs-select form-control" multiple="0" size="1" property="filterCountry" optionValueField="key" options="{countries}" id="filter-countries" /> - <f:form.select class="sgjobs-select form-control" multiple="0" size="1" property="filterLocation" optionValueField="key" options="{locations}" id="filter-locations" /> + <f:form.select class="sgjobs-select form-control" multiple="0" size="1" property="filterLocation" optionValueField="key" options="{cities}" id="filter-locations" /> <f:form.select class="sgjobs-select form-control" multiple="0" size="1" property="filterCompany" optionValueField="key" options="{companies}" id="filter-companies" /> <f:form.select class="sgjobs-select form-control" multiple="0" size="1" property="filterArea" optionValueField="key" options="{areas}" id="filter-areas" /> <f:form.select class="sgjobs-select form-control" multiple="0" size="1" property="filterFunction" optionValueField="key" options="{functions}" id="filter-functions" /> diff --git a/Resources/Private/Partials/Job.html b/Resources/Private/Partials/Job.html index 8f39a327..dcfb1868 100644 --- a/Resources/Private/Partials/Job.html +++ b/Resources/Private/Partials/Job.html @@ -1,7 +1,14 @@ <div> <h3>{job.title}</h3> <h4> - <f:format.date date="{job.startDate}" format="d.m.Y" /> + <f:if condition="{job.alternativeStartDate}"> + <f:then> + {job.alternativeStartDate} + </f:then> + <f:else> + <f:format.date date="{job.startDate}" format="d.m.Y" /> + </f:else> + </f:if> - {job.company.0.city} </h4> </div> @@ -45,7 +52,14 @@ <f:translate key="frontend.entry_date" /> </td> <td> - <f:format.date date="{job.startDate}" format="d.m.Y" /> + <f:if condition="{job.alternativeStartDate}"> + <f:then> + {job.alternativeStartDate} + </f:then> + <f:else> + <f:format.date date="{job.startDate}" format="d.m.Y" /> + </f:else> + </f:if> </td> </tr> </table> diff --git a/Resources/Private/Templates/Joblist/Index.html b/Resources/Private/Templates/Joblist/Index.html index dab56883..97312204 100644 --- a/Resources/Private/Templates/Joblist/Index.html +++ b/Resources/Private/Templates/Joblist/Index.html @@ -2,7 +2,10 @@ <f:section name="main"> - <f:render partial="Filter" arguments="{filters: filters}" /> + <f:render + partial="Filter" + arguments="{filters: filters, countries: countries, cities: cities, companies: companies, areas: areas, functions: functions}" + /> <div id="job-offer"> <f:for each="{jobs}" as="job"> diff --git a/Resources/Public/JavaScript/sgjobs.js b/Resources/Public/JavaScript/sgjobs.js new file mode 100644 index 00000000..f000fccc --- /dev/null +++ b/Resources/Public/JavaScript/sgjobs.js @@ -0,0 +1,12 @@ +module.exports = function() { + + 'use strict'; + + const $ = require('jquery'); + + let SgJobs = {}; + + SgJobs.init = function() { + + } +}; diff --git a/Resources/Public/Scripts/Backend.js b/Resources/Public/Scripts/Backend.js deleted file mode 100644 index 08b48a79..00000000 --- a/Resources/Public/Scripts/Backend.js +++ /dev/null @@ -1,88 +0,0 @@ -(function($) { - function deleteAllListener(_event) { - _event.preventDefault(); - - var confirm = SG.lang.SgRoutes['backend.delete_all']; - if (window.confirm(confirm)) { - window.location = $(_event.currentTarget).attr('href'); - } - } - - $(document).ready(function() { - $('.btn-delete-all').on('click', deleteAllListener); - }); -})(TYPO3.jQuery); - -// functions for backend docheader functionality -function jumpExt(URL, anchor) { // - var anc = anchor ? anchor : ""; - window.location.href = URL + (T3_THIS_LOCATION ? "&returnUrl=" + T3_THIS_LOCATION : "") + anc; - return false; -} - -function jumpSelf(URL) { // - window.location.href = URL + (T3_RETURN_URL ? "&returnUrl=" + T3_RETURN_URL : ""); - return false; -} - -function jumpToUrl(URL) { - window.location.href = URL; - return false; -} - -function setHighlight(id) { // - top.fsMod.recentIds["web"] = id; - top.fsMod.navFrameHighlightedID["web"] = "pages" + id + "_" + top.fsMod.currentBank; // For highlighting - if (top.content && top.content.nav_frame && top.content.nav_frame.refresh_nav) { - top.content.nav_frame.refresh_nav(); - } -} - -/** - * Switches to the spefied page in the BE - * - * @param {number} uid - * @param {string} path - */ -function sgJobsGoToPage(uid, path) { - if (top.nav) { - top.nav.invokePageId(uid, gotToPageCallback); - } else { - var tree = top.Ext.getCmp('typo3-pagetree'); - if (tree) { - tree.activeTree.selectPath(path); - } - var separator = '?'; - if (top.currentSubScript.indexOf('?') !== -1) { - separator = '&'; - } - top.TYPO3.Backend.ContentContainer.setUrl( - top.currentSubScript + separator + 'id=' + uid - ); - } -} - -/** - * Callback for page selection in the pagetree - */ -function gotToPageCallback(path) { - var callback = top.Ext.createDelegate(top.nav.mainTree.selectPath, top.nav.mainTree); - callback.apply(this, arguments); - var node = top.nav.getSelected(); - if (node) { - top.TYPO3.Components.PageTree.Actions.singleClick(node, top.TYPO3.Components.PageTree.Tree); - } -} - -/** - * opens the selected category edit form - * - * @return {boolean} - */ -function editSelectedLocation() { - var selected = TYPO3.jQuery('#filter-locations').val(); - if (selected && LocationEditLinks[selected[0]]) { - jumpToUrl(LocationEditLinks[selected[0]] + '&returnUrl=' + T3_THIS_LOCATION); - } - return false; -} diff --git a/ext_tables.sql b/ext_tables.sql index 42455db8..6d55c716 100644 --- a/ext_tables.sql +++ b/ext_tables.sql @@ -6,6 +6,7 @@ CREATE TABLE tx_sgjobs_domain_model_job ( title text DEFAULT '' NOT NULL, task text DEFAULT '' NOT NULL, qualification text DEFAULT '' NOT NULL, + alternative_start_date text DEFAULT '' NOT NULL, start_date int(11) unsigned DEFAULT '0' NOT NULL, company text DEFAULT '' NOT NULL, description text DEFAULT '' NOT NULL, -- GitLab