Commit 44f09957 authored by Shakarim Sapa's avatar Shakarim Sapa

- Добавлены комменты к некотрым частям кода

- Добавлена кнопка удаления условия "И"
- Добавлено событие на кнопку удаления условия "И" в js-скрипте
parent dd741cfc
...@@ -30,3 +30,7 @@ $(document).on('click', 'button.add-and-condition', function() { ...@@ -30,3 +30,7 @@ $(document).on('click', 'button.add-and-condition', function() {
} }
}) })
}); });
$(document).on('click', '.delete_row', function() {
$(this).closest('tr').remove();
});
...@@ -117,7 +117,9 @@ class Conditions { ...@@ -117,7 +117,9 @@ class Conditions {
* @return string * @return string
*/ */
public static function getControlButtons($condition_array=array(), $key=null){ public static function getControlButtons($condition_array=array(), $key=null){
// Сгенерировали случайный ключ (для массива в форме)
$key = ($key!==null) ? $key : rand(100000,999999); $key = ($key!==null) ? $key : rand(100000,999999);
// Сформировали и вернули новую строку в таблице
return '<tr data-key='.$key.'><td>'.Conditions::init()->getControlArea($condition_array, $key).'</td></tr>'; return '<tr data-key='.$key.'><td>'.Conditions::init()->getControlArea($condition_array, $key).'</td></tr>';
} }
...@@ -139,6 +141,7 @@ class Conditions { ...@@ -139,6 +141,7 @@ class Conditions {
$html .= '<ul class="dropdown-menu">'; $html .= '<ul class="dropdown-menu">';
foreach(Conditions::init()->getConditions() as $id=>$condition) foreach(Conditions::init()->getConditions() as $id=>$condition)
$html .= '<li><a href="#" data-id="'.$id.'" class="add_condition">'.$condition->getName().'</a></li>'; $html .= '<li><a href="#" data-id="'.$id.'" class="add_condition">'.$condition->getName().'</a></li>';
$html .= '<li><a href="#" class="delete_row" style="color: darkred;">Удалить условия</a></li>';
$html .= '</ul>'; $html .= '</ul>';
$html .= '</div>'; $html .= '</div>';
return $html; return $html;
......
...@@ -92,10 +92,12 @@ class TriggerTrigger extends \common\components\ActiveRecordModel ...@@ -92,10 +92,12 @@ class TriggerTrigger extends \common\components\ActiveRecordModel
} }
// Тут добавляем кнопки управления // Тут добавляем кнопки управления
if (count($this->conditions)>0) { if (count($this->conditions)>0) {
// Условие если эта форма уже содержит параметры
foreach($this->conditions as $condition_array) { foreach($this->conditions as $condition_array) {
$table .= Conditions::getControlButtons($condition_array); $table .= Conditions::getControlButtons($condition_array);
} }
} else } else
// И если это новая форма, еще пустая
$table .= Conditions::getControlButtons(); $table .= Conditions::getControlButtons();
$table .= '</tbody>'; $table .= '</tbody>';
// Формируем футер // Формируем футер
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment