Skip to content

Commit da9bd25

Browse files
committed
deploy to newspace2
1 parent e3f8f48 commit da9bd25

File tree

138 files changed

+185
-11635
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

138 files changed

+185
-11635
lines changed

.github/workflows/php-build-and-deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
id: meta
3636
uses: docker/metadata-action@v5
3737
with:
38-
images: ${{ secrets.REGISTRY_LOGIN_SERVER }}/newspace2_3
38+
images: ${{ secrets.REGISTRY_LOGIN_SERVER }}/newspace2_4
3939
flavor: |
4040
latest=false
4141
tags: |

app/Filament/Widgets/CalendarWidget.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,7 @@ protected function createConstraintAction()
157157
if (auth()->user()->getRoleNames()->count() === 1) {
158158
Constraint::requestConstraint($data);
159159
} else {
160-
Constraint::create([
161-
'constraint_type' => $data['constraint_type'],
162-
'start_date' => $data['start_date'],
163-
'end_date' => $data['end_date'],
164-
]);
160+
Constraint::createConstraint($data);
165161
}
166162
})
167163
->mountUsing(function (Form $form, array $arguments) {
@@ -287,7 +283,7 @@ protected function getBasicActions()
287283
: true
288284
)
289285
: true;
290-
// if (! empty($arguments) && $this->model === Shift::class && isset($this->mountedActionsArguments[0]['oldEvent'])) {
286+
// if (! empty($arguments) && $this->model === Shift::class) {
291287
// $oldDate = date('l', strtotime($this->mountedActionsArguments[0]['oldEvent']['start']));
292288
// $newDate = date('l', strtotime($this->mountedActionsData[0]['start_date']));
293289
// $startOfWeek = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday'];

app/Livewire/MyDatabaseNotifications.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ protected function shiftAssignmentConfirmExchange($soldierAId, $soldierBId, $shi
9393
[],
9494
$soldierB->user
9595
);
96-
if ($requesterId != $soldierAId->user->id && $requesterId != $soldierBId->user->id) {
96+
if ($requesterId != $soldierAId && $requesterId != $soldierBId) {
9797
$this->sendNotification(
9898
__('Exchange shift'),
9999
__(
@@ -267,7 +267,7 @@ protected function shiftAssignmentDenyExchange($soldierAId, $soldierBId, $shiftA
267267
$soldierB->user
268268
);
269269
}
270-
if ($requesterId != $soldierAId->user->id && $requesterId != $soldierBId->user->id) {
270+
if ($requesterId != $soldierAId && $requesterId != $soldierBId) {
271271
$this->sendNotification(
272272
__('Deny exchange shift request'),
273273
__(

app/Models/Constraint.php

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use Filament\Actions\Action;
1111
use Filament\Forms\Components\DateTimePicker;
1212
use Filament\Forms\Components\Grid;
13-
use Filament\Forms\Components\Hidden;
1413
use Filament\Forms\Components\Placeholder;
1514
use Filament\Forms\Components\Select;
1615
use Filament\Forms\Components\ToggleButtons;
@@ -57,7 +56,8 @@ public static function getSchema(): array
5756
&& \Str::contains($_SERVER['HTTP_REFERER'], 'my-soldiers-constraint')
5857
)
5958
->options(fn () => CommanderSoldier::getCommanderSoldier())
60-
->afterStateUpdated(fn ($state) => session()->put('soldier_id', $state))
59+
->afterStateUpdated(fn ($state) => session()->put('soldiers_ids', $state))
60+
->multiple(fn ($get) => $get('id') === null)
6161
->required(),
6262
ToggleButtons::make('constraint_type')
6363
->required()
@@ -75,12 +75,6 @@ public static function getSchema(): array
7575
->options(fn (Constraint $constraint) => [
7676
$constraint->constraint_type->getLabel(),
7777
]),
78-
// Hidden::make('start_date')
79-
// ->label(__('Start date'))
80-
// ->required(),
81-
// Hidden::make('end_date')
82-
// ->label(__('End date'))
83-
// ->required(),
8478
Placeholder::make('')
8579
->content(__('The constraint will only be approved after approval by the commander'))
8680
->visible(fn () => auth()->user()->getRoleNames()->count() === 1)
@@ -302,23 +296,33 @@ public static function updateDates(callable $set, $state, Get $get)
302296
}
303297
}
304298

305-
protected static function booted()
299+
public static function createConstraint($data)
306300
{
307-
static::creating(function ($constraint) {
308-
$constraint->soldier_id = $constraint->soldier_id ?: ($constraint->getCurrentUserSoldier() ?: null);
309-
session()->put('soldier_id', null);
301+
$soldiers = self::getCurrentUserSoldier();
302+
$soldiers = gettype($soldiers) == 'integer' ? [$soldiers] : $soldiers;
303+
collect($soldiers)->each(function ($soldierId) use ($data) {
304+
$constraint = new Constraint;
305+
$constraint->soldier_id = $soldierId;
306+
$constraint->constraint_type = $data['constraint_type'];
307+
$constraint->start_date = $data['start_date'];
308+
$constraint->end_date = $data['end_date'];
309+
$constraint->save();
310310
});
311+
session()->put('soldiers_ids', null);
312+
}
311313

314+
protected static function booted()
315+
{
312316
static::updating(function ($constraint) {
313317
$constraint->soldier_id = $constraint->soldier_id ?: ($constraint->getCurrentUserSoldier() ?: null);
314-
session()->put('soldier_id', null);
318+
session()->put('soldiers_ids', null);
315319
});
316320
}
317321

318-
private function getCurrentUserSoldier()
322+
protected static function getCurrentUserSoldier()
319323
{
320-
if (session()->get('soldier_id')) {
321-
return session()->get('soldier_id');
324+
if (session()->get('soldiers_ids')) {
325+
return session()->get('soldiers_ids');
322326
}
323327
$user = auth()->user();
324328
if ($user && $user->userable instanceof Soldier) {

app/Models/Shift.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ function (?Shift $shift, Get $get) {
106106
return $manual_assignment->getSoldiers();
107107
}
108108
)
109-
->searchable()
110109
->default(null)
111110
->placeholder(fn (?Shift $shift, Get $get) => self::soldierIdPlaceholder($get('soldier_type'), $shift))
112111
->visible(
@@ -149,7 +148,8 @@ function (?Shift $shift, Get $get) {
149148
protected static function soldierIdPlaceholder($soldierType, $shift)
150149
{
151150
if ($soldierType === 'all') {
152-
return Cache::remember('users', 30 * 60, fn () => User::all()->sortBy('first_name'))->count() > 0 ? __('Select a soldier') : __('No suitable soldiers'); }
151+
return Cache::remember('users', 30 * 60, fn () => User::all()->sortBy('first_name'))->count() > 0 ? __('Select a soldier') : __('No suitable soldiers');
152+
}
153153
$manual_assignment = new ManualAssignment($shift, $soldierType);
154154

155155
return
@@ -801,7 +801,8 @@ public static function getFilters($calendar)
801801
]),
802802
Select::make('soldier_id')
803803
->label(__('Soldier'))
804-
->options(fn (): array => Cache::remember('users', 30 * 60, fn () => User::all()->sortBy('first_name'))->mapWithKeys(fn ($user) => [$user->userable_id => $user->displayName]) ->toArray())
804+
->options(fn (): array => Cache::remember('users', 30 * 60, fn () => User::all()->sortBy('first_name'))->mapWithKeys(fn ($user) => [$user->userable_id => $user->displayName])
805+
->toArray())
805806
->multiple()
806807
->live()
807808
->reactive()

app/Models/Soldier.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function constraints(): HasMany
8888
{
8989
return $this->hasMany(Constraint::class);
9090
}
91-
91+
9292
public function shifts(): HasMany
9393
{
9494
return $this->hasMany(Shift::class);
@@ -113,7 +113,7 @@ public static function boot()
113113
Constraint::where('soldier_id', $record->id)
114114
->delete();
115115
Team::where('commander_id', $record->id)->update(['commander_id' => null]);
116-
Department::where('commander_id', $record->id)->update(['commander_id' => null]);
116+
Department::where('commander_id', $record->id)->update(['commander_id' => null]);
117117
});
118118
}
119119
}

app/Resources/ChartResource/Widgets/ChartFilter.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
use App\Services\RecurringEvents;
1313
use Carbon\Carbon;
1414
use Filament\Forms\Components\Actions\Action;
15-
use Filament\Forms\Components\Section;
1615
use Filament\Forms\Components\Radio;
16+
use Filament\Forms\Components\Section;
1717
use Filament\Forms\Components\Select;
1818
use Filament\Forms\Concerns\InteractsWithForms;
1919
use Filament\Forms\Contracts\HasForms;
@@ -22,7 +22,6 @@
2222
use Filament\Widgets\Widget;
2323
use Maatwebsite\Excel\Facades\Excel;
2424

25-
2625
class ChartFilter extends Widget implements HasForms
2726
{
2827
use InteractsWithForms;
@@ -102,7 +101,7 @@ public function form(Form $form): Form
102101
'month' => $form->getState()['year'].'-'.$form->getState()['month'],
103102
])))
104103
->extraAttributes(['style' => 'color: white; background-color: #a0cddf']),
105-
Action::make('Reset assignment')
104+
Action::make('Reset assignment')
106105
->color('danger')
107106
->label(__('Reset assignment'))
108107
->icon('heroicon-o-arrow-path')
@@ -183,9 +182,10 @@ protected function resetShifts($form)
183182
{
184183
$startDate =
185184
// (Carbon::now()->format('m') == Carbon::parse($form->getState()['year'].'-'.$form->getState()['month'])->format('m'))
186-
// ? Carbon::now()->addDay()->format('Y-m-d')
187-
// :
188-
Carbon::parse($form->getState()['year'].'-'.$form->getState()['month'])->startOfMonth()->format('Y-m-d'); Shift::whereNotNull('soldier_id')
185+
// ? Carbon::now()->addDay()->format('Y-m-d')
186+
// :
187+
Carbon::parse($form->getState()['year'].'-'.$form->getState()['month'])->startOfMonth()->format('Y-m-d');
188+
Shift::whereNotNull('soldier_id')
189189
->whereBetween('start_date', [$startDate, (Carbon::parse($form->getState()['year'].'-'.$form->getState()['month'])->endOfMonth()->addDay())->format('Y-m-d')])
190190
->update(['soldier_id' => null, 'manually_assigned' => false]);
191191
}
@@ -195,7 +195,7 @@ protected function resetShiftsByCondition($form, $manual_assignment)
195195
$startDate =
196196
// (Carbon::now()->format('m') == Carbon::parse($form->getState()['year'].'-'.$form->getState()['month'])->format('m'))
197197
// ? Carbon::now()->addDay()->format('Y-m-d')
198-
// :
198+
// :
199199
Carbon::parse($form->getState()['year'].'-'.$form->getState()['month'])->startOfMonth()->format('Y-m-d');
200200
Shift::whereNotNull('soldier_id')
201201
->whereBetween('start_date', [$startDate, (Carbon::parse($form->getState()['year'].'-'.$form->getState()['month'])->endOfMonth()->addDay())->format('Y-m-d')])
@@ -209,7 +209,7 @@ protected function deleteShifts($form)
209209
// (Carbon::now()->format('m') == Carbon::parse($form->getState()['year'].'-'.$form->getState()['month'])->format('m'))
210210
// ? Carbon::now()->addDay()->format('Y-m-d')
211211
// :
212-
Carbon::parse($form->getState()['year'].'-'.$form->getState()['month'])->startOfMonth()->format('Y-m-d');
212+
Carbon::parse($form->getState()['year'].'-'.$form->getState()['month'])->startOfMonth()->format('Y-m-d');
213213
Shift::whereBetween('start_date', [$startDate, (Carbon::parse($form->getState()['year'].'-'.$form->getState()['month'])->endOfMonth()->addDay())->format('Y-m-d')])
214214
->delete();
215215
}

app/Resources/ProfileResource.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,12 +173,13 @@ public static function table(Table $table): Table
173173
->whereBetween('start_date', [$startOfMonth, $endOfMonth])
174174
->orWhereBetween('end_date', [$startOfMonth, $endOfMonth]);
175175
})
176-
->with(['task' => fn($q) => $q->withTrashed()])
176+
->with(['task' => fn ($q) => $q->withTrashed()])
177177
->chunk(100, function ($shifts) use (&$total) {
178178
foreach ($shifts as $shift) {
179179
$total += $shift->parallel_weight ?? $shift->task?->parallel_weight ?? 0;
180180
}
181181
});
182+
182183
return $total;
183184
})
184185
->weight(FontWeight::SemiBold)

app/Resources/SoldierResource.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ function ($record) {
117117
->sortable()
118118
->date(),
119119
TextColumn::make('capacity_hold')
120-
->default(function ($record) {
120+
->default(function ($record) {
121121
$userId = $record->id;
122122
$startOfMonth = now()->startOfMonth();
123123
$endOfMonth = now()->endOfMonth();
@@ -128,12 +128,13 @@ function ($record) {
128128
->whereBetween('start_date', [$startOfMonth, $endOfMonth])
129129
->orWhereBetween('end_date', [$startOfMonth, $endOfMonth]);
130130
})
131-
->with(['task' => fn($q) => $q->withTrashed()])
131+
->with(['task' => fn ($q) => $q->withTrashed()])
132132
->chunk(100, function ($shifts) use (&$total) {
133133
foreach ($shifts as $shift) {
134134
$total += $shift->parallel_weight ?? $shift->task?->parallel_weight ?? 0;
135135
}
136136
});
137+
137138
return $total;
138139
})
139140
->label(__('Capacity hold'))

app/Resources/TaskResource.php

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -242,10 +242,10 @@ public static function getTaskDetails(): array
242242
->required(),
243243
Select::make('parallel_weight')
244244
->options([
245-
0 => '0',
246-
0.5 => '0.5',
247-
1 => '1',
248-
2 => '2',
245+
'0' => '0',
246+
'0.5' => '0.5',
247+
'1' => '1',
248+
'2' => '2',
249249
])
250250
->label(__('Parallel weight')),
251251
ColorPicker::make('color')
@@ -261,7 +261,7 @@ public static function getTaskDetails(): array
261261
->step(0.01)
262262
->label(__('Duration'))
263263
->required(),
264-
Select::make('kind')
264+
Select::make('kind')
265265
->label(__('Kind'))
266266
->live()
267267
->required()
@@ -277,7 +277,6 @@ public static function getTaskDetails(): array
277277
->pluck('type', 'type')
278278
->all())
279279
->visible(fn (Get $get) => $get('kind') === TaskKind::INPARALLEL->value),
280-
281280
];
282281
}
283282

@@ -363,12 +362,12 @@ public static function assignSoldier(): array
363362
->extraAttributes(['style' => 'color: red; font-family: Arial, Helvetica, sans-serif; font-size: 20px'])
364363
->live()
365364
->visible(fn (Get $get) => $get('soldier_type') === 'all'),
366-
])
367-
->visible(
368-
fn (Get $get) => $get('recurring.type') == 'One time'
369-
&& $get('recurring.date')
370-
&& $get('kind')
371-
),
365+
])
366+
->visible(
367+
fn (Get $get) => $get('recurring.type') == 'One time'
368+
&& $get('recurring.date')
369+
&& $get('kind')
370+
),
372371
];
373372
}
374373

0 commit comments

Comments
 (0)