diff --git a/.changes/unreleased/Fixed-20240416-161817.yaml b/.changes/unreleased/Fixed-20240416-161817.yaml new file mode 100644 index 000000000..6884c11fe --- /dev/null +++ b/.changes/unreleased/Fixed-20240416-161817.yaml @@ -0,0 +1,6 @@ +kind: Fixed +body: Fix broken link in homepage when a evaluation from a closed acc period was present + in the homepage widget +time: 2024-04-16T16:18:17.888645172+02:00 +custom: + Issue: "270" diff --git a/.changes/v2.18.2.md b/.changes/v2.18.2.md new file mode 100644 index 000000000..42eff9e25 --- /dev/null +++ b/.changes/v2.18.2.md @@ -0,0 +1,3 @@ +## v2.18.2 - 2024-04-12 +### Fixed +* ([#250](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/250)) Postal codes import : fix the source URL and the keys to handle each record diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c0a6b008..ae9407c8a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html), and is generated by [Changie](https://github.com/miniscruff/changie). +## v2.18.2 - 2024-04-12 +### Fixed +* ([#250](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/250)) Postal codes import : fix the source URL and the keys to handle each record + ## v2.18.1 - 2024-03-26 ### Fixed * Fix layout issue in document generation for admin (minor) diff --git a/docs/source/installation/load-addresses.rst b/docs/source/installation/load-addresses.rst index 779032fd0..85c29d618 100644 --- a/docs/source/installation/load-addresses.rst +++ b/docs/source/installation/load-addresses.rst @@ -8,6 +8,16 @@ Chill can store a list of geolocated address references, which are used to sugge Those addresses may be load from a dedicated source. +Countries +========= + +In order to load addresses into the chill application we first have to make sure that a list of countries is present. +To import the countries run the following command. + +.. code-block:: bash + + bin/console chill:main:countries:populate + In France ========= diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/Entity/UserRenderBoxBadge.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/Entity/UserRenderBoxBadge.vue index a9c2db9b4..7655f5878 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/Entity/UserRenderBoxBadge.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/Entity/UserRenderBoxBadge.vue @@ -1,6 +1,7 @@ diff --git a/src/Bundle/ChillMainBundle/Service/Import/PostalCodeFRFromOpenData.php b/src/Bundle/ChillMainBundle/Service/Import/PostalCodeFRFromOpenData.php index a7998af44..8893181a8 100644 --- a/src/Bundle/ChillMainBundle/Service/Import/PostalCodeFRFromOpenData.php +++ b/src/Bundle/ChillMainBundle/Service/Import/PostalCodeFRFromOpenData.php @@ -23,7 +23,7 @@ use Symfony\Contracts\HttpClient\HttpClientInterface; */ class PostalCodeFRFromOpenData { - private const CSV = 'https://datanova.laposte.fr/data-fair/api/v1/datasets/laposte-hexasmal/data-files/019HexaSmal.csv'; + private const CSV = 'https://datanova.laposte.fr/data-fair/api/v1/datasets/laposte-hexasmal/metadata-attachments/base-officielle-codes-postaux.csv'; public function __construct(private readonly PostalCodeBaseImporter $baseImporter, private readonly HttpClientInterface $client, private readonly LoggerInterface $logger) {} @@ -48,7 +48,7 @@ class PostalCodeFRFromOpenData fseek($tmpfile, 0); $csv = Reader::createFromStream($tmpfile); - $csv->setDelimiter(';'); + $csv->setDelimiter(','); $csv->setHeaderOffset(0); foreach ($csv as $offset => $record) { @@ -63,23 +63,23 @@ class PostalCodeFRFromOpenData private function handleRecord(array $record): void { - if ('' !== trim($record['coordonnees_geographiques'] ?? $record['coordonnees_gps'])) { - [$lat, $lon] = array_map(static fn ($el) => (float) trim($el), explode(',', $record['coordonnees_geographiques'] ?? $record['coordonnees_gps'])); + if ('' !== trim((string) $record['_geopoint'])) { + [$lat, $lon] = array_map(static fn ($el) => (float) trim($el), explode(',', (string) $record['_geopoint'])); } else { $lat = $lon = 0.0; } - $ref = trim((string) $record['Code_commune_INSEE']); + $ref = trim((string) $record['code_commune_insee']); if (str_starts_with($ref, '987')) { // some differences in French Polynesia - $ref .= '.'.trim((string) $record['Libellé_d_acheminement']); + $ref .= '.'.trim((string) $record['libelle_d_acheminement']); } $this->baseImporter->importCode( 'FR', - trim((string) $record['Libellé_d_acheminement']), - trim((string) $record['Code_postal']), + trim((string) $record['libelle_d_acheminement']), + trim((string) $record['code_postal']), $ref, 'INSEE', $lat, diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationRepository.php index 9c6ed19fc..6110f8bb0 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationRepository.php @@ -12,6 +12,7 @@ declare(strict_types=1); namespace Chill\PersonBundle\Repository\AccompanyingPeriod; use Chill\MainBundle\Entity\User; +use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork; use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation; use Doctrine\ORM\EntityManagerInterface; @@ -88,6 +89,7 @@ class AccompanyingPeriodWorkEvaluationRepository implements ObjectRepository ->where( $qb->expr()->andX( $qb->expr()->isNull('e.endDate'), + $qb->expr()->neq('period.step', ':closed'), $qb->expr()->gte(':now', $qb->expr()->diff('e.maxDate', 'e.warningInterval')), $qb->expr()->orX( $qb->expr()->eq('period.user', ':user'), @@ -100,6 +102,7 @@ class AccompanyingPeriodWorkEvaluationRepository implements ObjectRepository ->setParameters([ 'user' => $user, 'now' => new \DateTimeImmutable('now'), + 'closed' => AccompanyingPeriod::STEP_CLOSED, ]); return $qb; diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/PersonsAssociated.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/PersonsAssociated.vue index 7762ed29e..62f094920 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/PersonsAssociated.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/PersonsAssociated.vue @@ -3,10 +3,10 @@

{{ $t('persons_associated.title')}}

- +
- +
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Resources.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Resources.vue index 7287437a3..78da9ade8 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Resources.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Resources.vue @@ -4,10 +4,10 @@

{{ $t('resources.title')}}

- +
- +
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/components/Household.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/components/Household.vue index c9b1b8f8a..9e129a4e3 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/components/Household.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/HouseholdMembersEditor/components/Household.vue @@ -23,7 +23,7 @@ data-bs-toggle="collapse" aria-expanded="false" @click="toggleHouseholdSuggestion"> - {{ $tc('household_members_editor.show_household_suggestion', countHouseholdSuggestion) }} + {{ $t('household_members_editor.show_household_suggestion', { count: countHouseholdSuggestion }) }}
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonRenderBox.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonRenderBox.vue index 100dc9caf..2bd09eb1c 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonRenderBox.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonRenderBox.vue @@ -52,9 +52,7 @@ {{ $t('renderbox.deathdate') + ' ' + deathdate }} - {{ - $tc('renderbox.years_old', person.age) - }} + {{ $t('renderbox.years_old', { n: person.age }) }}

diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonText.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonText.vue index 8b991e3da..040a14327 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonText.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonText.vue @@ -7,7 +7,7 @@ ({{ altNameLabel }})  {{ person.suffixText }} - {{ $tc('renderbox.years_old', person.age) }} + {{ $t('renderbox.years_old', { n: person.age }) }}  (‡) diff --git a/src/Bundle/ChillTicketBundle/src/Entity/Ticket.php b/src/Bundle/ChillTicketBundle/src/Entity/Ticket.php index 04cfe828b..9fc4d6a15 100644 --- a/src/Bundle/ChillTicketBundle/src/Entity/Ticket.php +++ b/src/Bundle/ChillTicketBundle/src/Entity/Ticket.php @@ -69,6 +69,13 @@ class Ticket implements TrackCreationInterface, TrackUpdateInterface #[ORM\OneToMany(targetEntity: PersonHistory::class, mappedBy: 'ticket')] private Collection $personHistories; + #[ORM\ManyToOne(targetEntity: User::class)] + #[ORM\JoinColumn(nullable: true)] + private ?User $updatedBy = null; + + #[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE, nullable: true)] + private ?\DateTimeImmutable $createdAt = null; + public function __construct() { $this->addresseeHistory = new ArrayCollection(); @@ -76,6 +83,7 @@ class Ticket implements TrackCreationInterface, TrackUpdateInterface $this->motiveHistories = new ArrayCollection(); $this->personHistories = new ArrayCollection(); $this->inputHistories = new ArrayCollection(); + } public function getId(): ?int @@ -211,4 +219,16 @@ class Ticket implements TrackCreationInterface, TrackUpdateInterface { return $this->addresseeHistory; } + + public function getCreatedAt(): \DateTimeImmutable + { + return $this->createdAt; + } + + public function getUpdatedBy(): ?User + { + return $this->updatedBy; + } + + } diff --git a/src/Bundle/ChillTicketBundle/src/Resources/public/types.ts b/src/Bundle/ChillTicketBundle/src/Resources/public/types.ts index 0bcd1ecbb..5ff90bc42 100644 --- a/src/Bundle/ChillTicketBundle/src/Resources/public/types.ts +++ b/src/Bundle/ChillTicketBundle/src/Resources/public/types.ts @@ -2,10 +2,9 @@ import { DateTime, TranslatableString, User, - UserGroup, UserGroupOrUser } from "../../../../ChillMainBundle/Resources/public/types"; -import {Person} from "../../../../ChillPersonBundle/Resources/public/types"; +import { Person } from "../../../../ChillPersonBundle/Resources/public/types"; export interface Motive { type: "ticket_motive" @@ -21,7 +20,7 @@ interface TicketHistory { data: D } -interface PersonHistory { +export interface PersonHistory { type: "ticket_person_history", id: number, startDate: DateTime, @@ -32,7 +31,7 @@ interface PersonHistory { createdAt: DateTime|null } -interface MotiveHistory { +export interface MotiveHistory { type: "ticket_motive_history", id: number, startDate: null, @@ -42,7 +41,7 @@ interface MotiveHistory { createdAt: DateTime|null, } -interface Comment { +export interface Comment { type: "ticket_comment", id: number, content: string, @@ -52,7 +51,7 @@ interface Comment { updatedAt: DateTime|null, } -interface AddresseeHistory { +export interface AddresseeHistory { type: "ticket_addressee_history", id: number, startDate: DateTime|null, @@ -69,8 +68,9 @@ interface AddPersonEvent extends TicketHistory<"add_person", PersonHistory> {}; interface AddCommentEvent extends TicketHistory<"add_comment", Comment> {}; interface SetMotiveEvent extends TicketHistory<"set_motive", MotiveHistory> {}; interface AddAddressee extends TicketHistory<"add_addressee", AddresseeHistory> {}; +interface RemoveAddressee extends TicketHistory<"remove_addressee", AddresseeHistory> {}; -type TicketHistoryLine = AddPersonEvent | AddCommentEvent | SetMotiveEvent | AddAddressee; +type TicketHistoryLine = AddPersonEvent | AddCommentEvent | SetMotiveEvent | AddAddressee | RemoveAddressee; export interface Ticket { type: "ticket_ticket", @@ -80,5 +80,7 @@ export interface Ticket { currentPersons: Person[], currentMotive: null|Motive, history: TicketHistoryLine[], + createdAt: DateTime|null, + updatedBy: User|null, } diff --git a/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/App.vue b/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/App.vue index b6e28952e..305e22896 100644 --- a/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/App.vue +++ b/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/App.vue @@ -1,59 +1,161 @@ - - + diff --git a/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/components/ActionToolbarComponent.vue b/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/components/ActionToolbarComponent.vue new file mode 100644 index 000000000..818a46536 --- /dev/null +++ b/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/components/ActionToolbarComponent.vue @@ -0,0 +1,191 @@ + + + + diff --git a/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/components/AddresseeSelectorComponent.vue b/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/components/AddresseeSelectorComponent.vue new file mode 100644 index 000000000..36e6d64a6 --- /dev/null +++ b/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/components/AddresseeSelectorComponent.vue @@ -0,0 +1,215 @@ + + + + + diff --git a/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/components/MotiveSelectorComponent.vue b/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/components/MotiveSelectorComponent.vue new file mode 100644 index 000000000..c7f7f9b03 --- /dev/null +++ b/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/components/MotiveSelectorComponent.vue @@ -0,0 +1,56 @@ + + + + + diff --git a/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/components/TicketHistoryAddresseeComponent.vue b/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/components/TicketHistoryAddresseeComponent.vue new file mode 100644 index 000000000..234dfb26f --- /dev/null +++ b/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/components/TicketHistoryAddresseeComponent.vue @@ -0,0 +1,49 @@ + + + + + diff --git a/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/components/TicketHistoryCommentComponent.vue b/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/components/TicketHistoryCommentComponent.vue new file mode 100644 index 000000000..c50c44194 --- /dev/null +++ b/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/components/TicketHistoryCommentComponent.vue @@ -0,0 +1,67 @@ + + + + + diff --git a/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/components/TicketHistoryListComponent.vue b/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/components/TicketHistoryListComponent.vue new file mode 100644 index 000000000..8c301178f --- /dev/null +++ b/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/components/TicketHistoryListComponent.vue @@ -0,0 +1,91 @@ + + + + + diff --git a/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/components/TicketHistoryMotiveComponent.vue b/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/components/TicketHistoryMotiveComponent.vue new file mode 100644 index 000000000..132d782c1 --- /dev/null +++ b/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/components/TicketHistoryMotiveComponent.vue @@ -0,0 +1,30 @@ + + + + + diff --git a/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/components/TicketHistoryPersonComponent.vue b/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/components/TicketHistoryPersonComponent.vue new file mode 100644 index 000000000..f4831205b --- /dev/null +++ b/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/components/TicketHistoryPersonComponent.vue @@ -0,0 +1,35 @@ + + + + + diff --git a/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/components/TicketSelectorComponent.vue b/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/components/TicketSelectorComponent.vue new file mode 100644 index 000000000..2057af898 --- /dev/null +++ b/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/components/TicketSelectorComponent.vue @@ -0,0 +1,41 @@ + + + + + diff --git a/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/i18n/messages.ts b/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/i18n/messages.ts index 4065765f3..7175a7fe3 100644 --- a/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/i18n/messages.ts +++ b/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/i18n/messages.ts @@ -1,5 +1,52 @@ -export const messages = { +import { multiSelectMessages } from "../../../../../../../ChillMainBundle/Resources/public/vuejs/_js/i18n"; +import { personMessages } from "../../../../../../../ChillPersonBundle/Resources/public/vuejs/_js/i18n"; + +const messages = { fr: { - hello: "Bonjour {name}" - } + ticket: { + previous_tickets: "Précédents tickets", + }, + history: { + person: "Ouverture par appel téléphonique de {person}", + user: "Prise en charge par {username}", + motive: "Motif indiqué: {motive}", + comment: "Commentaire", + add_addressee_user_group: "Groupe {user_group} transferé", + remove_addressee_user_group: "Groupe {user_group} retiré", + add_addressee_user: " Utilisateur {user} Transferé", + remove_addressee_user: "Utilisateur {user} retiré", + }, + comment: { + title: "Commentaire", + label: "Ajouter un commentaire", + save: "Enregistrer", + succcess: "Commentaire enregistré", + content: "Ajouter un commentaire", + }, + motive: { + title: "Motif", + label: "Choisir un motif", + save: "Enregistrer", + success: "Motif enregistré", + }, + transfert: { + title: "Transfert", + user_group_label: "Transferer vers un groupe", + user_label: "Transferer vers un ou plusieurs utilisateurs", + save: "Enregistrer", + success: "Transfert effectué", + }, + close: "Fermer", + banner: { + concerned_patient: "Patient concerné", + caller: "Appelant", + speaker: "Intervenant", + open: "Ouvert", + since: "Aucun jour | Depuis 1 jour | Depuis {count} jours", + no_motive: "Pas de motif", + }, + }, }; +Object.assign(messages.fr, multiSelectMessages.fr); +Object.assign(messages.fr, personMessages.fr); +export default messages; diff --git a/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/index.ts b/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/index.ts index c63968469..753bd6ced 100644 --- a/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/index.ts +++ b/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/index.ts @@ -2,12 +2,12 @@ import App from './App.vue'; import {createApp} from "vue"; import { _createI18n } from "../../../../../../ChillMainBundle/Resources/public/vuejs/_js/i18n"; -import {messages} from "./i18n/messages"; import VueToast from 'vue-toast-notification'; import 'vue-toast-notification/dist/theme-sugar.css'; import { store } from "./store"; +import messages from './i18n/messages'; declare global { interface Window { @@ -15,7 +15,7 @@ declare global { } } -const i18n = _createI18n(messages); +const i18n = _createI18n(messages, false); const _app = createApp({ template: '', diff --git a/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/store/index.ts b/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/store/index.ts index b26eaa611..61c13b9b9 100644 --- a/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/store/index.ts +++ b/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/store/index.ts @@ -1,15 +1,22 @@ import { createStore } from "vuex"; import { State as MotiveStates, moduleMotive } from "./modules/motive"; import { State as TicketStates, moduleTicket } from "./modules/ticket"; +import { State as CommentStates, moduleComment } from "./modules/comment"; +import { State as UserStates, moduleUser } from "./modules/user"; export type RootState = { motive: MotiveStates; ticket: TicketStates; + comment: CommentStates; + user: UserStates; }; export const store = createStore({ modules: { motive:moduleMotive, ticket:moduleTicket, + comment:moduleComment, + user:moduleUser, + } }); diff --git a/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/store/modules/comment.ts b/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/store/modules/comment.ts new file mode 100644 index 000000000..b457e4e23 --- /dev/null +++ b/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/store/modules/comment.ts @@ -0,0 +1,40 @@ +import { + fetchResults, + makeFetch, +} from "../../../../../../../../ChillMainBundle/Resources/public/lib/api/apiMethods"; + +import { Module } from "vuex"; +import { RootState } from ".."; + +import { Comment } from "../../../../types"; + +export interface State { + comments: Array; +} + +export const moduleComment: Module = { + state: () => ({ + comments: [] as Array, + }), + getters: {}, + mutations: {}, + actions: { + async createComment( + { commit }, + datas: { ticketId: number; content: Comment["content"] } + ) { + const { ticketId, content } = datas; + try { + const result = await makeFetch( + "POST", + `/api/1.0/ticket/${ticketId}/comment/add`, + { content } + ); + commit("setTicket", result); + } + catch(e: any) { + throw e.name; + } + }, + }, +}; diff --git a/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/store/modules/motive.ts b/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/store/modules/motive.ts index 88d6091ba..1c2696106 100644 --- a/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/store/modules/motive.ts +++ b/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/store/modules/motive.ts @@ -1,4 +1,7 @@ -import { fetchResults, makeFetch } from "../../../../../../../../ChillMainBundle/Resources/public/lib/api/apiMethods"; +import { + fetchResults, + makeFetch, +} from "../../../../../../../../ChillMainBundle/Resources/public/lib/api/apiMethods"; import { Module } from "vuex"; import { RootState } from ".."; @@ -9,31 +12,52 @@ export interface State { motives: Array; } -export const moduleMotive: Module ={ +export const moduleMotive: Module = { state: () => ({ motives: [] as Array, }), getters: { getMotives(state) { return state.motives; - } + }, }, mutations: { setMotives(state, motives) { state.motives = motives; - } + }, }, actions: { async fetchMotives({ commit }) { - const results = await fetchResults("/api/1.0/ticket/motive.json") as Motive[]; - commit("setMotives", results); - return results; + try { + const results = (await fetchResults( + "/api/1.0/ticket/motive.json" + )) as Motive[]; + commit("setMotives", results); + } catch (e: any) { + throw e.name; + } + }, + + async createMotive( + { commit }, + datas: { ticketId: number; motive: Motive } + ) { + const { ticketId, motive } = datas; + try { + const result = await makeFetch( + "POST", + `/api/1.0/ticket/${ticketId}/motive/set`, + { + motive: { + id: motive.id, + type: motive.type, + }, + } + ); + commit("setTicket", result); + } catch (e: any) { + throw e.name; + } }, - async createMotive({ commit }, datas: {currentMotiveId: number, motive: Motive}) { - const { currentMotiveId, motive } = datas; - const result = await makeFetch("POST", `/api/1.0/ticket/${currentMotiveId}/motive/set`, motive); - commit("setMotives", result); - return result; - } }, }; diff --git a/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/store/modules/ticket.ts b/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/store/modules/ticket.ts index 4e3a55762..f3db197c2 100644 --- a/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/store/modules/ticket.ts +++ b/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/store/modules/ticket.ts @@ -1,5 +1,3 @@ -import { fetchResults, makeFetch } from "../../../../../../../../ChillMainBundle/Resources/public/lib/api/apiMethods"; - import { Module } from "vuex"; import { RootState } from ".."; @@ -16,7 +14,24 @@ export const moduleTicket: Module ={ getters: { getTicket(state) { return state.ticket; - } + }, + getDistinctAddressesHistory(state) { + const addresseeHistory = state.ticket.history.reduce((result, item) => { + const { datetime } = item.at; + if (!["add_addressee","remove_addressee"].includes(item.event_type)) { + result[datetime] = item + return result; + } + + if (!result[datetime]) { + result[datetime] = []; + } + result[datetime].push(item); + return result; + }, {} as any); + return Object.values(addresseeHistory) as Array; + } + }, mutations: { setTicket(state, ticket) { diff --git a/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/store/modules/user.ts b/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/store/modules/user.ts new file mode 100644 index 000000000..f4441e34b --- /dev/null +++ b/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/store/modules/user.ts @@ -0,0 +1,84 @@ +import { + fetchResults, + makeFetch, +} from "../../../../../../../../ChillMainBundle/Resources/public/lib/api/apiMethods"; + +import { Module } from "vuex"; +import { RootState } from ".."; + +import { + User, + UserGroup, + UserGroupOrUser, +} from "../../../../../../../../ChillMainBundle/Resources/public/types"; + +export interface State { + userGroups: Array; + users: Array; +} + +export const moduleUser: Module = { + state: () => ({ + userGroups: [] as Array, + users: [] as Array, + }), + getters: { + getUserGroups(state) { + return state.userGroups; + }, + getUsers(state) { + return state.users; + }, + }, + mutations: { + setUserGroups(state, userGroups) { + state.userGroups = userGroups; + }, + setUsers(state, users) { + state.users = users; + }, + }, + actions: { + fetchUserGroups({ commit }) { + try { + fetchResults("/api/1.0/main/user-group.json").then( + (results) => { + commit("setUserGroups", results); + } + ); + } catch (e: any) { + throw e.name; + } + }, + fetchUsers({ commit }) { + try { + fetchResults("/api/1.0/main/user.json").then((results) => { + commit("setUsers", results); + }); + } catch (e: any) { + throw e.name; + } + }, + + async setAdressees( + { commit }, + datas: { ticketId: number; addressees: Array } + ) { + const { ticketId, addressees } = datas; + try { + const result = await makeFetch( + "POST", + `/api/1.0/ticket/${ticketId}/addressees/set`, + { + addressees: addressees.map((addressee) => { + return { id: addressee.id, type: addressee.type }; + }), + } + ); + commit("setTicket", result); + } catch (e: any) { + throw e.name; + } + }, + }, +}; diff --git a/src/Bundle/ChillTicketBundle/src/Resources/views/Banner/banner.html.twig b/src/Bundle/ChillTicketBundle/src/Resources/views/Banner/banner.html.twig index f7263b387..5a33f7fc2 100644 --- a/src/Bundle/ChillTicketBundle/src/Resources/views/Banner/banner.html.twig +++ b/src/Bundle/ChillTicketBundle/src/Resources/views/Banner/banner.html.twig @@ -1,24 +1,8 @@ -