ADD редактирование путевых точек
This commit is contained in:
parent
c7a52b19d1
commit
97482ffc15
|
|
@ -47,4 +47,67 @@ class EdittrackController extends Controller
|
||||||
$trip->json = '';
|
$trip->json = '';
|
||||||
$trip->save();
|
$trip->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function actionDeletetrack()
|
||||||
|
{
|
||||||
|
$id = intval(App::getParam('id'));
|
||||||
|
|
||||||
|
$track = Tracks::model()->getByPK($id);
|
||||||
|
if ($track->isEmpty()) {
|
||||||
|
App::error404();
|
||||||
|
}
|
||||||
|
|
||||||
|
$trip = Trips::model()->getByPK($track->tripId);
|
||||||
|
if ($trip->isEmpty() || $trip->owner != App::$user->id) {
|
||||||
|
App::error404();
|
||||||
|
}
|
||||||
|
|
||||||
|
$track->delete($id);
|
||||||
|
|
||||||
|
$trip->json = '';
|
||||||
|
$trip->save();
|
||||||
|
|
||||||
|
App::redirect('/tracks/edit/id/'.$trip->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
function actionWaypoint()
|
||||||
|
{
|
||||||
|
$id = intval(App::getParam('id'));
|
||||||
|
|
||||||
|
$waypoint = WayPoints::model()->getByPK($id);
|
||||||
|
if (empty($_POST['name']) || $waypoint->isEmpty()) {
|
||||||
|
App::error404();
|
||||||
|
}
|
||||||
|
|
||||||
|
$trip = Trips::model()->getByPK($waypoint->tripId);
|
||||||
|
if ($trip->isEmpty() || $trip->owner != App::$user->id) {
|
||||||
|
App::error404();
|
||||||
|
}
|
||||||
|
|
||||||
|
$waypoint->name = trim($_POST['name']);
|
||||||
|
$waypoint->description = trim($_POST['description']);
|
||||||
|
$waypoint->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
function actionDeletewaypoint()
|
||||||
|
{
|
||||||
|
$id = intval(App::getParam('id'));
|
||||||
|
|
||||||
|
$waypoint = WayPoints::model()->getByPK($id);
|
||||||
|
if ($waypoint->isEmpty()) {
|
||||||
|
App::error404();
|
||||||
|
}
|
||||||
|
|
||||||
|
$trip = Trips::model()->getByPK($waypoint->tripId);
|
||||||
|
if ($trip->isEmpty() || $trip->owner != App::$user->id) {
|
||||||
|
App::error404();
|
||||||
|
}
|
||||||
|
|
||||||
|
$waypoint->delete($id);
|
||||||
|
|
||||||
|
$trip->json = '';
|
||||||
|
$trip->save();
|
||||||
|
|
||||||
|
App::redirect('/tracks/edit/id/'.$trip->id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -718,17 +718,17 @@ class JsonController extends Controller
|
||||||
|
|
||||||
$distance1 = Geo::distance($prevPoint, array('lat' => $trackPoint->lat, 'lng' => $trackPoint->lng));
|
$distance1 = Geo::distance($prevPoint, array('lat' => $trackPoint->lat, 'lng' => $trackPoint->lng));
|
||||||
|
|
||||||
if ($distance1 < 100) {
|
if ($distance1 < 30) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$distance2 = Geo::distance($nextPoint, array('lat' => $trackPoint->lat, 'lng' => $trackPoint->lng));
|
// $distance2 = Geo::distance($nextPoint, array('lat' => $trackPoint->lat, 'lng' => $trackPoint->lng));
|
||||||
$distance3 = Geo::distance($prevPoint, $nextPoint);
|
// $distance3 = Geo::distance($prevPoint, $nextPoint);
|
||||||
|
//
|
||||||
|
//
|
||||||
if (($distance3 / ($distance1+$distance2)) > 0.982) {
|
// if (($distance3 / ($distance1+$distance2)) > 0.982) {
|
||||||
continue;
|
// continue;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
$prevPoint = $trackPoints[$index];
|
$prevPoint = $trackPoints[$index];
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,7 @@ class TracksController extends Controller
|
||||||
self::render('/tracks/edit.php', array(
|
self::render('/tracks/edit.php', array(
|
||||||
'trip' => $trip,
|
'trip' => $trip,
|
||||||
'tracks' => Tracks::model()->getAll(array('where' => '`tripId` = ' . $trip->id)),
|
'tracks' => Tracks::model()->getAll(array('where' => '`tripId` = ' . $trip->id)),
|
||||||
|
'waypoints' => WayPoints::model()->getAll(array('where' => '`tripId` = ' . $trip->id)),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ class Trips extends Model
|
||||||
return new self();
|
return new self();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDistance()
|
function distance()
|
||||||
{
|
{
|
||||||
return Geo::formatedDistance($this->distance);
|
return Geo::formatedDistance($this->distance);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,7 @@ if (App::$user) {
|
||||||
<div style="border-bottom: solid 1px #CCC">
|
<div style="border-bottom: solid 1px #CCC">
|
||||||
<input type="checkbox" id="trackShowHide<?= $track->id ?>" onchange="showHideTrack(<?= $track->id ?>)" />
|
<input type="checkbox" id="trackShowHide<?= $track->id ?>" onchange="showHideTrack(<?= $track->id ?>)" />
|
||||||
<?= $track->name ?>
|
<?= $track->name ?>
|
||||||
<b><?= $track->getDistance(); ?></b>
|
<b><?= $track->distance(); ?></b>
|
||||||
<?php if($track->status == Trips::STATUS_PUBLIC):?>
|
<?php if($track->status == Trips::STATUS_PUBLIC):?>
|
||||||
<a href="/?track=<?= $track->id ?>" title="Ссылка на трек. <?="\n"?>[клик правой кнопкой -> копировать адрес]">
|
<a href="/?track=<?= $track->id ?>" title="Ссылка на трек. <?="\n"?>[клик правой кнопкой -> копировать адрес]">
|
||||||
<span class="glyphicon glyphicon-link" aria-hidden="true"></span>
|
<span class="glyphicon glyphicon-link" aria-hidden="true"></span>
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,8 @@
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<?php if ($tracks): ?>
|
<?php if ($tracks): ?>
|
||||||
<h3 onclick="$('#tracksBlock').toggle()" style="cursor: pointer;">Фрагменты трека</h3>
|
<h3 onclick="$('#tracksBlock').toggle()" style="cursor: pointer;">Фрагменты трека (<?= count($tracks) ?>)</h3>
|
||||||
<div id="tracksBlock" style="">
|
<div id="tracksBlock" style="display: none;">
|
||||||
<!--<hr/>-->
|
<!--<hr/>-->
|
||||||
<?php foreach ($tracks as $track): ?>
|
<?php foreach ($tracks as $track): ?>
|
||||||
<form onfocusout="saveChangesTrack(<?= $track->id ?>)" class="form-horizontal">
|
<form onfocusout="saveChangesTrack(<?= $track->id ?>)" class="form-horizontal">
|
||||||
|
|
@ -51,6 +51,32 @@
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
<span id="trackSavedOK" style="color: #999; display: none;">изменения сохранены...</span>
|
<span id="trackSavedOK" style="color: #999; display: none;">изменения сохранены...</span>
|
||||||
<span id="trackSavedError" style="color: #900; display: none;">при сохранении возникла ошибка!</span>
|
<span id="trackSavedError" style="color: #900; display: none;">при сохранении возникла ошибка!</span>
|
||||||
|
<br/>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<?php if ($waypoints): ?>
|
||||||
|
<h3 onclick="$('#waypointsBlock').toggle()" style="cursor: pointer;">Путевые точки (<?= count($waypoints) ?>)</h3>
|
||||||
|
<div id="waypointsBlock" style="display: none;">
|
||||||
|
<!--<hr/>-->
|
||||||
|
<?php foreach ($waypoints as $waypoint): ?>
|
||||||
|
<form onfocusout="saveChangesWaypoint(<?= $waypoint->id ?>)" class="form-horizontal">
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-sm-3">
|
||||||
|
<input type="text" class="form-control" id="waypointName<?= $waypoint->id ?>" placeholder="А здесь..." value="<?= $waypoint->name ?>">
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input type="text" class="form-control" id="waypointDescription<?= $waypoint->id ?>" placeholder="Здесь очень..." value="<?= $waypoint->description ?>">
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-1">
|
||||||
|
<a href="/edittrack/deletewaypoint/id/<?= $waypoint->id ?>" class="btn btn-danger" onclick="return confirm('Вы уверены, что хотите удалить путевую точку?')"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<!--<hr/>-->
|
||||||
|
<?php endforeach; ?>
|
||||||
|
<span id="waypointSavedOK" style="color: #999; display: none;">изменения сохранены...</span>
|
||||||
|
<span id="waypointSavedError" style="color: #900; display: none;">при сохранении возникла ошибка!</span>
|
||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
|
|
@ -103,4 +129,28 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function saveChangesWaypoint(id)
|
||||||
|
{
|
||||||
|
$('#waypointSavedOK').hide();
|
||||||
|
$('#waypointSavedError').hide();
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: "/edittrack/waypoint/id/" + id,
|
||||||
|
method: "POST",
|
||||||
|
data: {
|
||||||
|
name: $('#waypointName' + id).val(),
|
||||||
|
description: $('#waypointDescription' + id).val()
|
||||||
|
},
|
||||||
|
success: function (data) {
|
||||||
|
$('#waypointSavedOK').show();
|
||||||
|
setTimeout(function () {
|
||||||
|
$('#waypointSavedOK').fadeOut(300);
|
||||||
|
}, 2000);
|
||||||
|
},
|
||||||
|
error: function (data) {
|
||||||
|
$('#waypointSavedError').show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue