Skip to content
This repository has been archived by the owner on Sep 13, 2024. It is now read-only.

Tree view reworked #12569

Open
wants to merge 3 commits into
base: developer
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion languages/en-US/Install.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
"JS_S_LENGTH_MENU": "Show _MENU_ entries",
"JS_SEARCH": "Search:",
"JS_S_INFO": "Showing _START_ to _END_ of _TOTAL_ entries",
"JS_S_PREVIOUS": "Last",
"JS_S_PREVIOUS": "Previous",
"JS_S_NEXT": "Next"
}
}
12 changes: 2 additions & 10 deletions languages/en-US/_Base.json
Original file line number Diff line number Diff line change
Expand Up @@ -1346,14 +1346,6 @@
"LBL_NO_UPCOMING_PROJECT_TASKS": "No upcoming project tasks",
"LBL_COMPLETED_PROJECT_TASKS": "Completed project tasks",
"LBL_NO_COMPLETED_PROJECT_TASKS": "No completed project tasks",
"PLL_PLANNED": "Planned",
"PLL_ON_HOLD": "On hold",
"PLL_SUBMITTED_COMMENTS": "Submitted comments",
"PLL_IN_PROGRESSING": "In progress",
"PLL_IN_APPROVAL": "In approval",
"PLL_COMPLETED": "Completed",
"PLL_CANCELLED": "Cancelled",
"LBL_SELECT_UP_TO_RECORDS": "Select up to %s records",
"LBL_MASS_DOWNLOAD": "Mass download",
"LBL_AMOUNT_TO_RETURN": "Amount to be refunded",
"LBL_TABLE_TAX_SUMMARY_FOR_CORRECT": "Tax summary for correcting invoices",
Expand Down Expand Up @@ -1660,9 +1652,9 @@
"JS_S_INFO_EMPTY": "Showing 0 to 0 of 0 entries",
"JS_S_INFO_FILTERED": "(filtered from _MAX_ total entries)",
"JS_S_FIRST": "First",
"JS_S_PREVIOUS": "Last",
"JS_S_PREVIOUS": "Previous",
"JS_S_NEXT": "Next",
"JS_S_LAST": "Previous",
"JS_S_LAST": "Last",
"JS_S_SORT_ASCENDING": ": activate to sort column ascending",
"JS_S_SORT_DESCENDING": ": activate to sort column descending",
"JS_RELATION": "Company",
Expand Down
4 changes: 2 additions & 2 deletions layouts/basic/modules/Vtiger/TreeRecords.tpl
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{*<!-- {[The file is published on the basis of YetiForce Public License 3.0 that can be found in the following directory: licenses/LicenseEN.txt or yetiforce.com]} -->*}
{strip}
<table class="table table-striped">
<table class="table tableBorderHeadBody listViewEntriesTable medium js-fixed-thead">
<thead>
<tr>
{foreach item=HEADER from=$HEADERS}
<th>
<th class="noWrap">
{\App\Language::translate($HEADER->get('label'), $MODULE)}
</th>
{/foreach}
Expand Down
7 changes: 3 additions & 4 deletions layouts/basic/modules/Vtiger/TreeRecordsPostProcess.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
</div>
</div>
</div>
<div class="{if $USER_MODEL->get('leftpanelhide')}c-menu--open {/if}siteBarRight">
<div class="siteBarRight">
<div class="btn btn-block toggleSiteBarRightButton"
title="{\App\Language::translate('LBL_RIGHT_PANEL_SHOW_HIDE', $MODULE)}">
<span class="fas fa-chevron-right"></span>
</div>
<div class="siteBarContent">
<div class="row">
<div class="col-md-4 paddingTop10">
<div class="col-12 paddingTop10">
<h5>{\App\Language::translate('LBL_FILTERING',$MODULE)}</h5>
</div>
<div class="col-md-8 paddingTop10">
<div class="col-12 paddingBottom10">
<select class="select2 form-control" id="moduleFilter">
{foreach key=GROUP_LABEL item=GROUP_CUSTOM_VIEWS from=$CUSTOM_VIEWS}
<optgroup label="{\App\Language::translate('LBL_CV_GROUP_'|cat:strtoupper($GROUP_LABEL))}">
Expand All @@ -34,6 +34,5 @@
</div>
</div>
</div>
</div>
<!-- /tpl-TreeRecordsPostProcess -->
{/strip}
20 changes: 10 additions & 10 deletions layouts/basic/modules/Vtiger/TreeRecordsPreProcess.tpl
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{*<!-- {[The file is published on the basis of YetiForce Public License 3.0 that can be found in the following directory: licenses/LicenseEN.txt or yetiforce.com]} -->*}
{strip}
<div class="row padding0">
<div class="col-md-9 rowContent">
<div class="o-breadcrumb widget_header row paddingTop10">
<div class="float-left paddingLeftMd">
<div class="btn-toolbar">
{include file=\App\Layout::getTemplatePath('ButtonViewLinks.tpl') LINKS=$QUICK_LINKS['SIDEBARLINK']}
</div>
</div>
<div class="treeviewViewContainer rowContent js-sitebar--active">
<div class="o-breadcrumb widget_header mb-2 d-flex justify-content-between px-2">
<div class="col-md-10">
{include file=\App\Layout::getTemplatePath('BreadCrumbs.tpl', $MODULE_NAME)}
</div>
</div>
<div class="row">
<div class="c-list__buttons d-flex flex-wrap flex-sm-nowrap u-w-sm-down-100">
{include file=\App\Layout::getTemplatePath('ButtonViewLinks.tpl') LINKS=$QUICK_LINKS['SIDEBARLINK'] CLASS='buttonTextHolder mr-sm-1 mb-1 mb-sm-0 c-btn-block-sm-down'}
{foreach item=LINK from=$LISTVIEW_LINKS['LISTVIEWBASIC']}
{include file=\App\Layout::getTemplatePath('ButtonLink.tpl', $MODULE) BUTTON_VIEW='listView' CLASS='mr-sm-1 mb-1 c-btn-block-sm-down'}
{/foreach}
</div>
<div class="row overflow-auto">
<div class="col-md-12" id="recordsListContents">
{/strip}
{/strip}
35 changes: 0 additions & 35 deletions modules/Products/models/TreeView.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,39 +13,4 @@ public function isActive()
{
return true;
}

private function getRecords()
{
$pagingModel = new Vtiger_Paging_Model();
$pagingModel->set('limit', 0);
$listViewModel = Vtiger_ListView_Model::getInstance($this->getModuleName());
$listEntries = $listViewModel->getListViewEntries($pagingModel);
$tree = [];
foreach ($listEntries as $item) {
++$this->lastTreeId;
$parent = $item->get('pscategory');
$parent = (int) str_replace('T', '', $parent);
$tree[] = [
'id' => $this->lastTreeId,
'type' => 'record',
'record_id' => $item->getId(),
'parent' => $parent == 0 ? '#' : $parent,
'text' => $item->getName(),
'isrecord' => true,
'state' => [],
'icon' => 'fas fa-file',
];
}
return $tree;
}

/**
* Load tree.
*
* @return string
*/
public function getTreeList()
{
return array_merge(parent::getTreeList(), $this->getRecords());
}
}
73 changes: 0 additions & 73 deletions modules/Products/views/TreeRecords.php

This file was deleted.

34 changes: 0 additions & 34 deletions modules/Services/models/TreeView.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,4 @@ public function isActive()
{
return true;
}

private function getRecords()
{
$pagingModel = new Vtiger_Paging_Model();
$pagingModel->set('limit', 0);
$listViewModel = Vtiger_ListView_Model::getInstance($this->getModuleName());
$listEntries = $listViewModel->getListViewEntries($pagingModel);
$tree = [];
foreach ($listEntries as $item) {
++$this->lastTreeId;
$parent = $item->get('pscategory');
$parent = (int) str_replace('T', '', $parent);
$tree[] = [
'id' => $this->lastTreeId,
'record_id' => $item->getId(),
'parent' => $parent == 0 ? '#' : $parent,
'text' => $item->getName(),
'isrecord' => true,
'state' => [],
'icon' => 'fas fa-file',
];
}
return $tree;
}

/**
* Load tree.
*
* @return string
*/
public function getTreeList()
{
return array_merge(parent::getTreeList(), $this->getRecords());
}
}
24 changes: 0 additions & 24 deletions modules/Services/views/TreeRecords.php

This file was deleted.

43 changes: 43 additions & 0 deletions modules/Vtiger/models/TreeView.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,49 @@ public static function getInstance(string $moduleName)
return self::$_cached_instance[$moduleName];
}

/**
* Function to get Basic links for tree view
*
* @return array of Basic links
*/
public function getBasicLinks(): array
{
$moduleName = $this->getModuleName();
$moduleModel = Vtiger_Module_Model::getInstance($moduleName);
$basicLinks = [];
if ($moduleModel->isPermitted('CreateView')) {
$basicLinks[] = [
'linktype' => 'LISTVIEWBASIC',
'linklabel' => 'LBL_ADD_RECORD',
'linkurl' => $moduleModel->getCreateRecordUrl(),
'linkclass' => 'btn-light addButton modCT_' . $moduleModel->getName(),
'linkicon' => 'fas fa-plus',
'showLabel' => 1,
'linkhref' => true
];
}

return $basicLinks;
}

/**
* Function to get the list of tree view links.
*
* @param <Array> $linkParams
*
* @return <Array> - Associate array of Link Type to List of Vtiger_Link_Model instances
*/
public function getListViewLinks()
{
$basicLinks = $this->getBasicLinks();
$links = [];
foreach ($basicLinks as $basicLink) {
$links['LISTVIEWBASIC'][] = Vtiger_Link_Model::getInstanceFromValues($basicLink);
}

return $links;
}

/**
* Load tree.
*
Expand Down
13 changes: 3 additions & 10 deletions modules/Vtiger/views/TreeRecords.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ public function preProcess(\App\Request $request, $display = true)
parent::preProcess($request);
$moduleName = $request->getModule();
$treeViewModel = Vtiger_TreeView_Model::getInstance($moduleName);

$listViewLinks = $treeViewModel->getListViewLinks();
$treeList = $treeViewModel->getTreeList();
$viewer = $this->getViewer($request);
$viewer->assign('LISTVIEW_LINKS', $listViewLinks);
$viewer->assign('TREE_LIST', \App\Json::encode($treeList));
$viewer->view('TreeRecordsPreProcess.tpl', $moduleName);
}
Expand Down Expand Up @@ -69,11 +70,6 @@ public function process(\App\Request $request)
$moduleName = $request->getModule();
$viewer = $this->getViewer($request);
$filter = $request->has('filter') ? $request->getByType('filter', 'Alnum') : \App\CustomView::getInstance($moduleName)->getViewId();
$viewer->assign('VIEWID', $filter);

if ($request->isEmpty('branches', true)) {
return;
}
$branches = $request->getArray('branches', 'Text');
$treeViewModel = Vtiger_TreeView_Model::getInstance($moduleName);
$field = $treeViewModel->getTreeField();
Expand All @@ -82,11 +78,8 @@ public function process(\App\Request $request)
$listViewModel = Vtiger_ListView_Model::getInstance($moduleName, $filter);
$listViewModel->getQueryGenerator()->addCondition($field['fieldname'], implode('##', $branches), 'e');
$listEntries = $listViewModel->getListViewEntries($pagingModel);
if (count($listEntries) === 0) {
return;
}
$listHeaders = $listViewModel->getListViewHeaders();

$viewer->assign('VIEWID', $filter);
$viewer->assign('ENTRIES', $listEntries);
$viewer->assign('HEADERS', $listHeaders);
$viewer->assign('MODULE', $moduleName);
Expand Down

This file was deleted.

This file was deleted.

Loading