Skip to content

Commit

Permalink
getting add project to create demand dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
baradhili committed Nov 27, 2024
1 parent da5e682 commit ae11d1f
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 12 deletions.
18 changes: 17 additions & 1 deletion app/Http/Controllers/DemandController.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ public function show($id): View
$demand->fte = $demand_raw->first()->fte;


Log::info("demand: " . print_r($demand, true));
return view('demand.show', compact('demand'));
}

Expand Down Expand Up @@ -204,6 +203,23 @@ public function edit($project_id, Request $request): RedirectResponse
->with('success', 'Resource assigned to project successfully.');
}


/**
* Show the form for editing the specified resource.
* - TODO we need to make sure we don't wipe out other demands
* - TODO we should run to the end of the demand, or deal with each month by itself
*/
public function editFullDemand($project_id): View
{
$demandArray = Demand::where('projects_id', $project_id)
->whereBetween('demand_date', [now()->startOfYear(), now()->endOfYear()->addYear()])
->get();

$resources = Resource::all();

return view('demand.editFullDemand', compact('demandArray', 'resources'));
}

/**
* Update the specified resource in storage.
*/
Expand Down
10 changes: 8 additions & 2 deletions app/Http/Controllers/ProjectController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use App\Http\Requests\ProjectRequest;
use Illuminate\Support\Facades\Redirect;
use Illuminate\View\View;
use Illuminate\Support\Facades\Log;

class ProjectController extends Controller
{
Expand All @@ -25,10 +26,15 @@ public function index(Request $request): View
/**
* Show the form for creating a new resource.
*/
public function create(): View
public function create(Request $request): View
{
$project = new Project();


if ($request->has('name')) {
$project->name = $request->query('name');
}
Log::info("project: ". json_encode($project));

return view('project.create', compact('project'));
}

Expand Down
27 changes: 21 additions & 6 deletions resources/views/demand/form.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,29 @@

<div class="form-group mb-2 mb20">
<label for="projects_id" class="form-label">{{ __('Projects') }}</label>
<select name="projects_id" class="form-control @error('projects_id') is-invalid @enderror" id="projects_id">
<option value="">{{ __('Select a Project') }}</option>
<div class="input-group">
<input list="projects" name="projects_id" class="form-control @error('projects_id') is-invalid @enderror"
id="projects_id" value="{{ old('projects_id', $demand?->projects_id) }}"
placeholder="Search for a project">
<div class="input-group-append">
<button class="btn btn-outline-secondary" type="button"
onclick="document.getElementById('projects_id').value = '';">
<i class="fa fa-times-circle"></i>
</button>
<button type="button" class="btn btn-outline-secondary btn-plus"
onclick="
window.open('{{ route('projects.create') }}?name='+document.getElementById('projects_id').value, '_blank')">
<i class="fa fa-plus-circle fa-lg"></i>
</button>
</div>
</div>
<datalist id="projects">
@foreach ($projects as $project)
<option value="{{ $project->id }}" {{ old('projects_id') == $project->id ? 'selected' : '' }}>
{{ $project->name }} ({{ $project->empowerID }})
<option value="{{ $project->id }}">
{{ $project->empowerID }} {{ $project->name }}
</option>
@endforeach
</select>
@endforeach
</datalist>
{!! $errors->first('projects_id', '<div class="invalid-feedback" role="alert"><strong>:message</strong></div>') !!}
</div>

Expand Down
2 changes: 1 addition & 1 deletion resources/views/demand/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class="fa fa-fw fa-edit"></i> {{ __('Assign') }}</button>
href="{{ route('demands.show', $project->id) }}"><i
class="fa fa-fw fa-eye"></i> {{ __('Show') }}</a>
<a class="btn btn-sm btn-success"
href="{{ route('demands.edit', $project->id) }}"><i
href="{{ route('demands.editFullDemand', $project->id) }}"><i
class="fa fa-fw fa-edit"></i> {{ __('Edit') }}</a>
@csrf
@method('DELETE')
Expand Down
5 changes: 3 additions & 2 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@
//additional functions
Route::post('/allocations-upload', [AllocationController::class, 'populateAllocations'])->name('allocations.upload');
Route::resource('contracts', ContractController::class);
Route::get('/demands-export', [DemandController::class, 'exportDemands'])->name('demands.export');
Route::get('/demands/export', [DemandController::class, 'exportDemands'])->name('demands.export');
Route::get('/demands/{project}/editFullDemand', [DemandController::class, 'editFullDemand'])->name('demands.editFullDemand');
Route::resource('demands', DemandController::class);
Route::resource('leaves', LeaveController::class);
Route::resource('projects', ProjectController::class);
Route::resource('projects', ProjectController::class);
Route::get('/resources/{resource}/allocations', [ResourceController::class, 'allocations'])->name('resources.allocations');
Route::resource('resources', ResourceController::class);
Route::resource('skills', SkillController::class);
Expand Down

0 comments on commit ae11d1f

Please sign in to comment.