[TikiWiki-commits] [Git][tikiwiki/tiki][28.x] [BP][FIX] Trackers Rules: fix all the fields of a Tracker on which the Rules do not work
"Jonny Bradley \(@jonnybradley\) via TikiWiki-cvs" <[email protected]>
| Newsgroups | gmane.comp.cms.tiki.cvs |
|---|---|
| Message-ID | <68efcc9996eff_2c341e68485672@gitlab-sidekiq-low-urgency-cpu-bound-v2-59db778485-284tg.mail> |
Jonny Bradley pushed to branch 28.x at Tiki Wiki CMS Groupware / Tiki Commits: 6f143be8 by Jonny Bradley at 2025-10-15T16:25:46+00:00 [BP][FIX] Trackers Rules: fix all the fields of a Tracker on which the Rules do not work --- * [BP][FIX] Trackers Rules: fix all the fields of a Tracker on which the Rules do not work --- * [FIX] Trackers Rules: fix all the fields of a Tracker on which the Rules do not work --- * [FIX]Trackers Rules :fix all the fields of a Tracker on which the Rules do not work See merge request tikiwiki/tiki!7353 (cherry picked from commit 8786ba5b10235b51c272fd41d3efd9065097b78d) 63422970 [FIX]Trackers Rules :fix all the fields of a Tracker on which the Rules do not work Co-authored-by: Joel Mpunga <[email protected]> See merge request tikiwiki/tiki!8376 (cherry picked from commit 2750ffbb4fb9a9d29f6bd8557f76634d7d8624f4) c53f3b2f [FIX] Trackers Rules: fix all the fields of a Tracker on which the Rules do not work Co-authored-by: Joel Mpunga <[email protected]> See merge request tikiwiki/tiki!8787 - - - - - 9 changed files: - lib/core/Services/Tracker/Controller.php - lib/core/Tracker/Field/EmailFolder.php - lib/core/Tracker/Field/GeographicFeature.php - lib/core/Tracker/Rule/Rules.php - lib/vue/vuejslib.php - templates/trackerinput/autoincrement.tpl - templates/trackerinput/statictext.tpl - templates/trackeroutput/computed.tpl - templates/trackeroutput/usergroups.tpl Changes: ===================================== lib/core/Services/Tracker/Controller.php ===================================== @@ -1324,7 +1324,8 @@ class Services_Tracker_Controller } if ($prefs['tracker_field_rules'] === 'y') { - $js = TikiLib::lib('vuejs')->generateTrackerRulesJS($definition->getFields()); + $js = TikiLib::lib('vuejs')->generateTrackerRulesJS(fields: $definition->getFields(), isInEditContext: true); + //$js = TikiLib::lib('vuejs')->generateTrackerRulesJS($definition->getFields(), '', true); TikiLib::lib('header')->add_jq_onready($js); } ===================================== lib/core/Tracker/Field/EmailFolder.php ===================================== @@ -229,7 +229,11 @@ class Tracker_Field_EmailFolder extends Tracker_Field_Files implements \Tracker\ public function renderInput($context = []) { - return tr("Emails can be copied or moved here via the Webmail interface."); + $ins_id = $this->getInsertId(); + //This input is useful for facilitating the execution of rules + $hiddenInput = "<input type='hidden' name='$ins_id'>"; + $translatedText = tr("Emails can be copied or moved here via the Webmail interface."); + return $hiddenInput . $translatedText; } public function renderOutput($context = []) ===================================== lib/core/Tracker/Field/GeographicFeature.php ===================================== @@ -43,7 +43,11 @@ class Tracker_Field_GeographicFeature extends \Tracker\Field\AbstractItemField i public function renderInput($context = []) { - return tr('Feature cannot be set or modified through this interface.'); + $ins_id = $this->getInsertId(); + //This input is useful for facilitating the execution of rules + $hiddenInput = "<input type='hidden' name='$ins_id'>"; + $translatedText = tr("Feature cannot be set or modified through this interface."); + return $hiddenInput . $translatedText; } public function renderOutput($context = []) ===================================== lib/core/Tracker/Rule/Rules.php ===================================== @@ -39,7 +39,7 @@ class Rules * * @return string */ - public function getJavaScript(string $parentSelector, array $field): string + public function getJavaScript(string $parentSelector, array $field, $isInEditContext = false): string { global $prefs; @@ -70,8 +70,14 @@ class Rules $operator = ' || '; } + if ($isInEditContext) { + $selectorAttribute = 'name'; + } else { + $selectorAttribute = 'name^'; + } + foreach ($this->conditions->predicates as $predicate) { - $selector = '[name=\'' . $predicate->target_id . '\']' . $conditionQualifier; + $selector = "[$selectorAttribute='{$predicate->target_id}']$conditionQualifier"; $selectors[] = $selector; if ( in_array($field['type'], ['R', 'M']) || @@ -92,7 +98,8 @@ class Rules foreach ($this->actions->predicates as $predicate) { if ($predicate->operator_id !== 'NoOp') { - $targetSelector = "\$(\"[name='{$predicate->target_id}']\", $(this).closest(\"form\")).last()"; + $targetSelector = "\$(\"[{$selectorAttribute}='{$predicate->target_id}']\", \$(this).closest(\"form\")).last()"; + $actions[] = " if ($targetSelector.length === 0) { console.error('Tracker Rules: element $predicate->target_id not found'); return; }"; if (strpos($predicate->operator_id, 'Required') === false) { @@ -113,7 +120,7 @@ class Rules if ($this->else->predicates) { foreach ($this->else->predicates as $predicate) { if ($predicate->operator_id !== 'NoOp') { - $targetSelector = "\$(\"[name='{$predicate->target_id}']\", $(this).closest(\"form\")).last()"; + $targetSelector = "\$(\"[{$selectorAttribute}='{$predicate->target_id}']\", \$(this).closest(\"form\")).last()"; $else[] = " if ($targetSelector.length === 0) { console.error('Tracker Rules: element $predicate->target_id not found'); return; }"; if (strpos($predicate->operator_id, 'Required') === false) { ===================================== lib/vue/vuejslib.php ===================================== @@ -197,7 +197,7 @@ addScopedStyleIdentifier(vm, \"$scopedStyleIdentifier\"); return $appHtml; } - public function generateTrackerRulesJS($fields, $parentSelector = '.tracker-field-group:first') + public function generateTrackerRulesJS($fields, $parentSelector = '.tracker-field-group:first', $isInEditContext = false) { $js = ''; @@ -207,7 +207,7 @@ addScopedStyleIdentifier(vm, \"$scopedStyleIdentifier\"); foreach (array_filter($fields) as $field) { if (! empty($field['rules']) && $field['rules'] !== '{"conditions":null,"actions":null,"else":null}') { $rules = Tiki\Lib\core\Tracker\Rule\Rules::fromData($field['fieldId'], $field['rules']); - $js .= $rules->getJavaScript($parentSelector, $field); + $js .= $rules->getJavaScript($parentSelector, $field, $isInEditContext); } } ===================================== templates/trackerinput/autoincrement.tpl ===================================== @@ -1,3 +1,4 @@ +<input type="hidden" name="{$field.ins_id}"> {if !empty($item.itemId)} <div{if $field.options_map.prepend or $field.options_map.append} class="input-group"{/if}> {if !empty($field.options_map.prepend)} ===================================== templates/trackerinput/statictext.tpl ===================================== @@ -1,3 +1,4 @@ +<input type="hidden" name="{$field.ins_id}"> {if $field.options_array[0] eq 1 or $field.options_array[0] eq 2} {$field.value} {elseif $field.options_array[1] ne '' and $list_mode eq 'y'} ===================================== templates/trackeroutput/computed.tpl ===================================== @@ -1,3 +1,4 @@ +<input type="hidden" name="{$field.ins_id}"> {if $prefs.trackerfield_computed eq 'y'} {if isset($field.computedtype) and $field.computedtype eq 'duration'} {if !empty($field.value)} ===================================== templates/trackeroutput/usergroups.tpl ===================================== @@ -1,3 +1,4 @@ +<input type="hidden" name="{$field.ins_id}"> {foreach from=$field.groups item=val name=ix} <div> {$val|escape} View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/6f143be81f1ce997c2ea5ef1419d0c2b266c819a -- View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/6f143be81f1ce997c2ea5ef1419d0c2b266c819a You're receiving this email because of your account on gitlab.com. _______________________________________________ TikiWiki-cvs mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs