Skip to content

Commit

Permalink
-Preparing for V1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mikrosmile committed Dec 7, 2022
1 parent 92cca91 commit e28baa4
Show file tree
Hide file tree
Showing 16 changed files with 269 additions and 124 deletions.
3 changes: 2 additions & 1 deletion composer.json
Expand Up @@ -19,7 +19,8 @@
"require": {
"php": "^8.1",
"spatie/laravel-package-tools": "^1.13.0",
"illuminate/contracts": "^9.0"
"illuminate/contracts": "^9.0",
"filament/filament": "^v2.16.55"
},
"require-dev": {
"laravel/pint": "^1.0",
Expand Down
29 changes: 29 additions & 0 deletions config/timex.php
Expand Up @@ -60,7 +60,9 @@
'timex' => \Buildix\Timex\Pages\Timex::class,
'slug' => 'timex',
'group' => 'timex',
'sort' => 0,
'shouldRegisterNavigation' => true,
'enablePolicy' => false,
'modalWidth' => 'xl',
'icon' => [
'static' => true,
Expand Down Expand Up @@ -95,11 +97,38 @@
'nextMonth' => 'heroicon-o-chevron-right',
'createEvent' => 'heroicon-o-plus'
],
'modal' => [
'submit' => [
'outlined' => false,
'color' => 'primary',
'icon' => [
'enabled' => true,
'name' => 'heroicon-o-save'
],
],
'cancel' => [
'outlined' => false,
'color' => 'secondary',
'icon' => [
'enabled' => true,
'name' => 'heroicon-o-x-circle'
],
],
'delete' => [
'outlined' => false,
'color' => 'danger',
'icon' => [
'enabled' => true,
'name' => 'heroicon-o-trash'
],
],
],
],
],

'resources' => [
'event' => \Buildix\Timex\Resources\EventResource::class,
'sort' => 1,
'icon' => 'heroicon-o-calendar',
'slug' => 'timex-events',
'shouldRegisterNavigation' => true,
Expand Down
2 changes: 2 additions & 0 deletions resources/lang/en/timex.php
Expand Up @@ -6,6 +6,8 @@
'pluralLabel' => 'Events',
],
'modal' => [
'submit' => 'Submit',
'cancel' => 'Cancel',
'delete' => 'Delete',
],
'events' => [
Expand Down
2 changes: 2 additions & 0 deletions resources/lang/ru/timex.php
Expand Up @@ -6,6 +6,8 @@
'pluralLabel' => 'События',
],
'modal' => [
'submit' => 'Сохранить',
'cancel' => 'Отмена',
'delete' => 'Удалить',
],
'events' => [
Expand Down
14 changes: 3 additions & 11 deletions resources/views/calendar/day.blade.php
@@ -1,17 +1,9 @@
@php
$isCurrentDay = \Carbon\Carbon::createFromTimestamp($timestamp)->isCurrentDay();
$isCurrentMonthDay = \Carbon\Carbon::createFromTimestamp($timestamp)->isCurrentMonth();
$isWeekend = \Carbon\Carbon::createFromTimestamp($timestamp)->isWeekend();
$firstDayOfMonth = \Carbon\Carbon::createFromTimestamp($timestamp)->firstOfMonth()->timestamp;
$isFirstOfMonth = $timestamp == $firstDayOfMonth;
@endphp
<div class="timex-day">
<div
@class([
'text-gray-400' => !$isCurrentMonthDay || $isWeekend,
'border-t dark:border-gray-600',
'pl-2 pt-1 py-1'
'pl-2 pt-2'
])
wire:click="$emitUp('onDayClick','{{$timestamp}}')">
<span
Expand All @@ -20,7 +12,7 @@
[
'relative cursor-pointer inline-flex items-center justify-center text-sm ml-auto rtl:ml-0 rtl:mr-auto font-medium tracking-tight rounded-xl whitespace-normal',
'text-white bg-primary-500' => $isCurrentDay,
'rounded-full px-3 py-0.5 h-6 -mb-2',
'rounded-full px-3 h-6',
'hover:bg-gray-500 hover:text-white'
]
)
Expand All @@ -41,7 +33,7 @@
</div>
</span>
</div>
<div class="timex-event -mt-2 -pt-2" style="overflow-y: auto; overflow-x: hidden; overflow-scrolling: touch;">
<div class="timex-event" style="overflow-y: auto; overflow-x: hidden; overflow-scrolling: touch;">
<div class="grid grid-flow-row gap-0.5"
id="{{$timestamp}}"
data-status-id="{{$timestamp}}">
Expand Down
20 changes: 1 addition & 19 deletions resources/views/calendar/event.blade.php
@@ -1,21 +1,3 @@
@php
$isMyEvent = $organizer == Auth::id();
$isModelEnabled = \Buildix\Timex\Traits\TimexTrait::isCategoryModelEnabled() && Str::isUuid($category);
if ($isModelEnabled){
$model = \Buildix\Timex\Traits\TimexTrait::getCategoryModel()::query()->find($category)->getAttributes();
$icon = $model[\Buildix\Timex\Traits\TimexTrait::getCategoryModelColumn('icon')];
$color = $model[\Buildix\Timex\Traits\TimexTrait::getCategoryModelColumn('color')];
}elseif (Str::isUuid($category) && !$isModelEnabled){
$icon = "";
$color = "primary";
}else{
$icon = config('timex.categories.icons.'.$category);
$color = config('timex.categories.colors.'.$color);
}
$eventStart = \Carbon\Carbon::createFromTimestamp($start)->setHours(23);
$isInPast = $eventStart->isPast();
@endphp

<div class="flex"
style="height: 20px;">
<span
Expand Down Expand Up @@ -63,7 +45,7 @@
'col-span-2 ml-4 truncate' => $isWidgetEvent
])>
@if($isAllDay)
{{__('timex::timex.event.allDay')}}
{{trans('timex::timex.event.allDay')}}
@else
{{\Carbon\Carbon::parse($startTime)->isoFormat('H:mm')}}
@endif
Expand Down
59 changes: 59 additions & 0 deletions resources/views/calendar/header.blade.php
@@ -0,0 +1,59 @@
<div class="justify-between sm:items-center grid sm:flex gap-2">
<div class="font-medium text-lg">
{{$this->monthName}}
</div>
<div class="flex items-center gap-1">
<x-filament-support::button
wire:click="$emit('onPreviousYearClick')"
@class([
'hidden' => config('timex.pages.buttons.hideYearNavigation', false)
])
:size="'sm'"
:color="'secondary'"
:dark-mode="true"
:outlined="config('timex.pages.buttons.outlined')">
<x-dynamic-component :component="config('timex.pages.buttons.icons.previousYear', 'heroicon-o-chevron-double-left')" class="h-4 w-4"/>
</x-filament-support::button>
<x-filament-support::button
wire:click="$emit('onPrevClick')"
:size="'sm'"
:dark-mode="true"
:outlined="config('timex.pages.buttons.outlined')">
<x-dynamic-component :component="config('timex.pages.buttons.icons.previousMonth')" class="h-4 w-4"/>
</x-filament-support::button>
<x-filament-support::button
wire:click="$emit('onTodayClick')"
:size="'sm'"
:dark-mode="true"
:outlined="config('timex.pages.buttons.outlined')">
{{config('timex.pages.buttons.today.static') ? trans('timex::timex.labels.today') : self::getDynamicLabel('today')}}
</x-filament-support::button>
<x-filament-support::button
wire:click="$emit('onNextClick')"
:size="'sm'"
:dark-mode="true"
:outlined="config('timex.pages.buttons.outlined')">
<x-dynamic-component :component="config('timex.pages.buttons.icons.nextMonth')" class="h-4 w-4"/>
</x-filament-support::button>
<x-filament-support::button
wire:click="$emit('onNextYearClick')"
@class([
'hidden' => config('timex.pages.buttons.hideYearNavigation', false)
])
:size="'sm'"
:color="'secondary'"
:dark-mode="true"
:outlined="config('timex.pages.buttons.outlined')">
<x-dynamic-component :component="config('timex.pages.buttons.icons.nextYear','heroicon-o-chevron-double-right')" class="h-4 w-4"/>
</x-filament-support::button>
<span class="border border-gray-300 dark:border-gray-400 h-5 rounded ml-2 mr-2"></span>
<x-filament-support::button
wire:click="$emit('onCreateClick')"
:icon="config('timex.pages.buttons.icons.createEvent')"
:outlined="true"
:dark-mode="true"
:size="'sm'">
{{trans('filament::resources/pages/create-record.title', ['label' => Str::lower(__('timex::timex.model.label'))])}}
</x-filament-support::button>
</div>
</div>
5 changes: 0 additions & 5 deletions resources/views/calendar/month.blade.php
@@ -1,8 +1,3 @@
@php
$currentYear = today()->year;
$chosenYear = \Carbon\Carbon::create($today)->year;
@endphp

<div class="w-full" id="timex-calendar">
<div
wire:init="loaded" class="timex-month dark:bg-gray-800 dark:border-gray-600">
Expand Down
4 changes: 2 additions & 2 deletions resources/views/widgets/mini/event-widget-empty.blade.php
@@ -1,6 +1,6 @@
<div class="flex items-center pl-2 h-10 text-gray-500 dark:text-gray-400">
<x-heroicon-o-calendar class="w-5 h-5"/>
<div class="ml-2" style="font-weight: 200; font-size: 0.95rem; line-height: 1.5rem;">
{{__('timex::timex.events.empty', ['label' => Str::lower(__('timex::timex.model.pluralLabel'))])}}
<div class="ml-2">
{{trans('timex::timex.events.empty', ['label' => Str::lower(trans('timex::timex.model.pluralLabel'))])}}
</div>
</div>
13 changes: 13 additions & 0 deletions src/Calendar/Day.php
Expand Up @@ -14,10 +14,23 @@ class Day extends Component
public $first;
public $last;
public $events;
public bool $isCurrentDay;
public bool $isCurrentMonthDay;
public bool $isWeekend;
public $firstDayOfMonth;
public bool $isFirstOfMonth;



public function mount()
{
$this->events = $this->getEvents($this->timestamp);

$this->isCurrentDay = \Carbon\Carbon::createFromTimestamp($this->timestamp)->isCurrentDay();
$this->isCurrentMonthDay = \Carbon\Carbon::createFromTimestamp($this->timestamp)->isCurrentMonth();
$this->isWeekend = \Carbon\Carbon::createFromTimestamp($this->timestamp)->isWeekend();
$this->firstDayOfMonth = \Carbon\Carbon::createFromTimestamp($this->timestamp)->firstOfMonth()->timestamp;
$this->isFirstOfMonth = $this->timestamp == $this->firstDayOfMonth;
}


Expand Down
32 changes: 32 additions & 0 deletions src/Calendar/Event.php
Expand Up @@ -2,10 +2,12 @@

namespace Buildix\Timex\Calendar;

use Buildix\Timex\Traits\TimexTrait;
use Livewire\Component;

class Event extends Component
{
use TimexTrait;

public $body;
public $category;
Expand All @@ -18,6 +20,36 @@ class Event extends Component
public $start;
public $startTime;
public $subject;
public bool $isMyEvent;
public bool $isModelEnabled;
public bool $isInPast;

public function mount()
{
$this->isMyEvent = $this->organizer == \Auth::id() ? true : false;
$this->isModelEnabled = self::isCategoryModelEnabled() && \Str::isUuid($this->category) ? true : false;
$model = $this->isModelEnabled ? $this->getModelData() : null;
if ($this->isModelEnabled){
$this->icon = $model[self::getCategoryModelColumn('icon')];
$this->color = $model[self::getCategoryModelColumn('color')];

}elseif (!$this->isModelEnabled && \Str::isUuid($this->category)){
$this->icon = "";
$this->color = "primary";
}else{
$this->icon = config('timex.categories.icons.'.$this->category);
$this->color = config('timex.categories.colors.'.$this->color);
}

$eventStart = \Carbon\Carbon::createFromTimestamp($this->start)->setHours(23);
$this->isInPast = $eventStart->isPast();

}

public function getModelData()
{
return $model = self::getCategoryModel()::query()->find($this->category)->getAttributes();
}


public function render()
Expand Down
15 changes: 15 additions & 0 deletions src/Calendar/Header.php
@@ -0,0 +1,15 @@
<?php

namespace Buildix\Timex\Calendar;

use Livewire\Component;

class Header extends Component
{
public $monthName;

public function render()
{
return view('timex::calendar.header');
}
}
18 changes: 12 additions & 6 deletions src/Calendar/Month.php
Expand Up @@ -99,7 +99,7 @@ public function boot()

public function mount()
{
$this->monthName = today()->monthName;
$this->monthName = $this->getMonthName(today());
}

public function render()
Expand All @@ -110,7 +110,7 @@ public function render()
public function onPreviousMonthClick()
{
$this->today = $this->today->subMonth();
$this->monthName = $this->today->monthName;
$this->monthName = $this->getMonthName($this->today);
$this->setCalendar();
$this->loaded();
$this->emitUp('monthNameChanged',$this->monthName,$this->today->year);
Expand All @@ -119,7 +119,7 @@ public function onPreviousMonthClick()
public function onNextMonthClick()
{
$this->today = $this->today->addMonth();
$this->monthName = $this->today->monthName;
$this->monthName = $this->getMonthName($this->today);
$this->setCalendar();
$this->loaded();
$this->emitUp('monthNameChanged',$this->monthName,$this->today->year);
Expand All @@ -128,7 +128,7 @@ public function onNextMonthClick()
public function onNextYearClick()
{
$this->today = $this->today->addYear();
$this->monthName = $this->today->monthName;
$this->monthName = $this->getMonthName($this->today);
$this->setCalendar();
$this->loaded();
$this->emitUp('monthNameChanged',$this->monthName,$this->today->year);
Expand All @@ -137,7 +137,7 @@ public function onNextYearClick()
public function onPreviousYearClick()
{
$this->today = $this->today->subYear();
$this->monthName = $this->today->monthName;
$this->monthName = $this->getMonthName($this->today);
$this->setCalendar();
$this->loaded();
$this->emitUp('monthNameChanged',$this->monthName,$this->today->year);
Expand All @@ -146,7 +146,7 @@ public function onPreviousYearClick()
public function onTodayClick()
{
$this->today = Carbon::today();
$this->monthName = $this->today->monthName;
$this->monthName = $this->getMonthName($this->today);
$this->setCalendar();
$this->loaded();
$this->emitUp('monthNameChanged',$this->monthName,$this->today->year);
Expand Down Expand Up @@ -189,6 +189,12 @@ public function onEventChanged($eventID, $toDate)
$this->shouldSkipRender = true;
}

public function getMonthName($date){

return $date->monthName.' '.$date->year;

}




Expand Down

0 comments on commit e28baa4

Please sign in to comment.