Skip to content

Commit

Permalink
fix(confition): hide garbage conditions
Browse files Browse the repository at this point in the history
Signed-off-by: Thierry Bugier <[email protected]>
  • Loading branch information
btry committed Aug 7, 2020
1 parent 397a912 commit 8810cd6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
13 changes: 8 additions & 5 deletions css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,9 @@ input[type = radio]:checked + label.label-radio .check {
font-style: italic;
margin: 0 4px;
}

/* CONDITIONS */

.div_show_condition_field, .div_show_condition_operator,
.div_show_condition_value, .div_show_condition_logic,
.div_show_condition_add, .div_show_condition_remove {
Expand Down Expand Up @@ -491,12 +494,12 @@ input[type = radio]:checked + label.label-radio .check {
width: 12px;
vertical-align: middle;
}
/* jQuery UI Combobox*/
.pq-select-multiple {
display: inline-block;
width: 85% !important;
tr[data-itemtype="PluginFormcreatorCondition"] .div_show_condition_logic {
visibility: hidden;
}
tr[data-itemtype="PluginFormcreatorCondition"] ~ tr[data-itemtype="PluginFormcreatorCondition"] .div_show_condition_logic {
visibility: visible;
}

.select2-container + select {
display: none !important;
}
Expand Down
6 changes: 5 additions & 1 deletion inc/condition.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public function export($remove_uuid = false) {
* get conditions applied to an item
*
* @param PluginFormcreatorConditionnableInterface $item
* @return array array of PluginFotrmcreatorCondition
* @return PluginFotrmcreatorCondition[]
*/
public function getConditionsFromItem(PluginFormcreatorConditionnableInterface $item) {
global $DB;
Expand Down Expand Up @@ -250,6 +250,10 @@ public function showConditionsForItem(CommonDBTM $item) {
echo '</td>';
echo '</tr>';

if ($item->fields['show_rule'] == PluginFormcreatorCondition::SHOW_RULE_ALWAYS) {
return;
}

// Get existing conditions for the item
$conditions = $this->getConditionsFromItem($item);
foreach ($conditions as $condition) {
Expand Down
4 changes: 1 addition & 3 deletions js/scripts.js.php
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,7 @@ function plugin_formcreator_toggleCondition(target) {
function plugin_formcreator_addEmptyCondition(target) {
var form = $(target).closest('form');
var itemtype = form.attr('data-itemtype');
// value if the hidden id input field
// value of the hidden id input field
var id = form.find('[name="id"]').val();
var parentKey;
var parentId;
Expand All @@ -834,13 +834,11 @@ function plugin_formcreator_addEmptyCondition(target) {
data: data
}).done(function (data) {
$(target).parents('tr').after(data);
$('.plugin_formcreator_logicRow .div_show_condition_logic').first().hide();
});
}

function plugin_formcreator_removeNextCondition(target) {
$(target).parents('tr').remove();
$('.plugin_formcreator_logicRow .div_show_condition_logic').first().hide();
}

function plugin_formcreator_changeDropdownItemtype(rand) {
Expand Down

0 comments on commit 8810cd6

Please sign in to comment.