Удаление клиента

This commit is contained in:
Artem Vasilev 2024-03-03 23:21:53 +03:00
parent 6e14adfc86
commit 23a1d42c8c
4 changed files with 72 additions and 19 deletions

View File

@ -22,3 +22,5 @@ COM_OAUTHSERVER_CLIENTS_HEADING_SECRET = "Ключ"
COM_OAUTHSERVER_CLIENTS_HEADING_PUBLIC = "Публичный" COM_OAUTHSERVER_CLIENTS_HEADING_PUBLIC = "Публичный"
COM_OAUTHSERVER_SAVE_AND_RESET = "Сохранить и сбросить" COM_OAUTHSERVER_SAVE_AND_RESET = "Сохранить и сбросить"
COM_OAUTHSERVER_CLIENTS = "Клиенты"

View File

@ -0,0 +1,34 @@
<?php
namespace Webmasterskaya\Component\OauthServer\Administrator\Controller;
use Joomla\CMS\MVC\Controller\AdminController;
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
class ClientsController extends AdminController
{
/**
* The prefix to use with controller messages.
*
* @var string
* @since 1.6
*/
protected $text_prefix = 'COM_OAUTHSERVER_CLIENT';
/**
* Method to get a model object, loading it if required.
*
* @param string $name The model name. Optional.
* @param string $prefix The class prefix. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return \Joomla\CMS\MVC\Model\BaseDatabaseModel The model.
*
* @since 1.6
*/
public function getModel($name = 'Client', $prefix = 'Administrator', $config = array('ignore_request' => true)): BaseDatabaseModel
{
return parent::getModel($name, $prefix, $config);
}
}

View File

@ -129,9 +129,11 @@ class HtmlView extends \Joomla\CMS\MVC\View\HtmlView
$toolbar->addNew('client.add'); $toolbar->addNew('client.add');
} }
// Add actions dropdown if ($canDo->get('core.delete')) {
if (!$this->isEmptyState) { $toolbar->delete('clients.delete')
// TODO: Что мы тут в дропдаун пихаем? ->text('JTOOLBAR_DELETE')
->message('JGLOBAL_CONFIRM_DELETE')
->listCheck(true);
} }
// Add preferences button // Add preferences button

View File

@ -49,16 +49,16 @@ $listDirn = $this->escape($this->state->get('list.direction'));
<td class="w-1 text-center"> <td class="w-1 text-center">
<?php echo HTMLHelper::_('grid.checkall'); ?> <?php echo HTMLHelper::_('grid.checkall'); ?>
</td> </td>
<th scope="col"> <th scope="col" class="w-15">
<?php echo HTMLHelper::_('searchtools.sort', 'COM_OAUTHSERVER_CLIENTS_HEADING_NAME', 'client.name', $listDirn, $listOrder); ?> <?php echo HTMLHelper::_('searchtools.sort', 'COM_OAUTHSERVER_CLIENTS_HEADING_NAME', 'client.name', $listDirn, $listOrder); ?>
</th> </th>
<th scope="col"> <th scope="col" class="w-30 col-4">
<?php echo Text::_('COM_OAUTHSERVER_CLIENTS_HEADING_IDENTIFIER'); ?> <?php echo Text::_('COM_OAUTHSERVER_CLIENTS_HEADING_IDENTIFIER'); ?>
</th> </th>
<th scope="col"> <th scope="col" class="w-30 col-4">
<?php echo Text::_('COM_OAUTHSERVER_CLIENTS_HEADING_SECRET'); ?> <?php echo Text::_('COM_OAUTHSERVER_CLIENTS_HEADING_SECRET'); ?>
</th> </th>
<th scope="col"> <th scope="col" class="w-5">
<?php echo HTMLHelper::_('searchtools.sort', 'COM_OAUTHSERVER_CLIENTS_HEADING_PUBLIC', 'client.public', $listDirn, $listOrder); ?> <?php echo HTMLHelper::_('searchtools.sort', 'COM_OAUTHSERVER_CLIENTS_HEADING_PUBLIC', 'client.public', $listDirn, $listOrder); ?>
</th> </th>
<th scope="col" class="w-5 d-none d-md-table-cell"> <th scope="col" class="w-5 d-none d-md-table-cell">
@ -74,22 +74,37 @@ $listDirn = $this->escape($this->state->get('list.direction'));
$canCheckin = $user->authorise('core.manage', 'com_checkin') || $item->checked_out == $userId || is_null($item->checked_out); $canCheckin = $user->authorise('core.manage', 'com_checkin') || $item->checked_out == $userId || is_null($item->checked_out);
$canChange = $user->authorise('core.edit.state', 'com_oauthserver.clients') && $canCheckin; ?> $canChange = $user->authorise('core.edit.state', 'com_oauthserver.clients') && $canCheckin; ?>
<tr class="row<?php echo $i % 2; ?>"> <tr class="row<?php echo $i % 2; ?>">
<td class="text-center"> <td class="w-1 text-center">
<?php echo HTMLHelper::_('grid.id', $i, $item->id, false, 'cid', 'cb', $item->name); ?> <?php echo HTMLHelper::_('grid.id', $i, $item->id, false, 'cid', 'cb', $item->name); ?>
</td> </td>
<td class="small text-start"> <th scope="row" class="has-context">
<?php echo $item->name; ?> <div>
<?php if ($item->checked_out) : ?>
<?php echo HTMLHelper::_('jgrid.checkedout', $i, $item->editor, $item->checked_out_time, 'clients.', $canCheckin); ?>
<?php endif; ?>
<?php if ($canEdit) : ?>
<a href="<?php echo Route::_('index.php?option=com_oauthserver&task=client.edit&id=' . (int)$item->id); ?>"
title="<?php echo Text::_('JACTION_EDIT'); ?> <?php echo $this->escape($item->name); ?>">
<?php echo $this->escape($item->name); ?></a>
<?php else : ?>
<?php echo $this->escape($item->name); ?>
<?php endif; ?>
</div>
</th>
<td class="d-none d-md-table-cell">
<code>
<?php echo $item->identifier; ?>
</code>
</td> </td>
<td class="small text-center d-none d-md-table-cell"> <td class="d-none d-md-table-cell">
<?php echo $item->identifier; ?> <code>
<?php echo !empty($item->secret) ? substr($item->secret, 0, 29) . '...' : ''; ?>
</code>
</td> </td>
<td class="small d-none d-md-table-cell"> <td class="d-none d-md-table-cell">
<?php echo $item->secret; ?> <?php echo Text::_((bool)$item->public ? 'JYES' : 'JNO'); ?>
</td> </td>
<td class="small d-none d-md-table-cell"> <td class="w-1 text-center">
<?php echo Text::_((bool) $item->public ? 'JYES' : 'JNO'); ?>
</td>
<td class="small text-center">
<?php echo $item->id; ?> <?php echo $item->id; ?>
</td> </td>
</tr> </tr>