Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9f8e0c42ec | |||
| b1c531bb70 | |||
| 9cc1b7072c | |||
| 2968bcf3f8 | |||
| ad0f7a7a01 | |||
| 368b0a7cf7 | |||
| aa375ce0da | |||
| 340e16c610 | |||
| 33b236d881 | |||
| fb7704027b | |||
| e5902706f1 | |||
| 229c100cc4 | |||
| 9a4897bf0c | |||
| d779e4d7a1 | |||
| b2a9350d0f |
@@ -0,0 +1,27 @@
|
|||||||
|
name: Playwright Tests
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ main, master ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ main, master ]
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
timeout-minutes: 60
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: lts/*
|
||||||
|
- name: Install dependencies
|
||||||
|
run: npm ci
|
||||||
|
- name: Install Playwright Browsers
|
||||||
|
run: npx playwright install --with-deps
|
||||||
|
- name: Run Playwright tests
|
||||||
|
run: npx playwright test
|
||||||
|
- uses: actions/upload-artifact@v4
|
||||||
|
if: ${{ !cancelled() }}
|
||||||
|
with:
|
||||||
|
name: playwright-report
|
||||||
|
path: playwright-report/
|
||||||
|
retention-days: 30
|
||||||
@@ -39,3 +39,11 @@ docker-compose.local.yaml
|
|||||||
docker-compose.override.yaml
|
docker-compose.override.yaml
|
||||||
.env.local
|
.env.local
|
||||||
.env.docker
|
.env.docker
|
||||||
|
|
||||||
|
# Playwright
|
||||||
|
node_modules/
|
||||||
|
/test-results/
|
||||||
|
/playwright-report/
|
||||||
|
/blob-report/
|
||||||
|
/playwright/.cache/
|
||||||
|
/playwright/.auth/
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
use App\Models\SmsTemplate;
|
use App\Models\SmsTemplate;
|
||||||
use App\Services\Contact\PhoneSelector;
|
use App\Services\Contact\PhoneSelector;
|
||||||
use App\Services\Sms\SmsService;
|
use App\Services\Sms\SmsService;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Bus;
|
use Illuminate\Support\Facades\Bus;
|
||||||
@@ -50,6 +51,7 @@ public function create(Request $request): Response
|
|||||||
->get(['id', 'name', 'content']);
|
->get(['id', 'name', 'content']);
|
||||||
$segments = \App\Models\Segment::query()
|
$segments = \App\Models\Segment::query()
|
||||||
->where('active', true)
|
->where('active', true)
|
||||||
|
->where('exclude', false)
|
||||||
->orderBy('name')
|
->orderBy('name')
|
||||||
->get(['id', 'name']);
|
->get(['id', 'name']);
|
||||||
// Provide a lightweight list of recent clients with person names for filtering
|
// Provide a lightweight list of recent clients with person names for filtering
|
||||||
@@ -321,7 +323,6 @@ public function contracts(Request $request, PhoneSelector $selector): \Illuminat
|
|||||||
$request->validate([
|
$request->validate([
|
||||||
'segment_id' => ['nullable', 'integer', 'exists:segments,id'],
|
'segment_id' => ['nullable', 'integer', 'exists:segments,id'],
|
||||||
'q' => ['nullable', 'string'],
|
'q' => ['nullable', 'string'],
|
||||||
|
|
||||||
'client_id' => ['nullable', 'integer', 'exists:clients,id'],
|
'client_id' => ['nullable', 'integer', 'exists:clients,id'],
|
||||||
'only_mobile' => ['nullable', 'boolean'],
|
'only_mobile' => ['nullable', 'boolean'],
|
||||||
'only_validated' => ['nullable', 'boolean'],
|
'only_validated' => ['nullable', 'boolean'],
|
||||||
@@ -333,12 +334,12 @@ public function contracts(Request $request, PhoneSelector $selector): \Illuminat
|
|||||||
|
|
||||||
$segmentId = $request->input('segment_id') ? (int) $request->input('segment_id') : null;
|
$segmentId = $request->input('segment_id') ? (int) $request->input('segment_id') : null;
|
||||||
|
|
||||||
|
|
||||||
$query = Contract::query()
|
$query = Contract::query()
|
||||||
->with([
|
->with([
|
||||||
'clientCase.person.phones',
|
'clientCase.person.phones',
|
||||||
'clientCase.client.person',
|
'clientCase.client.person',
|
||||||
'account',
|
'account',
|
||||||
|
'segments:id,name',
|
||||||
])
|
])
|
||||||
->select('contracts.*')
|
->select('contracts.*')
|
||||||
->latest('contracts.id');
|
->latest('contracts.id');
|
||||||
@@ -350,6 +351,15 @@ public function contracts(Request $request, PhoneSelector $selector): \Illuminat
|
|||||||
->where('contract_segment.segment_id', '=', $segmentId)
|
->where('contract_segment.segment_id', '=', $segmentId)
|
||||||
->where('contract_segment.active', true);
|
->where('contract_segment.active', true);
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
// Only include contracts that have at least one active, non-excluded segment
|
||||||
|
$query->whereExists(fn ($exist) => $exist->select(\DB::raw(1))
|
||||||
|
->from('contract_segment')
|
||||||
|
->join('segments', 'segments.id', '=', 'contract_segment.segment_id')
|
||||||
|
->where('contract_segment.active', true)
|
||||||
|
->where('segments.exclude', false)
|
||||||
|
->whereColumn('contract_segment.contract_id', 'contracts.id')
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($q = trim((string) $request->input('q'))) {
|
if ($q = trim((string) $request->input('q'))) {
|
||||||
@@ -399,13 +409,14 @@ public function contracts(Request $request, PhoneSelector $selector): \Illuminat
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$contracts = $query->get();
|
$contracts = $query->limit(500)->get();
|
||||||
|
|
||||||
$data = collect($contracts)->map(function (Contract $contract) use ($selector) {
|
$data = collect($contracts)->map(function (Contract $contract) use ($selector) {
|
||||||
$person = $contract->clientCase?->person;
|
$person = $contract->clientCase?->person;
|
||||||
$selected = $person ? $selector->selectForPerson($person) : ['phone' => null, 'reason' => 'no_person'];
|
$selected = $person ? $selector->selectForPerson($person) : ['phone' => null, 'reason' => 'no_person'];
|
||||||
$phone = $selected['phone'];
|
$phone = $selected['phone'];
|
||||||
$clientPerson = $contract->clientCase?->client?->person;
|
$clientPerson = $contract->clientCase?->client?->person;
|
||||||
|
$segment = collect($contract->segments)->last();
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'id' => $contract->id,
|
'id' => $contract->id,
|
||||||
@@ -423,6 +434,7 @@ public function contracts(Request $request, PhoneSelector $selector): \Illuminat
|
|||||||
'uuid' => $person?->uuid,
|
'uuid' => $person?->uuid,
|
||||||
'full_name' => $person?->full_name,
|
'full_name' => $person?->full_name,
|
||||||
],
|
],
|
||||||
|
'segment' => $segment,
|
||||||
// Stranka: the client person
|
// Stranka: the client person
|
||||||
'client' => $clientPerson ? [
|
'client' => $clientPerson ? [
|
||||||
'id' => $contract->clientCase?->client?->id,
|
'id' => $contract->clientCase?->client?->id,
|
||||||
@@ -440,7 +452,7 @@ public function contracts(Request $request, PhoneSelector $selector): \Illuminat
|
|||||||
});
|
});
|
||||||
|
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'data' => $data
|
'data' => $data,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public function index(Client $client, Request $request)
|
|||||||
->where('person.full_name', 'ilike', '%'.$search.'%')
|
->where('person.full_name', 'ilike', '%'.$search.'%')
|
||||||
->groupBy('clients.id');
|
->groupBy('clients.id');
|
||||||
})
|
})
|
||||||
->where('clients.active', 1)
|
//->where('clients.active', 1)
|
||||||
// Use LEFT JOINs for aggregated data to avoid subqueries
|
// Use LEFT JOINs for aggregated data to avoid subqueries
|
||||||
->leftJoin('client_cases', 'client_cases.client_id', '=', 'clients.id')
|
->leftJoin('client_cases', 'client_cases.client_id', '=', 'clients.id')
|
||||||
->leftJoin('contracts', function ($join) {
|
->leftJoin('contracts', function ($join) {
|
||||||
@@ -51,7 +51,7 @@ public function index(Client $client, Request $request)
|
|||||||
|
|
||||||
return Inertia::render('Client/Index', [
|
return Inertia::render('Client/Index', [
|
||||||
'clients' => $query
|
'clients' => $query
|
||||||
->paginate($request->integer('per_page', 15))
|
->paginate($request->integer('per_page', default: 100))
|
||||||
->withQueryString(),
|
->withQueryString(),
|
||||||
'filters' => $request->only(['search']),
|
'filters' => $request->only(['search']),
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
use App\Models\ImportEvent;
|
use App\Models\ImportEvent;
|
||||||
use App\Models\ImportTemplate;
|
use App\Models\ImportTemplate;
|
||||||
use App\Services\CsvImportService;
|
use App\Services\CsvImportService;
|
||||||
use App\Services\Import\ImportServiceV2;
|
|
||||||
use App\Services\Import\ImportSimulationServiceV2;
|
use App\Services\Import\ImportSimulationServiceV2;
|
||||||
use App\Services\ImportProcessor;
|
use App\Services\ImportProcessor;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -190,6 +189,7 @@ public function process(Import $import, Request $request, ImportProcessor $proce
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
$result = $processor->process($import, user: $request->user());
|
$result = $processor->process($import, user: $request->user());
|
||||||
|
|
||||||
return response()->json($result);
|
return response()->json($result);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
\Log::error('Import processing failed', [
|
\Log::error('Import processing failed', [
|
||||||
@@ -712,8 +712,6 @@ public function simulatePayments(Import $import, Request $request)
|
|||||||
* templates. For payments templates, payment-specific summaries/entities will be included
|
* templates. For payments templates, payment-specific summaries/entities will be included
|
||||||
* automatically by the simulation service when mappings contain the payment root.
|
* automatically by the simulation service when mappings contain the payment root.
|
||||||
*
|
*
|
||||||
* @param Import $import
|
|
||||||
* @param Request $request
|
|
||||||
* @return \Illuminate\Http\JsonResponse
|
* @return \Illuminate\Http\JsonResponse
|
||||||
*/
|
*/
|
||||||
public function simulate(Import $import, Request $request)
|
public function simulate(Import $import, Request $request)
|
||||||
@@ -829,4 +827,19 @@ public function destroy(Request $request, Import $import)
|
|||||||
|
|
||||||
return back()->with('success', 'Import deleted successfully');
|
return back()->with('success', 'Import deleted successfully');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Download the original import file
|
||||||
|
public function download(Import $import)
|
||||||
|
{
|
||||||
|
// Verify file exists
|
||||||
|
if (! $import->disk || ! $import->path || ! Storage::disk($import->disk)->exists($import->path)) {
|
||||||
|
return response()->json([
|
||||||
|
'error' => 'File not found',
|
||||||
|
], 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
$fileName = $import->original_name ?? 'import_'.$import->uuid;
|
||||||
|
|
||||||
|
return Storage::disk($import->disk)->download($import->path, $fileName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -118,10 +118,10 @@ public function handle(SmsService $sms): void
|
|||||||
if ($template && $case) {
|
if ($template && $case) {
|
||||||
$note = '';
|
$note = '';
|
||||||
if ($log->status === 'sent') {
|
if ($log->status === 'sent') {
|
||||||
$note = sprintf('Št: %s | Telo: %s', (string) $this->to, (string) $this->content);
|
$note = sprintf('Tel: %s | Telo: %s', (string) $this->to, (string) $this->content);
|
||||||
} elseif ($log->status === 'failed') {
|
} elseif ($log->status === 'failed') {
|
||||||
$note = sprintf(
|
$note = sprintf(
|
||||||
'Št: %s | Telo: %s | Napaka: %s',
|
'Tel: %s | Telo: %s | Napaka: %s',
|
||||||
(string) $this->to,
|
(string) $this->to,
|
||||||
(string) $this->content,
|
(string) $this->content,
|
||||||
'SMS ni bil poslan!'
|
'SMS ni bil poslan!'
|
||||||
|
|||||||
@@ -1656,6 +1656,10 @@ private function upsertAccount(Import $import, array $mapped, $mappings, bool $h
|
|||||||
$value = $acc[$field] ?? null;
|
$value = $acc[$field] ?? null;
|
||||||
if (in_array($field, ['balance_amount', 'initial_amount'], true) && is_string($value)) {
|
if (in_array($field, ['balance_amount', 'initial_amount'], true) && is_string($value)) {
|
||||||
$value = $this->normalizeDecimal($value);
|
$value = $this->normalizeDecimal($value);
|
||||||
|
// Ensure the normalized value is numeric, otherwise default to 0
|
||||||
|
if ($value === '' || $value === '-' || ! is_numeric($value)) {
|
||||||
|
$value = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Convert empty string to 0 for amount fields
|
// Convert empty string to 0 for amount fields
|
||||||
if (in_array($field, ['balance_amount', 'initial_amount'], true) && ($value === '' || $value === null)) {
|
if (in_array($field, ['balance_amount', 'initial_amount'], true) && ($value === '' || $value === null)) {
|
||||||
@@ -1689,8 +1693,12 @@ private function upsertAccount(Import $import, array $mapped, $mappings, bool $h
|
|||||||
if ($existing) {
|
if ($existing) {
|
||||||
// Build non-null changes for account fields
|
// Build non-null changes for account fields
|
||||||
$changes = array_filter($applyUpdate, fn ($v) => ! is_null($v));
|
$changes = array_filter($applyUpdate, fn ($v) => ! is_null($v));
|
||||||
// Track balance change
|
// Track balance change - normalize in case DB has malformed data
|
||||||
$oldBalance = (float) ($existing->balance_amount ?? 0);
|
$rawBalance = $existing->balance_amount ?? 0;
|
||||||
|
if (is_string($rawBalance) && $rawBalance !== '') {
|
||||||
|
$rawBalance = $this->normalizeDecimal($rawBalance);
|
||||||
|
}
|
||||||
|
$oldBalance = is_numeric($rawBalance) ? (float) $rawBalance : 0;
|
||||||
// Note: meta merging for contracts is handled in upsertContractChain, not here
|
// Note: meta merging for contracts is handled in upsertContractChain, not here
|
||||||
if (! empty($changes)) {
|
if (! empty($changes)) {
|
||||||
$existing->fill($changes);
|
$existing->fill($changes);
|
||||||
@@ -1699,7 +1707,11 @@ private function upsertAccount(Import $import, array $mapped, $mappings, bool $h
|
|||||||
|
|
||||||
// If balance_amount changed and this wasn't caused by a payment (we are in account upsert), log an activity with before/after
|
// If balance_amount changed and this wasn't caused by a payment (we are in account upsert), log an activity with before/after
|
||||||
if (array_key_exists('balance_amount', $changes)) {
|
if (array_key_exists('balance_amount', $changes)) {
|
||||||
$newBalance = (float) ($existing->balance_amount ?? 0);
|
$rawNewBalance = $existing->balance_amount ?? 0;
|
||||||
|
if (is_string($rawNewBalance) && $rawNewBalance !== '') {
|
||||||
|
$rawNewBalance = $this->normalizeDecimal($rawNewBalance);
|
||||||
|
}
|
||||||
|
$newBalance = is_numeric($rawNewBalance) ? (float) $rawNewBalance : 0;
|
||||||
if ($newBalance !== $oldBalance) {
|
if ($newBalance !== $oldBalance) {
|
||||||
try {
|
try {
|
||||||
$contractId = $existing->contract_id;
|
$contractId = $existing->contract_id;
|
||||||
@@ -3194,7 +3206,7 @@ private function upsertAddress(int $personId, array $addrData, $mappings): array
|
|||||||
->first();*/
|
->first();*/
|
||||||
|
|
||||||
// Build search query combining address, post_code and city
|
// Build search query combining address, post_code and city
|
||||||
$searchParts = [$addrData['post_code']];
|
$searchParts = [$addrData['address']];
|
||||||
if (!empty($addrData['post_code'])) {
|
if (!empty($addrData['post_code'])) {
|
||||||
$searchParts[] = $addrData['post_code'];
|
$searchParts[] = $addrData['post_code'];
|
||||||
}
|
}
|
||||||
@@ -3204,7 +3216,7 @@ private function upsertAddress(int $personId, array $addrData, $mappings): array
|
|||||||
|
|
||||||
$searchQuery = implode(' ', $searchParts);
|
$searchQuery = implode(' ', $searchParts);
|
||||||
// Use fulltext search (GIN index optimized)
|
// Use fulltext search (GIN index optimized)
|
||||||
$existing = PersonAddress::where('person_id', $personId)
|
$existing = PersonAddress::query()->where('person_id', $personId)
|
||||||
->whereRaw("search_vector @@ plainto_tsquery('simple', ?)", [$searchQuery])
|
->whereRaw("search_vector @@ plainto_tsquery('simple', ?)", [$searchQuery])
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,10 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"dev": [
|
||||||
|
"Composer\\Config::disableProcessTimeout",
|
||||||
|
"npx concurrently -c \"#93c5fd,#c4b5fd,#fdba74\" \"php artisan serve --no-reload --port=8090\" \"php artisan queue:listen --tries=1\" \"npm run dev\" --names='server,queue,vite'"
|
||||||
|
],
|
||||||
"post-autoload-dump": [
|
"post-autoload-dump": [
|
||||||
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
|
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
|
||||||
"@php artisan package:discover --ansi"
|
"@php artisan package:discover --ansi"
|
||||||
|
|||||||
+49
@@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('person_addresses', function (Blueprint $table) {
|
||||||
|
$table->dropIndex('person_addresses_search_vector_idx');
|
||||||
|
$table->dropColumn('search_vector');
|
||||||
|
|
||||||
|
|
||||||
|
$table->string('post_code', 50)->nullable()->change();
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
// Add a generated tsvector column for fulltext search
|
||||||
|
DB::statement("
|
||||||
|
ALTER TABLE person_addresses
|
||||||
|
ADD COLUMN search_vector tsvector
|
||||||
|
GENERATED ALWAYS AS (
|
||||||
|
to_tsvector('simple',
|
||||||
|
coalesce(address, '') || ' ' ||
|
||||||
|
coalesce(post_code, '') || ' ' ||
|
||||||
|
coalesce(city, '')
|
||||||
|
)
|
||||||
|
) STORED
|
||||||
|
");
|
||||||
|
|
||||||
|
// Create GIN index on the tsvector column for fast fulltext search
|
||||||
|
DB::statement('CREATE INDEX person_addresses_search_vector_idx ON person_addresses USING GIN(search_vector)');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('person_addresses', function (Blueprint $table) {
|
||||||
|
$table->string('post_code', 20)->change();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
// @ts-check
|
||||||
|
import { test, expect } from '@playwright/test';
|
||||||
|
|
||||||
|
test('has title', async ({ page }) => {
|
||||||
|
await page.goto('https://playwright.dev/');
|
||||||
|
|
||||||
|
// Expect a title "to contain" a substring.
|
||||||
|
await expect(page).toHaveTitle(/Playwright/);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('get started link', async ({ page }) => {
|
||||||
|
await page.goto('https://playwright.dev/');
|
||||||
|
|
||||||
|
// Click the get started link.
|
||||||
|
await page.getByRole('link', { name: 'Get started' }).click();
|
||||||
|
|
||||||
|
// Expects page to have a heading with the name of Installation.
|
||||||
|
await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible();
|
||||||
|
});
|
||||||
Generated
+64
-18
@@ -48,6 +48,7 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@inertiajs/vue3": "2.0",
|
"@inertiajs/vue3": "2.0",
|
||||||
"@mdi/js": "^7.4.47",
|
"@mdi/js": "^7.4.47",
|
||||||
|
"@playwright/test": "^1.59.1",
|
||||||
"@tailwindcss/forms": "^0.5.10",
|
"@tailwindcss/forms": "^0.5.10",
|
||||||
"@tailwindcss/postcss": "^4.1.18",
|
"@tailwindcss/postcss": "^4.1.18",
|
||||||
"@tailwindcss/typography": "^0.5.19",
|
"@tailwindcss/typography": "^0.5.19",
|
||||||
@@ -1126,6 +1127,22 @@
|
|||||||
"state-local": "^1.0.6"
|
"state-local": "^1.0.6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@playwright/test": {
|
||||||
|
"version": "1.59.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.59.1.tgz",
|
||||||
|
"integrity": "sha512-PG6q63nQg5c9rIi4/Z5lR5IVF7yU5MqmKaPOe0HSc0O2cX1fPi96sUQu5j7eo4gKCkB2AnNGoWt7y4/Xx3Kcqg==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"dependencies": {
|
||||||
|
"playwright": "1.59.1"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"playwright": "cli.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@popperjs/core": {
|
"node_modules/@popperjs/core": {
|
||||||
"version": "2.11.8",
|
"version": "2.11.8",
|
||||||
"resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.8.tgz",
|
"resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.8.tgz",
|
||||||
@@ -5021,6 +5038,53 @@
|
|||||||
"url": "https://github.com/sponsors/jonschlinkert"
|
"url": "https://github.com/sponsors/jonschlinkert"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/playwright": {
|
||||||
|
"version": "1.59.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.59.1.tgz",
|
||||||
|
"integrity": "sha512-C8oWjPR3F81yljW9o5OxcWzfh6avkVwDD2VYdwIGqTkl+OGFISgypqzfu7dOe4QNLL2aqcWBmI3PMtLIK233lw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"dependencies": {
|
||||||
|
"playwright-core": "1.59.1"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"playwright": "cli.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18"
|
||||||
|
},
|
||||||
|
"optionalDependencies": {
|
||||||
|
"fsevents": "2.3.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/playwright-core": {
|
||||||
|
"version": "1.59.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.59.1.tgz",
|
||||||
|
"integrity": "sha512-HBV/RJg81z5BiiZ9yPzIiClYV/QMsDCKUyogwH9p3MCP6IYjUFu/MActgYAvK0oWyV9NlwM3GLBjADyWgydVyg==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"bin": {
|
||||||
|
"playwright-core": "cli.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/playwright/node_modules/fsevents": {
|
||||||
|
"version": "2.3.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
|
||||||
|
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
|
||||||
|
"dev": true,
|
||||||
|
"hasInstallScript": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"darwin"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/postcss": {
|
"node_modules/postcss": {
|
||||||
"version": "8.5.6",
|
"version": "8.5.6",
|
||||||
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.6.tgz",
|
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.6.tgz",
|
||||||
@@ -6029,24 +6093,6 @@
|
|||||||
"which": "bin/which"
|
"which": "bin/which"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/yaml": {
|
|
||||||
"version": "2.8.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/yaml/-/yaml-2.8.2.tgz",
|
|
||||||
"integrity": "sha512-mplynKqc1C2hTVYxd0PU2xQAc22TI1vShAYGksCCfxbn/dFwnHTNi1bvYsBTkhdUNtGIf5xNOg938rrSSYvS9A==",
|
|
||||||
"dev": true,
|
|
||||||
"license": "ISC",
|
|
||||||
"optional": true,
|
|
||||||
"peer": true,
|
|
||||||
"bin": {
|
|
||||||
"yaml": "bin.mjs"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 14.6"
|
|
||||||
},
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/eemeli"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/zod": {
|
"node_modules/zod": {
|
||||||
"version": "3.25.76",
|
"version": "3.25.76",
|
||||||
"resolved": "https://registry.npmjs.org/zod/-/zod-3.25.76.tgz",
|
"resolved": "https://registry.npmjs.org/zod/-/zod-3.25.76.tgz",
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@inertiajs/vue3": "2.0",
|
"@inertiajs/vue3": "2.0",
|
||||||
"@mdi/js": "^7.4.47",
|
"@mdi/js": "^7.4.47",
|
||||||
|
"@playwright/test": "^1.59.1",
|
||||||
"@tailwindcss/forms": "^0.5.10",
|
"@tailwindcss/forms": "^0.5.10",
|
||||||
"@tailwindcss/postcss": "^4.1.18",
|
"@tailwindcss/postcss": "^4.1.18",
|
||||||
"@tailwindcss/typography": "^0.5.19",
|
"@tailwindcss/typography": "^0.5.19",
|
||||||
|
|||||||
@@ -0,0 +1,81 @@
|
|||||||
|
// @ts-check
|
||||||
|
import { defineConfig, devices } from '@playwright/test';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read environment variables from file.
|
||||||
|
* https://github.com/motdotla/dotenv
|
||||||
|
*/
|
||||||
|
// import dotenv from 'dotenv';
|
||||||
|
// import path from 'path';
|
||||||
|
// dotenv.config({ path: path.resolve(__dirname, '.env') });
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see https://playwright.dev/docs/test-configuration
|
||||||
|
*/
|
||||||
|
export default defineConfig({
|
||||||
|
testDir: './e2e',
|
||||||
|
/* Run tests in files in parallel */
|
||||||
|
fullyParallel: true,
|
||||||
|
/* Fail the build on CI if you accidentally left test.only in the source code. */
|
||||||
|
forbidOnly: !!process.env.CI,
|
||||||
|
/* Retry on CI only */
|
||||||
|
retries: process.env.CI ? 2 : 0,
|
||||||
|
/* Opt out of parallel tests on CI. */
|
||||||
|
workers: process.env.CI ? 1 : undefined,
|
||||||
|
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
|
||||||
|
reporter: 'html',
|
||||||
|
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
|
||||||
|
use: {
|
||||||
|
/* Base URL to use in actions like `await page.goto('')`. */
|
||||||
|
// baseURL: 'http://localhost:3000',
|
||||||
|
|
||||||
|
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
||||||
|
trace: 'on-first-retry',
|
||||||
|
},
|
||||||
|
|
||||||
|
/* Configure projects for major browsers */
|
||||||
|
projects: [
|
||||||
|
{
|
||||||
|
name: 'chromium',
|
||||||
|
use: { ...devices['Desktop Chrome'] },
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
name: 'firefox',
|
||||||
|
use: { ...devices['Desktop Firefox'] },
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
name: 'webkit',
|
||||||
|
use: { ...devices['Desktop Safari'] },
|
||||||
|
},
|
||||||
|
|
||||||
|
/* Test against mobile viewports. */
|
||||||
|
// {
|
||||||
|
// name: 'Mobile Chrome',
|
||||||
|
// use: { ...devices['Pixel 5'] },
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// name: 'Mobile Safari',
|
||||||
|
// use: { ...devices['iPhone 12'] },
|
||||||
|
// },
|
||||||
|
|
||||||
|
/* Test against branded browsers. */
|
||||||
|
// {
|
||||||
|
// name: 'Microsoft Edge',
|
||||||
|
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// name: 'Google Chrome',
|
||||||
|
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
|
||||||
|
// },
|
||||||
|
],
|
||||||
|
|
||||||
|
/* Run your local dev server before starting the tests */
|
||||||
|
// webServer: {
|
||||||
|
// command: 'npm run start',
|
||||||
|
// url: 'http://localhost:3000',
|
||||||
|
// reuseExistingServer: !process.env.CI,
|
||||||
|
// },
|
||||||
|
});
|
||||||
|
|
||||||
@@ -69,7 +69,7 @@ const maxWidthClass = computed(() => {
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Dialog v-model:open="open">
|
<Dialog v-model:open="open">
|
||||||
<DialogContent :class="maxWidthClass">
|
<DialogContent class="overflow-auto max-h-3/4" :class="maxWidthClass">
|
||||||
<DialogHeader>
|
<DialogHeader>
|
||||||
<DialogTitle>
|
<DialogTitle>
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-2">
|
||||||
|
|||||||
@@ -6,34 +6,40 @@ import {
|
|||||||
DialogFooter,
|
DialogFooter,
|
||||||
DialogHeader,
|
DialogHeader,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
} from '@/Components/ui/dialog';
|
} from "@/Components/ui/dialog";
|
||||||
import { Button } from '@/Components/ui/button';
|
import { Button } from "@/Components/ui/button";
|
||||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
|
||||||
import { faTrashCan, faTriangleExclamation } from '@fortawesome/free-solid-svg-icons';
|
import { faTrashCan, faTriangleExclamation } from "@fortawesome/free-solid-svg-icons";
|
||||||
import { ref, watch } from 'vue';
|
import { ref, watch } from "vue";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
show: { type: Boolean, default: false },
|
show: { type: Boolean, default: false },
|
||||||
title: { type: String, default: 'Izbriši' },
|
title: { type: String, default: "Izbriši" },
|
||||||
message: { type: String, default: 'Ali ste prepričani, da želite izbrisati ta element?' },
|
message: {
|
||||||
confirmText: { type: String, default: 'Izbriši' },
|
type: String,
|
||||||
cancelText: { type: String, default: 'Prekliči' },
|
default: "Ali ste prepričani, da želite izbrisati ta element?",
|
||||||
|
},
|
||||||
|
confirmText: { type: String, default: "Izbriši" },
|
||||||
|
cancelText: { type: String, default: "Prekliči" },
|
||||||
processing: { type: Boolean, default: false },
|
processing: { type: Boolean, default: false },
|
||||||
itemName: { type: String, default: null }, // Optional name to show in confirmation
|
itemName: { type: String, default: null }, // Optional name to show in confirmation
|
||||||
});
|
});
|
||||||
|
|
||||||
const emit = defineEmits(['update:show', 'close', 'confirm']);
|
const emit = defineEmits(["update:show", "close", "confirm"]);
|
||||||
|
|
||||||
const open = ref(props.show);
|
const open = ref(props.show);
|
||||||
|
|
||||||
watch(() => props.show, (newVal) => {
|
watch(
|
||||||
|
() => props.show,
|
||||||
|
(newVal) => {
|
||||||
open.value = newVal;
|
open.value = newVal;
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
watch(open, (newVal) => {
|
watch(open, (newVal) => {
|
||||||
emit('update:show', newVal);
|
emit("update:show", newVal);
|
||||||
if (!newVal) {
|
if (!newVal) {
|
||||||
emit('close');
|
emit("close");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -42,7 +48,7 @@ const onClose = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const onConfirm = () => {
|
const onConfirm = () => {
|
||||||
emit('confirm');
|
emit("confirm");
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -59,8 +65,13 @@ const onConfirm = () => {
|
|||||||
<DialogDescription>
|
<DialogDescription>
|
||||||
<div class="flex items-start gap-4 pt-4">
|
<div class="flex items-start gap-4 pt-4">
|
||||||
<div class="flex-shrink-0">
|
<div class="flex-shrink-0">
|
||||||
<div class="flex items-center justify-center h-12 w-12 rounded-full bg-red-100">
|
<div
|
||||||
<FontAwesomeIcon :icon="faTriangleExclamation" class="h-6 w-6 text-red-600" />
|
class="flex items-center justify-center h-12 w-12 rounded-full bg-red-100"
|
||||||
|
>
|
||||||
|
<FontAwesomeIcon
|
||||||
|
:icon="faTriangleExclamation"
|
||||||
|
class="h-6 w-6 text-red-600"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex-1 space-y-2">
|
<div class="flex-1 space-y-2">
|
||||||
@@ -70,9 +81,7 @@ const onConfirm = () => {
|
|||||||
<p v-if="itemName" class="text-sm font-medium text-gray-900">
|
<p v-if="itemName" class="text-sm font-medium text-gray-900">
|
||||||
{{ itemName }}
|
{{ itemName }}
|
||||||
</p>
|
</p>
|
||||||
<p class="text-sm text-gray-500">
|
<p class="text-sm text-gray-500">Ta dejanje ni mogoče razveljaviti.</p>
|
||||||
Ta dejanje ni mogoče razveljaviti.
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</DialogDescription>
|
</DialogDescription>
|
||||||
@@ -82,15 +91,10 @@ const onConfirm = () => {
|
|||||||
<Button variant="outline" @click="onClose" :disabled="processing">
|
<Button variant="outline" @click="onClose" :disabled="processing">
|
||||||
{{ cancelText }}
|
{{ cancelText }}
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button variant="destructive" @click="onConfirm" :disabled="processing">
|
||||||
variant="destructive"
|
|
||||||
@click="onConfirm"
|
|
||||||
:disabled="processing"
|
|
||||||
>
|
|
||||||
{{ confirmText }}
|
{{ confirmText }}
|
||||||
</Button>
|
</Button>
|
||||||
</DialogFooter>
|
</DialogFooter>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ const maxWidthClass = computed(() => {
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Dialog v-model:open="open">
|
<Dialog v-model:open="open">
|
||||||
<DialogContent :class="maxWidthClass">
|
<DialogContent class="overflow-auto max-h-3/4" :class="maxWidthClass">
|
||||||
<DialogHeader>
|
<DialogHeader>
|
||||||
<DialogTitle>
|
<DialogTitle>
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-2">
|
||||||
|
|||||||
@@ -1,15 +1,27 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import CreateDialog from '@/Components/Dialogs/CreateDialog.vue'
|
import CreateDialog from "@/Components/Dialogs/CreateDialog.vue";
|
||||||
import { useForm } from 'vee-validate'
|
import { useForm } from "vee-validate";
|
||||||
import { toTypedSchema } from '@vee-validate/zod'
|
import { toTypedSchema } from "@vee-validate/zod";
|
||||||
import * as z from 'zod'
|
import * as z from "zod";
|
||||||
import { ref, watch } from 'vue'
|
import { ref, watch } from "vue";
|
||||||
import { router } from '@inertiajs/vue3'
|
import { router } from "@inertiajs/vue3";
|
||||||
import { FormControl, FormField, FormItem, FormLabel, FormMessage } from '@/Components/ui/form'
|
import {
|
||||||
import { Input } from '@/Components/ui/input'
|
FormControl,
|
||||||
import { Textarea } from '@/Components/ui/textarea'
|
FormField,
|
||||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/Components/ui/select'
|
FormItem,
|
||||||
import { Switch } from '@/Components/ui/switch'
|
FormLabel,
|
||||||
|
FormMessage,
|
||||||
|
} from "@/Components/ui/form";
|
||||||
|
import { Input } from "@/Components/ui/input";
|
||||||
|
import { Textarea } from "@/Components/ui/textarea";
|
||||||
|
import {
|
||||||
|
Select,
|
||||||
|
SelectContent,
|
||||||
|
SelectItem,
|
||||||
|
SelectTrigger,
|
||||||
|
SelectValue,
|
||||||
|
} from "@/Components/ui/select";
|
||||||
|
import { Switch } from "@/Components/ui/switch";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
show: { type: Boolean, default: false },
|
show: { type: Boolean, default: false },
|
||||||
@@ -17,112 +29,128 @@ const props = defineProps({
|
|||||||
// Optional list of contracts to allow attaching the document directly to a contract
|
// Optional list of contracts to allow attaching the document directly to a contract
|
||||||
// Each item should have at least: { uuid, reference }
|
// Each item should have at least: { uuid, reference }
|
||||||
contracts: { type: Array, default: () => [] },
|
contracts: { type: Array, default: () => [] },
|
||||||
})
|
});
|
||||||
const emit = defineEmits(['close', 'uploaded'])
|
const emit = defineEmits(["close", "uploaded"]);
|
||||||
|
|
||||||
const MAX_SIZE = 25 * 1024 * 1024 // 25MB
|
const MAX_SIZE = 25 * 1024 * 1024; // 25MB
|
||||||
const ALLOWED_EXTS = ['doc','docx','pdf','txt','csv','xls','xlsx','jpeg','jpg','png']
|
const ALLOWED_EXTS = [
|
||||||
|
"doc",
|
||||||
|
"docx",
|
||||||
|
"pdf",
|
||||||
|
"txt",
|
||||||
|
"csv",
|
||||||
|
"xls",
|
||||||
|
"xlsx",
|
||||||
|
"jpeg",
|
||||||
|
"jpg",
|
||||||
|
"png",
|
||||||
|
];
|
||||||
|
|
||||||
const formSchema = toTypedSchema(z.object({
|
const formSchema = toTypedSchema(
|
||||||
name: z.string().min(1, 'Ime je obvezno'),
|
z.object({
|
||||||
|
name: z.string().min(1, "Ime je obvezno"),
|
||||||
description: z.string().optional(),
|
description: z.string().optional(),
|
||||||
file: z.instanceof(File).refine((file) => file.size > 0, 'Izberite datoteko'),
|
file: z.instanceof(File).refine((file) => file.size > 0, "Izberite datoteko"),
|
||||||
is_public: z.boolean().default(true),
|
is_public: z.boolean().default(true),
|
||||||
contract_uuid: z.string().nullable().optional(),
|
contract_uuid: z.string().nullable().optional(),
|
||||||
}))
|
})
|
||||||
|
);
|
||||||
|
|
||||||
const form = useForm({
|
const form = useForm({
|
||||||
validationSchema: formSchema,
|
validationSchema: formSchema,
|
||||||
initialValues: {
|
initialValues: {
|
||||||
name: '',
|
name: "",
|
||||||
description: '',
|
description: "",
|
||||||
file: null,
|
file: null,
|
||||||
is_public: true,
|
is_public: true,
|
||||||
contract_uuid: null,
|
contract_uuid: null,
|
||||||
},
|
},
|
||||||
})
|
});
|
||||||
|
|
||||||
const localError = ref('')
|
const localError = ref("");
|
||||||
|
|
||||||
watch(() => props.show, (v) => {
|
watch(
|
||||||
if (!v) return
|
() => props.show,
|
||||||
localError.value = ''
|
(v) => {
|
||||||
form.resetForm()
|
if (!v) return;
|
||||||
})
|
localError.value = "";
|
||||||
|
form.resetForm();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
const onFileChange = (e) => {
|
const onFileChange = (e) => {
|
||||||
localError.value = ''
|
localError.value = "";
|
||||||
const f = e.target.files?.[0]
|
const f = e.target.files?.[0];
|
||||||
if (!f) {
|
if (!f) {
|
||||||
form.setFieldValue('file', null)
|
form.setFieldValue("file", null);
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
const ext = (f.name.split('.').pop() || '').toLowerCase()
|
const ext = (f.name.split(".").pop() || "").toLowerCase();
|
||||||
if (!ALLOWED_EXTS.includes(ext)) {
|
if (!ALLOWED_EXTS.includes(ext)) {
|
||||||
localError.value = 'Nepodprta vrsta datoteke. Dovoljeno: ' + ALLOWED_EXTS.join(', ')
|
localError.value = "Nepodprta vrsta datoteke. Dovoljeno: " + ALLOWED_EXTS.join(", ");
|
||||||
e.target.value = ''
|
e.target.value = "";
|
||||||
form.setFieldValue('file', null)
|
form.setFieldValue("file", null);
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
if (f.size > MAX_SIZE) {
|
if (f.size > MAX_SIZE) {
|
||||||
localError.value = 'Datoteka je prevelika. Največja velikost je 25MB.'
|
localError.value = "Datoteka je prevelika. Največja velikost je 25MB.";
|
||||||
e.target.value = ''
|
e.target.value = "";
|
||||||
form.setFieldValue('file', null)
|
form.setFieldValue("file", null);
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
form.setFieldValue('file', f)
|
form.setFieldValue("file", f);
|
||||||
if (!form.values.name) {
|
if (!form.values.name) {
|
||||||
form.setFieldValue('name', f.name.replace(/\.[^.]+$/, ''))
|
form.setFieldValue("name", f.name.replace(/\.[^.]+$/, ""));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const submit = form.handleSubmit(async (values) => {
|
const submit = form.handleSubmit(async (values) => {
|
||||||
localError.value = ''
|
localError.value = "";
|
||||||
if (!values.file) {
|
if (!values.file) {
|
||||||
localError.value = 'Prosimo izberite datoteko.'
|
localError.value = "Prosimo izberite datoteko.";
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
const ext = (values.file.name.split('.').pop() || '').toLowerCase()
|
const ext = (values.file.name.split(".").pop() || "").toLowerCase();
|
||||||
if (!ALLOWED_EXTS.includes(ext)) {
|
if (!ALLOWED_EXTS.includes(ext)) {
|
||||||
localError.value = 'Nepodprta vrsta datoteke. Dovoljeno: ' + ALLOWED_EXTS.join(', ')
|
localError.value = "Nepodprta vrsta datoteke. Dovoljeno: " + ALLOWED_EXTS.join(", ");
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
if (values.file.size > MAX_SIZE) {
|
if (values.file.size > MAX_SIZE) {
|
||||||
localError.value = 'Datoteka je prevelika. Največja velikost je 25MB.'
|
localError.value = "Datoteka je prevelika. Največja velikost je 25MB.";
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const formData = new FormData()
|
const formData = new FormData();
|
||||||
formData.append('name', values.name)
|
formData.append("name", values.name);
|
||||||
formData.append('description', values.description || '')
|
formData.append("description", values.description || "");
|
||||||
formData.append('file', values.file)
|
formData.append("file", values.file);
|
||||||
formData.append('is_public', values.is_public ? '1' : '0')
|
formData.append("is_public", values.is_public ? "1" : "0");
|
||||||
if (values.contract_uuid) {
|
if (values.contract_uuid) {
|
||||||
formData.append('contract_uuid', values.contract_uuid)
|
formData.append("contract_uuid", values.contract_uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
router.post(props.postUrl, formData, {
|
router.post(props.postUrl, formData, {
|
||||||
forceFormData: true,
|
forceFormData: true,
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
emit('uploaded')
|
emit("uploaded");
|
||||||
emit('close')
|
emit("close");
|
||||||
form.resetForm()
|
form.resetForm();
|
||||||
},
|
},
|
||||||
onError: (errors) => {
|
onError: (errors) => {
|
||||||
// Set form errors if any
|
// Set form errors if any
|
||||||
if (errors.name) form.setFieldError('name', errors.name)
|
if (errors.name) form.setFieldError("name", errors.name);
|
||||||
if (errors.description) form.setFieldError('description', errors.description)
|
if (errors.description) form.setFieldError("description", errors.description);
|
||||||
if (errors.file) form.setFieldError('file', errors.file)
|
if (errors.file) form.setFieldError("file", errors.file);
|
||||||
if (errors.contract_uuid) form.setFieldError('contract_uuid', errors.contract_uuid)
|
if (errors.contract_uuid) form.setFieldError("contract_uuid", errors.contract_uuid);
|
||||||
},
|
},
|
||||||
})
|
});
|
||||||
})
|
});
|
||||||
|
|
||||||
const close = () => emit('close')
|
const close = () => emit("close");
|
||||||
|
|
||||||
const onConfirm = () => {
|
const onConfirm = () => {
|
||||||
submit()
|
submit();
|
||||||
}
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -137,7 +165,11 @@ const onConfirm = () => {
|
|||||||
@confirm="onConfirm"
|
@confirm="onConfirm"
|
||||||
>
|
>
|
||||||
<form @submit.prevent="submit" class="space-y-4">
|
<form @submit.prevent="submit" class="space-y-4">
|
||||||
<FormField v-if="props.contracts && props.contracts.length" v-slot="{ value, handleChange }" name="contract_uuid">
|
<FormField
|
||||||
|
v-if="props.contracts && props.contracts.length"
|
||||||
|
v-slot="{ value, handleChange }"
|
||||||
|
name="contract_uuid"
|
||||||
|
>
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>Pripiši k</FormLabel>
|
<FormLabel>Pripiši k</FormLabel>
|
||||||
<Select :model-value="value" @update:model-value="handleChange">
|
<Select :model-value="value" @update:model-value="handleChange">
|
||||||
@@ -148,11 +180,7 @@ const onConfirm = () => {
|
|||||||
</FormControl>
|
</FormControl>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
<SelectItem :value="null">Primer</SelectItem>
|
<SelectItem :value="null">Primer</SelectItem>
|
||||||
<SelectItem
|
<SelectItem v-for="c in props.contracts" :key="c.uuid" :value="c.uuid">
|
||||||
v-for="c in props.contracts"
|
|
||||||
:key="c.uuid"
|
|
||||||
:value="c.uuid"
|
|
||||||
>
|
|
||||||
Pogodba: {{ c.reference }}
|
Pogodba: {{ c.reference }}
|
||||||
</SelectItem>
|
</SelectItem>
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
@@ -165,7 +193,11 @@ const onConfirm = () => {
|
|||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>Ime</FormLabel>
|
<FormLabel>Ime</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input id="doc_name" v-bind="componentField" />
|
<Input
|
||||||
|
id="doc_name"
|
||||||
|
v-bind="componentField"
|
||||||
|
class="w-full max-w-full overflow-hidden text-ellipsis"
|
||||||
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
@@ -184,29 +216,24 @@ const onConfirm = () => {
|
|||||||
<FormField v-slot="{ value, handleChange }" name="file">
|
<FormField v-slot="{ value, handleChange }" name="file">
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>Datoteka (max 25MB)</FormLabel>
|
<FormLabel>Datoteka (max 25MB)</FormLabel>
|
||||||
<FormControl>
|
<FormControl class="flex w-full">
|
||||||
<Input
|
<Input
|
||||||
id="doc_file"
|
id="doc_file"
|
||||||
type="file"
|
type="file"
|
||||||
@change="onFileChange"
|
@change="onFileChange"
|
||||||
accept=".doc,.docx,.pdf,.txt,.csv,.xls,.xlsx,.jpeg,.jpg,.png"
|
accept=".doc,.docx,.pdf,.txt,.csv,.xls,.xlsx,.jpeg,.jpg,.png"
|
||||||
|
class="min-w-0 w-full"
|
||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
<div v-if="localError" class="text-sm text-red-600 mt-1">{{ localError }}</div>
|
<div v-if="localError" class="text-sm text-red-600 mt-1">{{ localError }}</div>
|
||||||
<div v-if="value" class="text-sm text-gray-600 mt-1">
|
|
||||||
Izbrana datoteka: {{ value.name }} ({{ (value.size / 1024).toFixed(2) }} KB)
|
|
||||||
</div>
|
|
||||||
</FormItem>
|
</FormItem>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
<FormField v-slot="{ value, handleChange }" name="is_public">
|
<FormField v-slot="{ value, handleChange }" name="is_public">
|
||||||
<FormItem class="flex flex-row items-start space-x-3 space-y-0">
|
<FormItem class="flex flex-row items-start space-x-3 space-y-0">
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Switch
|
<Switch :model-value="value" @update:model-value="handleChange" />
|
||||||
:model-value="value"
|
|
||||||
@update:model-value="handleChange"
|
|
||||||
/>
|
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<div class="space-y-1 leading-none">
|
<div class="space-y-1 leading-none">
|
||||||
<FormLabel>Javno</FormLabel>
|
<FormLabel>Javno</FormLabel>
|
||||||
|
|||||||
@@ -1,30 +1,219 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
|
import { ref, computed, watch } from "vue";
|
||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
DialogContent,
|
DialogContent,
|
||||||
|
DialogDescription,
|
||||||
DialogHeader,
|
DialogHeader,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
} from '@/Components/ui/dialog'
|
} from "@/Components/ui/dialog";
|
||||||
import { Button } from '@/Components/ui/button'
|
import { Button } from "@/Components/ui/button";
|
||||||
|
import { Badge } from "../ui/badge";
|
||||||
|
import { Loader2 } from "lucide-vue-next";
|
||||||
|
import axios from "axios";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
show: { type: Boolean, default: false },
|
show: { type: Boolean, default: false },
|
||||||
src: { type: String, default: '' },
|
src: { type: String, default: "" },
|
||||||
title: { type: String, default: 'Dokument' }
|
title: { type: String, default: "Dokument" },
|
||||||
})
|
mimeType: { type: String, default: "" },
|
||||||
const emit = defineEmits(['close'])
|
filename: { type: String, default: "" },
|
||||||
|
});
|
||||||
|
const emit = defineEmits(["close"]);
|
||||||
|
|
||||||
|
const textContent = ref("");
|
||||||
|
const loading = ref(false);
|
||||||
|
const previewGenerating = ref(false);
|
||||||
|
const previewError = ref("");
|
||||||
|
|
||||||
|
const fileExtension = computed(() => {
|
||||||
|
if (props.filename) {
|
||||||
|
return props.filename.split(".").pop()?.toLowerCase() || "";
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
});
|
||||||
|
|
||||||
|
const viewerType = computed(() => {
|
||||||
|
const ext = fileExtension.value;
|
||||||
|
const mime = props.mimeType.toLowerCase();
|
||||||
|
|
||||||
|
if (ext === "pdf" || mime === "application/pdf") return "pdf";
|
||||||
|
// DOCX/DOC files are converted to PDF by backend - treat as PDF viewer
|
||||||
|
if (["doc", "docx"].includes(ext) || mime.includes("word") || mime.includes("msword"))
|
||||||
|
return "docx";
|
||||||
|
if (["jpg", "jpeg", "png", "gif", "webp"].includes(ext) || mime.startsWith("image/"))
|
||||||
|
return "image";
|
||||||
|
if (["txt", "csv", "xml"].includes(ext) || mime.startsWith("text/")) return "text";
|
||||||
|
|
||||||
|
return "unsupported";
|
||||||
|
});
|
||||||
|
|
||||||
|
const loadTextContent = async () => {
|
||||||
|
if (!props.src || viewerType.value !== "text") return;
|
||||||
|
loading.value = true;
|
||||||
|
try {
|
||||||
|
const response = await axios.get(props.src);
|
||||||
|
textContent.value = response.data;
|
||||||
|
} catch (e) {
|
||||||
|
textContent.value = "Napaka pri nalaganju vsebine.";
|
||||||
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// For DOCX files, the backend converts to PDF. If the preview isn't ready yet (202 status),
|
||||||
|
// we poll until it's available.
|
||||||
|
const docxPreviewUrl = ref("");
|
||||||
|
const loadDocxPreview = async () => {
|
||||||
|
if (!props.src || viewerType.value !== "docx") return;
|
||||||
|
|
||||||
|
previewGenerating.value = true;
|
||||||
|
previewError.value = "";
|
||||||
|
docxPreviewUrl.value = "";
|
||||||
|
|
||||||
|
const maxRetries = 15;
|
||||||
|
const retryDelay = 2000; // 2 seconds between retries
|
||||||
|
|
||||||
|
for (let attempt = 0; attempt < maxRetries; attempt++) {
|
||||||
|
try {
|
||||||
|
const response = await axios.head(props.src, { validateStatus: () => true });
|
||||||
|
|
||||||
|
if (response.status >= 200 && response.status < 300) {
|
||||||
|
// Preview is ready
|
||||||
|
docxPreviewUrl.value = props.src;
|
||||||
|
previewGenerating.value = false;
|
||||||
|
return;
|
||||||
|
} else if (response.status === 202) {
|
||||||
|
// Preview is being generated, wait and retry
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, retryDelay));
|
||||||
|
} else {
|
||||||
|
// Other error
|
||||||
|
previewError.value = "Napaka pri nalaganju predogleda.";
|
||||||
|
previewGenerating.value = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
previewError.value = "Napaka pri nalaganju predogleda.";
|
||||||
|
previewGenerating.value = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Max retries reached
|
||||||
|
previewError.value = "Predogled ni na voljo. Prosimo poskusite znova kasneje.";
|
||||||
|
previewGenerating.value = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => [props.show, props.src],
|
||||||
|
([show]) => {
|
||||||
|
if (show && viewerType.value === "text") {
|
||||||
|
loadTextContent();
|
||||||
|
}
|
||||||
|
if (show && viewerType.value === "docx") {
|
||||||
|
loadDocxPreview();
|
||||||
|
}
|
||||||
|
// Reset states when dialog closes
|
||||||
|
if (!show) {
|
||||||
|
previewGenerating.value = false;
|
||||||
|
previewError.value = "";
|
||||||
|
docxPreviewUrl.value = "";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ immediate: true }
|
||||||
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Dialog :open="show" @update:open="(open) => !open && $emit('close')">
|
<Dialog :open="show" @update:open="(open) => !open && $emit('close')">
|
||||||
<DialogContent class="max-w-4xl">
|
<DialogContent class="max-w-full xl:max-w-7xl">
|
||||||
<DialogHeader>
|
<DialogHeader>
|
||||||
<DialogTitle>{{ props.title }}</DialogTitle>
|
<DialogTitle>
|
||||||
|
{{ title }}
|
||||||
|
</DialogTitle>
|
||||||
|
<DialogDescription>
|
||||||
|
<Badge>
|
||||||
|
{{ fileExtension }}
|
||||||
|
</Badge>
|
||||||
|
</DialogDescription>
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
<div class="h-[70vh]">
|
|
||||||
<iframe v-if="props.src" :src="props.src" class="w-full h-full rounded border" />
|
<div class="h-[70vh] overflow-auto">
|
||||||
|
<!-- PDF Viewer (browser native) -->
|
||||||
|
<template v-if="viewerType === 'pdf' && props.src">
|
||||||
|
<iframe
|
||||||
|
:src="props.src"
|
||||||
|
class="w-full h-full rounded border"
|
||||||
|
type="application/pdf"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<!-- DOCX Viewer (converted to PDF by backend) -->
|
||||||
|
<template v-else-if="viewerType === 'docx'">
|
||||||
|
<!-- Loading/generating state -->
|
||||||
|
<div
|
||||||
|
v-if="previewGenerating"
|
||||||
|
class="flex flex-col items-center justify-center h-full gap-4"
|
||||||
|
>
|
||||||
|
<Loader2 class="h-8 w-8 animate-spin text-indigo-600" />
|
||||||
|
<span class="text-gray-500">Priprava predogleda dokumenta...</span>
|
||||||
|
</div>
|
||||||
|
<!-- Error state -->
|
||||||
|
<div
|
||||||
|
v-else-if="previewError"
|
||||||
|
class="flex flex-col items-center justify-center h-full gap-4 text-gray-500"
|
||||||
|
>
|
||||||
|
<span>{{ previewError }}</span>
|
||||||
|
<Button as="a" :href="props.src" target="_blank" variant="outline">
|
||||||
|
Prenesi datoteko
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
<!-- Preview ready -->
|
||||||
|
<iframe
|
||||||
|
v-else-if="docxPreviewUrl"
|
||||||
|
:src="docxPreviewUrl"
|
||||||
|
class="w-full h-full rounded border"
|
||||||
|
type="application/pdf"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<!-- Image Viewer -->
|
||||||
|
<template v-else-if="viewerType === 'image' && props.src">
|
||||||
|
<img
|
||||||
|
:src="props.src"
|
||||||
|
:alt="props.title"
|
||||||
|
class="max-w-full max-h-full mx-auto object-contain"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<!-- Text/CSV/XML Viewer -->
|
||||||
|
<template v-else-if="viewerType === 'text'">
|
||||||
|
<div v-if="loading" class="flex items-center justify-center h-full">
|
||||||
|
<div class="animate-pulse text-gray-500">Nalaganje...</div>
|
||||||
|
</div>
|
||||||
|
<pre
|
||||||
|
v-else
|
||||||
|
class="p-4 bg-gray-50 dark:bg-gray-900 rounded border text-sm overflow-auto h-full whitespace-pre-wrap wrap-break-word"
|
||||||
|
>{{ textContent }}</pre
|
||||||
|
>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<!-- Unsupported -->
|
||||||
|
<template v-else-if="viewerType === 'unsupported'">
|
||||||
|
<div
|
||||||
|
class="flex flex-col items-center justify-center h-full gap-4 text-gray-500"
|
||||||
|
>
|
||||||
|
<span>Predogled ni na voljo za to vrsto datoteke.</span>
|
||||||
|
<Button as="a" :href="props.src" target="_blank" variant="outline">
|
||||||
|
Prenesi datoteko
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<!-- No source -->
|
||||||
<div v-else class="text-sm text-gray-500">Ni dokumenta za prikaz.</div>
|
<div v-else class="text-sm text-gray-500">Ni dokumenta za prikaz.</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex justify-end mt-4">
|
<div class="flex justify-end mt-4">
|
||||||
<Button type="button" variant="outline" @click="$emit('close')">Zapri</Button>
|
<Button type="button" variant="outline" @click="$emit('close')">Zapri</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -299,7 +299,7 @@ const switchToTab = (tab) => {
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Tabs v-model="activeTab" class="mt-2">
|
<Tabs v-model="activeTab" class="mt-2">
|
||||||
<TabsList class="flex w-full bg-white gap-2 p-1">
|
<TabsList class="flex flex-row flex-wrap bg-white gap-2 p-1">
|
||||||
<TabsTrigger
|
<TabsTrigger
|
||||||
value="person"
|
value="person"
|
||||||
class="border border-gray-200 data-[state=active]:bg-primary-50 data-[state=active]:text-primary-700 flex-1 py-2"
|
class="border border-gray-200 data-[state=active]:bg-primary-50 data-[state=active]:text-primary-700 flex-1 py-2"
|
||||||
|
|||||||
@@ -8,7 +8,13 @@ import {
|
|||||||
} from "@/Components/ui/dropdown-menu";
|
} from "@/Components/ui/dropdown-menu";
|
||||||
import { Card } from "@/Components/ui/card";
|
import { Card } from "@/Components/ui/card";
|
||||||
import { Button } from "../ui/button";
|
import { Button } from "../ui/button";
|
||||||
import { EllipsisVertical, MessageSquare, MessageSquareText } from "lucide-vue-next";
|
import {
|
||||||
|
CircleCheckBigIcon,
|
||||||
|
CircleCheckIcon,
|
||||||
|
EllipsisVertical,
|
||||||
|
MessageSquare,
|
||||||
|
MessageSquareText,
|
||||||
|
} from "lucide-vue-next";
|
||||||
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "../ui/tooltip";
|
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "../ui/tooltip";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
@@ -79,8 +85,9 @@ const handleSms = (phone) => emit("sms", phone);
|
|||||||
</DropdownMenu>
|
</DropdownMenu>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<p class="font-medium leading-relaxed p-1">
|
<p class="font-medium leading-relaxed p-1 flex gap-1 items-center">
|
||||||
{{ phone.nu }}
|
{{ phone.nu }}
|
||||||
|
<CircleCheckBigIcon color="#3e9392" size="20" v-if="phone.validated" />
|
||||||
</p>
|
</p>
|
||||||
<p class="text-sm text-muted-foreground p-1" v-if="phone.description">
|
<p class="text-sm text-muted-foreground p-1" v-if="phone.description">
|
||||||
{{ phone.description }}
|
{{ phone.description }}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref, watch, computed } from "vue";
|
import { ref, watch, computed } from "vue";
|
||||||
|
import axios from "axios";
|
||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
DialogContent,
|
DialogContent,
|
||||||
@@ -301,28 +302,14 @@ const updateSmsFromSelection = async () => {
|
|||||||
const url = route("clientCase.sms.preview", {
|
const url = route("clientCase.sms.preview", {
|
||||||
client_case: props.clientCaseUuid,
|
client_case: props.clientCaseUuid,
|
||||||
});
|
});
|
||||||
const res = await fetch(url, {
|
const { data } = await axios.post(url, {
|
||||||
method: "POST",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-Requested-With": "XMLHttpRequest",
|
|
||||||
"X-CSRF-TOKEN":
|
|
||||||
document.querySelector('meta[name="csrf-token"]')?.getAttribute("content") ||
|
|
||||||
"",
|
|
||||||
},
|
|
||||||
body: JSON.stringify({
|
|
||||||
template_id: form.values.template_id,
|
template_id: form.values.template_id,
|
||||||
contract_uuid: form.values.contract_uuid || null,
|
contract_uuid: form.values.contract_uuid || null,
|
||||||
}),
|
|
||||||
credentials: "same-origin",
|
|
||||||
});
|
});
|
||||||
if (res.ok) {
|
|
||||||
const data = await res.json();
|
|
||||||
if (typeof data?.content === "string" && data.content.trim() !== "") {
|
if (typeof data?.content === "string" && data.content.trim() !== "") {
|
||||||
form.setFieldValue("message", data.content);
|
form.setFieldValue("message", data.content);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// ignore and fallback
|
// ignore and fallback
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,177 @@
|
|||||||
|
<script setup>
|
||||||
|
import { CalendarIcon, XIcon } from "lucide-vue-next";
|
||||||
|
import { computed, ref } from "vue";
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
import { Button } from "@/Components/ui/button";
|
||||||
|
import { Popover, PopoverContent, PopoverTrigger } from "@/Components/ui/popover";
|
||||||
|
import { RangeCalendar } from "@/Components/ui/range-calendar";
|
||||||
|
import {
|
||||||
|
DateFormatter,
|
||||||
|
getLocalTimeZone,
|
||||||
|
today,
|
||||||
|
parseDate,
|
||||||
|
CalendarDate,
|
||||||
|
} from "@internationalized/date";
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
modelValue: {
|
||||||
|
type: Object,
|
||||||
|
default: () => ({ start: null, end: null }),
|
||||||
|
},
|
||||||
|
placeholder: {
|
||||||
|
type: String,
|
||||||
|
default: "Izberi datumski obseg",
|
||||||
|
},
|
||||||
|
disabled: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
buttonClass: {
|
||||||
|
type: String,
|
||||||
|
default: "w-[280px]",
|
||||||
|
},
|
||||||
|
locale: {
|
||||||
|
type: String,
|
||||||
|
default: "sl-SI",
|
||||||
|
},
|
||||||
|
numberOfMonths: {
|
||||||
|
type: Number,
|
||||||
|
default: 2,
|
||||||
|
},
|
||||||
|
minValue: {
|
||||||
|
type: Object,
|
||||||
|
default: undefined,
|
||||||
|
},
|
||||||
|
maxValue: {
|
||||||
|
type: Object,
|
||||||
|
default: undefined,
|
||||||
|
},
|
||||||
|
clearable: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const emit = defineEmits(["update:modelValue"]);
|
||||||
|
|
||||||
|
const open = ref(false);
|
||||||
|
|
||||||
|
const df = new DateFormatter(props.locale, {
|
||||||
|
dateStyle: "medium",
|
||||||
|
});
|
||||||
|
|
||||||
|
// Check if there's a selected value
|
||||||
|
const hasValue = computed(() => {
|
||||||
|
const val = props.modelValue;
|
||||||
|
return val?.start || val?.end;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Convert string dates to CalendarDate objects for the calendar
|
||||||
|
const calendarValue = computed({
|
||||||
|
get() {
|
||||||
|
const val = props.modelValue;
|
||||||
|
if (!val) return undefined;
|
||||||
|
|
||||||
|
let start = null;
|
||||||
|
let end = null;
|
||||||
|
|
||||||
|
if (val.start) {
|
||||||
|
if (typeof val.start === "string") {
|
||||||
|
start = parseDate(val.start);
|
||||||
|
} else if (val.start instanceof CalendarDate) {
|
||||||
|
start = val.start;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (val.end) {
|
||||||
|
if (typeof val.end === "string") {
|
||||||
|
end = parseDate(val.end);
|
||||||
|
} else if (val.end instanceof CalendarDate) {
|
||||||
|
end = val.end;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!start && !end) return undefined;
|
||||||
|
return { start, end };
|
||||||
|
},
|
||||||
|
set(newValue) {
|
||||||
|
if (!newValue) {
|
||||||
|
emit("update:modelValue", { start: null, end: null });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert CalendarDate to ISO string (YYYY-MM-DD) for easier handling
|
||||||
|
const result = {
|
||||||
|
start: newValue.start ? newValue.start.toString() : null,
|
||||||
|
end: newValue.end ? newValue.end.toString() : null,
|
||||||
|
};
|
||||||
|
emit("update:modelValue", result);
|
||||||
|
|
||||||
|
// Close popover when both dates are selected
|
||||||
|
if (result.start && result.end) {
|
||||||
|
open.value = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const displayText = computed(() => {
|
||||||
|
const val = calendarValue.value;
|
||||||
|
if (!val?.start) return props.placeholder;
|
||||||
|
|
||||||
|
const startFormatted = df.format(val.start.toDate(getLocalTimeZone()));
|
||||||
|
if (!val.end) return startFormatted;
|
||||||
|
|
||||||
|
const endFormatted = df.format(val.end.toDate(getLocalTimeZone()));
|
||||||
|
return `${startFormatted} - ${endFormatted}`;
|
||||||
|
});
|
||||||
|
|
||||||
|
function clearValue(event) {
|
||||||
|
event.stopPropagation();
|
||||||
|
emit("update:modelValue", { start: null, end: null });
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Popover v-model:open="open">
|
||||||
|
<PopoverTrigger as-child>
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
:disabled="disabled"
|
||||||
|
:class="
|
||||||
|
cn(
|
||||||
|
'justify-start text-left font-normal',
|
||||||
|
!calendarValue?.start && 'text-muted-foreground',
|
||||||
|
buttonClass
|
||||||
|
)
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<CalendarIcon class="mr-2 h-4 w-4 shrink-0" />
|
||||||
|
<span class="truncate flex-1">{{ displayText }}</span>
|
||||||
|
<span
|
||||||
|
v-if="clearable && hasValue && !disabled"
|
||||||
|
class="ml-2 shrink-0 opacity-50 hover:opacity-100 cursor-pointer"
|
||||||
|
@click.stop.prevent="clearValue"
|
||||||
|
>
|
||||||
|
<XIcon class="h-4 w-4" />
|
||||||
|
</span>
|
||||||
|
</Button>
|
||||||
|
</PopoverTrigger>
|
||||||
|
<PopoverContent class="w-auto p-0" align="start">
|
||||||
|
<RangeCalendar
|
||||||
|
v-model="calendarValue"
|
||||||
|
:locale="locale"
|
||||||
|
:number-of-months="numberOfMonths"
|
||||||
|
:min-value="minValue"
|
||||||
|
:max-value="maxValue"
|
||||||
|
initial-focus
|
||||||
|
@update:start-value="
|
||||||
|
(startDate) => {
|
||||||
|
if (calendarValue?.start?.toString() !== startDate?.toString()) {
|
||||||
|
calendarValue = { start: startDate, end: undefined };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"
|
||||||
|
/>
|
||||||
|
</PopoverContent>
|
||||||
|
</Popover>
|
||||||
|
</template>
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
import AdminLayout from "@/Layouts/AdminLayout.vue";
|
import AdminLayout from "@/Layouts/AdminLayout.vue";
|
||||||
import { Link, router, useForm } from "@inertiajs/vue3";
|
import { Link, router, useForm } from "@inertiajs/vue3";
|
||||||
import { ref, computed, nextTick } from "vue";
|
import { ref, computed, nextTick } from "vue";
|
||||||
|
import axios from "axios";
|
||||||
import {
|
import {
|
||||||
Card,
|
Card,
|
||||||
CardContent,
|
CardContent,
|
||||||
@@ -39,6 +40,9 @@ import {
|
|||||||
BadgeCheckIcon,
|
BadgeCheckIcon,
|
||||||
} from "lucide-vue-next";
|
} from "lucide-vue-next";
|
||||||
import { fmtDateDMY } from "@/Utilities/functions";
|
import { fmtDateDMY } from "@/Utilities/functions";
|
||||||
|
import { upperFirst } from "lodash";
|
||||||
|
import AppCombobox from "@/Components/app/ui/AppCombobox.vue";
|
||||||
|
import AppRangeDatePicker from "@/Components/app/ui/AppRangeDatePicker.vue";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
profiles: { type: Array, default: () => [] },
|
profiles: { type: Array, default: () => [] },
|
||||||
@@ -123,13 +127,19 @@ const contracts = ref({
|
|||||||
const segmentId = ref(null);
|
const segmentId = ref(null);
|
||||||
const search = ref("");
|
const search = ref("");
|
||||||
const clientId = ref(null);
|
const clientId = ref(null);
|
||||||
const startDateFrom = ref("");
|
const startDateRange = ref({ start: null, end: null });
|
||||||
const startDateTo = ref("");
|
const promiseDateRange = ref({ start: null, end: null });
|
||||||
const promiseDateFrom = ref("");
|
|
||||||
const promiseDateTo = ref("");
|
|
||||||
const onlyMobile = ref(false);
|
const onlyMobile = ref(false);
|
||||||
const onlyValidated = ref(false);
|
const onlyValidated = ref(false);
|
||||||
const loadingContracts = ref(false);
|
const loadingContracts = ref(false);
|
||||||
|
|
||||||
|
// Transform clients for AppCombobox
|
||||||
|
const clientItems = computed(() =>
|
||||||
|
props.clients.map((c) => ({
|
||||||
|
value: c.id,
|
||||||
|
label: c.name,
|
||||||
|
}))
|
||||||
|
);
|
||||||
const selectedContractIds = ref(new Set());
|
const selectedContractIds = ref(new Set());
|
||||||
const perPage = ref(25);
|
const perPage = ref(25);
|
||||||
|
|
||||||
@@ -153,6 +163,11 @@ const contractColumns = [
|
|||||||
accessorFn: (row) => row.selected_phone?.number || "—",
|
accessorFn: (row) => row.selected_phone?.number || "—",
|
||||||
header: "Izbrana številka",
|
header: "Izbrana številka",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
id: "segment",
|
||||||
|
accessorFn: (row) => upperFirst(row.segment?.name) || "—",
|
||||||
|
header: "Segment",
|
||||||
|
},
|
||||||
{ accessorKey: "no_phone_reason", header: "Opomba" },
|
{ accessorKey: "no_phone_reason", header: "Opomba" },
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -175,19 +190,22 @@ async function loadContracts(url = null) {
|
|||||||
if (segmentId.value) params.append("segment_id", segmentId.value);
|
if (segmentId.value) params.append("segment_id", segmentId.value);
|
||||||
if (search.value) params.append("q", search.value);
|
if (search.value) params.append("q", search.value);
|
||||||
if (clientId.value) params.append("client_id", clientId.value);
|
if (clientId.value) params.append("client_id", clientId.value);
|
||||||
if (startDateFrom.value) params.append("start_date_from", startDateFrom.value);
|
if (startDateRange.value?.start)
|
||||||
if (startDateTo.value) params.append("start_date_to", startDateTo.value);
|
params.append("start_date_from", startDateRange.value.start);
|
||||||
if (promiseDateFrom.value) params.append("promise_date_from", promiseDateFrom.value);
|
if (startDateRange.value?.end)
|
||||||
if (promiseDateTo.value) params.append("promise_date_to", promiseDateTo.value);
|
params.append("start_date_to", startDateRange.value.end);
|
||||||
|
if (promiseDateRange.value?.start)
|
||||||
|
params.append("promise_date_from", promiseDateRange.value.start);
|
||||||
|
if (promiseDateRange.value?.end)
|
||||||
|
params.append("promise_date_to", promiseDateRange.value.end);
|
||||||
if (onlyMobile.value) params.append("only_mobile", "1");
|
if (onlyMobile.value) params.append("only_mobile", "1");
|
||||||
if (onlyValidated.value) params.append("only_validated", "1");
|
if (onlyValidated.value) params.append("only_validated", "1");
|
||||||
params.append("per_page", perPage.value);
|
params.append("per_page", perPage.value);
|
||||||
|
|
||||||
const target = url || `${route("admin.packages.contracts")}?${params.toString()}`;
|
const target = url || `${route("admin.packages.contracts")}?${params.toString()}`;
|
||||||
const res = await fetch(target, {
|
const { data: json } = await axios.get(target, {
|
||||||
headers: { "X-Requested-With": "XMLHttpRequest" },
|
headers: { "X-Requested-With": "XMLHttpRequest" },
|
||||||
});
|
});
|
||||||
const json = await res.json();
|
|
||||||
|
|
||||||
// Wait for next tick before updating to avoid Vue reconciliation issues
|
// Wait for next tick before updating to avoid Vue reconciliation issues
|
||||||
await nextTick();
|
await nextTick();
|
||||||
@@ -238,10 +256,13 @@ function goToPage(page) {
|
|||||||
if (segmentId.value) params.append("segment_id", segmentId.value);
|
if (segmentId.value) params.append("segment_id", segmentId.value);
|
||||||
if (search.value) params.append("q", search.value);
|
if (search.value) params.append("q", search.value);
|
||||||
if (clientId.value) params.append("client_id", clientId.value);
|
if (clientId.value) params.append("client_id", clientId.value);
|
||||||
if (startDateFrom.value) params.append("start_date_from", startDateFrom.value);
|
if (startDateRange.value?.start)
|
||||||
if (startDateTo.value) params.append("start_date_to", startDateTo.value);
|
params.append("start_date_from", startDateRange.value.start);
|
||||||
if (promiseDateFrom.value) params.append("promise_date_from", promiseDateFrom.value);
|
if (startDateRange.value?.end) params.append("start_date_to", startDateRange.value.end);
|
||||||
if (promiseDateTo.value) params.append("promise_date_to", promiseDateTo.value);
|
if (promiseDateRange.value?.start)
|
||||||
|
params.append("promise_date_from", promiseDateRange.value.start);
|
||||||
|
if (promiseDateRange.value?.end)
|
||||||
|
params.append("promise_date_to", promiseDateRange.value.end);
|
||||||
if (onlyMobile.value) params.append("only_mobile", "1");
|
if (onlyMobile.value) params.append("only_mobile", "1");
|
||||||
if (onlyValidated.value) params.append("only_validated", "1");
|
if (onlyValidated.value) params.append("only_validated", "1");
|
||||||
params.append("per_page", perPage.value);
|
params.append("per_page", perPage.value);
|
||||||
@@ -255,10 +276,8 @@ function resetFilters() {
|
|||||||
segmentId.value = null;
|
segmentId.value = null;
|
||||||
clientId.value = null;
|
clientId.value = null;
|
||||||
search.value = "";
|
search.value = "";
|
||||||
startDateFrom.value = "";
|
startDateRange.value = { start: null, end: null };
|
||||||
startDateTo.value = "";
|
promiseDateRange.value = { start: null, end: null };
|
||||||
promiseDateFrom.value = "";
|
|
||||||
promiseDateTo.value = "";
|
|
||||||
onlyMobile.value = false;
|
onlyMobile.value = false;
|
||||||
onlyValidated.value = false;
|
onlyValidated.value = false;
|
||||||
contracts.value = {
|
contracts.value = {
|
||||||
@@ -448,9 +467,10 @@ const numbersCount = computed(() => {
|
|||||||
<div class="flex items-center justify-between">
|
<div class="flex items-center justify-between">
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-2">
|
||||||
<Checkbox
|
<Checkbox
|
||||||
:checked="form.delivery_report"
|
:model-value="form.delivery_report"
|
||||||
@update:checked="(val) => (form.delivery_report = val)"
|
@update:model-value="(val) => (form.delivery_report = val)"
|
||||||
id="delivery-report"
|
id="delivery-report"
|
||||||
|
:disabled="true"
|
||||||
/>
|
/>
|
||||||
<Label for="delivery-report" class="cursor-pointer text-sm">
|
<Label for="delivery-report" class="cursor-pointer text-sm">
|
||||||
Zahtevaj delivery report
|
Zahtevaj delivery report
|
||||||
@@ -553,17 +573,15 @@ const numbersCount = computed(() => {
|
|||||||
</div>
|
</div>
|
||||||
<div class="space-y-2">
|
<div class="space-y-2">
|
||||||
<Label>Stranka</Label>
|
<Label>Stranka</Label>
|
||||||
<Select v-model="clientId" @update:model-value="loadContracts()">
|
<AppCombobox
|
||||||
<SelectTrigger>
|
v-model="clientId"
|
||||||
<SelectValue placeholder="Vse stranke" />
|
:items="clientItems"
|
||||||
</SelectTrigger>
|
placeholder="Vse stranke"
|
||||||
<SelectContent>
|
search-placeholder="Išči stranko..."
|
||||||
<SelectItem :value="null">Vse stranke</SelectItem>
|
empty-text="Stranka ni najdena."
|
||||||
<SelectItem v-for="c in clients" :key="c.id" :value="c.id">
|
button-class="w-full"
|
||||||
{{ c.name }}
|
@update:model-value="loadContracts()"
|
||||||
</SelectItem>
|
/>
|
||||||
</SelectContent>
|
|
||||||
</Select>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="space-y-2">
|
<div class="space-y-2">
|
||||||
<Label>Iskanje po referenci</Label>
|
<Label>Iskanje po referenci</Label>
|
||||||
@@ -586,29 +604,21 @@ const numbersCount = computed(() => {
|
|||||||
<div class="grid gap-4 md:grid-cols-2">
|
<div class="grid gap-4 md:grid-cols-2">
|
||||||
<div class="space-y-3">
|
<div class="space-y-3">
|
||||||
<p class="text-sm text-muted-foreground">Datum začetka pogodbe</p>
|
<p class="text-sm text-muted-foreground">Datum začetka pogodbe</p>
|
||||||
<div class="grid grid-cols-2 gap-2">
|
<AppRangeDatePicker
|
||||||
<div class="space-y-2">
|
v-model="startDateRange"
|
||||||
<Label class="text-xs">Od</Label>
|
placeholder="Izberi obdobje"
|
||||||
<Input v-model="startDateFrom" type="date" />
|
button-class="w-full"
|
||||||
</div>
|
:number-of-months="1"
|
||||||
<div class="space-y-2">
|
/>
|
||||||
<Label class="text-xs">Do</Label>
|
|
||||||
<Input v-model="startDateTo" type="date" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="space-y-3">
|
<div class="space-y-3">
|
||||||
<p class="text-sm text-muted-foreground">Datum obljube plačila</p>
|
<p class="text-sm text-muted-foreground">Datum obljube plačila</p>
|
||||||
<div class="grid grid-cols-2 gap-2">
|
<AppRangeDatePicker
|
||||||
<div class="space-y-2">
|
v-model="promiseDateRange"
|
||||||
<Label class="text-xs">Od</Label>
|
placeholder="Izberi obdobje"
|
||||||
<Input v-model="promiseDateFrom" type="date" />
|
button-class="w-full"
|
||||||
</div>
|
:number-of-months="1"
|
||||||
<div class="space-y-2">
|
/>
|
||||||
<Label class="text-xs">Do</Label>
|
|
||||||
<Input v-model="promiseDateTo" type="date" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -621,8 +631,8 @@ const numbersCount = computed(() => {
|
|||||||
<div class="flex flex-wrap gap-4">
|
<div class="flex flex-wrap gap-4">
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-2">
|
||||||
<Checkbox
|
<Checkbox
|
||||||
:checked="onlyMobile"
|
:model-value="onlyMobile"
|
||||||
@update:checked="
|
@update:model-value="
|
||||||
(val) => {
|
(val) => {
|
||||||
onlyMobile = val;
|
onlyMobile = val;
|
||||||
}
|
}
|
||||||
@@ -635,8 +645,8 @@ const numbersCount = computed(() => {
|
|||||||
</div>
|
</div>
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-2">
|
||||||
<Checkbox
|
<Checkbox
|
||||||
:checked="onlyValidated"
|
:model-value="onlyValidated"
|
||||||
@update:checked="
|
@update:model-value="
|
||||||
(val) => {
|
(val) => {
|
||||||
onlyValidated = val;
|
onlyValidated = val;
|
||||||
}
|
}
|
||||||
@@ -653,11 +663,11 @@ const numbersCount = computed(() => {
|
|||||||
<!-- Action buttons -->
|
<!-- Action buttons -->
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-2">
|
||||||
<Button @click="loadContracts()">
|
<Button @click="loadContracts()">
|
||||||
<SearchIcon class="h-4 w-4 mr-2" />
|
<SearchIcon class="h-4 w-4" />
|
||||||
Išči pogodbe
|
Išči pogodbe
|
||||||
</Button>
|
</Button>
|
||||||
<Button @click="resetFilters" variant="outline">
|
<Button @click="resetFilters" variant="outline">
|
||||||
<XCircleIcon class="h-4 w-4 mr-2" />
|
<XCircleIcon class="h-4 w-4" />
|
||||||
Počisti filtre
|
Počisti filtre
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
@@ -669,7 +679,7 @@ const numbersCount = computed(() => {
|
|||||||
<CardHeader>
|
<CardHeader>
|
||||||
<div class="flex items-center justify-between">
|
<div class="flex items-center justify-between">
|
||||||
<div>
|
<div>
|
||||||
<CardTitle>Rezultati iskanja</CardTitle>
|
<CardTitle>Rezultati iskanja (do 500 zapisov)</CardTitle>
|
||||||
<CardDescription v-if="contracts.meta.total > 0">
|
<CardDescription v-if="contracts.meta.total > 0">
|
||||||
Najdeno {{ contracts.meta.total }}
|
Najdeno {{ contracts.meta.total }}
|
||||||
{{
|
{{
|
||||||
@@ -689,7 +699,7 @@ const numbersCount = computed(() => {
|
|||||||
variant="secondary"
|
variant="secondary"
|
||||||
class="text-sm"
|
class="text-sm"
|
||||||
>
|
>
|
||||||
<CheckCircle2Icon class="h-3 w-3 mr-1" />
|
<CheckCircle2Icon class="h-3 w-3" />
|
||||||
Izbrano: {{ selectedContractIds.size }}
|
Izbrano: {{ selectedContractIds.size }}
|
||||||
</Badge>
|
</Badge>
|
||||||
<Button
|
<Button
|
||||||
@@ -702,7 +712,7 @@ const numbersCount = computed(() => {
|
|||||||
@click="submitCreateFromContracts"
|
@click="submitCreateFromContracts"
|
||||||
:disabled="selectedContractIds.size === 0 || creatingFromContracts"
|
:disabled="selectedContractIds.size === 0 || creatingFromContracts"
|
||||||
>
|
>
|
||||||
<SaveIcon class="h-4 w-4 mr-2" />
|
<SaveIcon class="h-4 w-4" />
|
||||||
Ustvari paket ({{ selectedContractIds.size }}
|
Ustvari paket ({{ selectedContractIds.size }}
|
||||||
{{
|
{{
|
||||||
selectedContractIds.size === 1
|
selectedContractIds.size === 1
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import {
|
|||||||
import DataTableNew2 from "@/Components/DataTable/DataTableNew2.vue";
|
import DataTableNew2 from "@/Components/DataTable/DataTableNew2.vue";
|
||||||
import { PackageIcon, PlusIcon, Trash2Icon, EyeIcon } from "lucide-vue-next";
|
import { PackageIcon, PlusIcon, Trash2Icon, EyeIcon } from "lucide-vue-next";
|
||||||
import AppCard from "@/Components/app/ui/card/AppCard.vue";
|
import AppCard from "@/Components/app/ui/card/AppCard.vue";
|
||||||
|
import { fmtDateTime } from "@/Utilities/functions";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
packages: { type: Object, required: true },
|
packages: { type: Object, required: true },
|
||||||
@@ -29,7 +30,6 @@ const showDeleteDialog = ref(false);
|
|||||||
|
|
||||||
const columns = [
|
const columns = [
|
||||||
{ accessorKey: "id", header: "ID" },
|
{ accessorKey: "id", header: "ID" },
|
||||||
{ accessorKey: "uuid", header: "UUID" },
|
|
||||||
{ accessorKey: "name", header: "Ime" },
|
{ accessorKey: "name", header: "Ime" },
|
||||||
{ accessorKey: "type", header: "Tip" },
|
{ accessorKey: "type", header: "Tip" },
|
||||||
{ accessorKey: "status", header: "Status" },
|
{ accessorKey: "status", header: "Status" },
|
||||||
@@ -84,7 +84,7 @@ function confirmDelete() {
|
|||||||
</div>
|
</div>
|
||||||
<Link :href="route('admin.packages.create')">
|
<Link :href="route('admin.packages.create')">
|
||||||
<Button>
|
<Button>
|
||||||
<PlusIcon class="h-4 w-4 mr-2" />
|
<PlusIcon class="h-4 w-4" />
|
||||||
Nov paket
|
Nov paket
|
||||||
</Button>
|
</Button>
|
||||||
</Link>
|
</Link>
|
||||||
@@ -111,10 +111,6 @@ function confirmDelete() {
|
|||||||
:meta="packages"
|
:meta="packages"
|
||||||
route-name="admin.packages.index"
|
route-name="admin.packages.index"
|
||||||
>
|
>
|
||||||
<template #cell-uuid="{ row }">
|
|
||||||
<span class="font-mono text-xs text-muted-foreground">{{ row.uuid }}</span>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<template #cell-name="{ row }">
|
<template #cell-name="{ row }">
|
||||||
<span class="text-sm">{{ row.name ?? "—" }}</span>
|
<span class="text-sm">{{ row.name ?? "—" }}</span>
|
||||||
</template>
|
</template>
|
||||||
@@ -128,7 +124,9 @@ function confirmDelete() {
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #cell-finished_at="{ row }">
|
<template #cell-finished_at="{ row }">
|
||||||
<span class="text-xs text-muted-foreground">{{ row.finished_at ?? "—" }}</span>
|
<span class="text-xs text-muted-foreground">{{
|
||||||
|
fmtDateTime(row.finished_at) ?? "—"
|
||||||
|
}}</span>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #cell-actions="{ row }">
|
<template #cell-actions="{ row }">
|
||||||
@@ -157,8 +155,10 @@ function confirmDelete() {
|
|||||||
<AlertDialogTitle>Izbriši paket?</AlertDialogTitle>
|
<AlertDialogTitle>Izbriši paket?</AlertDialogTitle>
|
||||||
<AlertDialogDescription>
|
<AlertDialogDescription>
|
||||||
Ali ste prepričani, da želite izbrisati paket
|
Ali ste prepričani, da želite izbrisati paket
|
||||||
<strong v-if="packageToDelete">#{{ packageToDelete.id }} - {{ packageToDelete.name || 'Brez imena' }}</strong>?
|
<strong v-if="packageToDelete"
|
||||||
Tega dejanja ni mogoče razveljaviti.
|
>#{{ packageToDelete.id }} -
|
||||||
|
{{ packageToDelete.name || "Brez imena" }}</strong
|
||||||
|
>? Tega dejanja ni mogoče razveljaviti.
|
||||||
</AlertDialogDescription>
|
</AlertDialogDescription>
|
||||||
</AlertDialogHeader>
|
</AlertDialogHeader>
|
||||||
<AlertDialogFooter>
|
<AlertDialogFooter>
|
||||||
|
|||||||
@@ -54,7 +54,9 @@ const form = useInertiaForm({
|
|||||||
props.actions[0].decisions.length > 0
|
props.actions[0].decisions.length > 0
|
||||||
? props.actions[0].decisions[0].id
|
? props.actions[0].decisions[0].id
|
||||||
: null,
|
: null,
|
||||||
contract_uuids: props.contractUuid ? [props.contractUuid] : [],
|
contract_uuids: props.contractUuid ? [props.contractUuid] : (props.contracts && Array.isArray(props.contracts)
|
||||||
|
? props.contracts.map((c) => c.uuid)
|
||||||
|
: []),
|
||||||
send_auto_mail: true,
|
send_auto_mail: true,
|
||||||
attach_documents: false,
|
attach_documents: false,
|
||||||
attachment_document_ids: [],
|
attachment_document_ids: [],
|
||||||
@@ -104,7 +106,9 @@ watch(
|
|||||||
() => props.show,
|
() => props.show,
|
||||||
(visible) => {
|
(visible) => {
|
||||||
if (visible) {
|
if (visible) {
|
||||||
form.contract_uuids = props.contractUuid ? [props.contractUuid] : [];
|
form.contract_uuids = props.contractUuid ? [props.contractUuid] : (props.contracts && Array.isArray(props.contracts)
|
||||||
|
? props.contracts.map((c) => c.uuid)
|
||||||
|
: []);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -120,7 +124,8 @@ const store = async () => {
|
|||||||
return `${y}-${m}-${day}`;
|
return `${y}-${m}-${day}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
const contractUuids = Array.isArray(form.contract_uuids) && form.contract_uuids.length > 0
|
const contractUuids =
|
||||||
|
Array.isArray(form.contract_uuids) && form.contract_uuids.length > 0
|
||||||
? form.contract_uuids
|
? form.contract_uuids
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
@@ -175,9 +180,9 @@ const autoMailRequiresContract = computed(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const contractItems = computed(() => {
|
const contractItems = computed(() => {
|
||||||
return pageContracts.value.map(c => ({
|
return pageContracts.value.map((c) => ({
|
||||||
value: c.uuid,
|
value: c.uuid,
|
||||||
label: `${c.reference}${c.name ? ` - ${c.name}` : ''}`
|
label: `${c.reference}${c.name ? ` - ${c.name}` : ""}`,
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -188,7 +193,10 @@ const autoMailDisabled = computed(() => {
|
|||||||
if (form.contract_uuids && form.contract_uuids.length > 1) return true;
|
if (form.contract_uuids && form.contract_uuids.length > 1) return true;
|
||||||
|
|
||||||
// Disable if template requires contract but none selected
|
// Disable if template requires contract but none selected
|
||||||
if (autoMailRequiresContract.value && (!form.contract_uuids || form.contract_uuids.length === 0)) {
|
if (
|
||||||
|
autoMailRequiresContract.value &&
|
||||||
|
(!form.contract_uuids || form.contract_uuids.length === 0)
|
||||||
|
) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,7 +210,10 @@ const autoMailDisabledHint = computed(() => {
|
|||||||
return "Avtomatska e-pošta ni na voljo pri več pogodbah.";
|
return "Avtomatska e-pošta ni na voljo pri več pogodbah.";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (autoMailRequiresContract.value && (!form.contract_uuids || form.contract_uuids.length === 0)) {
|
if (
|
||||||
|
autoMailRequiresContract.value &&
|
||||||
|
(!form.contract_uuids || form.contract_uuids.length === 0)
|
||||||
|
) {
|
||||||
return "Ta e-poštna predloga zahteva pogodbo. Najprej izberite pogodbo.";
|
return "Ta e-poštna predloga zahteva pogodbo. Najprej izberite pogodbo.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -373,8 +384,12 @@ watch(
|
|||||||
:clearable="true"
|
:clearable="true"
|
||||||
:show-selected-chips="true"
|
:show-selected-chips="true"
|
||||||
/>
|
/>
|
||||||
<p v-if="form.contract_uuids && form.contract_uuids.length > 1" class="text-xs text-muted-foreground">
|
<p
|
||||||
Bo ustvarjenih {{ form.contract_uuids.length }} aktivnosti (ena za vsako pogodbo).
|
v-if="form.contract_uuids && form.contract_uuids.length > 1"
|
||||||
|
class="text-xs text-muted-foreground"
|
||||||
|
>
|
||||||
|
Bo ustvarjenih {{ form.contract_uuids.length }} aktivnosti (ena za vsako
|
||||||
|
pogodbo).
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -383,7 +398,7 @@ watch(
|
|||||||
<Textarea
|
<Textarea
|
||||||
id="activityNote"
|
id="activityNote"
|
||||||
v-model="form.note"
|
v-model="form.note"
|
||||||
class="block w-full"
|
class="block w-full max-h-72"
|
||||||
placeholder="Opomba"
|
placeholder="Opomba"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -412,10 +427,7 @@ watch(
|
|||||||
<div v-if="showSendAutoMail()" class="space-y-2">
|
<div v-if="showSendAutoMail()" class="space-y-2">
|
||||||
<div class="flex items-center justify-between">
|
<div class="flex items-center justify-between">
|
||||||
<div class="flex items-center space-x-2">
|
<div class="flex items-center space-x-2">
|
||||||
<Switch
|
<Switch v-model="form.send_auto_mail" :disabled="autoMailDisabled" />
|
||||||
v-model="form.send_auto_mail"
|
|
||||||
:disabled="autoMailDisabled"
|
|
||||||
/>
|
|
||||||
<Label class="cursor-pointer">Send auto email</Label>
|
<Label class="cursor-pointer">Send auto email</Label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -423,7 +435,14 @@ watch(
|
|||||||
{{ autoMailDisabledHint }}
|
{{ autoMailDisabledHint }}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div v-if="templateAllowsAttachments && form.contract_uuids && form.contract_uuids.length === 1" class="mt-3">
|
<div
|
||||||
|
v-if="
|
||||||
|
templateAllowsAttachments &&
|
||||||
|
form.contract_uuids &&
|
||||||
|
form.contract_uuids.length === 1
|
||||||
|
"
|
||||||
|
class="mt-3"
|
||||||
|
>
|
||||||
<label class="inline-flex items-center gap-2">
|
<label class="inline-flex items-center gap-2">
|
||||||
<Switch v-model="form.attach_documents" />
|
<Switch v-model="form.attach_documents" />
|
||||||
<span class="text-sm">Dodaj priponke iz izbrane pogodbe</span>
|
<span class="text-sm">Dodaj priponke iz izbrane pogodbe</span>
|
||||||
@@ -445,21 +464,28 @@ watch(
|
|||||||
<div
|
<div
|
||||||
v-for="doc in availableContractDocs"
|
v-for="doc in availableContractDocs"
|
||||||
:key="doc.uuid || doc.id"
|
:key="doc.uuid || doc.id"
|
||||||
class="flex items-center gap-2 text-sm"
|
class="flex items-center max-w-sm gap-2 text-sm"
|
||||||
>
|
>
|
||||||
<Switch
|
<Switch
|
||||||
:model-value="form.attachment_document_ids.includes(doc.id)"
|
:model-value="form.attachment_document_ids.includes(doc.id)"
|
||||||
@update:model-value="(checked) => {
|
@update:model-value="
|
||||||
|
(checked) => {
|
||||||
if (checked) {
|
if (checked) {
|
||||||
if (!form.attachment_document_ids.includes(doc.id)) {
|
if (!form.attachment_document_ids.includes(doc.id)) {
|
||||||
form.attachment_document_ids.push(doc.id);
|
form.attachment_document_ids.push(doc.id);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
form.attachment_document_ids = form.attachment_document_ids.filter(id => id !== doc.id);
|
form.attachment_document_ids = form.attachment_document_ids.filter(
|
||||||
|
(id) => id !== doc.id
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}"
|
}
|
||||||
|
"
|
||||||
/>
|
/>
|
||||||
<span>{{ doc.original_name || doc.name }}</span>
|
<div class="wrap-anywhere">
|
||||||
|
<p>
|
||||||
|
{{ doc.original_name || doc.name }}
|
||||||
|
</p>
|
||||||
<span class="text-xs text-gray-400"
|
<span class="text-xs text-gray-400"
|
||||||
>({{ doc.extension?.toUpperCase() || "" }},
|
>({{ doc.extension?.toUpperCase() || "" }},
|
||||||
{{ (doc.size / 1024 / 1024).toFixed(2) }} MB)</span
|
{{ (doc.size / 1024 / 1024).toFixed(2) }} MB)</span
|
||||||
@@ -467,6 +493,7 @@ watch(
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<div
|
<div
|
||||||
v-if="availableContractDocs.length === 0"
|
v-if="availableContractDocs.length === 0"
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ const onDocSaved = () => {
|
|||||||
router.reload({ only: ["documents"] });
|
router.reload({ only: ["documents"] });
|
||||||
};
|
};
|
||||||
|
|
||||||
const viewer = ref({ open: false, src: "", title: "" });
|
const viewer = ref({ open: false, src: "", title: "", mimeType: "", filename: "" });
|
||||||
const openViewer = (doc) => {
|
const openViewer = (doc) => {
|
||||||
const kind = classifyDocument(doc);
|
const kind = classifyDocument(doc);
|
||||||
const isContractDoc = (doc?.documentable_type || "").toLowerCase().includes("contract");
|
const isContractDoc = (doc?.documentable_type || "").toLowerCase().includes("contract");
|
||||||
@@ -122,7 +122,13 @@ const openViewer = (doc) => {
|
|||||||
client_case: props.client_case.uuid,
|
client_case: props.client_case.uuid,
|
||||||
document: doc.uuid,
|
document: doc.uuid,
|
||||||
});
|
});
|
||||||
viewer.value = { open: true, src: url, title: doc.original_name || doc.name };
|
viewer.value = {
|
||||||
|
open: true,
|
||||||
|
src: url,
|
||||||
|
title: doc.name || doc.original_name,
|
||||||
|
mimeType: doc.mime_type || "",
|
||||||
|
filename: doc.original_name || doc.name || "",
|
||||||
|
};
|
||||||
} else {
|
} else {
|
||||||
const url =
|
const url =
|
||||||
isContractDoc && doc.contract_uuid
|
isContractDoc && doc.contract_uuid
|
||||||
@@ -140,6 +146,8 @@ const openViewer = (doc) => {
|
|||||||
const closeViewer = () => {
|
const closeViewer = () => {
|
||||||
viewer.value.open = false;
|
viewer.value.open = false;
|
||||||
viewer.value.src = "";
|
viewer.value.src = "";
|
||||||
|
viewer.value.mimeType = "";
|
||||||
|
viewer.value.filename = "";
|
||||||
};
|
};
|
||||||
|
|
||||||
const clientDetails = ref(false);
|
const clientDetails = ref(false);
|
||||||
@@ -482,6 +490,8 @@ const submitAttachSegment = () => {
|
|||||||
:show="viewer.open"
|
:show="viewer.open"
|
||||||
:src="viewer.src"
|
:src="viewer.src"
|
||||||
:title="viewer.title"
|
:title="viewer.title"
|
||||||
|
:mime-type="viewer.mimeType"
|
||||||
|
:filename="viewer.filename"
|
||||||
@close="closeViewer"
|
@close="closeViewer"
|
||||||
/>
|
/>
|
||||||
</AppLayout>
|
</AppLayout>
|
||||||
|
|||||||
@@ -6,10 +6,8 @@ import CreateDialog from "@/Components/Dialogs/CreateDialog.vue";
|
|||||||
import DataTable from "@/Components/DataTable/DataTableNew2.vue";
|
import DataTable from "@/Components/DataTable/DataTableNew2.vue";
|
||||||
import { hasPermission } from "@/Services/permissions";
|
import { hasPermission } from "@/Services/permissions";
|
||||||
import { Button } from "@/Components/ui/button";
|
import { Button } from "@/Components/ui/button";
|
||||||
import { Card, CardHeader, CardTitle, CardContent } from "@/Components/ui/card";
|
import { CardTitle } from "@/Components/ui/card";
|
||||||
import { Input } from "@/Components/ui/input";
|
import { Input } from "@/Components/ui/input";
|
||||||
import ActionMenuItem from "@/Components/DataTable/ActionMenuItem.vue";
|
|
||||||
import { faPlus } from "@fortawesome/free-solid-svg-icons";
|
|
||||||
import {
|
import {
|
||||||
Select,
|
Select,
|
||||||
SelectContent,
|
SelectContent,
|
||||||
@@ -27,8 +25,7 @@ import {
|
|||||||
import { useForm } from "vee-validate";
|
import { useForm } from "vee-validate";
|
||||||
import { toTypedSchema } from "@vee-validate/zod";
|
import { toTypedSchema } from "@vee-validate/zod";
|
||||||
import * as z from "zod";
|
import * as z from "zod";
|
||||||
import ActionMessage from "@/Components/ActionMessage.vue";
|
import { Plus, UsersRoundIcon } from "lucide-vue-next";
|
||||||
import { Mail, Plug2Icon, Plus, UsersRoundIcon } from "lucide-vue-next";
|
|
||||||
import { Separator } from "@/Components/ui/separator";
|
import { Separator } from "@/Components/ui/separator";
|
||||||
import AppCard from "@/Components/app/ui/card/AppCard.vue";
|
import AppCard from "@/Components/app/ui/card/AppCard.vue";
|
||||||
|
|
||||||
@@ -162,7 +159,7 @@ const fmtCurrency = (v) => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<AppLayout>
|
<AppLayout title="Clients">
|
||||||
<template #header> </template>
|
<template #header> </template>
|
||||||
<div class="py-6">
|
<div class="py-6">
|
||||||
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
|
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
|
||||||
@@ -201,6 +198,7 @@ const fmtCurrency = (v) => {
|
|||||||
:show-pagination="false"
|
:show-pagination="false"
|
||||||
:show-toolbar="true"
|
:show-toolbar="true"
|
||||||
:hoverable="true"
|
:hoverable="true"
|
||||||
|
:page-size="100"
|
||||||
row-key="uuid"
|
row-key="uuid"
|
||||||
:striped="true"
|
:striped="true"
|
||||||
empty-text="Ni najdenih naročnikov."
|
empty-text="Ni najdenih naročnikov."
|
||||||
|
|||||||
@@ -245,7 +245,7 @@ async function startImport() {
|
|||||||
|
|
||||||
<!-- Has Header Checkbox -->
|
<!-- Has Header Checkbox -->
|
||||||
<div class="flex items-center space-x-2">
|
<div class="flex items-center space-x-2">
|
||||||
<Checkbox id="has-header" v-model:checked="form.has_header" />
|
<Checkbox id="has-header" :model-value="form.has_header" />
|
||||||
<Label
|
<Label
|
||||||
for="has-header"
|
for="has-header"
|
||||||
class="cursor-pointer text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
class="cursor-pointer text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
||||||
|
|||||||
@@ -1094,6 +1094,16 @@ async function fetchEvents() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function downloadImport() {
|
||||||
|
if (!importId.value) return;
|
||||||
|
try {
|
||||||
|
const url = route("imports.download", { import: importId.value });
|
||||||
|
window.location.href = url;
|
||||||
|
} catch (e) {
|
||||||
|
console.error("Download failed", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Simulation (generic or payments) state
|
// Simulation (generic or payments) state
|
||||||
const showPaymentSim = ref(false);
|
const showPaymentSim = ref(false);
|
||||||
const paymentSimLoading = ref(false);
|
const paymentSimLoading = ref(false);
|
||||||
@@ -1307,7 +1317,8 @@ async function fetchSimulation() {
|
|||||||
<Checkbox
|
<Checkbox
|
||||||
:id="'show-missing-checkbox'"
|
:id="'show-missing-checkbox'"
|
||||||
:checked="showMissingEnabled"
|
:checked="showMissingEnabled"
|
||||||
@update:checked="
|
:model-value="showMissingEnabled"
|
||||||
|
@update:model-value="
|
||||||
(val) => {
|
(val) => {
|
||||||
showMissingEnabled = val;
|
showMissingEnabled = val;
|
||||||
saveImportOptions();
|
saveImportOptions();
|
||||||
@@ -1339,6 +1350,7 @@ async function fetchSimulation() {
|
|||||||
:can-process="canProcess"
|
:can-process="canProcess"
|
||||||
:selected-mappings-count="selectedMappingsCount"
|
:selected-mappings-count="selectedMappingsCount"
|
||||||
@preview="openPreview"
|
@preview="openPreview"
|
||||||
|
@download="downloadImport"
|
||||||
@save-mappings="saveMappings"
|
@save-mappings="saveMappings"
|
||||||
@process-import="processImport"
|
@process-import="processImport"
|
||||||
@simulate="openSimulation"
|
@simulate="openSimulation"
|
||||||
|
|||||||
@@ -4,9 +4,10 @@ import {
|
|||||||
ArrowPathIcon,
|
ArrowPathIcon,
|
||||||
BeakerIcon,
|
BeakerIcon,
|
||||||
ArrowDownOnSquareIcon,
|
ArrowDownOnSquareIcon,
|
||||||
|
ArrowDownTrayIcon,
|
||||||
} from "@heroicons/vue/24/outline";
|
} from "@heroicons/vue/24/outline";
|
||||||
import { Button } from '@/Components/ui/button';
|
import { Button } from "@/Components/ui/button";
|
||||||
import { Badge } from '@/Components/ui/badge';
|
import { Badge } from "@/Components/ui/badge";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
importId: [Number, String],
|
importId: [Number, String],
|
||||||
@@ -16,15 +17,30 @@ const props = defineProps({
|
|||||||
canProcess: Boolean,
|
canProcess: Boolean,
|
||||||
selectedMappingsCount: Number,
|
selectedMappingsCount: Number,
|
||||||
});
|
});
|
||||||
const emits = defineEmits(["preview", "save-mappings", "process-import", "simulate"]);
|
const emits = defineEmits([
|
||||||
|
"preview",
|
||||||
|
"save-mappings",
|
||||||
|
"process-import",
|
||||||
|
"simulate",
|
||||||
|
"download",
|
||||||
|
]);
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div class="flex flex-wrap gap-2 items-center" v-if="!isCompleted">
|
<div class="flex flex-wrap gap-2 items-center">
|
||||||
|
<!-- Download button - always visible -->
|
||||||
<Button
|
<Button
|
||||||
variant="secondary"
|
variant="secondary"
|
||||||
@click.prevent="$emit('preview')"
|
@click.prevent="$emit('download')"
|
||||||
:disabled="!importId"
|
:disabled="!importId"
|
||||||
|
title="Preznesi originalno uvozno datoteko"
|
||||||
>
|
>
|
||||||
|
<ArrowDownTrayIcon class="h-4 w-4" />
|
||||||
|
Prenos datoteko
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
<!-- Other action buttons - only when not completed -->
|
||||||
|
<div class="flex flex-wrap gap-2 items-center" v-if="!isCompleted">
|
||||||
|
<Button variant="secondary" @click.prevent="$emit('preview')" :disabled="!importId">
|
||||||
<EyeIcon class="h-4 w-4 mr-2" />
|
<EyeIcon class="h-4 w-4 mr-2" />
|
||||||
Predogled vrstic
|
Predogled vrstic
|
||||||
</Button>
|
</Button>
|
||||||
@@ -41,11 +57,9 @@ const emits = defineEmits(["preview", "save-mappings", "process-import", "simula
|
|||||||
></span>
|
></span>
|
||||||
<ArrowPathIcon v-else class="h-4 w-4 mr-2" />
|
<ArrowPathIcon v-else class="h-4 w-4 mr-2" />
|
||||||
<span>Shrani preslikave</span>
|
<span>Shrani preslikave</span>
|
||||||
<Badge
|
<Badge v-if="selectedMappingsCount" variant="secondary" class="ml-2 text-xs">{{
|
||||||
v-if="selectedMappingsCount"
|
selectedMappingsCount
|
||||||
variant="secondary"
|
}}</Badge>
|
||||||
class="ml-2 text-xs"
|
|
||||||
>{{ selectedMappingsCount }}</Badge>
|
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
variant="default"
|
variant="default"
|
||||||
@@ -66,4 +80,5 @@ const emits = defineEmits(["preview", "save-mappings", "process-import", "simula
|
|||||||
Simulacija vnosa
|
Simulacija vnosa
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,10 +1,24 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/Components/ui/table';
|
import {
|
||||||
import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue } from '@/Components/ui/select';
|
Table,
|
||||||
import { Checkbox } from '@/Components/ui/checkbox';
|
TableBody,
|
||||||
import { Input } from '@/Components/ui/input';
|
TableCell,
|
||||||
import { Badge } from '@/Components/ui/badge';
|
TableHead,
|
||||||
import { ScrollArea } from '@/Components/ui/scroll-area';
|
TableHeader,
|
||||||
|
TableRow,
|
||||||
|
} from "@/Components/ui/table";
|
||||||
|
import {
|
||||||
|
Select,
|
||||||
|
SelectContent,
|
||||||
|
SelectGroup,
|
||||||
|
SelectItem,
|
||||||
|
SelectTrigger,
|
||||||
|
SelectValue,
|
||||||
|
} from "@/Components/ui/select";
|
||||||
|
import { Checkbox } from "@/Components/ui/checkbox";
|
||||||
|
import { Input } from "@/Components/ui/input";
|
||||||
|
import { Badge } from "@/Components/ui/badge";
|
||||||
|
import { ScrollArea } from "@/Components/ui/scroll-area";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
rows: Array,
|
rows: Array,
|
||||||
@@ -19,12 +33,12 @@ const props = defineProps({
|
|||||||
mappingError: String,
|
mappingError: String,
|
||||||
show: { type: Boolean, default: true },
|
show: { type: Boolean, default: true },
|
||||||
fieldsForEntity: Function,
|
fieldsForEntity: Function,
|
||||||
})
|
});
|
||||||
const emits = defineEmits(['update:rows','save'])
|
const emits = defineEmits(["update:rows", "save"]);
|
||||||
|
|
||||||
function duplicateTarget(row) {
|
function duplicateTarget(row) {
|
||||||
if(!row || !row.entity || !row.field) return false
|
if (!row || !row.entity || !row.field) return false;
|
||||||
return props.duplicateTargets?.has?.(row.entity + '.' + row.field) || false
|
return props.duplicateTargets?.has?.(row.entity + "." + row.field) || false;
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
@@ -32,39 +46,63 @@ function duplicateTarget(row){
|
|||||||
<div class="flex items-center justify-between mb-2">
|
<div class="flex items-center justify-between mb-2">
|
||||||
<h3 class="font-semibold">
|
<h3 class="font-semibold">
|
||||||
Detected Columns
|
Detected Columns
|
||||||
<Badge variant="outline" class="ml-2 text-[10px]">{{ detected?.has_header ? 'header' : 'positional' }}</Badge>
|
<Badge variant="outline" class="ml-2 text-[10px]">{{
|
||||||
|
detected?.has_header ? "header" : "positional"
|
||||||
|
}}</Badge>
|
||||||
</h3>
|
</h3>
|
||||||
<div class="text-xs text-muted-foreground">
|
<div class="text-xs text-muted-foreground">
|
||||||
detected: {{ detected?.columns?.length || 0 }}, rows: {{ rows.length }}, delimiter: {{ detected?.delimiter || 'auto' }}
|
detected: {{ detected?.columns?.length || 0 }}, rows: {{ rows.length }},
|
||||||
|
delimiter: {{ detected?.delimiter || "auto" }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<p v-if="detectedNote" class="text-xs text-muted-foreground mb-2">{{ detectedNote }}</p>
|
<p v-if="detectedNote" class="text-xs text-muted-foreground mb-2">
|
||||||
|
{{ detectedNote }}
|
||||||
|
</p>
|
||||||
<div class="relative border rounded-lg">
|
<div class="relative border rounded-lg">
|
||||||
<ScrollArea class="h-[420px]">
|
<ScrollArea class="h-[420px]">
|
||||||
<Table>
|
<Table>
|
||||||
<TableHeader class="sticky top-0 z-10 bg-background">
|
<TableHeader class="sticky top-0 z-10 bg-background">
|
||||||
<TableRow class="hover:bg-transparent">
|
<TableRow class="hover:bg-transparent">
|
||||||
<TableHead class="w-[180px] bg-muted/95 backdrop-blur">Source column</TableHead>
|
<TableHead class="w-[180px] bg-muted/95 backdrop-blur"
|
||||||
|
>Source column</TableHead
|
||||||
|
>
|
||||||
<TableHead class="w-[150px] bg-muted/95 backdrop-blur">Entity</TableHead>
|
<TableHead class="w-[150px] bg-muted/95 backdrop-blur">Entity</TableHead>
|
||||||
<TableHead class="w-[150px] bg-muted/95 backdrop-blur">Field</TableHead>
|
<TableHead class="w-[150px] bg-muted/95 backdrop-blur">Field</TableHead>
|
||||||
<TableHead class="w-[140px] bg-muted/95 backdrop-blur">Meta key</TableHead>
|
<TableHead class="w-[140px] bg-muted/95 backdrop-blur">Meta key</TableHead>
|
||||||
<TableHead class="w-[120px] bg-muted/95 backdrop-blur">Meta type</TableHead>
|
<TableHead class="w-[120px] bg-muted/95 backdrop-blur">Meta type</TableHead>
|
||||||
<TableHead class="w-[120px] bg-muted/95 backdrop-blur">Transform</TableHead>
|
<TableHead class="w-[120px] bg-muted/95 backdrop-blur">Transform</TableHead>
|
||||||
<TableHead class="w-[130px] bg-muted/95 backdrop-blur">Apply mode</TableHead>
|
<TableHead class="w-[130px] bg-muted/95 backdrop-blur"
|
||||||
<TableHead class="w-[60px] text-center bg-muted/95 backdrop-blur">Skip</TableHead>
|
>Apply mode</TableHead
|
||||||
|
>
|
||||||
|
<TableHead class="w-[60px] text-center bg-muted/95 backdrop-blur"
|
||||||
|
>Skip</TableHead
|
||||||
|
>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
</TableHeader>
|
</TableHeader>
|
||||||
<TableBody>
|
<TableBody>
|
||||||
<TableRow v-for="(row, idx) in rows" :key="idx" :class="duplicateTarget(row) ? 'bg-destructive/10' : ''">
|
<TableRow
|
||||||
|
v-for="(row, idx) in rows"
|
||||||
|
:key="idx"
|
||||||
|
:class="duplicateTarget(row) ? 'bg-destructive/10' : ''"
|
||||||
|
>
|
||||||
<TableCell class="font-medium">{{ row.source_column }}</TableCell>
|
<TableCell class="font-medium">{{ row.source_column }}</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<Select :model-value="row.entity || ''" @update:model-value="(val) => row.entity = val || ''" :disabled="isCompleted">
|
<Select
|
||||||
|
:model-value="row.entity || ''"
|
||||||
|
@update:model-value="(val) => (row.entity = val || '')"
|
||||||
|
:disabled="isCompleted"
|
||||||
|
>
|
||||||
<SelectTrigger class="h-8 text-xs">
|
<SelectTrigger class="h-8 text-xs">
|
||||||
<SelectValue placeholder="Select entity..." />
|
<SelectValue placeholder="Select entity..." />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
<SelectGroup>
|
<SelectGroup>
|
||||||
<SelectItem v-for="opt in entityOptions" :key="opt.value" :value="opt.value">{{ opt.label }}</SelectItem>
|
<SelectItem
|
||||||
|
v-for="opt in entityOptions"
|
||||||
|
:key="opt.value"
|
||||||
|
:value="opt.value"
|
||||||
|
>{{ opt.label }}</SelectItem
|
||||||
|
>
|
||||||
</SelectGroup>
|
</SelectGroup>
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
@@ -72,16 +110,26 @@ function duplicateTarget(row){
|
|||||||
<TableCell>
|
<TableCell>
|
||||||
<Select
|
<Select
|
||||||
:model-value="row.field || ''"
|
:model-value="row.field || ''"
|
||||||
@update:model-value="(val) => row.field = val || ''"
|
@update:model-value="(val) => (row.field = val || '')"
|
||||||
:disabled="isCompleted"
|
:disabled="isCompleted"
|
||||||
:class="duplicateTarget(row) ? 'border-destructive' : ''"
|
:class="duplicateTarget(row) ? 'border-destructive' : ''"
|
||||||
>
|
>
|
||||||
<SelectTrigger class="h-8 text-xs" :class="duplicateTarget(row) ? 'border-destructive bg-destructive/10' : ''">
|
<SelectTrigger
|
||||||
|
class="h-8 text-xs"
|
||||||
|
:class="
|
||||||
|
duplicateTarget(row) ? 'border-destructive bg-destructive/10' : ''
|
||||||
|
"
|
||||||
|
>
|
||||||
<SelectValue placeholder="Select field..." />
|
<SelectValue placeholder="Select field..." />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
<SelectGroup>
|
<SelectGroup>
|
||||||
<SelectItem v-for="f in fieldsForEntity(row.entity)" :key="f" :value="f">{{ f }}</SelectItem>
|
<SelectItem
|
||||||
|
v-for="f in fieldsForEntity(row.entity)"
|
||||||
|
:key="f"
|
||||||
|
:value="f"
|
||||||
|
>{{ f }}</SelectItem
|
||||||
|
>
|
||||||
</SelectGroup>
|
</SelectGroup>
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
@@ -101,7 +149,7 @@ function duplicateTarget(row){
|
|||||||
<Select
|
<Select
|
||||||
v-if="row.field === 'meta'"
|
v-if="row.field === 'meta'"
|
||||||
:model-value="(row.options ||= {}).type || 'string'"
|
:model-value="(row.options ||= {}).type || 'string'"
|
||||||
@update:model-value="(val) => (row.options ||= {}).type = val"
|
@update:model-value="(val) => ((row.options ||= {}).type = val)"
|
||||||
:disabled="isCompleted"
|
:disabled="isCompleted"
|
||||||
>
|
>
|
||||||
<SelectTrigger class="h-8 text-xs">
|
<SelectTrigger class="h-8 text-xs">
|
||||||
@@ -119,7 +167,13 @@ function duplicateTarget(row){
|
|||||||
<span v-else class="text-muted-foreground text-xs">—</span>
|
<span v-else class="text-muted-foreground text-xs">—</span>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<Select :model-value="row.transform || 'none'" @update:model-value="(val) => row.transform = val === 'none' ? '' : val" :disabled="isCompleted">
|
<Select
|
||||||
|
:model-value="row.transform || 'none'"
|
||||||
|
@update:model-value="
|
||||||
|
(val) => (row.transform = val === 'none' ? '' : val)
|
||||||
|
"
|
||||||
|
:disabled="isCompleted"
|
||||||
|
>
|
||||||
<SelectTrigger class="h-8 text-xs">
|
<SelectTrigger class="h-8 text-xs">
|
||||||
<SelectValue />
|
<SelectValue />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
@@ -134,7 +188,11 @@ function duplicateTarget(row){
|
|||||||
</Select>
|
</Select>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<Select :model-value="row.apply_mode || 'both'" @update:model-value="(val) => row.apply_mode = val" :disabled="isCompleted">
|
<Select
|
||||||
|
:model-value="row.apply_mode || 'both'"
|
||||||
|
@update:model-value="(val) => (row.apply_mode = val)"
|
||||||
|
:disabled="isCompleted"
|
||||||
|
>
|
||||||
<SelectTrigger class="h-8 text-xs">
|
<SelectTrigger class="h-8 text-xs">
|
||||||
<SelectValue />
|
<SelectValue />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
@@ -149,20 +207,31 @@ function duplicateTarget(row){
|
|||||||
</Select>
|
</Select>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell class="text-center">
|
<TableCell class="text-center">
|
||||||
<Checkbox :checked="row.skip" @update:checked="(val) => row.skip = val" :disabled="isCompleted" />
|
<Checkbox
|
||||||
|
:model-value="row.skip"
|
||||||
|
@update:model-value="(val) => (row.skip = val)"
|
||||||
|
:disabled="isCompleted"
|
||||||
|
/>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
</TableBody>
|
</TableBody>
|
||||||
</Table>
|
</Table>
|
||||||
</ScrollArea>
|
</ScrollArea>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="mappingSaved" class="text-sm text-emerald-700 mt-2 flex items-center gap-2">
|
<div
|
||||||
|
v-if="mappingSaved"
|
||||||
|
class="text-sm text-emerald-700 mt-2 flex items-center gap-2"
|
||||||
|
>
|
||||||
<Badge variant="default" class="bg-emerald-600">Saved</Badge>
|
<Badge variant="default" class="bg-emerald-600">Saved</Badge>
|
||||||
<span>{{ mappingSavedCount }} mappings saved</span>
|
<span>{{ mappingSavedCount }} mappings saved</span>
|
||||||
</div>
|
</div>
|
||||||
<div v-else-if="mappingError" class="text-sm text-destructive mt-2">{{ mappingError }}</div>
|
<div v-else-if="mappingError" class="text-sm text-destructive mt-2">
|
||||||
|
{{ mappingError }}
|
||||||
|
</div>
|
||||||
<div v-if="missingCritical?.length" class="mt-2">
|
<div v-if="missingCritical?.length" class="mt-2">
|
||||||
<Badge variant="destructive" class="text-xs">Missing critical: {{ missingCritical.join(', ') }}</Badge>
|
<Badge variant="destructive" class="text-xs"
|
||||||
|
>Missing critical: {{ missingCritical.join(", ") }}</Badge
|
||||||
|
>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ const props = defineProps({
|
|||||||
completed_mode: { type: Boolean, default: false },
|
completed_mode: { type: Boolean, default: false },
|
||||||
});
|
});
|
||||||
|
|
||||||
const viewer = reactive({ open: false, src: "", title: "" });
|
const viewer = reactive({ open: false, src: "", title: "", mimeType: "", filename: "" });
|
||||||
function openViewer(doc) {
|
function openViewer(doc) {
|
||||||
const kind = classifyDocument(doc);
|
const kind = classifyDocument(doc);
|
||||||
const isContractDoc = (doc?.documentable_type || "").toLowerCase().includes("contract");
|
const isContractDoc = (doc?.documentable_type || "").toLowerCase().includes("contract");
|
||||||
@@ -85,6 +85,8 @@ function openViewer(doc) {
|
|||||||
viewer.open = true;
|
viewer.open = true;
|
||||||
viewer.src = url;
|
viewer.src = url;
|
||||||
viewer.title = doc.original_name || doc.name;
|
viewer.title = doc.original_name || doc.name;
|
||||||
|
viewer.mimeType = doc.mime_type || "";
|
||||||
|
viewer.filename = doc.original_name || doc.name || "";
|
||||||
} else {
|
} else {
|
||||||
const url =
|
const url =
|
||||||
isContractDoc && doc.contract_uuid
|
isContractDoc && doc.contract_uuid
|
||||||
@@ -102,6 +104,8 @@ function openViewer(doc) {
|
|||||||
function closeViewer() {
|
function closeViewer() {
|
||||||
viewer.open = false;
|
viewer.open = false;
|
||||||
viewer.src = "";
|
viewer.src = "";
|
||||||
|
viewer.mimeType = "";
|
||||||
|
viewer.filename = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatAmount(val) {
|
function formatAmount(val) {
|
||||||
@@ -610,6 +614,8 @@ const clientSummary = computed(() => {
|
|||||||
:show="viewer.open"
|
:show="viewer.open"
|
||||||
:src="viewer.src"
|
:src="viewer.src"
|
||||||
:title="viewer.title"
|
:title="viewer.title"
|
||||||
|
:mime-type="viewer.mimeType"
|
||||||
|
:filename="viewer.filename"
|
||||||
@close="closeViewer"
|
@close="closeViewer"
|
||||||
/>
|
/>
|
||||||
<ActivityDrawer
|
<ActivityDrawer
|
||||||
|
|||||||
@@ -1,13 +1,21 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from "vue";
|
import { ref, watch } from "vue";
|
||||||
import AppLayout from "@/Layouts/AppLayout.vue";
|
import AppLayout from "@/Layouts/AppLayout.vue";
|
||||||
import DataTableClient from "@/Components/DataTable/DataTableClient.vue";
|
import DataTableClient from "@/Components/DataTable/DataTableClient.vue";
|
||||||
import DataTableExample from "../Examples/DataTableExample.vue";
|
import DataTableExample from "../Examples/DataTableExample.vue";
|
||||||
|
import { useForm } from "@inertiajs/vue3";
|
||||||
|
import Checkbox from "@/Components/ui/checkbox/Checkbox.vue";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
example: { type: String, default: "Demo" },
|
example: { type: String, default: "Demo" },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const checkboxValue = ref(false);
|
||||||
|
|
||||||
|
const testForm = useForm({
|
||||||
|
allowed: false,
|
||||||
|
});
|
||||||
|
|
||||||
// Dummy columns
|
// Dummy columns
|
||||||
const columns = [
|
const columns = [
|
||||||
{ key: "id", label: "ID", sortable: true, class: "w-16" },
|
{ key: "id", label: "ID", sortable: true, class: "w-16" },
|
||||||
@@ -53,10 +61,17 @@ function onRowClick(row) {
|
|||||||
// no-op demo; could show toast or details
|
// no-op demo; could show toast or details
|
||||||
console.debug("Row clicked:", row);
|
console.debug("Row clicked:", row);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => testForm.allowed,
|
||||||
|
(newVal) => {
|
||||||
|
console.log(newVal);
|
||||||
|
}
|
||||||
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
<AppLayout>
|
||||||
<DataTableExample></DataTableExample>
|
<Checkbox v-model:checked="testForm.allowed" />
|
||||||
|
</AppLayout>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -463,6 +463,7 @@
|
|||||||
Route::get('imports/{import}/missing-keyref-rows', [ImportController::class, 'missingKeyrefRows'])->name('imports.missing-keyref-rows');
|
Route::get('imports/{import}/missing-keyref-rows', [ImportController::class, 'missingKeyrefRows'])->name('imports.missing-keyref-rows');
|
||||||
Route::get('imports/{import}/missing-keyref-csv', [ImportController::class, 'exportMissingKeyrefCsv'])->name('imports.missing-keyref-csv');
|
Route::get('imports/{import}/missing-keyref-csv', [ImportController::class, 'exportMissingKeyrefCsv'])->name('imports.missing-keyref-csv');
|
||||||
Route::get('imports/{import}/preview', [ImportController::class, 'preview'])->name('imports.preview');
|
Route::get('imports/{import}/preview', [ImportController::class, 'preview'])->name('imports.preview');
|
||||||
|
Route::get('imports/{import}/download', [ImportController::class, 'download'])->name('imports.download');
|
||||||
Route::get('imports/{import}/missing-contracts', [ImportController::class, 'missingContracts'])->name('imports.missing-contracts');
|
Route::get('imports/{import}/missing-contracts', [ImportController::class, 'missingContracts'])->name('imports.missing-contracts');
|
||||||
Route::post('imports/{import}/options', [ImportController::class, 'updateOptions'])->name('imports.options');
|
Route::post('imports/{import}/options', [ImportController::class, 'updateOptions'])->name('imports.options');
|
||||||
// Generic simulation endpoint (new) – provides projected effects for first N rows regardless of payments template
|
// Generic simulation endpoint (new) – provides projected effects for first N rows regardless of payments template
|
||||||
|
|||||||
@@ -0,0 +1,72 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Models\Import;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
it('downloads the original import file', function () {
|
||||||
|
// Create a test file
|
||||||
|
$uuid = (string) Str::uuid();
|
||||||
|
$disk = 'local';
|
||||||
|
$path = "imports/{$uuid}.csv";
|
||||||
|
$csv = "email,reference\nalpha@example.com,REF-1\n";
|
||||||
|
Storage::disk($disk)->put($path, $csv);
|
||||||
|
|
||||||
|
// Authenticate a user
|
||||||
|
$user = User::factory()->create();
|
||||||
|
Auth::login($user);
|
||||||
|
|
||||||
|
// Create import record
|
||||||
|
$import = Import::create([
|
||||||
|
'uuid' => $uuid,
|
||||||
|
'user_id' => $user->id,
|
||||||
|
'import_template_id' => null,
|
||||||
|
'client_id' => null,
|
||||||
|
'source_type' => 'csv',
|
||||||
|
'file_name' => basename($path),
|
||||||
|
'original_name' => 'test-import.csv',
|
||||||
|
'disk' => $disk,
|
||||||
|
'path' => $path,
|
||||||
|
'size' => strlen($csv),
|
||||||
|
'status' => 'uploaded',
|
||||||
|
'meta' => ['has_header' => true],
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Test download endpoint
|
||||||
|
$response = test()->get(route('imports.download', ['import' => $import->id]));
|
||||||
|
|
||||||
|
$response->assertSuccessful();
|
||||||
|
expect($response->headers->get('Content-Disposition'))->toContain('test-import.csv');
|
||||||
|
|
||||||
|
// Clean up
|
||||||
|
Storage::disk($disk)->delete($path);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns 404 when file does not exist', function () {
|
||||||
|
// Authenticate a user
|
||||||
|
$user = User::factory()->create();
|
||||||
|
Auth::login($user);
|
||||||
|
|
||||||
|
// Create import record with non-existent file
|
||||||
|
$import = Import::create([
|
||||||
|
'uuid' => (string) Str::uuid(),
|
||||||
|
'user_id' => $user->id,
|
||||||
|
'import_template_id' => null,
|
||||||
|
'client_id' => null,
|
||||||
|
'source_type' => 'csv',
|
||||||
|
'file_name' => 'missing.csv',
|
||||||
|
'original_name' => 'missing.csv',
|
||||||
|
'disk' => 'local',
|
||||||
|
'path' => 'imports/nonexistent.csv',
|
||||||
|
'size' => 0,
|
||||||
|
'status' => 'uploaded',
|
||||||
|
'meta' => ['has_header' => true],
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Test download endpoint
|
||||||
|
$response = test()->get(route('imports.download', ['import' => $import->id]));
|
||||||
|
|
||||||
|
$response->assertNotFound();
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user