start linking notification to project based of project page UUID
This commit is contained in:
parent
5f734ab45b
commit
8c6e21c707
4 changed files with 23 additions and 8 deletions
|
|
@ -5,19 +5,22 @@ use Kirby;
|
||||||
|
|
||||||
class ProjectDetails
|
class ProjectDetails
|
||||||
{
|
{
|
||||||
public string $title;
|
private string $title;
|
||||||
public string $uri;
|
private string $uri;
|
||||||
|
private string $uuid;
|
||||||
|
|
||||||
public function __construct(Kirby\Cms\Page $page)
|
public function __construct(Kirby\Cms\Page $page)
|
||||||
{
|
{
|
||||||
$this->title = (string) $page->title();
|
$this->title = (string) $page->title();
|
||||||
$this->uri = (string) $page->uri();
|
$this->uri = (string) $page->uri();
|
||||||
|
$this->uuid = (string) $page->uuid();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function toArray() {
|
public function toArray() {
|
||||||
return [
|
return [
|
||||||
"title" => $this->title,
|
"title" => $this->title,
|
||||||
"uri" => $this->uri
|
"uri" => $this->uri,
|
||||||
|
"uuid" => $this->uuid,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,8 @@ function getProjectData($project) {
|
||||||
'currentStep' => $project->currentStep()->value(),
|
'currentStep' => $project->currentStep()->value(),
|
||||||
'status' => $project->status(),
|
'status' => $project->status(),
|
||||||
'logo' => $project->client()->toPage() ? $project->client()->toPage()->logo()->toFile()->url() : '',
|
'logo' => $project->client()->toPage() ? $project->client()->toPage()->logo()->toFile()->url() : '',
|
||||||
'steps' => $project->getSteps()
|
'steps' => $project->getSteps(),
|
||||||
|
"uuid" => (string) $project->uuid()
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,9 +12,10 @@
|
||||||
data-icon="comment"
|
data-icon="comment"
|
||||||
>Commentaire</strong
|
>Commentaire</strong
|
||||||
>
|
>
|
||||||
<span class="notification__client | text-grey-700">{{
|
<span class="notification__client | text-grey-700"
|
||||||
notification.location.project.title
|
>{{ project.title }}
|
||||||
}}</span>
|
{{ project?.status === "unlisted" ? "(archivé)" : "" }}</span
|
||||||
|
>
|
||||||
<time
|
<time
|
||||||
datetime=""
|
datetime=""
|
||||||
class="notification__date | text-grey-700 | ml-auto"
|
class="notification__date | text-grey-700 | ml-auto"
|
||||||
|
|
@ -39,8 +40,12 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { useRouter } from "vue-router";
|
import { useRouter } from "vue-router";
|
||||||
import { useNotificationsStore } from "../../stores/notifications";
|
import { useNotificationsStore } from "../../stores/notifications";
|
||||||
|
import { useProjectsStore } from "../../stores/projects";
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { notification } = defineProps({ notification: Object });
|
const { notification } = defineProps({ notification: Object });
|
||||||
const { formatDate } = useNotificationsStore();
|
const { formatDate } = useNotificationsStore();
|
||||||
|
const { getProjectByUuid } = useProjectsStore();
|
||||||
|
|
||||||
|
const project = getProjectByUuid(notification.location.project.uuid);
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -17,5 +17,11 @@ export const useProjectsStore = defineStore("projects", () => {
|
||||||
.fetchData("projects")
|
.fetchData("projects")
|
||||||
.then((json) => (projects.value = json.page.children));
|
.then((json) => (projects.value = json.page.children));
|
||||||
|
|
||||||
return { projects, currentProjects, archivedProjects };
|
// Functions
|
||||||
|
function getProjectByUuid(uuid) {
|
||||||
|
const project = projects.value.find((project) => project.uuid === uuid);
|
||||||
|
return project;
|
||||||
|
}
|
||||||
|
|
||||||
|
return { projects, currentProjects, archivedProjects, getProjectByUuid };
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue