Skip to content

Commit

Permalink
Merge pull request #595 from art-institute-of-chicago/feature/digital…
Browse files Browse the repository at this point in the history
…-pub-media-sizes

Digital publication media sizes [PUB-285]
  • Loading branch information
nikhiltri authored Nov 13, 2024
2 parents 52982b0 + ad8727f commit 863a85e
Show file tree
Hide file tree
Showing 12 changed files with 126 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
use App\Models\Vendor\Block;

return new class extends Migration
Expand All @@ -17,7 +16,7 @@ public function up(): void
foreach ($digiPubImageBlocks as $block) {
$content = $block->content;
if ($content['size'] == 'm') {
$content['size'] = 's';
$content['size'] = 'l';
}
$content['use_alt_background'] = true;
$content['use_contain'] = true;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

use Illuminate\Database\Migrations\Migration;
use App\Models\Vendor\Block;

return new class extends Migration
{
public function up(): void
{
$types = [
'360_embed' => [],
'artwork' => [],
'image_slider' => [],
'layered_image_viewer' => [],
'media_embed' => [],
'mirador_embed' => [],
'table' => [],
'video' => ['use_alt_background'],
'vtour_embed' => [],
];

foreach ($types as $type => $fieldsToSetToTrue) {
// Find all blocks of digitalPublicationArticles
$digiPubBlocks = Block::where('type', $type)
->where('blockable_type', 'digitalPublicationArticles')
->get();

// Update the content JSON column for image block on digital publication articles
foreach ($digiPubBlocks as $block) {
$content = $block->content;
if ($content['size'] == 'm') {
$content['size'] = 'l';
}

foreach ($fieldsToSetToTrue as $field) {
$content[$field] = true;
}

// Update the block with the new JSON
$block->content = $content;
$block->save();
}
}
}

public function down(): void
{
// There's no going back...
}
};
8 changes: 7 additions & 1 deletion resources/views/admin/blocks/360_embed.blade.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
@php
$currentUrl = explode('/', request()->url());
$type = $currentUrl[5] ?? null;
@endphp

@twillBlockTitle('360 Embed')
@twillBlockIcon('image')

@formField('select', [
'name' => 'size',
'label' => 'Size',
'placeholder' => 'Select size',
'default' => 's',
'default' => ($type === 'digitalPublications' ? 'l' : 's'),
'disabled' => ($type === 'digitalPublications' ? true : false),
'options' => [
[
'value' => 's',
Expand Down
3 changes: 2 additions & 1 deletion resources/views/admin/blocks/artwork.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
'name' => 'size',
'label' => 'Size',
'placeholder' => 'Select size',
'default' => 'm',
'default' => ($type === 'digitalPublications' ? 'l' : 'm'),
'disabled' => ($type === 'digitalPublications' ? true : false),
'options' => [
[
'value' => 's',
Expand Down
33 changes: 18 additions & 15 deletions resources/views/admin/blocks/image.blade.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
@php
$currentUrl = explode('/', request()->url());
$type = $currentUrl[5] ?? null;
$options = [];
$options[] = [
'value' => 's',
'label' => 'Small'
];
if ($type !== 'digitalPublications') {
$options[] = [
'value' => 'm',
'label' => 'Medium'
];
}
$options[] = [
'value' => 'l',
'label' => 'Large'
];
@endphp

@twillBlockTitle('Image')
Expand All @@ -19,21 +36,7 @@
'label' => 'Size',
'placeholder' => 'Select size',
'default' => ($type === 'digitalPublications' ? 'l' : 'm'),
'disabled' => ($type === 'digitalPublications' ? true : false),
'options' => [
[
'value' => 's',
'label' => 'Small'
],
[
'value' => 'm',
'label' => 'Medium'
],
[
'value' => 'l',
'label' => 'Large'
]
]
'options' => $options,
])

@formField('checkbox', [
Expand Down
8 changes: 7 additions & 1 deletion resources/views/admin/blocks/image_slider.blade.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
@php
$currentUrl = explode('/', request()->url());
$type = $currentUrl[5] ?? null;
@endphp

@twillBlockTitle('Image Slider')
@twillBlockIcon('image')

Expand All @@ -10,7 +15,8 @@
'name' => 'size',
'label' => 'Size',
'placeholder' => 'Select size',
'default' => 'm',
'default' => ($type === 'digitalPublications' ? 'l' : 'm'),
'disabled' => ($type === 'digitalPublications' ? true : false),
'options' => [
[
'value' => 's',
Expand Down
8 changes: 7 additions & 1 deletion resources/views/admin/blocks/layered_image_viewer.blade.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
@php
$currentUrl = explode('/', request()->url());
$type = $currentUrl[5] ?? null;
@endphp

@twillBlockTitle('Layered Image Viewer')
@twillBlockIcon('image')

Expand All @@ -23,7 +28,8 @@
'name' => 'size',
'label' => 'Size',
'placeholder' => 'Select size',
'default' => 'm',
'default' => ($type === 'digitalPublications' ? 'l' : 'm'),
'disabled' => ($type === 'digitalPublications' ? true : false),
'options' => [
[
'value' => 's',
Expand Down
8 changes: 7 additions & 1 deletion resources/views/admin/blocks/media_embed.blade.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
@php
$currentUrl = explode('/', request()->url());
$type = $currentUrl[5] ?? null;
@endphp

@twillBlockTitle('Media embed')
@twillBlockIcon('text')

@formField('select', [
'name' => 'size',
'label' => 'Size',
'placeholder' => 'Select size',
'default' => 's',
'default' => ($type === 'digitalPublications' ? 'l' : 's'),
'disabled' => ($type === 'digitalPublications' ? true : false),
'options' => [
[
'value' => 's',
Expand Down
8 changes: 7 additions & 1 deletion resources/views/admin/blocks/mirador_embed.blade.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
@php
$currentUrl = explode('/', request()->url());
$type = $currentUrl[5] ?? null;
@endphp

@twillBlockTitle('Mirador Embed')
@twillBlockIcon('image')

Expand All @@ -18,7 +23,8 @@
'name' => 'size',
'label' => 'Size',
'placeholder' => 'Select size',
'default' => 'm',
'default' => ($type === 'digitalPublications' ? 'l' : 'm'),
'disabled' => ($type === 'digitalPublications' ? true : false),
'options' => [
[
'value' => 's',
Expand Down
9 changes: 7 additions & 2 deletions resources/views/admin/blocks/table.blade.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
@php
$currentUrl = explode('/', request()->url());
$type = $currentUrl[5] ?? null;
@endphp

@twillBlockTitle('Table')
@twillBlockIcon('text')

Expand All @@ -9,7 +14,8 @@
'name' => 'size',
'label' => 'Size',
'placeholder' => 'Select size',
'default' => 's',
'default' => ($type === 'digitalPublications' ? 'l' : 's'),
'disabled' => ($type === 'digitalPublications' ? true : false),
'options' => [
[
'value' => 's',
Expand Down Expand Up @@ -62,4 +68,3 @@
'name' => 'hide_columns',
'label' => 'Hide vertical cell borders',
])

8 changes: 7 additions & 1 deletion resources/views/admin/blocks/video.blade.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
@php
$currentUrl = explode('/', request()->url());
$type = $currentUrl[5] ?? null;
@endphp

@twillBlockTitle('Video')
@twillBlockIcon('image')

@formField('select', [
'name' => 'size',
'label' => 'Size',
'placeholder' => 'Select size',
'default' => 'm',
'default' => ($type === 'digitalPublications' ? 'l' : 'm'),
'disabled' => ($type === 'digitalPublications' ? true : false),
'options' => [
[
'value' => 's',
Expand Down
6 changes: 6 additions & 0 deletions resources/views/admin/blocks/vtour_embed.blade.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
@php
$currentUrl = explode('/', request()->url());
$type = $currentUrl[5] ?? null;
@endphp

@twillBlockTitle('Virtual Tour Embed')
@twillBlockIcon('image')

Expand All @@ -12,6 +17,7 @@
'label' => 'Size',
'placeholder' => 'Select size',
'default' => 'l',
'disabled' => ($type === 'digitalPublications' ? true : false),
'options' => [
[
'value' => 'm',
Expand Down

0 comments on commit 863a85e

Please sign in to comment.