Form->label('CoPerson.date_of_birth', _txt('fd.date_of_birth')); ?>
@@ -1107,41 +1070,14 @@
$rcnt = 1;
foreach($co_people[0]['CoPersonRole'] as $r) {
$badge_list_role = array();
- // Set the status styling
- $statusClass = $this->Badge->getBadgeColor('Light');
- // Set ordering
- $bgOrder = $this->Badge->getBadgeOrder('Other');
// Store the action list
$action_args = array();
$action_args['vv_attr_mdl'] = "CoPersonRole";
$action_args['vv_attr_id'] = $r["id"];
- if($r['status'] == StatusEnum::Suspended
- || $r['status'] == StatusEnum::Expired
- || $r['status'] == StatusEnum::Deleted) {
- // Style status for suspended, expired, deleted
- $bgOrder = $this->Badge->getBadgeOrder('Status');
- $statusClass = $this->Badge->getBadgeColor('Danger'); // reddish
- } elseif($r['status'] != StatusEnum::Active) {
- // Style status if otherwise not active
- $bgOrder = $this->Badge->getBadgeOrder('Status');
- $statusClass = $this->Badge->getBadgeColor('Warning'); // yellowish
- }
- // Independent of status, set the style based on dates if needed:
- $validThroughDate = !empty($r['valid_through']) ? $this->Time->format($r['valid_through'], "%F", false, $vv_tz) : false;
- $validFromDate = !empty($r['valid_from']) ? $this->Time->format($r['valid_from'], "%F", false, $vv_tz) : false;
-
- if ($validThroughDate && $this->Time->isPast($validThroughDate)) {
- // valid through date exists and is in the past
- $bgOrder = $this->Badge->getBadgeOrder('Status');
- $statusClass = $this->Badge->getBadgeColor('Danger'); // reddish
- } elseif ($validFromDate && $this->Time->isFuture($validFromDate)) {
- // valid from date is in the future
- $bgOrder = $this->Badge->getBadgeOrder('Status');
- $statusClass = $this->Badge->getBadgeColor('Warning'); // yellowish
- }
+ // Calculate the badge color,text and status
+ list($status, $statusClass, $bgOrder) = $this->Badge->calculateStatusNBadge($r, $vv_tz);
- $status = !empty($r['status']) ? _txt('en.status', null, $r['status']) : '-';
if($r['status'] != StatusEnum::Active) {
$badge_list_role[] = array(
'order' => $bgOrder,
diff --git a/app/View/Elements/changelog.ctp b/app/View/Elements/changelog.ctp
index 4977f5b2d..a41aa4d09 100644
--- a/app/View/Elements/changelog.ctp
+++ b/app/View/Elements/changelog.ctp
@@ -54,7 +54,7 @@
|
-
+ |
|
@@ -62,7 +62,7 @@
|
-
+ |
- |
+ |
Time->format(${$modelpl}[0][$req]['modified'], "%c $vv_tz", false, $vv_tz);
?>
@@ -92,7 +92,7 @@
|
|
-
+ |
+
+ name);
+ $mdl_tbl = Inflector::tableize($mdl);
+ $mdl_pt = $$mdl_tbl;
+ global $cm_lang, $cm_texts;
+
+
+ // Create a PUT Form
+ print $this->Form->create(
+ $mdl,
+ array(
+ 'default' => false,
+ 'inputDefaults' => array('div' => false),
+ 'url' => array(
+ 'action' => 'edit',
+ $mdl_pt[0][$mdl]['id'], // todo: Make the id optional
+ ),
+ )
+ );
+ print $this->Form->hidden($mdl . '.co_id', array('default' => $cur_co['Co']['id'])). PHP_EOL;
+
+ $input_options = array(
+ 'label' => $label,
+ 'type' => $type,
+ 'class' => 'ml-1 vmiddle',
+ 'value' => $mdl_pt[0][$mdl][$field],
+ );
+ if ($type === "select") {
+ $input_options['options'] = $cm_texts[$cm_lang]['en.' . $field];
+ $input_options['value'] = $mdl_pt[0][$mdl][$field];
+ $input_options['label'] = $label . ":";
+ $input_options['aria-label'] = $label;
+ if(!$empty) {
+ $input_options['empty'] = $label . ' ' . _txt('op.select.empty');
+ }
+ }
+ print $this->Form->input($field, $input_options);
+
+ if($this->Form->isFieldError($field)) {
+ print $this->Form->error($field);
+ }
+ // Submit
+ $sr_edit = $this->Html->tag('span', 'edit', array('class' => 'sr-only'));
+ print $this->Form->button(
+ $this->Html->tag('i', $sr_edit, array('class' => 'fa fa-check')),
+ array(
+ 'name' => 'ok',
+ 'type' => 'submit',
+ 'class' => 'btn btn-primary ml-1 btn-sz9',
+ 'escape' => false,
+ 'onclick' => 'javascript:update_field(this,'
+ . '{'
+ . '\'model\': \'' . $mdl . '\''
+ . ', \'field\': \'' . $field . '\''
+ . '});'
+ )
+ );
+ // Cancel
+ $sr_cancel = $this->Html->tag('span', 'cancel', array('class' => 'sr-only'));
+ print $this->Form->button(
+ $this->Html->tag('i', $sr_cancel, array('class' => 'fa fa-times')),
+ array(
+ 'name' => 'cancel',
+ 'type' => 'submit',
+ 'class' => 'btn btn-warning ml-1 btn-sz9',
+ 'escape' => false,
+ 'onclick' => 'javascript:inline_edit(false);'
+ )
+ );
+ print $this->Form->end();
+ ?>
+
\ No newline at end of file
diff --git a/app/View/Elements/javascript.ctp b/app/View/Elements/javascript.ctp
index dab8b54a6..d5551e9ec 100644
--- a/app/View/Elements/javascript.ctp
+++ b/app/View/Elements/javascript.ctp
@@ -569,6 +569,40 @@
?>
});
+ // Date fields used around the framework and their formats
+ const $dateFieldsNFormats = {
+ 'modified': 'EEE LLL d HH:mm:ss yyyy',
+ 'created': 'EEE LLL d HH:mm:ss yyyy',
+ 'date_of_birth': 'yyyy-LL-dd'
+ }
+
+ // Update the Change Log view block after an Ajax call
+ // data - data response (array, required)
+ // vmodel - Model updated (string, required)
+ function changelog_update(data, vmodel) {
+ //Update Changelog DOM
+ $dateFields = Object.keys($dateFieldsNFormats);
+ $.each(data[0][vmodel], (column, value) => {
+ if(column == 'deleted') {
+ value = (value) ? '' : '';
+ }
+ ccol = capitalize(column);
+ ccolfound = $.inArray(column, $dateFields);
+ if(ccolfound > -1 && ccolfound !== false) {
+ // Browser's timezone
+ user_tz = jstz.determine().name();
+ // Timezone we use to store data in the database
+ db_tz = '';
+ dObj = luxon.DateTime;
+ // Convert whatever timezone to UTC
+ unform_date = dObj.fromSQL(value, {zone: db_tz}).toUTC();
+ // Set users timezone and Format
+ value = unform_date.setZone(user_tz).toFormat($dateFieldsNFormats[column]) + " " + user_tz;
+ }
+ $('#' + vmodel + ccol + 'Changelog').text(value);
+ });
+ }
+
// Observers list
var observer = new Array();
// Options for the Dropdown Action Menu Observer
diff --git a/app/View/Elements/pageTitleAndButtons.ctp b/app/View/Elements/pageTitleAndButtons.ctp
index a0eb0338b..9d9b53f82 100644
--- a/app/View/Elements/pageTitleAndButtons.ctp
+++ b/app/View/Elements/pageTitleAndButtons.ctp
@@ -30,8 +30,63 @@
-
+
+
+
+ Badge->calculateStatusNBadge($co_people[0]['CoPerson'], $vv_tz);
+ $outline = ($status === 'Active') ? true : false;
+ $statusBadge = ' ' . $this->Badge->badgeIt(
+ $status,
+ $badgeColor,
+ false,
+ $outline,
+ $this->Badge->getBadgeIcon('Edit'),
+ 'inline-edit'
+ );
+
+ $e = false;
+ $es = false;
+
+ if(($this->action == "invite" && $permissions['invite'])
+ || ($this->action == "canvas" && $permissions['canvas']))
+ $e = true;
+
+ if($this->action == "canvas" && $permissions['editself'])
+ $es = true;
+ if($e && $permissions['edit']
+ && !$permissions['editself']) {
+ $linkparams = array(
+ 'class' => 'status-edit-link',
+ 'escape' => false,
+ 'onclick' => 'inline_edit(true);',
+ );
+ // Tag link
+ print $this->Html->link(
+ $statusBadge,
+ 'javascript:void(0);',
+ $linkparams
+ );
+ $field_args = array(
+ 'field' => 'status',
+ 'label' => _txt('fd.status'),
+ 'type' => 'select',
+ 'empty' => true,
+ );
+ print $this->element('inlineFieldEdit', $field_args);
+ } else {
+ print $statusBadge;
+ }
+ ?>
+
+
diff --git a/app/View/Helper/BadgeHelper.php b/app/View/Helper/BadgeHelper.php
index dd190aa3f..8f8c02f3f 100644
--- a/app/View/Helper/BadgeHelper.php
+++ b/app/View/Helper/BadgeHelper.php
@@ -30,7 +30,7 @@
class BadgeHelper extends AppHelper {
- public $helpers = array('Html');
+ public $helpers = array('Html', 'Time');
/**
* Parse System Group names. The ones having the prefix CO: or CO:COU:
@@ -105,11 +105,26 @@ public function systemGroupHFormat($name, $cur_co = "") {
* Defaults to light
* @param boolean $badge_pill Is this a badge-pill. Defaults to false
* @param boolean $badge_outline Is this an outlined badge. Defaults to false
+ * @param string $badge_fa Provide Fonts Awesome Icon to prepend
+ * @param string $badge_fa_class Provide extra class(es) for element
+ * @param string $badge_class Provide extra class(es) for element
*
*/
- public function badgeIt($title, $type = 'secondary', $badge_pill = false, $badge_outline = false) {
+ public function badgeIt(
+ $title,
+ $type = 'secondary',
+ $badge_pill = false,
+ $badge_outline = false,
+ $badge_fa = null,
+ $badge_fa_class = null,
+ $badge_class = null
+ ) {
$badge_classes = array();
+ if(!is_null($badge_class)) {
+ $badge_classes[] = $badge_class;
+ }
+
if($badge_pill) {
$badge_classes[] = "badge-pill";
}
@@ -118,6 +133,12 @@ public function badgeIt($title, $type = 'secondary', $badge_pill = false, $badge
} else {
$badge_classes[] = "badge-" . $type;
}
+ if(!empty($badge_fa)) {
+ if(!empty($badge_fa_class)) {
+ $badge_fa = $badge_fa . ' ' . $badge_fa_class;
+ }
+ $title = '' . $title;
+ }
return $this->Html->tag(
'span',
@@ -185,4 +206,88 @@ public function getBadgeColor($color) {
return $color_map[$color];
}
+
+ /**
+ * Get the Badge Icon per action
+ *
+ * @param string $action
+ * @return string|null
+ *
+ * @since COmanage Registry v4.0.0
+ */
+ public function getBadgeIcon($action) {
+ if(empty($action)) {
+ return null;
+ }
+
+ $icon = array(
+ 'Edit' => 'fa fa-pencil',
+ );
+
+ return $icon[$action];
+ }
+
+
+ /**
+ * @param $ob
+ * @param $vv_tz
+ * @return array
+ */
+ public function calculateStatusNBadge($ob, $vv_tz) {
+ // Set default color
+ $statusClass = $this->getBadgeColor('Light');
+ // Set ordering
+ $bgOrder = $this->getBadgeOrder('Other');
+
+ if($ob['status'] == StatusEnum::Suspended
+ || $ob['status'] == StatusEnum::Expired
+ || $ob['status'] == StatusEnum::Deleted) {
+ // Style status for suspended, expired, deleted
+ $bgOrder = $this->getBadgeOrder('Status');
+ $statusClass = $this->getBadgeColor('Danger'); // reddish
+ } elseif($ob['status'] != StatusEnum::Active) {
+ // Style status if otherwise not active
+ $bgOrder = $this->getBadgeOrder('Status');
+ $statusClass = $this->getBadgeColor('Warning'); // yellowish
+ }
+ // Independent of status, set the style based on dates if needed:
+ $validThroughDate = !empty($ob['valid_through']) ? $this->Time->format($ob['valid_through'], "%F", false, $vv_tz) : false;
+ $validFromDate = !empty($ob['valid_from']) ? $this->Time->format($ob['valid_from'], "%F", false, $vv_tz) : false;
+
+ if ($validThroughDate && $this->Time->isPast($validThroughDate)) {
+ // valid through date exists and is in the past
+ $bgOrder = $this->getBadgeOrder('Status');
+ $statusClass = $this->getBadgeColor('Danger'); // reddish
+ } elseif ($validFromDate && $this->Time->isFuture($validFromDate)) {
+ // valid from date is in the future
+ $bgOrder = $this->getBadgeOrder('Status');
+ $statusClass = $this->getBadgeColor('Warning'); // yellowish
+ }
+ $status = !empty($ob['status']) ? _txt('en.status', null, $ob['status']) : '-';
+
+ return array($status, $statusClass, $bgOrder);
+ }
+
+ /**
+ * @return array
+ */
+ public function statusBadgeColorMap() {
+ global $cm_lang, $cm_texts;
+
+ $mapper = array();
+ foreach($cm_texts[$cm_lang]['en.status'] as $scode => $status) {
+ $mapper[$status] = $this->getBadgeColor('Light');
+ if($scode == StatusEnum::Suspended
+ || $scode == StatusEnum::Expired
+ || $scode == StatusEnum::Deleted) {
+ // Style status for suspended, expired, deleted
+ $mapper[$status] = $this->getBadgeColor('Danger'); // reddish
+ } elseif($scode != StatusEnum::Active) {
+ // Style status if otherwise not active
+ $mapper[$status] = $this->getBadgeColor('Warning'); // yellowish
+ }
+ }
+ return $mapper;
+ }
+
}
\ No newline at end of file
diff --git a/app/View/Layouts/default.ctp b/app/View/Layouts/default.ctp
index e6bc87ee6..eed24b732 100644
--- a/app/View/Layouts/default.ctp
+++ b/app/View/Layouts/default.ctp
@@ -317,6 +317,8 @@
Html->script('jstimezonedetect/jstz.min.js'); ?>
+
+ Html->script('luxon/luxon.min.js'); ?>
|