Skip to content
Code-Schnipsel Gruppen Projekte
Bestätigt Commit 833b8034 erstellt von Henning Leutz's avatar Henning Leutz :martial_arts_uniform:
Dateien durchsuchen

feat: history / comment entries are clickable

Übergeordneter 43271312
Keine zugehörigen Branchen gefunden
Keine zugehörigen Tags gefunden
2 Merge Requests!61feat: erp process object extended,!60feat: erp process object extended
......@@ -11,6 +11,16 @@
width: 100%;
}
.quiqqer-erp-comments-comment--clickable:hover {
background: #2F8FC6;
color: #FFFFFF;
cursor: pointer;
}
.quiqqer-erp-comments-comment--clickable:hover .quiqqer-erp-comments-comment-type {
color: #FFFFFF;
}
/** title
================================================== */
......
......@@ -21,6 +21,7 @@
<div class="quiqqer-erp-comments-comment"
data-id="{{id}}"
data-source="{{source}}"
data-object-hash="{{objectHash}}"
>
<span class="quiqqer-erp-comments-comment-type" title="{{title}}"
{{#editable}}data-editable="1"{{/editable}}
......
......@@ -10,13 +10,14 @@ define('package/quiqqer/erp/bin/backend/controls/Comments', [
'qui/QUI',
'qui/controls/Control',
'utils/Panels',
'Mustache',
'Locale',
'text!package/quiqqer/erp/bin/backend/controls/Comments.html',
'css!package/quiqqer/erp/bin/backend/controls/Comments.css'
], function(QUI, QUIControl, Mustache, QUILocale, template) {
], function(QUI, QUIControl, PanelUtils, Mustache, QUILocale, template) {
'use strict';
const lg = 'quiqqer/erp';
......@@ -27,7 +28,8 @@ define('package/quiqqer/erp/bin/backend/controls/Comments', [
Type: 'package/quiqqer/erp/bin/backend/controls/Comments',
Binds: [
'$onCreate'
'$onCreate',
'$onEntryClick'
],
options: {
......@@ -114,6 +116,10 @@ define('package/quiqqer/erp/bin/backend/controls/Comments', [
entry.id = '';
}
if (typeof entry.objectHash === 'undefined') {
entry.objectHash = '';
}
if (typeof entry.editable === 'undefined') {
entry.editable = false;
}
......@@ -126,7 +132,8 @@ define('package/quiqqer/erp/bin/backend/controls/Comments', [
timestamp: entry.time,
id: entry.id,
source: entry.source,
editable: entry.editable
editable: entry.editable,
objectHash: entry.objectHash
};
});
......@@ -166,7 +173,8 @@ define('package/quiqqer/erp/bin/backend/controls/Comments', [
id: entry.id,
source: entry.source,
title: entry.source !== '' ? title : '',
editable: entry.editable
editable: entry.editable,
objectHash: entry.objectHash
});
}
......@@ -236,6 +244,15 @@ define('package/quiqqer/erp/bin/backend/controls/Comments', [
})
});
this.$Elm.querySelectorAll('.quiqqer-erp-comments-comment').forEach((Comment) => {
if (!Comment.get('data-object-hash')) {
return;
}
Comment.addClass('quiqqer-erp-comments-comment--clickable');
Comment.addEventListener('click', this.$onEntryClick);
});
this.$Elm.getElements('[data-editable]').addEvent('click', function(event) {
let Parent = event.target;
......@@ -245,7 +262,8 @@ define('package/quiqqer/erp/bin/backend/controls/Comments', [
const data = {
id: Parent.get('data-id'),
source: Parent.get('data-source')
source: Parent.get('data-source'),
objectHash: Parent.get('data-object-hash')
};
self.fireEvent('edit', [
......@@ -313,6 +331,78 @@ define('package/quiqqer/erp/bin/backend/controls/Comments', [
}
},
$onEntryClick: function(event) {
let Target = event.target;
if (!Target.hasClass('quiqqer-erp-comments-comment')) {
Target = Target.getParent('.quiqqer-erp-comments-comment');
}
console.log(Target.get('data-object-hash'));
switch (Target.get('data-source')) {
case 'quiqqer/order':
require([
'package/quiqqer/order/bin/backend/controls/panels/Order'
], (Order) => {
PanelUtils.openPanelInTasks(
new Order({
orderId: Target.get('data-object-hash')
})
);
});
break;
case 'quiqqer/invoice':
require([
'package/quiqqer/invoice/bin/backend/controls/panels/Invoice'
], (Invoice) => {
PanelUtils.openPanelInTasks(
new Invoice({
invoiceId: Target.get('data-object-hash')
})
);
});
break;
case 'quiqqer/offer':
require([
'package/quiqqer/offers/bin/js/backend/controls/panels/Offer'
], (Offer) => {
PanelUtils.openPanelInTasks(
new Offer({
offerId: Target.get('data-object-hash')
})
);
});
break;
case 'quiqqer/purchasing':
require([
'package/quiqqer/purchasing/bin/js/backend/controls/panels/processes/Process'
], (Process) => {
PanelUtils.openPanelInTasks(
new Process({
processId: Target.get('data-object-hash')
})
);
});
break;
case 'quiqqer/salesorders':
require([
'package/quiqqer/salesorders/bin/js/backend/controls/panels/SalesOrder'
], (SalesOrder) => {
PanelUtils.openPanelInTasks(
new SalesOrder({
salesOrderHash: Target.get('data-object-hash')
})
);
});
break;
}
},
//region filter
/**
......
......@@ -60,6 +60,7 @@ define('package/quiqqer/erp/bin/backend/controls/process/ProcessPanel', [
require(['package/quiqqer/erp/bin/backend/controls/Comments'], (Comments) => {
this.$Comments = new Comments().inject(this.getBody());
this.$onShow();
});
},
......@@ -76,8 +77,6 @@ define('package/quiqqer/erp/bin/backend/controls/process/ProcessPanel', [
this.Loader.show();
QUIAjax.get('package_quiqqer_erp_ajax_dashboard_globalProcess_getProcess', (result) => {
console.warn(result);
this.$Comments.clear();
this.$Comments.unserialize(result.history);
this.Loader.hide();
......
......@@ -695,15 +695,19 @@
</locale>
<locale name="process.history.order.created">
<de><![CDATA[Bestellung #[hash] erstellt]]></de>
<en><![CDATA[Order created #[hash]]]></en>
<en><![CDATA[Order #[hash] created]]></en>
</locale>
<locale name="process.history.offer.created">
<de><![CDATA[Angebot #[hash] erstellt]]></de>
<en><![CDATA[Created offer #[hash]]]></en>
<en><![CDATA[Offer #[hash] created]]></en>
</locale>
<locale name="process.history.purchasing.created">
<de><![CDATA[Einkauf #[hash] erstellt]]></de>
<en><![CDATA[Purchase created #[hash]]]></en>
<en><![CDATA[Purchase #[hash] created]]></en>
</locale>
<locale name="process.history.salesorders.created">
<de><![CDATA[Auftrag #[hash] erstellt]]></de>
<en><![CDATA[Sales order #[hash] created]]></en>
</locale>
</groups>
......
......@@ -129,7 +129,8 @@ public function addComment(
bool|int $time = false,
string $source = '',
string $sourceIcon = '',
bool|string $id = false
bool|string $id = false,
bool|string $objectHash = false
) {
if ($time === false) {
$time = time();
......@@ -151,14 +152,15 @@ public function addComment(
'time' => (int)$time,
'source' => $source,
'sourceIcon' => $sourceIcon,
'id' => $id
'id' => $id,
'objectHash' => $objectHash
];
}
/**
* Clear all comments
*/
public function clear()
public function clear(): void
{
$this->comments = [];
}
......@@ -166,7 +168,7 @@ public function clear()
/**
* Sort all comments via its time
*/
public function sort()
public function sort(): void
{
usort($this->comments, function ($commentA, $commentB) {
if ($commentA['time'] == $commentB['time']) {
......@@ -182,7 +184,7 @@ public function sort()
*
* @param Comments $Comments
*/
public function import(Comments $Comments)
public function import(Comments $Comments): void
{
$comments = $Comments->toArray();
......@@ -204,7 +206,8 @@ public function import(Comments $Comments)
$comment['time'],
$comment['source'],
$comment['sourceIcon'],
$comment['id']
$comment['id'],
$comment['objectHash'] ?? '',
);
}
......
......@@ -9,6 +9,7 @@
use QUI;
use QUI\ERP\Accounting\Offers\Handler as OfferHandler;
use QUI\ERP\Purchasing\Processes\Handler as PurchasingHandler;
use QUI\ERP\SalesOrders\Handler as SalesOrdersHandler;
use function count;
use function strtotime;
......@@ -133,6 +134,7 @@ public function getCompleteHistory(): Comments
$this->parseOrders($History);
$this->parseOffers($History);
$this->parsePurchasing($History);
$this->parseSalesOrders($History);
try {
QUI::getEvents()->fireEvent('quiqqerErpGetCompleteHistory', [$this, $this->processId]);
......@@ -164,7 +166,9 @@ protected function parseInvoices(Comments $History): void
]),
strtotime($Invoice->getAttribute('date')),
'quiqqer/invoice',
'fa fa-file-text-o'
'fa fa-file-text-o',
false,
$Invoice->getHash()
);
$history = $Invoice->getHistory()->toArray();
......@@ -183,7 +187,8 @@ protected function parseInvoices(Comments $History): void
$entry['time'],
$entry['source'],
$entry['sourceIcon'],
$entry['id']
$entry['id'],
$Invoice->getHash()
);
}
}
......@@ -272,7 +277,8 @@ protected function parseOrders(Comments $History): void
$entry['time'],
$entry['source'],
$entry['sourceIcon'],
$entry['id']
$entry['id'],
$Order->getHash()
);
}
}
......@@ -347,7 +353,9 @@ protected function parseOffers(Comments $History): void
]),
strtotime($Offer->getAttribute('date')),
'quiqqer/offer',
'fa fa-file-text-o'
'fa fa-file-text-o',
false,
$Offer->getHash()
);
$history = $Offer->getHistory()->toArray();
......@@ -366,7 +374,8 @@ protected function parseOffers(Comments $History): void
$entry['time'],
$entry['source'],
$entry['sourceIcon'],
$entry['id']
$entry['id'],
$Offer->getHash()
);
}
}
......@@ -422,7 +431,9 @@ protected function parsePurchasing(Comments $History): void
]),
strtotime($Purchasing->getAttribute('c_date')),
'quiqqer/purchasing',
'fa fa-suitcase'
'fa fa-cart-arrow-down',
false,
$Purchasing->getHash()
);
$history = $Purchasing->getHistory()->toArray();
......@@ -433,7 +444,7 @@ protected function parsePurchasing(Comments $History): void
}
if (empty($entry['sourceIcon'])) {
$entry['sourceIcon'] = 'fa fa-suitcase';
$entry['sourceIcon'] = 'fa fa-cart-arrow-down';
}
$History->addComment(
......@@ -441,7 +452,8 @@ protected function parsePurchasing(Comments $History): void
$entry['time'],
$entry['source'],
$entry['sourceIcon'],
$entry['id']
$entry['id'],
$Purchasing->getHash()
);
}
}
......@@ -483,6 +495,83 @@ public function getPurchasing(): array
//endregion
//region sales orders / Aufträge
protected function parseSalesOrders(Comments $History): void
{
// orders
$salesOrders = $this->getSalesOrders();
foreach ($salesOrders as $SalesOrder) {
$History->addComment(
QUI::getLocale()->get('quiqqer/erp', 'process.history.salesorders.created', [
'hash' => $SalesOrder->getHash()
]),
strtotime($SalesOrder->getAttribute('c_date')),
'quiqqer/salesorders',
'fa fa-suitcase',
false,
$SalesOrder->getHash()
);
$history = $SalesOrder->getHistory()->toArray();
foreach ($history as $entry) {
if (empty($entry['source'])) {
$entry['source'] = 'quiqqer/salesorders';
}
if (empty($entry['sourceIcon'])) {
$entry['sourceIcon'] = 'fa fa-suitcase';
}
$History->addComment(
$entry['message'],
$entry['time'],
$entry['source'],
$entry['sourceIcon'],
$entry['id'],
$SalesOrder->getHash()
);
}
}
}
/**
* @return QUI\ERP\Purchasing\Processes\PurchasingProcess[]
*/
public function getSalesOrders(): array
{
if (!QUI::getPackageManager()->isInstalled('quiqqer/salesorders')) {
return [];
}
try {
$salesOrders = QUI::getDatabase()->fetch([
'select' => 'id,hash,global_process_id,date',
'from' => SalesOrdersHandler::getTableSalesOrders(),
'where_or' => [
'global_process_id' => $this->processId,
'hash' => $this->processId
]
]);
} catch (\Exception) {
return [];
}
$result = [];
foreach ($salesOrders as $salesOrder) {
try {
$result[] = SalesOrdersHandler::getSalesOrder($salesOrder['id']);
} catch (\Exception) {
}
}
return $result;
}
//endregion
//region transactions
/**
......
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