Skip to content
Code-Schnipsel Gruppen Projekte
Commit 83f31e42 erstellt von Henning Leutz's avatar Henning Leutz :martial_arts_uniform:
Dateien durchsuchen

feat: refactor: added id and source attribute to comments

Übergeordneter daaa0156
Keine zugehörigen Branchen gefunden
Keine zugehörigen Tags gefunden
Keine zugehörigen Merge Requests gefunden
......@@ -18,10 +18,13 @@
</div>
<div class="quiqqer-erp-comments-list">
{{#data}}
<div class="quiqqer-erp-comments-comment">
<span class="quiqqer-erp-comments-comment-type">
<span class="fa {{type}}"></span>
</span>
<div class="quiqqer-erp-comments-comment"
data-id="{{id}}"
data-source="{{source}}"
>
<span class="quiqqer-erp-comments-comment-type" title="{{title}}">
<span class="fa {{type}}"></span>
</span>
<div class="quiqqer-erp-comments-comment-data">
<span class="quiqqer-erp-comments-comment-time">{{time}}</span>
<span class="quiqqer-erp-comments-comment-message">{{message}}</span>
......@@ -33,4 +36,4 @@
{{/comments}}
{{^comments}}
{{textNoComments}}
{{/comments}}
\ No newline at end of file
{{/comments}}
......@@ -91,17 +91,27 @@ define('package/quiqqer/erp/bin/backend/controls/Comments', [
type = entry.sourceIcon;
}
if (typeof entry.source === 'undefined') {
entry.source = '';
}
if (typeof entry.id === 'undefined') {
entry.id = '';
}
return {
date : date,
time : Formatter.format(date),
message : entry.message,
type : type,
timestamp: entry.time
timestamp: entry.time,
id : entry.id,
source : entry.source
};
});
// grouping
var i, len, day, date, entry;
var i, len, day, date, entry, title;
var group = {};
var DayFormatter = this.$getDayFormatter();
......@@ -118,11 +128,18 @@ define('package/quiqqer/erp/bin/backend/controls/Comments', [
};
}
title = QUILocale.get(lg, 'comments.comment.title', {
source: entry.source
});
group[day].data.push({
time : entry.time,
message : entry.message,
type : entry.type,
timestamp: entry.timestamp
timestamp: entry.timestamp,
id : entry.id,
source : entry.source,
title : entry.source !== '' ? title : ''
});
}
......
......@@ -307,6 +307,10 @@
<de><![CDATA[nä. zu vergebende Nummer]]></de>
<en><![CDATA[next number to be assigned]]></en>
</locale>
<locale name="comments.comment.title">
<de><![CDATA[Kommentar aus: [source]]]></de>
<en><![CDATA[Comment from: [source]]]></en>
</locale>
</groups>
</locales>
\ No newline at end of file
</locales>
......@@ -37,6 +37,10 @@ public function __construct($comments = [])
}
foreach ($comments as $comment) {
if (!isset($comment['id'])) {
$comment['id'] = QUI\Utils\Uuid::get();
}
if (isset($comment['message']) && isset($comment['time'])) {
$this->comments[] = $comment;
}
......@@ -100,24 +104,31 @@ public function toArray()
* @param int|false $time - optional, unix timestamp
* @param string $source - optional, name of the package
* @param string $sourceIcon - optional, source icon
* @param string|false $id - optional, comment id, if needed, it will set one
*/
public function addComment(
$message,
$time = false,
$source = '',
$sourceIcon = ''
$sourceIcon = '',
$id = false
) {
if ($time === false) {
$time = \time();
}
if ($id === false) {
$id = QUI\Utils\Uuid::get();
}
$message = QUI\Utils\Security\Orthos::clearFormRequest($message);
$this->comments[] = [
'message' => $message,
'time' => (int)$time,
'source' => $source,
'sourceIcon' => $sourceIcon
'sourceIcon' => $sourceIcon,
'id' => $id
];
}
......@@ -161,11 +172,16 @@ public function import(Comments $Comments)
$comment['sourceIcon'] = '';
}
if (!isset($comment['id'])) {
$comment['id'] = false;
}
$this->addComment(
$comment['message'],
$comment['time'],
$comment['source'],
$comment['sourceIcon']
$comment['sourceIcon'],
$comment['id']
);
}
......
0% Lade oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren