Skip to content

Commit

Permalink
change feed filters to better version
Browse files Browse the repository at this point in the history
  • Loading branch information
temaotl committed May 24, 2024
1 parent 195bd57 commit f4331c7
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 11 deletions.
20 changes: 18 additions & 2 deletions app/Http/Controllers/FederationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,14 @@ public function store(StoreFederation $request)
{
$this->authorize('create', Federation::class);


$validated = $request->validated();
$id = generateFederationID($validated['name']);



$federation = DB::transaction(function () use ($validated, $id) {
$federation = Federation::create(array_merge($validated, [
'tagfile' => "$id.tag",
'cfgfile' => "$id.cfg",
'xml_id' => $id,
'xml_name' => "urn:mace:cesnet.cz:$id",
'filters' => $id,
Expand Down Expand Up @@ -164,9 +166,23 @@ public function update(UpdateFederation $request, Federation $federation)
->with('status', __('federations.approved', ['name' => $federation->name]));

case 'update':


$this->authorize('update', $federation);

$validated = $request->validated();
$id = generateFederationID($validated['name']);

$additionalFilters = $request->input('sp_and_ip_feed', 0);
$filters = $id;

if($additionalFilters){
$filters .= ', '.$id.'+idp';
$filters .= ', '.$id.'+sp';
}
$validated['filters'] = $filters;
$validated['additional_filters'] = $additionalFilters;

$federation->update($validated);

if (! $federation->wasChanged()) {
Expand Down
1 change: 1 addition & 0 deletions lang/cs/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,5 @@
'metadata' => 'Metadata',
'confirm' => 'Potvrdit',
'organization' => 'Organizace',
'add_sp_idp' => 'Přidat IdP a Sp feedy',
];
1 change: 1 addition & 0 deletions lang/cs/federations.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@
'updated' => 'Federace byla úspěšně upravena.',
'xml_id' => 'Atribut XML ID',
'xml_name' => 'Atribut XML Name',
'add_sp_and_idp' => 'Přidat SP & IDP',
];
1 change: 1 addition & 0 deletions lang/en/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,5 @@
'metadata' => 'Metadata',
'confirm' => 'Confirm',
'organization' => 'Organization',
'add_sp_idp' => 'Add additional IdP and Sp feeds',
];
1 change: 1 addition & 0 deletions lang/en/federations.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@
'updated' => 'Federation has been successfully updated.',
'xml_id' => 'XML ID attribute',
'xml_name' => 'XML Name attribute',
'add_sp_and_idp' => 'Add SP & IDP',
];
18 changes: 18 additions & 0 deletions resources/views/federations/create.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

</x-forms.section.form-body-section>


<x-forms.section.form-body-section
name="common.description"
label="name"
Expand All @@ -43,5 +44,22 @@

</x-forms.section.form-body-section>



{{--
<x-forms.section.form-body-section
name="common.add_sp_idp"
label="add_sp_and_idp_section"
>
<label for="use_sp">
<input type="checkbox" name="sp_and_ip_feed" id="sp_and_ip_feed" value="1" {{ old('sp_and_ip_feed') ? 'checked' : '' }}>
{{ __('federations.add_sp_and_idp') }}
</label>
</x-forms.section.form-body-section>
--}}


@endsection

16 changes: 9 additions & 7 deletions resources/views/federations/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,17 @@
</x-forms.section.form-body-section>

<x-forms.section.form-body-section
name="federations.filters"
label="filters"
name="common.add_sp_idp"
label="add_sp_and_idp_section"
>
<x-forms.element.input err="filters">
type="text" name="filters" id="filters" maxlength="32"
placeholder="{{ __('federations.name_placeholder') }}"
value="{{ $federation->filters }}" required
</x-forms.element.input>
<label for="use_sp">

<input type="checkbox" name="sp_and_ip_feed" id="sp_and_ip_feed" value="1" {{ $federation->additional_filters == 1 ? 'checked' : '' }}>
<span class="{{ $federation->additional_filters == 1 ? 'checked-label' : 'unchecked-label' }}">
{{ __('federations.add_sp_and_idp') }}
</span>

</label>
</x-forms.section.form-body-section>

@endsection
15 changes: 13 additions & 2 deletions resources/views/federations/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@

@section('admin_section')




<x-element.body-section>
<x-slot name="dt">
{{ __('federations.tagfile') }}
Expand All @@ -91,16 +94,24 @@
</x-slot>
</x-element.body-section>


<x-element.body-section>
<x-slot name="dt">
{{ __('federations.filters') }}
{{ __('common.add_sp_idp') }}
</x-slot>

<x-slot name="dd">
{{ $federation->filters }}
<label for="use_sp" class="checkbox-label">
<input type="checkbox" name="sp_and_ip_feed" id="sp_and_ip_feed" value="1" disabled {{ $federation->additional_filters == 1 ? 'checked' : '' }}>
<span class="{{ $federation->additional_filters == 1 ? 'checked-label' : 'unchecked-label' }}">
{{ __('federations.add_sp_and_idp') }}
</span>
</label>
</x-slot>
</x-element.body-section>



@endsection

@section('specific_condition')
Expand Down

0 comments on commit f4331c7

Please sign in to comment.