Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-App-Alsijil
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AlekSIS®
Official
AlekSIS-App-Alsijil
Commits
80f43961
Commit
80f43961
authored
9 months ago
by
Julian
Browse files
Options
Downloads
Patches
Plain Diff
Allow deletion of text-based personal notes
parent
8cec13a4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!362
Resolve "Add personal note management dialog in course book"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
aleksis/apps/alsijil/frontend/components/coursebook/personal_notes/TextNote.vue
+96
-36
96 additions, 36 deletions
...rontend/components/coursebook/personal_notes/TextNote.vue
with
96 additions
and
36 deletions
aleksis/apps/alsijil/frontend/components/coursebook/personal_notes/TextNote.vue
+
96
−
36
View file @
80f43961
<
script
>
import
{
createPersonalNotes
,
deletePersonalNotes
,
updatePersonalNotes
,
}
from
"
./personal_notes.graphql
"
;
import
personalNoteRelatedMixin
from
"
./personalNoteRelatedMixin
"
;
import
mutateMixin
from
"
aleksis.core/mixins/mutateMixin.js
"
;
import
DeleteDialog
from
"
aleksis.core/components/generic/dialogs/DeleteDialog.vue
"
;
export
default
{
name
:
"
TextNote
"
,
components
:
{
DeleteDialog
},
mixins
:
[
mutateMixin
,
personalNoteRelatedMixin
],
props
:
{
value
:
{
...
...
@@ -21,43 +24,17 @@ export default {
return
this
.
value
.
note
;
},
set
(
newValue
)
{
const
input
=
(
extras
)
=>
({
input
:
[
{
note
:
newValue
,
...
extras
,
},
],
});
const
updater
=
(
replace
)
=>
(
storedDocumentations
,
incomingPersonalNotes
)
=>
{
const
note
=
incomingPersonalNotes
[
0
];
const
documentation
=
storedDocumentations
.
find
(
(
doc
)
=>
doc
.
id
===
this
.
documentation
.
id
,
);
const
participationStatus
=
documentation
.
participations
.
find
(
(
part
)
=>
part
.
id
===
this
.
participation
.
id
,
);
if
(
replace
)
{
const
index
=
participationStatus
.
notesWithNote
.
findIndex
(
(
n
)
=>
n
.
id
===
this
.
participation
.
id
,
);
participationStatus
.
notesWithNote
.
splice
(
index
,
1
,
note
);
}
else
{
participationStatus
.
notesWithNote
.
push
(
note
);
this
.
$emit
(
"
create
"
);
}
return
storedDocumentations
;
};
if
(
!
newValue
)
{
// this is a DELETE action, show the dialog, ...
this
.
showDeleteConfirm
=
true
;
return
;
}
const
create
=
!
this
.
value
.
id
;
this
.
mutate
(
create
?
createPersonalNotes
:
updatePersonalNotes
,
input
(
this
.
getInput
(
newValue
,
create
?
{
documentation
:
this
.
documentation
.
id
,
...
...
@@ -68,11 +45,66 @@ export default {
id
:
this
.
value
.
id
,
},
),
updater
(
!
create
),
this
.
getUpdater
(
create
?
"
create
"
:
"
update
"
),
);
},
},
},
methods
:
{
getInput
(
newValue
,
extras
)
{
return
{
input
:
[
{
note
:
newValue
,
...
extras
,
},
],
};
},
getUpdater
(
mode
)
{
return
(
storedDocumentations
,
incomingPersonalNotes
)
=>
{
const
note
=
incomingPersonalNotes
?.[
0
]
||
undefined
;
const
documentation
=
storedDocumentations
.
find
(
(
doc
)
=>
doc
.
id
===
this
.
documentation
.
id
,
);
const
participationStatus
=
documentation
.
participations
.
find
(
(
part
)
=>
part
.
id
===
this
.
participation
.
id
,
);
switch
(
mode
.
toLowerCase
())
{
case
"
update
"
:
case
"
delete
"
:
{
const
updateIndex
=
participationStatus
.
notesWithNote
.
findIndex
(
(
n
)
=>
n
.
id
===
this
.
value
.
id
,
);
if
(
mode
===
"
update
"
)
{
participationStatus
.
notesWithNote
.
splice
(
updateIndex
,
1
,
note
);
}
else
{
participationStatus
.
notesWithNote
.
splice
(
updateIndex
,
1
);
}
break
;
}
case
"
create
"
:
participationStatus
.
notesWithNote
.
push
(
note
);
this
.
$emit
(
"
create
"
);
break
;
default
:
console
.
error
(
"
Invalid mode in getUpdater():
"
,
mode
);
break
;
}
return
storedDocumentations
;
};
},
},
data
()
{
return
{
showDeleteConfirm
:
false
,
deletePersonalNotes
,
};
},
};
</
script
>
...
...
@@ -83,10 +115,38 @@ export default {
outlined
hide-details
class=
"mb-4"
clearable
:label=
"$t('alsijil.personal_notes.note')"
:value=
"model"
@
change=
"model = $event"
:loading=
"loading"
/>
>
<template
#append
>
<v-slide-x-reverse-transition>
<v-btn
v-if=
"!!model"
icon
@
click=
"showDeleteConfirm = true"
>
<v-icon>
$deleteContent
</v-icon>
</v-btn>
</v-slide-x-reverse-transition>
<delete-dialog
v-model=
"showDeleteConfirm"
:gql-delete-mutation=
"deletePersonalNotes"
:affected-query=
"affectedQuery"
item-attribute=
"fullName"
:items=
"[value]"
:custom-update=
"getUpdater('delete')"
>
<template
#title
>
{{
$t
(
"
alsijil.personal_notes.confirm_delete
"
)
}}
</
template
>
<
template
#body
>
{{
$t
(
"
alsijil.personal_notes.confirm_delete_explanation
"
,
{
note
:
value
.
note
,
name
:
participation
.
person
.
fullName
,
}
)
}}
<
/template
>
<
/delete-dialog
>
<
/template
>
<
/v-textarea
>
<
/template
>
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment