Merge pull request #442 from openclassify/dia

#1011 Ad post preview page
This commit is contained in:
Fatih Alp 2020-03-24 12:49:47 +03:00 committed by GitHub
commit dcab7cedaf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 254 additions and 84 deletions

View File

@ -0,0 +1,63 @@
.preview-wrapper {
border: 4px solid #999;
}
.preview-wrapper:before, .preview-wrapper:after {
content: '';
position: absolute;
left: 50%;
top: -30px;
width: 0;
height: 0;
border-style: solid;
border-width: 0 39px 30px 39px;
border-color: transparent transparent #999 transparent;
margin-left: -39px;
}
.preview-wrapper:after {
top: inherit;
bottom: -30px;
border-width: 30px 39px 0 39px;
border-color: #999 transparent transparent transparent;
}
.preview-overlay {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
opacity: .07;
background-color: #000;
z-index: 400;
}
.preview-paragraph {
font-size: 15px;
font-weight: bold;
text-align: center;
}
.preview-actions {
margin-top: 3em;
margin-bottom: 4em;
}
.preview-edit {
color: #438ed8;
background: #f7f7f7;
border: 1px solid #f7f7f7;
}
.preview-edit:hover {
background: #eaeaea;
border-color: #eaeaea;
color: #438ed8;
}
.preview-continue {
border-radius: 2px;
color: #fff;
background: #438ed8;
}
.preview-continue:hover {
background: #3c7fc1;
border-color: #3c7fc1;
color: #fff;
}
#compare-sidebar, .dropleft-edit {
display: none;
}

View File

@ -13,6 +13,7 @@ return [
'decline' => 'Decline',
'extend' => 'Extend',
'extend_all' => 'Extend All',
'convert_currency' => 'Convert Currency',
'categories' => 'Categories',
'sub_category' => 'Sub Categories',
'add_sub_category' => 'Add Sub Category',

View File

@ -270,5 +270,11 @@ return [
'pending_message_3' => 'Estimated Waiting Time',
'pending_message_4' => 'The time spent in the approval process will be added to the doping time.',
'pending_message_5' => 'No transactions can be made from the call center regarding the ad in the approval process.',
'hours' => 'hours'
'hours' => 'hours',
// Preview page
'preview_text' => [
'part_1' => 'If the following information about your ad is correct, click the "Continue" button and go to the next step.',
'part_2' => 'If not, click the "Edit" button.',
]
];

View File

@ -28,4 +28,5 @@ return [
'pending_ad_status' => 'Your ad is pending approval by the Editor.',
'extended' => ':number ad(s) has been extended successfully.',
'category_not_exist' => 'This category does not exist anymore!',
'currency_converted' => 'Currency Converted Successfully.',
];

View File

@ -12,7 +12,7 @@
</a>
</li>
{{ addBlock('ads-list/partials/breadcrumb',{'mainCats':mainCats})|raw }}
{{ addBlock('ads-list/partials/breadcrumb',{'mainCats': mainCats, 'category': categoryId})|raw }}
</ol>
</nav>

View File

@ -0,0 +1,33 @@
{% if setting_value('visiosoft.theme.base::breadcrumbs') %}
<!-- breadcrumb -->
{% include "visiosoft.module.advs::ad-detail/partials/breadcrumb" %}
<!-- breadcrumb -->
{% endif %}
<h2 class="title">
{{ adv.title }}
{{ addBlock('ad-detail/title/action',{'adv_id':adv.id})|raw }}
</h2>
<!--detail-ad -->
<div class="section slider mb-4">
<div class="row">
{% include "visiosoft.module.advs::ad-detail/partials/slider" %}
<div class="col-md-5">
{% if setting_value('visiosoft.theme.base::ad_details') %}
{% include "visiosoft.module.advs::ad-detail/partials/detail" %}
{% endif %}
</div>
</div>
</div>
<!--detail-ad -->
{% if setting_value('visiosoft.theme.base::ad_details_tab') %}
{% if blocks('ad-item-content-block-area') is null %}
{% include "visiosoft.module.advs::ad-detail/partials/content" %}
{% else %}
{{ blocks('ad-item-content-block-area') }}
{% endif %}
{{ addBlock('ad-detail/widget', {'price': adv.price, 'id': adv.id})|raw }}
{% endif %}

View File

@ -0,0 +1,41 @@
{% extends "theme::layouts/default" %}
{% block content %}
<div class="pt-5">
<p class="preview-paragraph">
{{ trans('visiosoft.module.advs::field.preview_text.part_1') }}
<br>
{{ trans('visiosoft.module.advs::field.preview_text.part_2') }}
</p>
</div>
<div class="preview-actions text-center">
{% if isActiveDopings %}
{% set continueLink = url_route('add_doping', [adv.id]) %}
{% else %}
{% set continueLink = url_route('visiosoft.module.advs::edit_adv', [adv.id]) %}
{% endif %}
<a href="{{ url_route('visiosoft.module.advs::edit_adv', [adv.id]) }}"
class="btn preview-edit shadow-sm border">
{{ trans('visiosoft.module.advs::field.edit') }}
</a>
<a href="{{ continueLink }}" class="btn preview-continue shadow-sm ml-4">
{{ trans('visiosoft.module.advs::field.continue') }}
</a>
</div>
<div class="preview-wrapper position-relative">
{% include "visiosoft.module.advs::new-ad/preview/partials/preview-window" %}
<div class="preview-overlay position-absolute"></div>
</div>
<div class="preview-actions text-center">
<a href="{{ url_route('visiosoft.module.advs::edit_adv', [adv.id]) }}" class="btn preview-edit shadow-sm border">
{{ trans('visiosoft.module.advs::field.edit') }}
</a>
<a href="{{ continueLink }}" class="btn preview-continue shadow-sm ml-4">
{{ trans('visiosoft.module.advs::field.continue') }}
</a>
</div>
{{ asset_add("styles.css", "visiosoft.module.advs::css/detail.css") }}
{{ asset_add("styles.css", "visiosoft.module.advs::css/preview.css") }}
{% endblock %}

View File

@ -116,9 +116,9 @@ class AdvModel extends AdvsAdvsEntryModel implements AdvInterface
->where('advs_advs.finish_at', '>', date('Y-m-d H:i:s'));
}
public function foreignCurrency($currency, $price, $curencies, $isUpdate, $settings)
public function foreignCurrency($currency, $price, $isUpdate, $settings)
{
$currencies = explode(',', $curencies);
$currencies = setting_value('visiosoft.module.advs::enabled_currencies');
$foreign_currency = array();
$client = new Client();
@ -128,18 +128,19 @@ class AdvModel extends AdvsAdvsEntryModel implements AdvInterface
$foreign_currency[$currency] = (int)$price;
} else {
try {
$url = $currency . "_" . $currencyIn;
$freecurrencykey = $settings->value('visiosoft.module.advs::free_currencyconverterapi_key');
$response = $client->get('http://free.currencyconverterapi.com/api/v6/convert?q=' . $url . '&compact=y&apiKey=' . $freecurrencykey);
} catch (RequestException $e) {
if ($e->getResponse()->getStatusCode() == '200') {
$response = \GuzzleHttp\json_decode($e->getResponse()->getBody()->getContents());
$rate = $response->$url->val;
$foreign_currency[$currencyIn] = $price * $rate;
$freeCurrencyKey = $settings->value('visiosoft.module.advs::free_currencyconverterapi_key');
$response = $client->get('http://free.currencyconverterapi.com/api/v6/convert?q='
. $url . '&compact=y&apiKey=' . $freeCurrencyKey);
if ($response->getStatusCode() == '200') {
$response = (array)\GuzzleHttp\json_decode($response->getBody()->getContents());
if (!empty($response)) {
$rate = $response[$url]->val;
$foreign_currency[$currencyIn] = $price * $rate;
}
}
} catch (RequestException $e) {
$this->messages->error($e->getMessage());
}
}
}
@ -150,7 +151,6 @@ class AdvModel extends AdvsAdvsEntryModel implements AdvInterface
}
$adv->foreign_currencies = json_encode($foreign_currency);
$adv->save();
}
public function popularAdvs()

View File

@ -77,6 +77,10 @@ class AdvTableBuilder extends TableBuilder
'handler' => \Visiosoft\AdvsModule\Adv\Table\Handler\Extend::class,
'class' => 'btn btn-info'
],
'convert_currency' => [
'handler' => \Visiosoft\AdvsModule\Adv\Table\Handler\ConvertCurrency::class,
'class' => 'btn btn-warning'
],
];
/**

View File

@ -0,0 +1,22 @@
<?php namespace Visiosoft\AdvsModule\Adv\Table\Handler;
use Anomaly\SettingsModule\Setting\Contract\SettingRepositoryInterface;
use Anomaly\Streams\Platform\Ui\Table\Component\Action\ActionHandler;
use Visiosoft\AdvsModule\Adv\Table\AdvTableBuilder;
class ConvertCurrency extends ActionHandler
{
public function handle(AdvTableBuilder $builder, array $selected, SettingRepositoryInterface $settingRepository)
{
$model = $builder->getTableModel();
foreach ($selected as $id) {
$entry = $model->newQuery()->find($id);
$model->foreignCurrency($entry->currency, $entry->price, $id, $settingRepository);
}
if ($selected) {
$this->messages->success(trans('visiosoft.module.advs::message.currency_converted'));
}
}
}

View File

@ -125,6 +125,10 @@ class AdvsModuleServiceProvider extends AddonServiceProvider
'as' => 'adv_detail_seo',
'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@view'
],
'advs/preview/{id}' => [
'as' => 'advs_preview',
'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@preview'
],
'advs/map?country={country}&city[]={city}&district={districts}' => [
'as' => 'visiosoft.module.advs::show_ad_map_location',
'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@map'
@ -151,7 +155,10 @@ class AdvsModuleServiceProvider extends AddonServiceProvider
],
'advs/my_advs' => 'Visiosoft\AdvsModule\Http\Controller\advsController@myAdvs',
'advs/my_advs/{params}' => 'Visiosoft\AdvsModule\Http\Controller\advsController@myAdvs',
'advs/edit_advs/{id}' => 'Visiosoft\AdvsModule\Http\Controller\advsController@edit',
'advs/edit_advs/{id}' => [
'as' => 'visiosoft.module.advs::edit_adv',
'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@edit',
],
'advs/status/{id},{type}' => [
'as' => 'visiosoft.module.advs::status',
'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@statusAds'

View File

@ -387,6 +387,38 @@ class AdvsController extends PublicController
}
public function preview($id)
{
$categories = array();
$categories_id = array();
$adv = $this->adv_repository->getListItemAdv($id);
for ($i = 1; $i <= 10; $i++) {
$cat = "cat" . $i;
if ($adv->$cat != null) {
$item = $this->category_repository->getItem($adv->$cat);
if (!is_null($item)) {
$categories['cat' . $i] = [
'name' => $item->name,
'id' => $item->id
];
$categories_id[] = $item->id;
}
}
}
if ($this->adv_model->is_enabled('customfields')) {
$features = app('Visiosoft\CustomfieldsModule\Http\Controller\cfController')->view($adv);
}
$isActiveDopings = $this->adv_model->is_enabled('dopings');
return $this->view->make('visiosoft.module.advs::new-ad/preview/preview',
compact('adv', 'categories', 'features', 'isActiveDopings'));
}
public function getLocations()
{
$table = $this->requestHttp->table;
@ -581,20 +613,20 @@ class AdvsController extends PublicController
return redirect('/advs/edit_advs/' . $request->update_id)->with('cats_d', $cats_d)->with('request', $request);
}
$foreign_currencies = new AdvModel();
$isUpdate = $request->update_id;
$foreign_currencies->foreignCurrency($request->currency, $request->price, $request->currencies, $isUpdate, $settings);
if ($adv->slug == "") {
$events->dispatch(new CreateAd($request->update_id, $settings));//Create Notify
} else {
$events->dispatch(new EditAd($request->update_id, $settings, $adv));//Update Notify
}
if ($isActiveDopings) {
return redirect(route('add_doping', [$request->update_id]));
if ($adv->slug == "") { // Only preview when new
return redirect(route('advs_preview', [$request->update_id]));
} else {
return redirect('/advs/adv/' . $request->update_id);
if ($isActiveDopings) {
return redirect(route('add_doping', [$request->update_id]));
} else {
return redirect('/advs/adv/' . $request->update_id);
}
}
}

View File

@ -1,9 +1,4 @@
{% set catSlug = null %}
{% set pathInfo = app.request.pathinfo|split('/') %}
{% if pathInfo[1] == 'c' %}
{% set catSlug = pathInfo[2] %}
{% endif %}
{% if catSlug %}
{% if params.category %}
{% for category_breadcrumbs in params.mainCats %}
<li class="breadcrumb-item">
<a href="{{ url_route('visiosoft.module.advs::list_cat', [category_breadcrumbs['id']]) }}"

View File

@ -2,9 +2,4 @@
background-color: #343a40 !important;
border-color: #343a40 #343a40 #343a40;
color: white!important;
}
/* Hide profile upload table */
.selected.file-rows-table table td:first-child ~ td {
display: none;
}

View File

@ -1,15 +1,18 @@
<?php namespace Visiosoft\ProfileModule\Http\Controller;
use Anomaly\Streams\Platform\Http\Controller\PublicController;
use Anomaly\UsersModule\User\Contract\UserRepositoryInterface;
use Illuminate\Http\Request;
use Visiosoft\AddblockExtension\Command\addBlock;
class CacheController extends PublicController
{
public function getUserInfo(Request $request, UserRepositoryInterface $userRepository)
public function getUserInfo()
{
$user = $userRepository->find($request->userId);
$user = auth()->user();
$user = $user ? $user->first_name . ' ' . $user->last_name : $user;
return ['userName' => $user->first_name . ' ' . $user->last_name];
$getAddBlockHtml = new addBlock('navigation/dropdown', []);
$addBlockHtml = $getAddBlockHtml->handle();
return ['userName' => $user, 'addBlockHtml' => $addBlockHtml];
}
}

View File

@ -26,6 +26,8 @@ class ProfileFormHandler
if ($builder->getPostValue('file') != null) {
$parameters['file_id'] = $builder->getPostValue('file');
} elseif (empty($builder->getPostValue('file'))) {
$parameters['file_id'] = null;
}
$userModel->newQuery()->where('id', Auth::id())->update($parameters);

View File

@ -5,6 +5,10 @@
table {
tr {
td {
a, a:hover {
color: #fff;
}
padding: 9px 0;
border-top: none;
border-bottom: none;

View File

@ -33,6 +33,7 @@
progress {
margin-bottom: 0.25em;
width: 100%;
}
.progress-upload {
@ -48,3 +49,7 @@
}
}
}
.btn-success {
color: #fff !important;
}

View File

@ -17,7 +17,7 @@
{% include "visiosoft.field_type.singlefile::upload/partials/body" %}
{% include "visiosoft.field_type.singlefile::upload/partials/template" %}
<div class="uploaded">
<div class="uploaded px-3">
{{ table.content|raw }}
</div>

View File

@ -51,28 +51,6 @@ class UploadTableBuilder extends TableBuilder
'entry.preview' => [
'heading' => 'anomaly.module.files::field.preview.name',
],
'name' => [
'sort_column' => 'name',
'wrapper' => '
<strong>{value.file}</strong>
<br>
<small class="text-muted">{value.disk}://{value.folder}/{value.file}</small>
<br>
<span>{value.size} {value.keywords}</span>',
'value' => [
'file' => 'entry.name',
'folder' => 'entry.folder.slug',
'keywords' => 'entry.keywords.labels|join',
'disk' => 'entry.folder.disk.slug',
'size' => 'entry.size_label',
],
],
'size' => [
'sort_column' => 'size',
'value' => 'entry.readable_size',
],
'mime_type',
'folder',
];
/**

View File

@ -37,28 +37,6 @@ class ValueTableBuilder extends TableBuilder
'entry.preview' => [
'heading' => 'anomaly.module.files::field.preview.name',
],
'name' => [
'sort_column' => 'name',
'wrapper' => '
<strong>{value.file}</strong>
<br>
<small class="text-muted">{value.disk}://{value.folder}/{value.file}</small>
<br>
<span>{value.size} {value.keywords}</span>',
'value' => [
'file' => 'entry.name',
'folder' => 'entry.folder.slug',
'keywords' => 'entry.keywords.labels|join',
'disk' => 'entry.folder.disk.slug',
'size' => 'entry.size_label',
],
],
'size' => [
'sort_column' => 'size',
'value' => 'entry.readable_size',
],
'mime_type',
'folder',
];
/**