Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tushargugnani committed Jan 27, 2023
1 parent 555016a commit f082b92
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
11 changes: 10 additions & 1 deletion resources/dist/js/smart-banner.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,16 @@ fetch('/smart-banner-auto-placements')
if(placement.selector){
var adSelector = document.querySelector(placement.selector);
if(adSelector){
let adBody = "<div class=\"smart-banner-temp\" banner-slug=\""+ad.slug+"\">"+ad.body+"</div>"
let adBody = '';
if(ad.adType == 'HTML'){
adBody = "<div class=\"smart-banner-temp\" banner-slug=\""+ad.slug+"\">"+ad.body+"</div>"
}else if(ad.adType == 'IMAGE'){
adBody = "<div class=\"smart-banner-temp\" banner-slug=\""+ad.slug+"\">\
<a href=\""+ad.imageUrl+"\" target=\"_blank\">\
<img src=\""+ad.image+"\" alt=\""+ad.imageAlt+"\" />\
</a>\
</div>"
}
adSelector.insertAdjacentHTML(placement.position, adBody);
}
}
Expand Down
17 changes: 12 additions & 5 deletions resources/views/smart-ad-manager/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,19 @@ class="block w-full mt-1 text-sm dark:border-gray-600 dark:bg-gray-700 focus:bor

<div x-data="{
placements: [
@foreach(json_decode($smartAd->placements) as $placement)
{
position: '{{$placement->position}}',
selector: '{{$placement->selector}}'
},
@isset($smartAd->placements)
@foreach(json_decode($smartAd->placements) as $placement)
{
position: '{{$placement->position}}',
selector: '{{$placement->selector}}'
},
@endforeach
@else
{
position: '',
selector: ''
}
@endisset
],
addNewPlacement() {
this.placements.push({
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Controllers/SmartAdManagerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function store(StoreSmartAdRequest $request){
'image' => isset($imagePath) ? $imagePath : null,
'imageUrl' => $request->imageUrl,
'imageAlt' => $request->imageAlt,
'placements' => $request->placements,
'placements' => !empty(json_decode($request->placements)[0]->selector) ? $request->placements : null,
]);
return redirect("/smart-ad-manager/ads/{$smartAd->id}")->with(['message' => 'Ad Created', 'color' => 'green']);
}
Expand Down

0 comments on commit f082b92

Please sign in to comment.