Skip to content
This repository has been archived by the owner on Jul 12, 2022. It is now read-only.

Commit

Permalink
Version 1.2.0 - Corporation Title Affiliation (#19)
Browse files Browse the repository at this point in the history
This is a major update to SeAT-Groups as it introduces many asked features and refactoring lots of front end mistakes i made. This is just an initial working release. I will continue to improve SeAT Groups and refactor even classes i have introuced with this release and i see room for improvement.

* Introducing `Corporation Title Filter`
* Refactor affiliation box on `edit`
** Introducing of actions and custom validation for corporation-titles
** Serverside processed affiliation-table
** Logic refactoring to prevent assigning of corp-title affiliation whilst there is corp affiliated
** Logic introduction to prevent assigning other corporation wit `All Corporations` option enabled

* Refactor `index`-page
** Removing of laravel-form-builder inside
** Refactoring of many routes.
** split view in many partials to optimize maintainability.
** Reworked `managed` SeAT group modal: using `Datatables` asynchronously and bigger buttons.

* Refactor of `SeatGroups`
** Introducing of `isQualified()` method
** `GroupSync` will take use of this method.
** Refactoring of `isMember()` function
** Reducing of switch-complexity in `GroupSync`

![image](https://user-images.githubusercontent.com/6583519/45206929-af3a5e80-b286-11e8-9a27-ed9994a24cd3.png)

This closes #5
  • Loading branch information
herpaderpaldent authored Sep 7, 2018
1 parent 3088093 commit d4c7083
Show file tree
Hide file tree
Showing 48 changed files with 1,788 additions and 827 deletions.
25 changes: 24 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
# Version 1.2.0
This is a major update to SeAT-Groups as it introduces many asked features and refactoring lots of front end mistakes i made. This is just an initial working release. I will continue to improve SeAT Groups and refactor even classes i have introuced with this release and i see room for improvement.

* Introducing `Corporation Title Filter`
* Refactor affiliation box on `edit`
** Introducing of actions and custom validation for corporation-titles
** Serverside processed affiliation-table
** Logic refactoring to prevent assigning of corp-title affiliation whilst there is corp affiliated
** Logic introduction to prevent assigning other corporation wit `All Corporations` option enabled

* Refactor `index`-page
** Removing of laravel-form-builder inside
** Refactoring of many routes.
** split view in many partials to optimize maintainability.
** Reworked `managed` SeAT group modal: using `Datatables` asynchronously and bigger buttons.

* Refactor of `SeatGroups`
** Introducing of `isQualified()` method
** `GroupSync` will take use of this method.
** Refactoring of `isMember()` function
** Reducing of switch-complexity in `GroupSync`


# Version 1.1.1
Fix changed class name.

Expand All @@ -12,7 +35,7 @@ This release consist of many improvements:

This means every time the scheduled update `seat-groups:users:update` runs, every user group gets updated as an individual job, which is tracked and observable in Horizon dashboard. If the update job fails, the error can been seen in the workers dashboard. This further means, if one user group fails others are not blocked anymore.
Thanks to some refactoring and a new observer, user groups with a missing RefreshToken are getting striped from their roles until every character in SeAT has a valid RefreshToken again.
Thanks to Logs every Sync is getting logged and is viewable on the about-view, for anyone with the `seatgroups.edit` permission.
Thanks to Logs every Sync is getting logged and is viewable on the about-view, for anyone with the `seatgroups.create` permission.
Finally with `seat-groups:users:update --character_ids=123456789` you are able to dispatch an update job for the given character's SeAT group.

Thanks at this point to @warlof and his two packages https://github.com/warlof/slackbot and https://github.com/warlof/seat-discord-connector without him and his packages (which btw. integrate very well with SeAT-Groups) i wouldn't have been able to write all the job-logic.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Seat\Services\Repositories\Corporation\Corporation;


class AddCorpAffiliation
class AddCorporationAffiliationAction
{
use Corporation;
/**
Expand All @@ -16,17 +16,20 @@ class AddCorpAffiliation
*/
public function execute(array $data)
{
//dd($data);

$seat_group_id = $data['seatgroup_id'];
$corporations = $data['corporations'];
$corporations = $data['corporation_ids'];

$seat_group = Seatgroup::find($seat_group_id);

if(in_array("1337",$corporations)){
if(in_array("-1",$corporations)){
// First set SeAT Group to $all_corporation = true
$seat_group->all_corporations = true;
$seat_group->save();

// Secondly remove the -1 value from the array
$corporations = array_filter($corporations,function($value){
return $value !== "1337";
return $value !== "-1";
});
}

Expand Down
47 changes: 47 additions & 0 deletions src/Actions/Corporations/GetCorporationListAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
/**
* Created by PhpStorm.
* User: felix
* Date: 05.09.2018
* Time: 17:57
*/

namespace Herpaderpaldent\Seat\SeatGroups\Actions\Corporations;


use Herpaderpaldent\Seat\SeatGroups\Models\Seatgroup;
use Seat\Eveapi\Models\Corporation\CorporationInfo;

class GetCorporationListAction
{
public function execute(array $data)
{

$seatgroup = Seatgroup::find($data['seatgroup_id']);

$existing_affiliations = collect();

if($seatgroup->all_corporations && !$data['origin'] === 'SeatGroupsController')
return;

//if either corporation or a corporation-title is assigned don't show it in available list
$existing_affiliations->push($seatgroup->corporation->pluck('corporation_id'));


if($data['origin'] != 'corporation-tile-form')
$existing_affiliations->push($seatgroup->corporationTitles->pluck('corporation_id'));

$existing_affiliations = $existing_affiliations->filter(function ($affiliation){
return !$affiliation->isEmpty();
})->flatten()->unique();

if($existing_affiliations->isEmpty())
return CorporationInfo::select('corporation_id','name')->get();


return CorporationInfo::whereNotIn('corporation_id',$existing_affiliations)
->select('corporation_id','name')
->get();
}

}
32 changes: 32 additions & 0 deletions src/Actions/Corporations/RemoveAllCorporationAffiliationAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
/**
* Created by PhpStorm.
* User: felix
* Date: 06.09.2018
* Time: 09:13
*/

namespace Herpaderpaldent\Seat\SeatGroups\Actions\Corporations;


use Herpaderpaldent\Seat\SeatGroups\Models\Seatgroup;

class RemoveAllCorporationAffiliationAction
{
public function execute(array $data)
{
try {
$seatgroup_id = $data['seatgroup_id'];
$seatgroup = Seatgroup::find($seatgroup_id);

$seatgroup->all_corporations = false;
$seatgroup->save();

return true;
} catch (\Exception $e){
return false;
}

}

}
40 changes: 0 additions & 40 deletions src/Actions/Corporations/RemoveCorpAffiliation.php

This file was deleted.

37 changes: 37 additions & 0 deletions src/Actions/Corporations/RemoveCorpAffiliationAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace Herpaderpaldent\Seat\SeatGroups\Actions\Corporations;

use Herpaderpaldent\Seat\SeatGroups\Http\Validation\RemoveCorporationAffiliationRequest;
use Herpaderpaldent\Seat\SeatGroups\Models\Seatgroup;
use Illuminate\Http\Request;
use Seat\Services\Repositories\Corporation\Corporation;


class RemoveCorpAffiliationAction
{
use Corporation;
/**
* @param array $data
*
* @return mixed
*/
public function execute(array $data)
{
try{
$group_id = $data['seatgroup_id'];
$corporation_id = $data['corporation_id'];

$seat_group = Seatgroup::find($group_id);

$seat_group->corporation()->detach($corporation_id);

return true;

} catch (\Exception $e) {
return false;
}

}

}
31 changes: 31 additions & 0 deletions src/Actions/Corporations/Titles/AddCorporationTitleAffiliation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
/**
* Created by PhpStorm.
* User: felix
* Date: 05.09.2018
* Time: 15:21
*/

namespace Herpaderpaldent\Seat\SeatGroups\Actions\Corporations\Titles;


use Herpaderpaldent\Seat\SeatGroups\Models\CorporationTitleSeatgroups;

class AddCorporationTitleAffiliation
{
public function execute (array $data)
{

$seatgroup_corporation_id = $data['seatgroup-corporation-id'];
$seatgroup_id = $data['seatgroup_id'];
$seatgroup_title_id = $data['seatgroup-title-id'];

return CorporationTitleSeatgroups::firstOrCreate([
'seatgroup_id' => $seatgroup_id,
'corporation_id' => $seatgroup_corporation_id,
'title_id' => $seatgroup_title_id
]);

}

}
42 changes: 42 additions & 0 deletions src/Actions/Corporations/Titles/GetCorporationTitleAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php
/**
* Created by PhpStorm.
* User: felix
* Date: 05.09.2018
* Time: 16:42
*/

namespace Herpaderpaldent\Seat\SeatGroups\Actions\Corporations\Titles;

use Herpaderpaldent\Seat\SeatGroups\Models\Seatgroup;
use Seat\Eveapi\Models\Corporation\CorporationTitle;

class GetCorporationTitleAction
{
public function execute(array $data)
{
$corporationId = $data['corporation_id'];
$seatgroup_id = $data['seatgroup_id'];

$existing_affiliations = Seatgroup::find($seatgroup_id)
->corporationTitles
->where('corporation_id',$corporationId)
->pluck('title_id');


if (!empty($corporationId)) {
$titles = CorporationTitle::where('corporation_id', $corporationId)
->whereNotIn('title_id',$existing_affiliations)
->select('title_id', 'name')
->get();
return $titles->map(function($item){
return [
'title_id' => $item->title_id,
'name' => strip_tags($item->name)
];
});
}
return [];
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
/**
* Created by PhpStorm.
* User: felix
* Date: 06.09.2018
* Time: 09:56
*/

namespace Herpaderpaldent\Seat\SeatGroups\Actions\Corporations\Titles;

use Herpaderpaldent\Seat\SeatGroups\Models\CorporationTitleSeatgroups;

class RemoveCorporationTitleAffiliationAction
{
public function execute(array $data)
{
try{
$corporation_id = $data['corporation_id'];
$seatgroup_id = $data['seatgroup_id'];
$title_id = $data['title_id'];

CorporationTitleSeatgroups::where('corporation_id', $corporation_id)
->where('title_id', $title_id)
->where('seatgroup_id', $seatgroup_id)
->delete();
return true;
} catch (\Exception $e){
return false;
}



}

}
Loading

0 comments on commit d4c7083

Please sign in to comment.