Добавлены дополниельные поля
This commit is contained in:
parent
78a6d50b9a
commit
187dae5983
|
|
@ -75,6 +75,15 @@ class JsonController extends Controller
|
||||||
$point->images = $tmp;
|
$point->images = $tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$extraParams = $point->getExtraParams();
|
||||||
|
if (!empty($extraParams)) {
|
||||||
|
$tmp = array();
|
||||||
|
foreach ($extraParams as $extraParam) {
|
||||||
|
$tmp[] = array($extraParam->name, $extraParam->value);
|
||||||
|
}
|
||||||
|
$point->extraParams = $tmp;
|
||||||
|
}
|
||||||
|
|
||||||
$categories = Category::model()->getAll(array('order' => 'ord ASC', 'asArray' => true));
|
$categories = Category::model()->getAll(array('order' => 'ord ASC', 'asArray' => true));
|
||||||
|
|
||||||
$point->categoryIcon = $categories[$point->categoryId]['icon'];
|
$point->categoryIcon = $categories[$point->categoryId]['icon'];
|
||||||
|
|
@ -183,6 +192,25 @@ class JsonController extends Controller
|
||||||
$point->save();
|
$point->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ExtraParams::model()->delByPoint($id);
|
||||||
|
$params = isset($_POST['extraParamNames']) ? $_POST['extraParamNames'] : NULL;
|
||||||
|
$values = isset($_POST['extraParamValues']) ? $_POST['extraParamValues'] : NULL;
|
||||||
|
if ($params && $values) {
|
||||||
|
foreach ($params as $paramIndex => $param) {
|
||||||
|
$paramName = $param;
|
||||||
|
$paramValue = isset($values[$paramIndex]) ? $values[$paramIndex] : NULL;
|
||||||
|
|
||||||
|
if ($paramName && $paramValue) {
|
||||||
|
ExtraParams::model()->add(array(
|
||||||
|
'pointId' => $point->id,
|
||||||
|
'name' => $paramName,
|
||||||
|
'value' => $paramValue,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
App::redirect('/?point=' . $id);
|
App::redirect('/?point=' . $id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class ExtraParams extends Model
|
||||||
|
{
|
||||||
|
|
||||||
|
function __construct($fromArray = array())
|
||||||
|
{
|
||||||
|
$this->_tableName_ = 'extraParams';
|
||||||
|
parent::__construct($fromArray);
|
||||||
|
}
|
||||||
|
|
||||||
|
static function model()
|
||||||
|
{
|
||||||
|
return new self();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function delByPoint($pointId)
|
||||||
|
{
|
||||||
|
App::DB()->query('DELETE FROM `' . $this->_tableName_ . '` WHERE `pointId` = ' . $pointId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -106,4 +106,11 @@ class Point extends Model
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getExtraParams()
|
||||||
|
{
|
||||||
|
return ExtraParams::model()->getAll(array(
|
||||||
|
'where' => '`pointId` = '.$this->id,
|
||||||
|
'order' => '`id` ASC',
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,11 @@
|
||||||
</div>
|
</div>
|
||||||
<div id="imgsContainer">
|
<div id="imgsContainer">
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group extraImage asLink">
|
||||||
|
<label class="control-label" for="imgs">Дополнительные поля</label>
|
||||||
|
<span class="btn btn-sm add button" onclick="addNewExtraParam()" title="Добавить ещё одно изображение"><span class="glyphicon glyphicon-plus"></span> <span class="glyphicon glyphicon-bookmark"></span></span>
|
||||||
|
</div>
|
||||||
|
<div id="extraParamsContainer"></div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label" for="categoryId">Тип</label>
|
<label class="control-label" for="categoryId">Тип</label>
|
||||||
<select id="addPointCategoryId" name="categoryId" class="form-control">
|
<select id="addPointCategoryId" name="categoryId" class="form-control">
|
||||||
|
|
@ -71,6 +75,15 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="newExtraParam">
|
||||||
|
<div class="form-group extraParam" style="display: none;">
|
||||||
|
<div class="input-group">
|
||||||
|
<input type="text" name="extraParamNames[]" class="form-control names" placeholder="Название параметра (тел., сайт, ...)" />
|
||||||
|
<input type="text" name="extraParamValues[]" class="form-control values" placeholder="Значение параметра" />
|
||||||
|
<div class="input-group-addon remove button" onclick="removeInput($(this))" title="Удалить это поле"><span class="glyphicon glyphicon-trash"></span></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,13 @@ div.fotorama__caption div.fotorama__caption__wrap {padding: 0px 5px;}
|
||||||
#addPointModal .extraImage .type.button:hover {background-color: #ddd;}
|
#addPointModal .extraImage .type.button:hover {background-color: #ddd;}
|
||||||
#addPointModal .extraImage .input-group-addon.type.button {border-left: 0px;}
|
#addPointModal .extraImage .input-group-addon.type.button {border-left: 0px;}
|
||||||
|
|
||||||
|
#addPointModal .extraParam .button {cursor: pointer; background-color: #eeeeee;}
|
||||||
|
#addPointModal .extraParam .remove:hover {background-color: #f4bfbf;}
|
||||||
|
#addPointModal .extraParam .add:hover {background-color: #bff4c8;}
|
||||||
|
#addPointModal .extraParam .type.button:hover {background-color: #ddd;}
|
||||||
|
#addPointModal .extraParam .input-group-addon.type.button {border-left: 0px;}
|
||||||
|
#addPointModal .extraParam input.form-control {width: 50%}
|
||||||
|
|
||||||
div.leaflet-popup-content div.control {margin-top: 7px;}
|
div.leaflet-popup-content div.control {margin-top: 7px;}
|
||||||
div.leaflet-popup-content div.control a {min-width: 150px; color: #333; font-size: 14px; font-weight: normal;}
|
div.leaflet-popup-content div.control a {min-width: 150px; color: #333; font-size: 14px; font-weight: normal;}
|
||||||
div.leaflet-popup-content div.control a span.label {display: inline; font-size: 12px; font-weight: normal; color: #333;}
|
div.leaflet-popup-content div.control a span.label {display: inline; font-size: 12px; font-weight: normal; color: #333;}
|
||||||
|
|
|
||||||
|
|
@ -399,6 +399,14 @@ function editPoint(id)
|
||||||
addNewImage(pointsSources[id].img);
|
addNewImage(pointsSources[id].img);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pointsSources[id].extraParams != undefined)
|
||||||
|
{
|
||||||
|
for( var paramKey in pointsSources[id].extraParams )
|
||||||
|
{
|
||||||
|
addNewExtraParam(pointsSources[id].extraParams[paramKey][0], pointsSources[id].extraParams[paramKey][1])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
closePopup();
|
closePopup();
|
||||||
$('#addPointModal').modal('show');
|
$('#addPointModal').modal('show');
|
||||||
setStatus(statusEdit);
|
setStatus(statusEdit);
|
||||||
|
|
|
||||||
|
|
@ -369,6 +369,19 @@ function addNewImage(link)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addNewExtraParam(name, value)
|
||||||
|
{
|
||||||
|
if ($('.extraParam', '#addPointForm').length < 10)
|
||||||
|
{
|
||||||
|
$('.extraParam', '#newExtraParam').clone().appendTo('#extraParamsContainer').show(200);
|
||||||
|
if (name != undefined && value != undefined)
|
||||||
|
{
|
||||||
|
$('.form-control.names', '#addPointForm').last().val(name);
|
||||||
|
$('.form-control.values', '#addPointForm').last().val(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function removeInput(el)
|
function removeInput(el)
|
||||||
{
|
{
|
||||||
container = $(el).parent().parent();
|
container = $(el).parent().parent();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue