diff --git a/class/Cost/Cost.php b/class/Cost/Cost.php index 6b31fc6..51ae499 100644 --- a/class/Cost/Cost.php +++ b/class/Cost/Cost.php @@ -34,4 +34,9 @@ public function getAddedOn():string { public function getDateFormatted():string { return $this->date->format("jS M Y"); } + + #[BindGetter] + public function getDateValue():string { + return $this->date->format("Y-m-d"); + } } diff --git a/page/_component/cost-editor.html b/page/_component/cost-editor.html index b82a7b7..9976464 100644 --- a/page/_component/cost-editor.html +++ b/page/_component/cost-editor.html @@ -1,7 +1,7 @@
diff --git a/page/_component/cost-editor.php b/page/_component/cost-editor.php index 68d7bdc..a2ee645 100644 --- a/page/_component/cost-editor.php +++ b/page/_component/cost-editor.php @@ -29,8 +29,8 @@ function go( $document->querySelector("select[name=artist]"), ); - $artistId = $input->getString("artist"); $id = $dynamicPath->get("cost"); + $artistId = $input->getString("artist"); $cost = null; if($id === "_new") { @@ -42,7 +42,9 @@ function go( else { $cost = $costRepository->getById($id); $binder->bindData($cost); - $artistId = $cost->product->artist->id; + if(!$artistId) { + $artistId = $cost->product->artist->id; + } } if($artistId) { @@ -58,7 +60,7 @@ function go( } } - $binder->bindKeyValue("date", date("Y-m-d")); + $binder->bindKeyValue("dateValue", date("Y-m-d")); } function do_set_artist(Input $input, Response $response, Uri $uri):void { diff --git a/page/_component/cost-table.html b/page/_component/cost-table.html index 1599928..6d9cc50 100644 --- a/page/_component/cost-table.html +++ b/page/_component/cost-table.html @@ -39,7 +39,7 @@ - + Artist Name Product Title 0.00 diff --git a/page/_component/cost-table.php b/page/_component/cost-table.php index 8a84449..fc1b9f3 100644 --- a/page/_component/cost-table.php +++ b/page/_component/cost-table.php @@ -1,4 +1,5 @@ bindList($costRepository->getAll($user)); + + if($updatedId = $input->getString("updated")) { + if($updatedElement = $document->querySelector("[data-cost-id='$updatedId']")) { + $updatedElement->classList->add("new"); + } + } } function do_delete( diff --git a/query/Cost/getAllForUser.sql b/query/Cost/getAllForUser.sql index 1dc375a..f84ac51 100644 --- a/query/Cost/getAllForUser.sql +++ b/query/Cost/getAllForUser.sql @@ -25,4 +25,4 @@ where Cost.userId = ? order by - Artist.name, Product.title + Cost.date, Artist.name, Product.title diff --git a/script/page/_common.es6 b/script/page/_common.es6 index e962fbe..4187094 100644 --- a/script/page/_common.es6 +++ b/script/page/_common.es6 @@ -7,4 +7,9 @@ Page.go(function() { Modal.init(); LiveUpdate.init(); Currency.init(); + + let newElement = document.querySelector(".new"); + if(newElement) { + newElement.scrollIntoView({behavior: "smooth"}) + } }); diff --git a/style/component/upload-table.scss b/style/component/upload-table.scss index 879267e..a16eb3e 100644 --- a/style/component/upload-table.scss +++ b/style/component/upload-table.scss @@ -32,14 +32,5 @@ upload-table { } } - - &.new { - @keyframes highlight-new { - from { - background-color: #81df6a; - } - } - animation: highlight-new 2s forwards 1; - } } } diff --git a/style/decorator/data-table.scss b/style/decorator/data-table.scss index 9fa0504..13932e0 100644 --- a/style/decorator/data-table.scss +++ b/style/decorator/data-table.scss @@ -45,4 +45,13 @@ } } } + + .new { + @keyframes highlight-new { + from { + background-color: #81df6a; + } + } + animation: highlight-new 2s forwards 1; + } }