Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop-craft-4'
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewmenich committed Oct 1, 2024
2 parents 9ae0089 + d768fdb commit 21b6a6b
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 18 deletions.
7 changes: 7 additions & 0 deletions src/assetbundles/synchronizecpsection/dist/js/Synchronize.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,16 @@
fieldsToSync.push($(field).val());
})

var showsToSync = [];
var showsToSyncInputs = $('input[name="showsToSync[]"]:checked').each(function (index, field) {
showsToSync.push($(field).val());
})

var data = {
fieldsToSync: fieldsToSync,
showsToSync: showsToSync
};

Craft.sendActionRequest('POST', 'mediamanager/synchronize/synchronize-show-entries', {data: data})
.then((response) => {
if (response.data.success) {
Expand Down
11 changes: 5 additions & 6 deletions src/controllers/SynchronizeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,11 @@ public function actionSynchronizeShowEntries()
$validatedShows = [];
$request = Craft::$app->getRequest();

foreach( $shows as $show ) {

if( $show->apiKey && $show->name ) {

$show[ 'siteId' ] = json_decode( $show[ 'siteId' ] );
array_push( $validatedShows, $show );
$showsToSync = $request->getBodyParam('showsToSync', []);
foreach($shows as $show) {
if($show->apiKey && $show->name && (collect($showsToSync)->search($show->apiKey) !== false)) {
$show['siteId'] = json_decode($show['siteId']);
$validatedShows[] = $show;
}
}

Expand Down
7 changes: 4 additions & 3 deletions src/jobs/ShowEntriesSync.php
Original file line number Diff line number Diff line change
Expand Up @@ -371,10 +371,11 @@ private function getShowAvailability(string $attribute, $showEntry): int
continue;
}

$publicEndDate = new DateTime($asset->attributes->availabilities->public->end) ?? null;
$passportEndDate = new DateTime($asset->attributes->availabilities->all_members->end) ?? null;
$publicEndDate = $asset->attributes->availabilities->public->end ? new DateTime($asset->attributes->availabilities->public->end) : null;

$passportEndDate = $asset->attributes->availabilities->all_members->end ? new DateTime($asset->attributes->availabilities->all_members->end) : null;

if($publicEndDate instanceof DateTime){
if($publicEndDate instanceof DateTime){
$availableToPublic = DateTimeHelper::isInThePast($publicEndDate) ? 0 : 1;
}

Expand Down
2 changes: 1 addition & 1 deletion src/templates/show.twig
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<ul id="shows">
{% for show in shows %}
<li>
<a data-id="{{ show.id }}" href="{{ url( pluginCpUrl ) ~ '/shows/' ~ show.id }}" {% if activeShow | length and activeShow.id == show.id %}class="sel"{% endif %}>{{ show.name }}</a>
<a data-id="{{ show.id }}" href="{{ url( 'mediamanager/shows/' ~ show.id )}}" {% if activeShow | length and activeShow.id == show.id %}class="sel"{% endif %}>{{ show.name }}</a>
</li>
{% endfor %}
</ul>
Expand Down
25 changes: 17 additions & 8 deletions src/templates/synchronize.twig
Original file line number Diff line number Diff line change
Expand Up @@ -245,14 +245,23 @@
<label id="group-label" for="group">Synchronize Show Entries : {{ validatedShows }} valid show{{ validatedShows > 1 ? 's' : '' }} available to sync</label><br><br>
</div>

{% if validatedShows | length %}
<ol>
{% for show in shows %}
{% if show.apiKey %}
<li>{{ show.name }}</li>
{% endif %}
{% endfor %}
</ol><br/>
{% if validatedShows|length %}
{% set showsToSync = [] %}
{% for show in shows %}
{% if show.apiKey %}
{% set showsToSync = showsToSync|merge({(show.apiKey): show.name}) %}
{% endif %}
{% endfor %}

{{ forms.checkboxSelectField({
id: 'showsToSync',
name: 'showsToSync',
label: 'Shows to Sync',
showAllOption: true,
options: showsToSync,
values: '*',
instructions: 'Choose which shows you would like to be updated during this sync.',
}) }}
{% endif %}
</div>

Expand Down

0 comments on commit 21b6a6b

Please sign in to comment.