Status Updated

This commit is contained in:
Devansh 2022-01-05 18:20:27 +05:30
parent 94ea9f8aeb
commit f0ac527b48
14 changed files with 104 additions and 44 deletions

View File

@ -1360,6 +1360,7 @@ return [
'cancel-error' => 'لا يمكن إلغاؤه :name',
'already-taken' => 'بالفعل :name تم أخذ ',
'order-pending' => 'لا يمكن حذف الحساب لأن بعض الطلبات (الطلبات) معلقة أو قيد المعالجة.',
'something-went-wrong' => 'Something went wrong!',
],
'footer' => [

View File

@ -1367,6 +1367,7 @@ return [
'cancel-error' => ':name können nicht storniert werden.',
'already-taken' => 'Der :name wird bereits verwendet.',
'order-pending' => 'Konto kann nicht gelöscht werden, da einige Bestellungen ausstehen oder verarbeitet werden.',
'something-went-wrong' => 'Something went wrong!',
],
'footer' =>
[

View File

@ -44,7 +44,7 @@ return [
'layouts' => [
'app-version' => 'Version : :version',
'account-title' => 'Account',
'account-title' => 'Account',
'my-account' => 'My Account',
'logout' => 'Logout',
'visit-shop' => 'Visit Shop',
@ -85,7 +85,7 @@ return [
'cms' => 'CMS',
'transactions' => 'Transactions',
'newsletter-subscriptions' => 'Newsletter Subscriptions',
'mode' => 'Mode'
'mode' => 'Mode',
],
'acl' => [
@ -598,7 +598,7 @@ return [
'save' => 'Save',
'cancel' => 'Cancel',
'saved-inventory-message' => 'Product inventory saved successfully.',
'image-size' => 'Image resolution should be like 640px X 640px'
'image-size' => 'Image resolution should be like 640px X 640px',
],
'attributes' => [
@ -702,7 +702,7 @@ return [
'filterable-attributes' => 'Filterable Attributes',
'attributes' => 'Attributes',
'image-size' => 'Image resolution should be like 300px X 168px',
'image-size-logo' => 'Image resolution should be like 20px X 20px'
'image-size-logo' => 'Image resolution should be like 20px X 20px',
],
],
@ -882,7 +882,7 @@ return [
'maintenance-mode-text' => 'Message',
'allowed-ips' => 'Allowed IPs',
'logo-size' => 'Image resolution should be like 192px X 50px',
'favicon-size' => 'Image resolution should be like 16px X 16px'
'favicon-size' => 'Image resolution should be like 16px X 16px',
],
'sliders' => [
@ -903,7 +903,7 @@ return [
'delete-fail' => 'Slider item successfully deleted',
'expired-at' => 'Expire Date',
'sort-order' => 'Sort Order',
'image-size' => 'Image resolution should be like 1920px X 550px'
'image-size' => 'Image resolution should be like 1920px X 550px',
],
'tax-categories' => [
@ -1384,6 +1384,7 @@ return [
'cancel-error' => ':name can not be canceled.',
'already-taken' => 'The :name has already been taken.',
'order-pending' => 'Cannot delete :name account because some Order(s) are pending or processing state.',
'something-went-wrong' => 'Something went wrong!',
],
'footer' => [
@ -1566,7 +1567,7 @@ return [
'records-found' => 'Record(s) found',
'logo-size' => 'Image resolution should be like 112px X 41px',
'favicon-size' => 'Image resolution should be like 16px X 16px',
'invoice-logo-size' => 'Image resolution should be like 192px X 50px'
'invoice-logo-size' => 'Image resolution should be like 192px X 50px',
],
],
@ -1590,26 +1591,26 @@ return [
],
'notification' => [
'title' => 'Notification',
'title-plural' => 'Notifications',
'status' => [
'title' => 'Notification',
'title-plural' => 'Notifications',
'status' => [
'all' => 'All',
'pending' => 'Pending',
'processing' => 'Processing',
'canceled' => 'Canceled',
'closed' => 'Closed',
'completed' => 'Completed'
'completed' => 'Completed',
],
'view-all' => 'View All Notifications',
'no-record' => 'No Record Found',
'read-all' => 'Mark as Read',
'view-all' => 'View All Notifications',
'no-record' => 'No Record Found',
'read-all' => 'Mark as Read',
'notification-marked-success' => 'Notification Marked Successfully',
'order-status-messages' => [
'completed' => 'Order Completed',
'closed' => 'Order Closed',
'canceled' => 'Order Canceled',
'pending' => 'Order Pending',
'processing' => 'Order Processing',
]
'order-status-messages' => [
'completed' => 'Order Completed',
'closed' => 'Order Closed',
'canceled' => 'Order Canceled',
'pending' => 'Order Pending',
'processing' => 'Order Processing',
],
],
];

View File

@ -1369,6 +1369,7 @@ return [
'cancel-error' => ':name no puede ser cancelado.',
'already-taken' => 'El :name ya ha sido tomado.',
'order-pending' => 'No puede borrar la cuenta porque algun(os) pedido(s) están en estado pendiente o procesando.',
'something-went-wrong' => 'Something went wrong!',
],
'footer' => [

View File

@ -1357,6 +1357,7 @@ return [
'cancel-error' => ' قابل لغو نیست :name',
'already-taken' => ' قبلا گرفته شده :name',
'order-pending' => 'حساب حذف نمی شود زیرا برخی از سفارش ها حالت معلق یا در حال پردازش هستند',
'something-went-wrong' => 'Something went wrong!',
],
'footer' => [

View File

@ -1383,6 +1383,7 @@ return [
'cancel-error' => ':name ne peut pas être annulé.',
'already-taken' => 'Le :name a déjà été pris.',
'order-pending' => 'Impossible de supprimer le compte :name car certaines commandes sont en attente ou en cours de traitement.',
'something-went-wrong' => 'Something went wrong!',
],
'footer' => [

View File

@ -1360,6 +1360,7 @@ return [
'cancel-error' => ':name non può essere cancellato.',
'already-taken' => 'Il nome :name è stato giù utilizzato.',
'order-pending' => 'Non è possibile eliminare l\'account perchè alcuni Ordini sono in stato di attesa o in corso.',
'something-went-wrong' => 'Something went wrong!',
],
'footer' => [

View File

@ -1354,6 +1354,7 @@ return [
'cancel-error' => ':name kan niet worden geannuleerd.',
'already-taken' => 'The :name is al bezet.',
'order-pending' => 'Kan account niet verwijderen omdat sommige bestelling (en) in behandeling of in behandeling zijn.',
'something-went-wrong' => 'Something went wrong!',
],
'footer' => [

View File

@ -1357,6 +1357,7 @@ return [
'cancel-error' => ':name nie można anulować.',
'already-taken' => 'Ta :name jest już zajęta.',
'order-pending' => 'Nie można usunąć konta, ponieważ niektóre zamówienia są w toku lub są przetwarzane.',
'something-went-wrong' => 'Something went wrong!',
],
'footer' => [

View File

@ -1356,6 +1356,7 @@ return [
'cancel-error' => ':name não pode ser cancelado.',
'already-taken' => 'O :name já foi tomada.',
'order-pending' => 'Não é possível excluir a conta porque alguns pedidos estão em estado pendente ou em processamento.',
'something-went-wrong' => 'Something went wrong!',
],
'footer' => [

View File

@ -1344,6 +1344,7 @@ return [
'cancel-error' => ':name iptal edilemez.',
'already-taken' => ':name daha önceden girilmiş.',
'order-pending' => 'Bu hesaba ait işlem bekleyen siparişler bulunduğundan hesap silinemez.',
'something-went-wrong' => 'Something went wrong!',
],
'footer' => [

View File

@ -72,14 +72,18 @@
<span class="control-error" v-if="errors.has('role_id')">@{{ errors.first('role_id') }}</span>
</div>
<div class="control-group">
<label for="status">{{ __('admin::app.users.users.status') }}</label>
@if (auth()->guard('admin')->user()->id !== $user->id)
<div class="control-group">
<label for="status">{{ __('admin::app.users.users.status') }}</label>
<label class="switch">
<input type="checkbox" id="status" name="status" value="{{ $user->status }}" {{ $user->status ? 'checked' : '' }}>
<span class="slider round"></span>
</label>
</div>
<label class="switch">
<input type="checkbox" id="status" name="status" value="{{ $user->status }}" {{ $user->status ? 'checked' : '' }}>
<span class="slider round"></span>
</label>
</div>
@else
<input type="hidden" name="status" value="{{ $user->status }}">
@endif
</div>
</accordian>
</div>

View File

@ -256,7 +256,13 @@ class UserController extends Controller
$isStatusChangedToInactive = (int) $data['status'] === 0 && (int) $user->status === 1;
if ($isStatusChangedToInactive && $this->adminRepository->countAdminsWithAllAccessAndActiveStatus() === 1) {
if (
$isStatusChangedToInactive
&& (
auth()->guard('admin')->user()->id === (int) $id
|| $this->adminRepository->countAdminsWithAllAccessAndActiveStatus() === 1
)
) {
return $this->cannotChangeRedirectResponse('status');
}
@ -264,8 +270,8 @@ class UserController extends Controller
* Is user with `permission_type` all role changed.
*/
$isRoleChanged = $user->role->permission_type === 'all'
&& isset($data['role_id'])
&& (int) $data['role_id'] !== $user->role_id;
&& isset($data['role_id'])
&& (int) $data['role_id'] !== $user->role_id;
if ($isRoleChanged && $this->adminRepository->countAdminsWithAllAccess() === 1) {
return $this->cannotChangeRedirectResponse('role');
@ -283,7 +289,7 @@ class UserController extends Controller
private function cannotChangeRedirectResponse(string $columnName): \Illuminate\Http\RedirectResponse
{
session()->flash('error', trans('admin::app.response.cannot-change', [
'name' => $columnName
'name' => $columnName,
]));
return redirect()->route($this->_config['redirect']);

View File

@ -16,7 +16,9 @@ class UsersCest
public function testIndex(FunctionalTester $I): void
{
$I->loginAsAdmin();
$I->amOnAdminRoute('admin.dashboard.index');
$I->seeCurrentRouteIs('admin.dashboard.index');
}
@ -29,14 +31,31 @@ class UsersCest
public function testAdminInactiveStatusWithSingleAdmin(FunctionalTester $I): void
{
/**
* Change the status.
* Logged in user.
*/
$this->proceedToChangeStatus($I);
$admin = $I->loginAsAdmin();
/**
* Current route should be user listing page with error.
* Change the status.
*/
$this->proceedToChangeStatus($I, $admin);
/**
* Current route should be user listing page.
*/
$I->seeCurrentRouteIs('admin.users.index');
/**
* Grabbed latest record.
*/
$latestRecord = $I->grabRecord(Admin::class, [
'id' => $admin->id,
]);
/**
* Assertion.
*/
$I->assertEquals(1, $latestRecord->status);
}
/**
@ -47,20 +66,37 @@ class UsersCest
*/
public function testAdminInactiveStatusWhenMoreAdminsPresent(FunctionalTester $I): void
{
/**
* Logged in user.
*/
$I->loginAsAdmin();
/**
* Created one more admin so that status get changed.
*/
$I->have(Admin::class);
$anotherAdmin = $I->have(Admin::class);
/**
* Change the status.
*/
$this->proceedToChangeStatus($I);
$this->proceedToChangeStatus($I, $anotherAdmin);
/**
* Admin should be logged out.
* Current route should be user listing page.
*/
$I->seeCurrentRouteIs('admin.session.create');
$I->seeCurrentRouteIs('admin.users.index');
/**
* Grabbed latest record.
*/
$latestRecord = $I->grabRecord(Admin::class, [
'id' => $anotherAdmin->id,
]);
/**
* Assertion.
*/
$I->assertEquals(0, $latestRecord->status);
}
/**
@ -69,13 +105,16 @@ class UsersCest
* @param FunctionalTester $I
* @return void
*/
private function proceedToChangeStatus(FunctionalTester $I): void
private function proceedToChangeStatus(FunctionalTester $I, $editableAdmin = null): void
{
$I->loginAsAdmin();
$I->amOnAdminRoute('admin.users.edit', ['id' => 1], true);
$I->amOnAdminRoute('admin.users.edit', ['id' => $editableAdmin->id], true);
$I->seeElement('#status', ['value' => '1']);
$I->uncheckOption('#status');
if (auth()->guard('admin')->user()->id !== $editableAdmin->id) {
$I->seeElement('#status', ['value' => '1']);
$I->uncheckOption('#status');
} else {
$I->dontSeeElement('#status');
}
$I->click(__('admin::app.users.users.save-btn-title'));
}