Commit 9f826856 authored by Dainis Abols's avatar Dainis Abols
Browse files

Tag and search by ID changes

4.4.1
parent ba693ea8
......@@ -121,7 +121,7 @@ class DocumentController extends ActionController
/**
* List Action
*
* @return void
* @throws \TYPO3\CMS\Backend\Routing\Exception\RouteNotFoundException
*/
public function listAction()
{
......@@ -138,7 +138,6 @@ class DocumentController extends ActionController
// Get current page @FIXME There has to be a better way!
$currentPage = !empty($request['@widget_0']['currentPage']) ? (int)$request['@widget_0']['currentPage'] : 1;
// Get filters
$filters = $filterModel->getFilters($request);
if ($filters) {
......@@ -175,37 +174,42 @@ class DocumentController extends ActionController
}
// Get records
$recordCount = $documentsModel->getCount();
$documents = $documentsModel->getAll($entriesPerPage, $currentPage, $order);
$recordCount = $documentsModel->getCount(@$filters['id']);
$documents = $documentsModel->getAll($entriesPerPage, $currentPage, $order, @$filters['id']);
$statusList = $statusModel->getStatus();
$uriBuilder = GeneralUtility::makeInstance(BackendUriBuilder::class);
// Add edit url
$routeBuilder = GeneralUtility::makeInstance(BackendUriBuilder::class);
$returnUrl = (string)$routeBuilder->buildUriFromRoutePath(
'/web/LuNasDocuments/', [
$returnUrl = (string)$routeBuilder->buildUriFromRoutePath('/web/LuNasDocuments/', [
'id' => $this->pageUid,
'token' => $this->getToken(true),
]
);
]);
foreach ($documents as &$doc) {
$url = $uriBuilder->buildUriFromRoute(
'record_edit',
[
'edit[tx_lunas_domain_model_document]['.$doc['uid'].']' => 'edit',
'returnUrl' => $returnUrl,
]
);
$url = $uriBuilder->buildUriFromRoute('record_edit', [
'edit[tx_lunas_domain_model_document]['.$doc['uid'].']' => 'edit',
'returnUrl' => $returnUrl,
]);
$doc['onClick'] = "window.location.href='{$url}'; return false;";
}
// Check if single ID found
if (isset($filters['id']) && $filters['id'] > 0 && $recordCount == 1) {
$url = $uriBuilder->buildUriFromRoute('record_edit', [
'edit[tx_lunas_domain_model_document]['.$filters['id'].']' => 'edit',
'returnUrl' => $returnUrl,
]);
$filterModel->clearFilters();
HttpUtility::redirect($url);
}
// Prepare data for view
$data = [
'documents' => $documents,
'filter' => $filters,
'recordsCount' => $recordCount,
'range' => range(1, $recordCount),
'showPager' => $recordCount > $entriesPerPage ? true : false,
'showPager' => $recordCount > $entriesPerPage,
'itemsPerPage' => $entriesPerPage,
'maximumNumberOfLinks' => $maximumNumberOfLinks,
'status' => ["" => ""] + $statusList,
......@@ -222,7 +226,7 @@ class DocumentController extends ActionController
$pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
$pageRenderer->loadRequireJsModule('TYPO3/CMS/LuNas/LuNas');
$syncResult = $this->backendSession->pull('lu_nas_syn_result');
$syncResult = $this->backendSession->pull('lu_nas_sync_result');
// Assign data to view
$this->view->assign('syncResult', $syncResult);
......@@ -242,20 +246,16 @@ class DocumentController extends ActionController
$uriBuilder = GeneralUtility::makeInstance(BackendUriBuilder::class);
// Create redirect url
$returnUrl = $uriBuilder->buildUriFromRoutePath(
'/web/LuNasDocuments/', [
$returnUrl = $uriBuilder->buildUriFromRoutePath('/web/LuNasDocuments/', [
'id' => $this->pageUid,
'token' => $this->getToken(true),
]
);
]);
$pid = $config['storage_page_id'];
$url = $uriBuilder->buildUriFromRoute(
'record_edit', [
'edit['.$table.']['.$pid.']' => 'new',
'returnUrl' => (string)$returnUrl,
]
);
$url = $uriBuilder->buildUriFromRoute('record_edit', [
'edit['.$table.']['.$pid.']' => 'new',
'returnUrl' => (string)$returnUrl,
]);
// Redirect
HttpUtility::redirect($url);
......@@ -279,12 +279,10 @@ class DocumentController extends ActionController
$toggleButton = $buttonBar->makeLinkButton()
->setHref('#')
->setClasses('toggle')
->setDataAttributes(
[
'togglelink' => '1',
'toggle' => 'filterMenu',
]
)
->setDataAttributes([
'togglelink' => '1',
'toggle' => 'filterMenu',
])
->setTitle($title)
->setIcon($iconFactory->getIcon('actions-filter', Icon::SIZE_SMALL));
$buttonBar->addButton($toggleButton, ButtonBar::BUTTON_POSITION_LEFT, 1);
......
......@@ -242,7 +242,7 @@ class FrontController extends ActionController
$pageRenderer->addCssFile("EXT:lu_nas/Resources/Public/Css/jquery-ui/jquery-ui.css");
$pageRenderer->addJsFooterFile("EXT:lu_nas/Resources/Public/JavaScript/jquery-ui.js");
$syncResult = $this->frontendSession->pull('lu_nas_syn_result');
$syncResult = $this->frontendSession->pull('lu_nas_sync_result');
// Assign data to view
$this->view->assign('syncResult', $syncResult);
......
......@@ -162,7 +162,7 @@ class Document extends AbstractEntity
*
* @return int
*/
public function getCount(): int
public function getCount($uid = null): int
{
// Build query
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($this->tableName);
......@@ -181,6 +181,16 @@ class Document extends AbstractEntity
);
}
// Check if ID requested
if ($uid > 0) {
$queryBuilder->andWhere(
$queryBuilder->expr()->like(
'uid',
$queryBuilder->createNamedParameter('%' . $queryBuilder->escapeLikeWildcards((int)$uid) . '%')
)
);
}
// Build the query
$count = (int)$queryBuilder->execute()->fetchColumn(0);
......@@ -222,13 +232,14 @@ class Document extends AbstractEntity
/**
* Retrieve records
*
* @param int $entriesPerPage
* @param int $currentPage
* @param int $entriesPerPage
* @param int|null $currentPage
* @param array $order
* @param int|null $uid
*
* @return array
*/
public function getAll(int $entriesPerPage, int $currentPage = null, array $order = []): array
public function getAll(int $entriesPerPage, int $currentPage = null, array $order = [], $uid = null): array
{
// Pre-set used methods/variables
$orderTypesModel = new OrderType();
......@@ -251,6 +262,16 @@ class Document extends AbstractEntity
);
}
// Check if ID requested
if ($uid > 0) {
$queryBuilder->andWhere(
$queryBuilder->expr()->like(
'uid',
$queryBuilder->createNamedParameter('%' . $queryBuilder->escapeLikeWildcards((int)$uid) . '%')
)
);
}
if (!empty($this->filter['view_count'])) {
// Execute
$result = $queryBuilder->orderBy("view_count", "DESC")->setMaxResults(10)->execute()->fetchAll();
......@@ -316,7 +337,7 @@ class Document extends AbstractEntity
$uid = $item['uid_local'] == $this->uid ? $item['uid_foreign'] : $item['uid_local'];
$relDoc = $this->getDocument($uid);
if (!empty($relDoc['title'])) {
$related[] = [
$related[$uid] = [
'uid' => $uid,
'number' => $relDoc['number'],
'date_accepted' => date('d.m.Y', $relDoc['date_accepted']),
......@@ -326,7 +347,7 @@ class Document extends AbstractEntity
}
}
return $related;
return array_values($related);
}
/**
......
......@@ -21,6 +21,13 @@ class Filter
*/
private $filter = [];
/**
* Local session value
*
* @var
*/
private $bfSession;
/**
* Filter constructor. Sets filter options
*
......@@ -28,6 +35,8 @@ class Filter
*/
public function __construct($request, $bfSession)
{
$this->bfSession = $bfSession;
if (empty($request['clear'])) {
if ($bfSession) {
$sessionFilter = $bfSession->get('lu_nas_filter');
......@@ -70,4 +79,12 @@ class Filter
{
return $this->filter;
}
/**
* Clears all filter value
*/
public function clearFilters(): void
{
$this->bfSession->store('lu_nas_filter', []);
}
}
......@@ -73,7 +73,7 @@ class TCEmainHook
$solrSync = new SolrSynchronize();
$jsonData = $solrSync->syncRegulations();
$result = $dataHelper->APIDecode($jsonData);
$backendSession->store('lu_nas_syn_result', $result);
$backendSession->store('lu_nas_sync_result', $result);
}
/**
......
......@@ -103,7 +103,7 @@ return [
'maxitems' => 1,
'foreign_table' => 'tx_lunas_domain_model_type',
'foreign_table_where' => 'ORDER BY tx_lunas_domain_model_type.title ASC',
'items' => [['', 0,]],
'items' => [['', '',]],
'default' => 0,
],
],
......@@ -151,6 +151,7 @@ return [
'foreign_table' => 'tx_lunas_domain_model_process',
'foreign_table_where' => 'ORDER BY tx_lunas_domain_model_process.title ASC',
'items' => [['', '',]],
'default' => 0,
],
],
......
......@@ -140,6 +140,9 @@
<trans-unit id="form.viewDocuments">
<source><![CDATA[Rādīt skatītākos dokumentus]]></source>
</trans-unit>
<trans-unit id="form.id">
<source><![CDATA[ID]]></source>
</trans-unit>
<trans-unit id="issuer.title">
<source><![CDATA[NAS Izdevējs]]></source>
</trans-unit>
......@@ -150,7 +153,7 @@
<source><![CDATA[NAS Statuss]]></source>
</trans-unit>
<trans-unit id="sync.description">
<source><![CDATA[Meklētāja dati tiek sinhrinizēti, tas var prasīt līdz 10 minūtēm]]></source>
<source><![CDATA[Meklētāja dati tiek sinhronizēti, tas var prasīt līdz 20 minūtēm]]></source>
</trans-unit>
<trans-unit id="sync.title">
<source><![CDATA[Notiek sinhronizācija]]></source>
......
......@@ -177,6 +177,10 @@
<source><![CDATA[Rādīt skatītākos dokumentus]]></source>
<target><![CDATA[Rādīt skatītākos dokumentus]]></target>
</trans-unit>
<trans-unit id="form.id">
<source><![CDATA[ID]]></source>
<target><![CDATA[ID]]></target>
</trans-unit>
<trans-unit id="issuer.title" approved="yes">
<source><![CDATA[NAS Izdevējs]]></source>
<target><![CDATA[NAS Izdevējs]]></target>
......@@ -190,8 +194,8 @@
<target><![CDATA[NAS Statuss]]></target>
</trans-unit>
<trans-unit id="sync.description" approved="yes">
<source><![CDATA[Meklētāja dati tiek sinhrinizēti, tas var prasīt līdz 10 minūtēm]]></source>
<target><![CDATA[Meklētāja dati tiek sinhrinizēti, tas var prasīt līdz 10 minūtēm]]></target>
<source><![CDATA[Meklētāja dati tiek sinhronizēti, tas var prasīt līdz 20 minūtēm]]></source>
<target><![CDATA[Meklētāja dati tiek sinhronizēti, tas var prasīt līdz 20 minūtēm]]></target>
</trans-unit>
<trans-unit id="sync.title" approved="yes">
<source><![CDATA[Notiek sinhronizācija]]></source>
......
......@@ -18,6 +18,21 @@
<div class="settings">
<div class="row form-horizontal">
<div class="col-xs-12">
<!-- Search by uid -->
<f:if condition="{front} == true">
<f:else>
<div class="form-group">
<label class="col-xs-4 control-label">
<f:translate key="form.id"/>
</label>
<div class="col-xs-8">
<div class="form-control-clearable">
<f:form.textfield class="form-control" name="Filter[id]" value="{filter.id}" />
</div>
</div>
</div>
</f:else>
</f:if>
<!-- Search by title -->
<div class="form-group">
......@@ -50,7 +65,7 @@
</label>
<div class="col-xs-8">
<div class="input-group">
<f:form.textfield name="Filter[accepted_date_from]" value="{filter.accepted_date_from}" type="text" id="accepted_date_from" class="form-control t3js-datetimepicker t3js-clearable" data="{date-type:'date',date-offset:'0'}" additionalAttributes="{autocomplete='off', readonly='readonly'}" />
<f:form.textfield name="Filter[accepted_date_from]" value="{filter.accepted_date_from}" type="text" id="accepted_date_from" class="form-control t3js-datetimepicker t3js-clearable" data="{date-type:'date',date-offset:'0'}" additionalAttributes="{f:if(condition:'{show}', then: '{autocomplete=\'off\', readonly=\'readonly\'}')}" />
<span class="input-group-btn">
<label class="btn btn-default" for="accepted_date_from">
<span class="fa fa-calendar"></span>
......@@ -67,7 +82,7 @@
</label>
<div class="col-xs-8">
<div class="input-group">
<f:form.textfield name="Filter[accepted_date_till]" value="{filter.accepted_date_till}" type="text" id="accepted_date_till" class="form-control t3js-datetimepicker t3js-clearable" data="{date-type:'date',date-offset:'0'}" additionalAttributes="{autocomplete='off', readonly='readonly'}" />
<f:form.textfield name="Filter[accepted_date_till]" value="{filter.accepted_date_till}" type="text" id="accepted_date_till" class="form-control t3js-datetimepicker t3js-clearable" data="{date-type:'date',date-offset:'0'}" additionalAttributes="{f:if(condition:'{show}', then: '{autocomplete=\'off\', readonly=\'readonly\'}')}" />
<span class="input-group-btn">
<label class="btn btn-default" for="accepted_date_till">
<span class="fa fa-calendar"></span>
......@@ -102,13 +117,14 @@
</div>
<!-- Show/hide archived -->
<div class="form-group">
<label class="control-label" for="nas-form-archived">
<f:translate key="form.archived"/>
</label>
<f:form.checkbox id="nas-form-archived" value="1" class="form-control" checked="{filter.archived} == 1" name="Filter[archived]" />
<f:if condition="{front} == true">
<div class="form-group">
<label class="control-label" for="nas-form-archived">
<f:translate key="form.archived"/>
</label>
<f:form.checkbox id="nas-form-archived" value="1" class="form-control" checked="{filter.archived} == 1" name="Filter[archived]" />
</div>
</div>
</f:if>
<f:if condition="{filter.facet_field}">
<div class="form-group">
......
......@@ -164,7 +164,7 @@
</f:for>
</f:then>
<f:else>
<tr><td colspan="8" style="text-align: center; font-style: italic;"><f:translate key="document.none_found" /></td></tr>
<tr><td colspan="10" style="text-align: center; font-style: italic;"><f:translate key="document.none_found" /></td></tr>
</f:else>
</tbody>
</f:if>
......
......@@ -16,7 +16,7 @@
<!-- <p class="lead"><strong><a href="http://www.lu.lv/studentiem/dokumenti/celvedis/" target="_blank"><f:translate key="form.study_guide" /></a></strong></p>-->
<!-- Filter -->
<f:render partial="Filter" arguments="{filter: data.filter, status: data.status, form: data.form, show: 'true'}"/>
<f:render partial="Filter" arguments="{front: 'true', filter: data.filter, status: data.status, form: data.form, show: 'true'}"/>
<!-- Facets -->
<f:render partial="Facets" arguments="{facets: data.facets, data: data, hide: 'tag'}"/>
......@@ -147,7 +147,7 @@
</f:then>
<f:else>
<tr>
<td colspan="8" style="text-align: center; font-style: italic;">
<td colspan="10" style="text-align: center; font-style: italic;">
<f:translate key="document.none_found"/>
</td>
</tr>
......@@ -164,7 +164,9 @@
</f:if>
<!-- Tag facets -->
<f:comment>
<f:render partial="Facets" arguments="{facets: data.facets, data: data, show: 'tag'}"/>
</f:comment>
</td>
</tr>
</table>
......
{
"name": "luitd/lu-nas",
"version": "4.4.0",
"version": "4.4.1",
"description": "Latvijas Universitātes Normatīvo Aktu sistēmas TYPO3 spraudnis",
"type": "typo3-cms-extension",
"keywords": [
......
......@@ -9,7 +9,7 @@ $EM_CONF[$_EXTKEY] = [
'author_email' => 'dainis.abols@lu.lv',
'state' => 'stable',
'clearCacheOnLoad' => true,
'version' => '4.4.0',
'version' => '4.4.1',
'constraints' => [
'depends' => [
'typo3' => '10.4.0-10.9.99',
......
......@@ -4,7 +4,7 @@ TYPO3 Extension for Regulations (NAS)
## Version
4.4.0
4.4.1
- archived documents changed to status "Nav aktuāls"
- added tag to document view
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment