Skip to content

Commit

Permalink
prompt for tag deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
NyaomiDEV committed Aug 14, 2024
1 parent 2de0686 commit d48efaa
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 6 deletions.
38 changes: 33 additions & 5 deletions src/modals/TagEdit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
IonModal,
IonSegment,
IonTextarea,
useIonRouter
useIonRouter,
alertController
} from "@ionic/vue";
import MD3SegmentButton from "../components/MD3SegmentButton.vue";
import Color from "../components/Color.vue";
Expand All @@ -39,8 +40,10 @@
import { globalEvents, SearchEvent } from "../lib/globalEvents";
import { getMembersTable } from "../lib/db/entities/members";
import { getJournalPostsTable } from "../lib/db/entities/journalPosts";
import { useTranslation } from "i18next-vue";
const isIOS = inject<boolean>("isIOS");
const i18next = useTranslation();
const props = defineProps<{
tag: PartialBy<Tag, "uuid">
Expand Down Expand Up @@ -89,11 +92,36 @@
// however it's safe for us to ignore
}
function promptDeletion(): Promise<boolean> {
return new Promise(async (resolve) => {
const alert = await alertController.create({
header: i18next.t("options:tagManagement.edit.actions.delete.title"),
subHeader: i18next.t("options:tagManagement.edit.actions.delete.confirm"),
buttons: [
{
text: i18next.t("other:alerts.cancel"),
role: "cancel",
handler: () => resolve(false)
},
{
text: i18next.t("other:alerts.ok"),
role: "confirm",
handler: () => resolve(true)
}
]
});
await alert.present();
});
}
async function deleteTag(){
await removeTag(tag.value.uuid!);
try{
await modalController.dismiss(undefined, "deleted");
}catch(_){}
if(await promptDeletion()){
await removeTag(tag.value.uuid!);
try {
await modalController.dismiss(undefined, "deleted");
} catch (_) { }
}
}
function present() {
Expand Down
3 changes: 2 additions & 1 deletion translations/en/options.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@
},
"delete": {
"title": "Delete tag",
"desc": "You won't be able to undo this action!"
"desc": "You won't be able to undo this action!",
"confirm": "Are you sure you want to delete this tag?"
}
}
}
Expand Down

0 comments on commit d48efaa

Please sign in to comment.