diff --git a/src/Bundle/ChillTicketBundle/src/Resources/public/types.ts b/src/Bundle/ChillTicketBundle/src/Resources/public/types.ts index 5fdabec3a..2c347977c 100644 --- a/src/Bundle/ChillTicketBundle/src/Resources/public/types.ts +++ b/src/Bundle/ChillTicketBundle/src/Resources/public/types.ts @@ -21,7 +21,7 @@ interface TicketHistory { data: D } -interface PersonHistory { +export interface PersonHistory { type: "ticket_person_history", id: number, startDate: DateTime, @@ -32,7 +32,7 @@ interface PersonHistory { createdAt: DateTime|null } -interface MotiveHistory { +export interface MotiveHistory { type: "ticket_motive_history", id: number, startDate: null, @@ -42,7 +42,7 @@ interface MotiveHistory { createdAt: DateTime|null, } -interface Comment { +export interface Comment { type: "ticket_comment", id: number, content: string, 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 da1c60d2e..b993caa2f 100644 --- a/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/App.vue +++ b/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/App.vue @@ -1,5 +1,5 @@ @@ -34,10 +28,22 @@ import { PropType, defineComponent } from 'vue'; import { DateTime } from '../../../../../../../ChillMainBundle/Resources/public/types'; + +// Types import { Ticket } from '../../../types'; +// Components +import TicketHistoryPersonComponent from './TicketHistoryPersonComponent.vue'; +import TicketHistoryMotiveComponent from './TicketHistoryMotiveComponent.vue'; +import TicketHistoryCommentComponent from './TicketHistoryCommentComponent.vue'; + export default defineComponent({ name: 'TicketHistoryListComponent', + components: { + TicketHistoryPersonComponent, + TicketHistoryMotiveComponent, + TicketHistoryCommentComponent, + }, props: { history: { type: Array as PropType, @@ -46,11 +52,10 @@ export default defineComponent({ }, setup() { - function formatDate(d: DateTime) { const date = new Date(d.datetime); const month = date.toLocaleString('default', { month: 'long' }); - return `${date.getDate()} ${month} ${date.getFullYear()}, ${date.getHours()}:${date.getMinutes()}` + return `${date.getDate()} ${month} ${date.getFullYear()}, ${date.toLocaleTimeString()}` } return { formatDate } 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..6ecd96039 --- /dev/null +++ b/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/components/TicketHistoryPersonComponent.vue @@ -0,0 +1,29 @@ + + + + + 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 index bfab4dfb8..ff291a11c 100644 --- a/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/components/TicketSelectorComponent.vue +++ b/src/Bundle/ChillTicketBundle/src/Resources/public/vuejs/TicketApp/components/TicketSelectorComponent.vue @@ -1,5 +1,5 @@ @@ -32,7 +27,10 @@ export default defineComponent({ }, }, setup() { - return {} + function handleClick() { + alert('Sera disponible plus tard') + } + return { handleClick } } }); 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 3b678559b..f1605c4a5 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,27 +1,36 @@ -export const messages = { +import { multiSelectMessages } from"../../../../../../../ChillMainBundle/Resources/public/vuejs/_js/i18n"; + +const messages = { fr: { ticket: { previous_tickets: "Précédents tickets", }, history: { - person: "Ouverture par appel téléphonique de {text}", + person: "Ouverture par appel téléphonique de {person}", user: "Prise en charge par {username}", motive: "Motif indiqué: {motive}", + comment: "Commentaire: {comment}", }, comment: { title: "Commentaire", label: "Ajouter un commentaire", save: "Enregistrer", + succcess: "Commentaire enregistré", }, motive: { title: "Motif", - label: "Ajouter un motif", + label: "Choisir un motif", save: "Enregistrer", + success: "Motif enregistré", }, transfert: { title: "Transfert", label: "Transferer vers", save: "Enregistrer", + success: "Transfert effectué", }, + close: "Fermer" }, }; +Object.assign(messages.fr, multiSelectMessages.fr); +export default messages; 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..82dd600a9 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,19 @@ 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"; export type RootState = { motive: MotiveStates; ticket: TicketStates; + comment: CommentStates; }; export const store = createStore({ modules: { motive:moduleMotive, ticket:moduleTicket, + comment:moduleComment, + } }); 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..296301fc2 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,55 @@ export interface State { motives: Array; } -export const moduleMotive: Module ={ +export const moduleMotive: Module = { state: () => ({ motives: [] as Array, }), getters: { getMotives(state) { return state.motives; - } + }, + getMotiveOptions(state) { + return state.motives.map((motive) => ({ + value: motive.id, + text: motive.label.fr, + })); + }, }, 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 } + ); + 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/views/Banner/banner.html.twig b/src/Bundle/ChillTicketBundle/src/Resources/views/Banner/banner.html.twig index ab53626b2..c8a7ff724 100644 --- a/src/Bundle/ChillTicketBundle/src/Resources/views/Banner/banner.html.twig +++ b/src/Bundle/ChillTicketBundle/src/Resources/views/Banner/banner.html.twig @@ -7,7 +7,14 @@ #{{ ticket.getExternalRef() }}

- {{ticket.getMotive()}} + {% if ticket.getMotive() %} + {{ ticket.getMotive().label.fr }} + {% else %} + {{ ticket.getMotive() }} +

+ {{ "no_motive"|trans }} +

+ {% endif %}

diff --git a/src/Bundle/ChillTicketBundle/translations/messages.fr.yaml b/src/Bundle/ChillTicketBundle/translations/messages.fr.yaml index 6f2c57afa..bcc75537e 100644 --- a/src/Bundle/ChillTicketBundle/translations/messages.fr.yaml +++ b/src/Bundle/ChillTicketBundle/translations/messages.fr.yaml @@ -3,3 +3,4 @@ caller: Appelant speaker: Intervenant open: Ouvert since: Depuis +no_motive: Pas de motif