32
1
mirror of https://github.com/joomla-extensions/weblinks.git synced 2025-02-04 10:18:25 +00:00

Replace pr #460, add empty state

This commit is contained in:
chmst 2021-09-24 07:49:35 +02:00
parent 8aa92f906b
commit f53b42c8cc
3 changed files with 46 additions and 1 deletions

View File

@ -61,6 +61,14 @@ class HtmlView extends BaseHtmlView
*/
public $activeFilters;
/**
* Is this view an Empty State
*
* @var boolean
* @since 4.0.0
*/
private $isEmptyState = false;
/**
* Display the view.
*
@ -82,6 +90,11 @@ class HtmlView extends BaseHtmlView
throw new GenericDataException(implode("\n", $errors), 500);
}
if (!\count($this->items) && $this->isEmptyState = $this->get('IsEmptyState'))
{
$this->setLayout('emptystate');
}
// We don't need toolbar in the modal layout.
if ($this->getLayout() !== 'modal')
{
@ -130,7 +143,7 @@ class HtmlView extends BaseHtmlView
ToolbarHelper::addNew('weblink.add');
}
if ($canDo->get('core.edit.state'))
if (!$this->isEmptyState && $canDo->get('core.edit.state'))
{
$dropdown = $toolbar->dropdownButton('status-group')
->text('JTOOLBAR_CHANGE_STATUS')

View File

@ -0,0 +1,29 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage Weblinks
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Layout\LayoutHelper;
$displayData = [
'textPrefix' => 'COM_WEBLINKS',
'formURL' => 'index.php?option=com_weblinks',
'helpURL' => 'https://docs.joomla.org/Special:MyLanguage/Help4.x:Weblinks',
'icon' => 'icon-globe weblink',
];
$user = Factory::getApplication()->getIdentity();
if ($user->authorise('core.create', 'com_weblinks') || count($user->getAuthorisedCategories('com_weblinks', 'core.create')) > 0)
{
$displayData['createURL'] = 'index.php?option=com_weblinks&task=weblink.add';
}
echo LayoutHelper::render('joomla.content.emptystate', $displayData);

View File

@ -14,6 +14,9 @@ COM_WEBLINKS_COMPONENT_LABEL="Web Link"
COM_WEBLINKS_CONFIGURATION="Web Links Manager Options"
COM_WEBLINKS_CONFIG_INTEGRATION_SETTINGS_DESC="These settings determine how the Web Links Component will integrate with other extensions."
COM_WEBLINKS_EDIT_WEBLINK="Edit Web Link"
COM_WEBLINKS_EMPTYSTATE_BUTTON_ADD="Add your first Web Link"
COM_WEBLINKS_EMPTYSTATE_CONTENT="Add, edit and remove links to other web sites on your Joomla! web site, and organize them into categories. You can then display these links on your site, and optionally let visitors add new links."
COM_WEBLINKS_EMPTYSTATE_TITLE="No Web Links have been created yet."
COM_WEBLINKS_ERROR_UNIQUE_ALIAS="Another Web Link from this category has the same alias (remember it may be a trashed item)."
COM_WEBLINKS_ERR_TABLES_NAME="There is already a Web Link with that name in this category. Please try again."
COM_WEBLINKS_ERR_TABLES_PROVIDE_URL="Please provide a valid URL"