Skip to content

Commit

Permalink
Render request and resolution times in matchgrid record view (NOJIRA)
Browse files Browse the repository at this point in the history
  • Loading branch information
Benn Oshrin committed Aug 5, 2022
1 parent 2417df4 commit 5f89259
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
3 changes: 3 additions & 0 deletions app/resources/locales/en_US/default.po
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,9 @@ msgstr "Required"
msgid "match.fd.resolution_mode"
msgstr "Resolution Mode"

msgid "match.fd.resolution_time"
msgstr "Resolution Time"

msgid "match.fd.RuleAttributes.match_empty"
msgstr "Match Empty Values"

Expand Down
23 changes: 20 additions & 3 deletions app/src/View/Helper/FieldHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
use \Cake\View\Helper;

class FieldHelper extends Helper {
public $helpers = ['Form'];
public $helpers = ['Form', 'Time'];

// Is this read-only or read-write?
protected $editable = true;
Expand Down Expand Up @@ -65,6 +65,7 @@ public function control(string $fieldName,
array $childControls=[]) {
$coptions = $options;
$coptions['label'] = false;
$isRequired = $required; // We might override this below

$label = null;
$desc = null;
Expand Down Expand Up @@ -106,6 +107,17 @@ public function control(string $fieldName,
}
}

$control = '';

if(is_object($this->viewObj->$fieldName)
&& get_class($this->viewObj->$fieldName) == 'Cake\I18n\FrozenTime') {
// This is a read-only timestamp, use the field to render itself
$control = $this->viewObj->$fieldName->nice();
$isRequired = false;
} else {
$control = $this->Form->control($fieldName, $coptions);
}

$children = '';

if(!empty($childControls)) {
Expand All @@ -120,18 +132,23 @@ public function control(string $fieldName,
$children .= "</ul>";
}

if(isset($options['readonly']) && $options['readonly']) {
// Read only attributes can't be required
$isRequired = false;
}

return '<li>
<div class="field-name">
<div class="field-title">
' . ($this->editable
? $this->Form->label($fieldName, $label)
: $label)
. ($required ? ' <span class="required">*</span>' : '') . '
. ($isRequired ? ' <span class="required">*</span>' : '') . '
</div>
' . ($desc ? '<span class="field-desc">' . $desc . '</span>' : "") .'
</div>
<div class="field-info">
' . $this->Form->control($fieldName, $coptions) . '
' . $control . '
' . $children . '
</div>
</li>
Expand Down
5 changes: 5 additions & 0 deletions app/templates/MatchgridRecords/fields.inc
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,9 @@ if($action == 'add' || $action == 'edit') {
}

print $this->Field->control('referenceid', [], false, __('match.fd.referenceid', [1]));
}

if($action == 'edit') {
print $this->Field->control('request_time');
print $this->Field->control('resolution_time');
}

0 comments on commit 5f89259

Please sign in to comment.