Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
asbiin committed Nov 6, 2023
1 parent 6218993 commit a358f67
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 43 deletions.
23 changes: 7 additions & 16 deletions app/Http/Controllers/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
use Illuminate\Http\RedirectResponse;
use App\Notifications\InvitationMail;
use App\Http\Requests\SettingsRequest;
use App\Services\Contact\Tag\UpdateTag;
use LaravelWebauthn\Models\WebauthnKey;
use App\Http\Requests\InvitationRequest;
use App\Services\Contact\Tag\DestroyTag;
use Illuminate\Support\Facades\Validator;
use App\Services\Account\Settings\ResetAccount;
use App\Services\Account\Settings\DestroyAccount;
use PragmaRX\Google2FALaravel\Facade as Google2FA;
Expand Down Expand Up @@ -370,7 +370,7 @@ public function deleteTag($tagId)
}

/**
* Method editTag
* Edit a tag name.
*
* @param Tag $tag
* @param Request $request
Expand All @@ -379,22 +379,13 @@ public function deleteTag($tagId)
*/
public function editTag(Tag $tag, Request $request): RedirectResponse
{
$validator = Validator::make($request->all(), [
'tag_name' => 'required|string|max:255',
app(UpdateTag::class)->execute([
'tag_id' => $tag->id,
'account_id' => auth()->user()->account_id,
'name' => $request->input('name'),
]);

if ($validator->fails()) {
return redirect()->route('settings.tags.index')
->with('error', $validator->errors());
}

$newName = $request->input('tag_name');

$tag->name = $newName;
$tag->save();


return redirect()->route('settings.tags.index')
return back()
->with('success', trans('settings.tags_list_edit_success'));
}

Expand Down
14 changes: 14 additions & 0 deletions resources/sass/settings.scss
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,20 @@
}
}

.tags-list {
h3.with-actions {
padding-bottom: 13px;
}

.table-cell.actions {
@if $htmldir == ltr {
text-align: right;
} @else {
text-align: left;
}
}
}

.blank-screen {
text-align: center;

Expand Down
8 changes: 4 additions & 4 deletions resources/views/settings/export.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,16 @@
</li>
@foreach ($exports as $export)
<li class="table-row">
<div class="table-cell table-cell">
<div class="table-cell">
{{ trans("settings.export_type_{$export['type']}") }}
</div>
<div class="table-cell table-cell date">
<div class="table-cell date">
{{ \App\Helpers\DateHelper::getShortDateWithTime($export['created_at']) }}
</div>
<div class="table-cell table-cell">
<div class="table-cell">
{{ trans("settings.export_status_{$export['status']}") }}
</div>
<div class="table-cell actions table-cell">
<div class="table-cell actions">
@if ($export['status'] === \App\Models\Account\ExportJob::EXPORT_DONE)
<form method="POST" action="{{ route('settings.export.download', ['uuid' => $export['uuid']]) }}">
@csrf
Expand Down
45 changes: 24 additions & 21 deletions resources/views/settings/tags.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

@include('settings._sidebar')

<div class="col-12 col-sm-9">
<div class="col-12 col-sm-9 tags-list">
<div class="br3 ba b--gray-monica bg-white mb4">
<div class="pa3 bb b--gray-monica">
@if (auth()->user()->account->tags->count() == 0)
Expand Down Expand Up @@ -62,29 +62,34 @@
<ul class="table">
@foreach (auth()->user()->account->tags as $tag)
<li class="table-row" data-tag-id="{{ $tag->id }}">
<div class="table-cell">
<form method="GET" action="{{ route('settings.tags.edit', $tag) }}" class="edit-tag-form hidden">
<div class="table-cell fl">
<form method="POST" action="{{ route('settings.tags.update', $tag) }}" class="fl edit-tag-form hidden">
@method('PUT')
@csrf
<input name="tag_name" value="{{ $tag->name }}" class="di br2 f5 ba b--black-40 pa2 outline-0 edit-tag-input" />
<input name="name" value="{{ $tag->name }}" class="di br2 f5 ba b--black-40 pa2 outline-0 edit-tag-input" />
<a class="pointer" html="" onclick="this.parentNode.submit(); return false;">{{ trans('app.save') }}</a>
<a class="pointer" html="" onclick="toggleEditInput(this); return false;">{{ trans('app.close') }}</a>
</form>
<span class="tag-name">{{ $tag->name }}</span>
<span class="tags-list-contact-number">({{ trans_choice('settings.tags_list_contact_number', $tag->contacts()->count(), ['count' => $tag->contacts()->count()]) }})</span>
<ul>
@foreach($tag->contacts as $contact)
<li class="di mr1"><a href="people/{{ $contact->hashID() }}">{{ $contact->name }}</a></li>
@endforeach
</ul>
<div class="tag-content">
<span class="tag-name">{{ $tag->name }}</span>
<span class="tags-list-contact-number">({{ trans_choice('settings.tags_list_contact_number', $tag->contacts()->count(), ['count' => $tag->contacts()->count()]) }})</span>
<ul>
@foreach($tag->contacts as $contact)
<li class="di mr1"><a href="people/{{ $contact->hashID() }}">{{ $contact->name }}</a></li>
@endforeach
</ul>
</div>
</div>
<div class="table-cell actions">
<div class="edit-icon-btn" onclick="toggleEditInput(this)">
<i class="fa fa-pencil" aria-hidden="true"></i>
</a>
<form method="POST" action="{{ route('settings.tags.delete', $tag) }}">
<span class="fl edit-icon-btn" onclick="toggleEditInput(this)">
<i class="fa fa-pencil pointer" aria-hidden="true"></i>
</span>

<form method="POST" action="{{ route('settings.tags.delete', $tag) }}" class="fl">
@method('DELETE')
@csrf
<confirm message="{{ trans('settings.tags_list_delete_confirmation') }}">
<i class="fa fa-trash-o" aria-hidden="true"></i>
<i class="fa fa-trash-o pointer" aria-hidden="true"></i>
</confirm>
</form>
</div>
Expand All @@ -105,12 +110,10 @@
<script>
function toggleEditInput(editIcon) {
let tableRow = editIcon.closest('.table-row');
let tagName = tableRow.querySelector('.tag-name');
let contactNumber = tableRow.querySelector('.tags-list-contact-number');
let tagContent = tableRow.querySelector('.tag-content');
let editInput = tableRow.querySelector('.edit-tag-form');
tagName.classList.toggle('hidden');
contactNumber.classList.toggle('hidden');
tagContent.classList.toggle('hidden');
editInput.classList.toggle('hidden');
}
</script>
3 changes: 1 addition & 2 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,7 @@

Route::name('tags.')->group(function () {
Route::get('/settings/tags', 'SettingsController@tags')->name('index');
Route::get('/settings/tags/update/{tag}', 'SettingsController@editTag')->name('edit');
Route::get('/settings/tags/add', 'SettingsController@addUser')->name('add');
Route::put('/settings/tags/{tag}', 'SettingsController@editTag')->name('update');
Route::delete('/settings/tags/{tag}', 'SettingsController@deleteTag')->name('delete');
});

Expand Down

0 comments on commit a358f67

Please sign in to comment.