Skip to content

Commit

Permalink
Merge branch 'release/6.0-beta55'
Browse files Browse the repository at this point in the history
# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
  • Loading branch information
IllyaMoskvin committed Dec 20, 2019
2 parents 8f1a6e4 + d482288 commit c09f5ef
Show file tree
Hide file tree
Showing 84 changed files with 4,088 additions and 2,411 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.0-beta54
6.0-beta55
9 changes: 8 additions & 1 deletion app/Helpers/BlockHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@
*/
function getBlocksForEditor($toUse = [])
{
return array_intersect(array_keys(config('twill.block_editor.blocks')), $toUse);
$allBlocks = array_keys(config('twill.block_editor.blocks'));

// Hide 3D blocks from production until they're ready for production use
if ( app()->environment('production')) {
$allBlocks = array_except($allBlocks, ['3d_model', '3d_tour', '3d_embed']);
}

return array_intersect($allBlocks, $toUse);
}
}

Expand Down
1 change: 1 addition & 0 deletions app/Http/Controllers/ArtworkController.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public function show($id, $slug = null)
// Start building data for output to view
$viewData = [
'item' => $item,
'model3d' => $item->model3d,
'contrastHeader' => $item->present()->contrastHeader,
'borderlessHeader' => $item->present()->borderlessHeader,
'primaryNavCurrent' => 'collection',
Expand Down
35 changes: 33 additions & 2 deletions app/Http/Requests/Admin/EventRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,42 @@

use App\Models\Event;
use Illuminate\Validation\Rule;
use Illuminate\Support\Facades\Validator;

use A17\Twill\Http\Requests\Admin\Request;

class EventRequest extends Request
{
public function rulesForCreate() {
/**
* Adapted from https://stackoverflow.com/questions/29454798
*/
public function __construct()
{
Validator::extend('emails', function($attribute, $value, $parameters) {
$values = array_map('trim', array_filter(explode(',', rtrim($this->test_emails, ','))));

if (count($values) < 1) {
return true;
}

foreach ($values as $email) {
$validator = Validator::make([
'email' => $email
],[
'email' => 'required|email',
]);

if ($validator->fails()) {
return false;
}
}

return true;
});
}

public function rulesForCreate()
{
return [];
}

Expand All @@ -22,7 +52,8 @@ public function rulesForUpdate()
'event_host_id' => [
'required_if:add_to_event_email_series,true',
Rule::notIn([Event::NULL_OPTION_EVENT_HOST]),
]
],
'test_emails' => 'emails',
];

return $rules;
Expand Down
41 changes: 41 additions & 0 deletions app/Http/Resources/Slide.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Http\Resources\SlideMedia as SlideMediaResource;
use App\Http\Resources\SlideModal as SlideModalResource;
use Illuminate\Support\Arr;
use Illuminate\Http\Resources\Json\JsonResource;

class Slide extends JsonResource
Expand Down Expand Up @@ -43,6 +44,9 @@ protected function getSlideAttributes()
case 'compare':
return $this->getCompareAttributes();
break;
case '3dtour':
return $this->get3DTourAttributes();
break;
case 'end':
return $this->getEndAttributes();
break;
Expand Down Expand Up @@ -138,6 +142,22 @@ protected function getFullWidthMediaAttributes()
return $image->image('experience_image');
})->toArray();
}
elseif ($this->asset_type === '3dModel') {
$model3d = $this->model3d()->first();
if ($model3d) {
return [
'model_id' => $model3d->model_id,
'model_caption' => $model3d->model_caption,
'camera_position' => $model3d->camera_position,
'camera_target' => $model3d->camera_target,
'annotation_list' => json_decode($model3d->annotation_list)
];
} else {
return [

];
}
}
else {
$src = '';
}
Expand Down Expand Up @@ -183,6 +203,23 @@ protected function getCompareAttributes()
];
}

protected function get3DTourAttributes()
{
$model3d = $this->model3d()->first();
if ($model3d) {
return [
'model_id' => $model3d->model_id,
'camera_position' => $model3d->camera_position,
'camera_target' => $model3d->camera_target,
'annotation_list' => json_decode($model3d->annotation_list)
];
} else {
return [

];
}
}

protected function getEndAttributes()
{
$this->media = $this->endBackgroundExperienceImages;
Expand Down Expand Up @@ -282,6 +319,10 @@ protected function commonStructure()
];
}

if ($this->module_type === '3dtour') {
Arr::forget($rst, ['seamlessAsset', 'assetType', '__mediaType', 'media', 'headline', 'vScalePercent']);
}

return $rst;
}

Expand Down
14 changes: 14 additions & 0 deletions app/Http/Resources/SlideModal.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,20 @@ public function toArray($request)
'caption' => $this->image_sequence_caption ?? $this->imageCaption('experience_image'),
];
break;
case '3d_model':
$model3d = $this->model3d;
if ($model3d) {
return [
'id' => (string) $this->id,
'__mediaType' => '3d_model',
'model_id' => $model3d->model_id,
'camera_position' => (array) $model3d->camera_position,
'camera_target' => $model3d->camera_target,
'annotation_list' => json_decode($model3d->annotation_list, true),
'caption' => $this->image_sequence_caption ?? ''
];
}
break;
}
}
}
5 changes: 5 additions & 0 deletions app/Models/Artwork.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ public function getFullTitleAttribute()
return $this->title;
}

public function model3d()
{
return $this->belongsTo('App\Models\Model3d', '3d_model_id');
}

public function getTrackingSlugAttribute()
{
return $this->title;
Expand Down
36 changes: 36 additions & 0 deletions app/Models/EmailSeries.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ class EmailSeries extends AbstractModel implements Sortable
'show_member',
'show_sustaining_fellow',
'show_nonmember',
'show_affiliate_test',
'show_member_test',
'show_sustaining_fellow_test',
'show_nonmember_test',
'position',
'published',
];
Expand All @@ -37,6 +41,10 @@ class EmailSeries extends AbstractModel implements Sortable
'show_member',
'show_sustaining_fellow',
'show_nonmember',
'show_affiliate_test',
'show_member_test',
'show_sustaining_fellow_test',
'show_nonmember_test',
'published',
];

Expand All @@ -45,6 +53,10 @@ class EmailSeries extends AbstractModel implements Sortable
'show_member' => 'boolean',
'show_sustaining_fellow' => 'boolean',
'show_nonmember' => 'boolean',
'show_affiliate_test' => 'boolean',
'show_member_test' => 'boolean',
'show_sustaining_fellow_test' => 'boolean',
'show_nonmember_test' => 'boolean',
'published' => 'boolean',
];

Expand Down Expand Up @@ -93,6 +105,30 @@ protected function transformMappingInternal()
'type' => 'boolean',
'value' => function () {return $this->show_nonmember;},
],
[
"name" => 'show_affiliate_test',
'doc' => 'Whether to show the "Send affiliate test" option',
'type' => 'boolean',
'value' => function () {return $this->show_affiliate_test;},
],
[
"name" => 'show_member_test',
'doc' => 'Whether to show the "Send member test" option',
'type' => 'boolean',
'value' => function () {return $this->show_member_test;},
],
[
"name" => 'show_sustaining_fellow_test',
'doc' => 'Whether to show the "Send sustaining fellow test" option',
'type' => 'boolean',
'value' => function () {return $this->show_sustaining_fellow_test;},
],
[
"name" => 'show_nonmember_test',
'doc' => 'Whether to show the "Send nonmember test" option',
'type' => 'boolean',
'value' => function () {return $this->show_nonmember_test;},
],
];
}

Expand Down
11 changes: 11 additions & 0 deletions app/Models/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class Event extends AbstractModel
'show_presented_by',
'event_host_id',
'entrance',
'test_emails',
'publish_start_date',
'publish_end_date',
];
Expand Down Expand Up @@ -213,6 +214,10 @@ public function emailSeries()
->belongsToMany('App\Models\EmailSeries', 'event_email_series')
->using('App\Models\EventEmailSeries')
->withPivot(
'send_affiliate_test',
'send_member_test',
'send_sustaining_fellow_test',
'send_nonmember_test',
'override_affiliate',
'override_member',
'override_sustaining_fellow',
Expand Down Expand Up @@ -857,6 +862,12 @@ protected function transformMappingInternal()
"type" => "string",
"value" => function () {return $this->survey_url;},
],
[
"name" => "test_emails",
"doc" => "Extra email addresses to which to send email series tests",
"type" => "string",
"value" => function () {return $this->test_emails;},
],
[
"name" => "email_series",
"doc" => "email_series",
Expand Down
5 changes: 5 additions & 0 deletions app/Models/ExperienceModal.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,9 @@ public function toRepeaterArray()
$fields['video_play_settings'] = $fields['video_play_settings'] ?? [];
return $fields;
}

public function model3d()
{
return $this->belongsTo('App\Models\Model3d', '3d_model_id');
}
}
27 changes: 27 additions & 0 deletions app/Models/Model3d.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace App\Models;

use Illuminate\Support\Str;
use Illuminate\Database\Eloquent\Model;

class Model3d extends Model
{
protected $table = '3d_models';
protected $fillable = [
'model_url',
'model_id',
'camera_position',
'camera_target',
'annotation_list',
'model_caption_title',
'model_caption',
'guided_tour',
'hide_annotation'
];
protected $casts = [
'camera_position' => 'array',
'camera_target' => 'array',
'annotation_list' => 'array',
];
}
6 changes: 6 additions & 0 deletions app/Models/Slide.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@ public function compareExperienceModal()
return $this->morphMany('App\Models\ExperienceImage', 'imagable')->where('imagable_repeater_name', 'compare_experience_modal');
}

public function model3d()
{
return $this->belongsTo('App\Models\Model3d', '3d_model_id');
}

public function getContentBundleAttribute()
{
return SlideResource::collection(collect([$this]))->toArray(request());
Expand All @@ -203,4 +208,5 @@ public function getAssetLibraryAttribute()
{
return $this->experience->assetLibrary;
}

}
17 changes: 17 additions & 0 deletions app/Repositories/ArtworkRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,31 @@
use App\Repositories\Behaviors\HandleFeaturedRelated;
use App\Models\Artwork;
use App\Repositories\Api\BaseApiRepository;
use App\Repositories\Behaviors\Handle3DModel;

class ArtworkRepository extends BaseApiRepository
{
use HandleFeaturedRelated;
use Handle3DModel;

public function __construct(Artwork $model)
{
$this->model = $model;
}

public function afterSave($object, $fields)
{
$this->handle3DModel($object, $fields);

parent::afterSave($object, $fields);
}

public function getFormFields($object)
{
$fields = parent::getFormFields($object);

$fields = $this->getFormFieldsFor3DModel($object, $fields);

return $fields;
}
}
Loading

0 comments on commit c09f5ef

Please sign in to comment.