Browse Source

Calendar pages properly use new category colors

tags/3.1.0
Mike Koch 2 years ago
parent
commit
028be8d187

+ 10
- 4
internal-api/dao/calendar_dao.php View File

@@ -6,7 +6,8 @@ function get_events($start, $end, $hesk_settings, $staff = true) {
$start_time_sql = "CONVERT_TZ(FROM_UNIXTIME(" . hesk_dbEscape($start) . " / 1000), @@session.time_zone, '+00:00')";
$end_time_sql = "CONVERT_TZ(FROM_UNIXTIME(" . hesk_dbEscape($end) . " / 1000), @@session.time_zone, '+00:00')";

$sql = "SELECT `events`.*, `categories`.`name` AS `category_name`, `categories`.`background_color` AS `category_color` ";
$sql = "SELECT `events`.*, `categories`.`name` AS `category_name`, `categories`.`background_color` AS `background_color`,
`categories`.`foreground_color` AS `foreground_color`, `categories`.`display_border_outline` AS `display_border` ";

if ($staff) {
$sql .= ",`reminders`.`amount` AS `reminder_value`, `reminders`.`unit` AS `reminder_unit` ";
@@ -47,7 +48,9 @@ function get_events($start, $end, $hesk_settings, $staff = true) {
$event['comments'] = $row['comments'];
$event['categoryId'] = $row['category'];
$event['categoryName'] = $row['category_name'];
$event['categoryColor'] = $row['category_color'];
$event['backgroundColor'] = $row['background_color'];
$event['foregroundColor'] = $row['foreground_color'];
$event['displayBorder'] = $row['display_border'];

if ($staff) {
$event['reminderValue'] = $row['reminder_value'];
@@ -63,7 +66,8 @@ function get_events($start, $end, $hesk_settings, $staff = true) {
$current_date = hesk_date();
$hesk_settings['timeformat'] = $old_time_setting;

$sql = "SELECT `trackid`, `subject`, `due_date`, `category`, `categories`.`name` AS `category_name`, `categories`.`background_color` AS `category_color`,
$sql = "SELECT `trackid`, `subject`, `due_date`, `category`, `categories`.`name` AS `category_name`, `categories`.`background_color` AS `background_color`,
`categories`.`foreground_color` AS `foreground_color`, `categories`.`display_border_outline` AS `display_border`,
CASE WHEN `due_date` < '{$current_date}' THEN 1 ELSE 0 END AS `overdue`, `owner`.`name` AS `owner_name`, `tickets`.`owner` AS `owner_id`,
`tickets`.`priority` AS `priority`
FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` AS `tickets`
@@ -94,7 +98,9 @@ function get_events($start, $end, $hesk_settings, $staff = true) {
$event['url'] = $hesk_settings['hesk_url'] . '/' . $hesk_settings['admin_dir'] . '/admin_ticket.php?track=' . $event['trackingId'];
$event['categoryId'] = $row['category'];
$event['categoryName'] = $row['category_name'];
$event['categoryColor'] = $row['category_color'];
$event['backgroundColor'] = $row['background_color'];
$event['foregroundColor'] = $row['foreground_color'];
$event['displayBorder'] = $row['display_border'];
$event['owner'] = $row['owner_name'];

$priorities = array(

+ 16
- 6
js/calendar/mods-for-hesk-calendar-admin-readonly.js View File

@@ -89,9 +89,17 @@ $(document).ready(function() {
.tip()
.css('padding', '0')
.find('.popover-title')
.css('background-color', event.color === '#fff' ? '#f7f7f7' : event.color)
.css('background-color', event.backgroundColor)
.addClass('background-volatile');

if (event.textColor === 'AUTO') {
$eventMarkup.addClass('background-volatile');
} else {
$eventMarkup.data('bs.popover').tip().find('.popover-title')
.css('color', event.textColor)
.css('border', 'solid 1px ' + event.borderColor);
}

$eventMarkup.popover('show');
refreshBackgroundVolatileItems();
},
@@ -120,7 +128,9 @@ function buildEvent(id, dbObject) {
trackingId: dbObject.trackingId,
start: moment(dbObject.startTime),
url: dbObject.url,
color: dbObject.categoryColor === '' || dbObject.categoryColor === null ? '#fff' : dbObject.categoryColor,
backgroundColor: dbObject.backgroundColor,
textColor: dbObject.foregroundColor === 'AUTO' ? calculateTextColor(dbObject.backgroundColor) : dbObject.foregroundColor,
borderColor: parseInt(dbObject.displayBorder) === 1 ? dbObject.foregroundColor : dbObject.backgroundColor,
allDay: true,
type: dbObject.type,
categoryId: dbObject.categoryId,
@@ -128,7 +138,6 @@ function buildEvent(id, dbObject) {
className: 'category-' + dbObject.categoryId,
owner: dbObject.owner,
priority: dbObject.priority,
textColor: calculateTextColor(dbObject.categoryColor),
fontIconMarkup: getIcon(dbObject)
};
}
@@ -151,8 +160,9 @@ function buildEvent(id, dbObject) {
categoryId: dbObject.categoryId,
categoryName: dbObject.categoryName,
className: 'category-' + dbObject.categoryId,
color: dbObject.categoryColor === '' || dbObject.categoryColor === null ? '#fff' : dbObject.categoryColor,
textColor: calculateTextColor(dbObject.categoryColor),
backgroundColor: dbObject.backgroundColor,
textColor: dbObject.foregroundColor === 'AUTO' ? calculateTextColor(dbObject.backgroundColor) : dbObject.foregroundColor,
borderColor: parseInt(dbObject.displayBorder) === 1 ? dbObject.foregroundColor : dbObject.backgroundColor,
reminderValue: dbObject.reminderValue == null ? '' : dbObject.reminderValue,
reminderUnits: dbObject.reminderUnits,
fontIconMarkup: '<i class="fa fa-calendar"></i>'
@@ -170,7 +180,7 @@ function getIcon(dbObject) {
}

function calculateTextColor(color) {
if (color === null || color === '') {
if (color === null || color === '' || color === undefined) {
return 'black';
}


+ 13
- 4
js/calendar/mods-for-hesk-calendar-readonly.js View File

@@ -78,9 +78,17 @@ $(document).ready(function() {
.tip()
.css('padding', '0')
.find('.popover-title')
.css('background-color', event.color === '#fff' ? '#f7f7f7' : event.color)
.css('background-color', event.backgroundColor)
.addClass('background-volatile');

if (event.textColor === 'AUTO') {
$eventMarkup.addClass('background-volatile');
} else {
$eventMarkup.data('bs.popover').tip().find('.popover-title')
.css('color', event.textColor)
.css('border', 'solid 1px ' + event.borderColor);
}

$eventMarkup.popover('show');
refreshBackgroundVolatileItems();
},
@@ -116,15 +124,16 @@ function buildEvent(id, dbObject) {
categoryId: dbObject.categoryId,
categoryName: dbObject.categoryName,
className: 'category-' + dbObject.categoryId,
color: dbObject.categoryColor === '' || dbObject.categoryColor === null ? '#fff' : dbObject.categoryColor,
textColor: calculateTextColor(dbObject.categoryColor),
backgroundColor: dbObject.backgroundColor,
textColor: dbObject.foregroundColor === 'AUTO' ? calculateTextColor(dbObject.backgroundColor) : dbObject.foregroundColor,
borderColor: parseInt(dbObject.displayBorder) === 1 ? dbObject.foregroundColor : dbObject.backgroundColor,
reminderValue: dbObject.reminderValue == null ? '' : dbObject.reminderValue,
reminderUnits: dbObject.reminderUnits
};
}

function calculateTextColor(color) {
if (color === null || color === '') {
if (color === null || color === '' || color === undefined) {
return 'black';
}


+ 18
- 8
js/calendar/mods-for-hesk-calendar.js View File

@@ -102,8 +102,16 @@ $(document).ready(function() {
.tip()
.css('padding', '0')
.find('.popover-title')
.css('background-color', event.color === '#fff' ? '#f7f7f7' : event.color)
.addClass('background-volatile');
.css('background-color', event.backgroundColor);

if (event.textColor === 'AUTO') {
$eventMarkup.addClass('background-volatile');
} else {
$eventMarkup.data('bs.popover').tip().find('.popover-title')
.css('color', event.textColor)
.css('border', 'solid 1px ' + event.borderColor);
}


$eventMarkup.popover('show');
refreshBackgroundVolatileItems();
@@ -282,7 +290,9 @@ function buildEvent(id, dbObject) {
trackingId: dbObject.trackingId,
start: moment(dbObject.startTime),
url: dbObject.url,
color: dbObject.categoryColor === '' || dbObject.categoryColor === null ? '#fff' : dbObject.categoryColor,
backgroundColor: dbObject.backgroundColor,
textColor: dbObject.foregroundColor === 'AUTO' ? calculateTextColor(dbObject.backgroundColor) : dbObject.foregroundColor,
borderColor: parseInt(dbObject.displayBorder) === 1 ? dbObject.foregroundColor : dbObject.backgroundColor,
allDay: true,
type: dbObject.type,
categoryId: dbObject.categoryId,
@@ -290,7 +300,6 @@ function buildEvent(id, dbObject) {
className: 'category-' + dbObject.categoryId,
owner: dbObject.owner,
priority: dbObject.priority,
textColor: calculateTextColor(dbObject.categoryColor),
fontIconMarkup: getIcon(dbObject)
};
}
@@ -299,7 +308,7 @@ function buildEvent(id, dbObject) {
if (dbObject.allDay) {
endTime.add(1, 'days');
}
console.log(dbObject);
return {
id: id,
title: dbObject.title,
@@ -313,8 +322,9 @@ function buildEvent(id, dbObject) {
categoryId: dbObject.categoryId,
categoryName: dbObject.categoryName,
className: 'category-' + dbObject.categoryId,
color: dbObject.categoryColor === '' || dbObject.categoryColor === null ? '#fff' : dbObject.categoryColor,
textColor: calculateTextColor(dbObject.categoryColor),
backgroundColor: dbObject.backgroundColor,
textColor: dbObject.foregroundColor === 'AUTO' ? calculateTextColor(dbObject.backgroundColor) : dbObject.foregroundColor,
borderColor: parseInt(dbObject.displayBorder) === 1 ? dbObject.foregroundColor : dbObject.backgroundColor,
reminderValue: dbObject.reminderValue == null ? '' : dbObject.reminderValue,
reminderUnits: dbObject.reminderUnits,
fontIconMarkup: '<i class="fa fa-calendar"></i>'
@@ -332,7 +342,7 @@ function getIcon(dbObject) {
}

function calculateTextColor(color) {
if (color === null || color === '') {
if (color === null || color === '' || color === undefined) {
return 'black';
}


Loading…
Cancel
Save