[TikiWiki-commits] [Git][tikiwiki/tiki][master] [ENH][FIX] Trackers: Add password display option to Text Field

Benoit Grégoire (@benoitg) via TikiWiki-cvs <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <68926ce2b1a53_2cd5d5434916@gitlab-sidekiq-low-urgency-cpu-bound-v2-86c757c9d6-5xqd9.mail>

Benoit Grégoire pushed to branch master at Tiki Wiki CMS Groupware / Tiki


Commits:
8ce8badb by MAGENE Sem Joel at 2025-08-05T20:33:28+00:00
[ENH][FIX] Trackers: Add password display option to Text Field
---
* [ENH][FIX] Trackers: Add password display option to Text Field

See merge request tikiwiki/tiki!8165

- - - - -


3 changed files:

- lib/core/Search/ContentSource/TrackerItemSource.php
- lib/core/Tracker/Field/Text.php
- templates/tracker/edit_field.tpl


Changes:

=====================================
lib/core/Search/ContentSource/TrackerItemSource.php
=====================================
@@ -59,6 +59,17 @@ class Search_ContentSource_TrackerItemSource implements Search_ContentSource_Int
         $fieldPermissions = [];
 
         foreach (self::getIndexableHandlers($definition, $item) as $handler) {
+            if ($handler) {
+                $fieldType = $handler->getConfiguration('type');
+                if ($fieldType === 't') {
+                    $optionsJson = $handler->getConfiguration('options');
+                    $optionsArray = json_decode($optionsJson, true);
+                    if (is_array($optionsArray) && ! empty($optionsArray['is_password'])) {
+                        // This is a password field. Skip it. Do not index it.
+                        continue;
+                    }
+                }
+            }
             if ($this->indexer) {
                 $this->indexer->errorContext = 'Field ' . $handler->getConfiguration('fieldId') . ' / ' . $handler->getConfiguration('name');
             }


=====================================
lib/core/Tracker/Field/Text.php
=====================================
@@ -91,6 +91,16 @@ class Tracker_Field_Text extends \Tracker\Field\AbstractItemField implements \Tr
                             1 => tr('Yes'),
                         ],
                     ],
+                    'is_password' => [
+                        'name' => tr('Display as password'),
+                        'description' => tr('If enabled, the field will hide its value and provide a toggle to show it. The value will not be searchable.'),
+                        'filter' => 'int',
+                        'default' => 0,
+                        'options' => [
+                            0 => tr('No'),
+                            1 => tr('Yes'),
+                        ],
+                    ],
                 ],
             ],
         ];
@@ -105,11 +115,18 @@ class Tracker_Field_Text extends \Tracker\Field\AbstractItemField implements \Tr
 
     public function renderInput($context = [])
     {
+        if (! empty($this->trackerField->getOption('is_password'))) {
+            $value = $this->getValue();
+            return '<input type="password" name="' . $this->getHTMLFieldName() . '" value="' . htmlspecialchars($value) . '" class="form-control">';
+        }
         return $this->renderTemplate('trackerinput/text.tpl', $context);
     }
 
     public function renderInnerOutput($context = [])
     {
+        if (! empty($this->trackerField->getOption('is_password'))) {
+            return '******';
+        }
         $pre = '';
         $post = '';
 


=====================================
templates/tracker/edit_field.tpl
=====================================
@@ -326,3 +326,16 @@
     </div>
 </form>
 {/block}
+
+{jq}
+    const validationTypeDropdown = $('select[name="validation_type"]');
+    const isPasswordDropdown = $('select[name="option~is_password"]');
+
+    // Automatically set "Display as password" to "Yes" when the user 
+    // selects "Password" as the validation type.
+    validationTypeDropdown.on('change', function() {
+        if ($(this).val() === 'password') {
+            isPasswordDropdown.val('1');
+        }
+    });
+{/jq}
\ No newline at end of file



View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/8ce8badb96a3ba5568254ceccf2f5d08d2339f4e

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/8ce8badb96a3ba5568254ceccf2f5d08d2339f4e
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.