From 1b48fdaa007331d51a0fcc1ab5af1bcd4329de92 Mon Sep 17 00:00:00 2001 From: Mootfrost777 Date: Wed, 7 Dec 2022 16:30:28 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A3=D1=80=D0=B0,=20=D1=83=D1=80=D0=B0,=20?= =?UTF-8?q?=D1=83=D1=80=D0=B0,=20=D1=8F=20=D0=BD=D0=B0=D1=88=D0=B5=D0=BB?= =?UTF-8?q?=20=D0=B2=D1=80=D0=B5=D0=BC=D1=8F.=20=D0=94=D0=BE=D0=B1=D0=B0?= =?UTF-8?q?=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5,=20=D1=83=D0=B4=D0=B0?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5.=20edit=20=D0=BF=D0=BE=D1=87?= =?UTF-8?q?=D0=B5=D0=BC=D1=83-=D1=82=D0=BE=20=D0=BF=D0=BE=D0=BB=D1=83?= =?UTF-8?q?=D1=87=D0=B0=D0=B5=D1=82=20=D0=BD=D0=B8=D1=87=D0=B5=D0=B3=D0=BE?= =?UTF-8?q?=20=D0=B2=D0=BC=D0=B5=D1=81=D1=82=D0=BE=20note.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 31 +++++++++++++++++++++++++++---- src/components/Edit.vue | 8 ++++++-- src/components/Item.vue | 12 +++++++----- src/main.ts | 1 + src/models/Note.ts | 11 +++++++++++ tsconfig.json | 3 ++- 6 files changed, 54 insertions(+), 12 deletions(-) create mode 100644 src/models/Note.ts diff --git a/src/App.vue b/src/App.vue index eaf52cd..773ff76 100644 --- a/src/App.vue +++ b/src/App.vue @@ -2,16 +2,39 @@ import { ref } from 'vue' import Item from "./components/Item.vue"; import Edit from "./components/Edit.vue"; +import { Note } from "./models/Note"; -const items = ref([{title: 'Item 1'}, {title: 'Item 2'}, {title: 'Item 3'}]) +const notes = ref([new Note(undefined, 'Make SUS'), new Note(undefined, 'аырофщшгвыпгыфа')]) +const currentNote = ref(new Note()) + +function processNote(note: Note) { + const index = notes.value.findIndex((item) => item.id === note.id) + if (index !== -1) { + notes.value[index] = note + } + else { + notes.value.push(note) + } +} + +function deleteNote(note: Note) { + notes.value = notes.value.filter((item) => item.id !== note.id) +} + +function editNote(note: Note) { + currentNote.value = note +}