todo item markup

This commit is contained in:
Markus Thielen 2023-03-11 12:15:55 +01:00
parent 19ed9ebaeb
commit 31348bbc63
Signed by: markus
GPG Key ID: 3D4980D3EC9C8E26
4 changed files with 84 additions and 23 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -6,6 +6,21 @@
--> -->
<template> <template>
<h1>ToDo List</h1>
<div id="todo-container">
<div :class="todoItemClass(task)" v-for="(task, i) in tasks" :id="i">
<div class="todo-v-container">
<input class="todo-title" type="text" v-bind="task.title">
<input class="todo-description" type="text" v-bind="task.description">
</div>
<div class="todo-meta">
<img src="@/assets/img/trash-solid.png" class="btn-icon">
</div>
</div>
</div>
</template> </template>
<script> <script>
@ -19,15 +34,38 @@ export default {
data() { data() {
return { return {
/* array of todo lists currently known */ /* array of todo lists currently known */
lists: [], lists: [
/* the name of the list currently being shown */ { id: 1, title: "Default"},
currentList: null, { id: 2, title: "House" },
/* tasks of the current list */ { id: 3, title: "Car" },
tasks: [], ],
/* the id of the list currently being shown */
currentList: 1,
/* known tasks */
tasks: [
{ id: 1, completed: false, title: "Go to dentist", description: "Last time is way too long ago...", list: { id: 1 } },
{ id: 2, completed: true, title: "Change engine oil", description: "", list: { id: 3 } },
{ id: 3, completed: false, title: "Clean windows", description: "Regualar stuff", list: { id: 2 } },
{ id: 4, completed: false, title: "Oil ove hinges", description: "They are stiff and screechy", list: { id: 2 } },
],
} }
}, },
methods: {
/**
* Return class object for a todo item
*
* @param task the item
*/
todoItemClass(task) {
return {
"todo-item": true,
"completed": task.completed,
}
},
},
/** /**
* mounted lifecycle hook. * mounted lifecycle hook.
@ -50,6 +88,7 @@ export default {
id id
title title
description description
completed
list { list {
id id
} }
@ -66,6 +105,28 @@ export default {
} }
</script> </script>
<style scoped> <style lang="scss" scoped>
.todo-item {
display: flex;
background-color: #aaa;
margin-bottom: 5px;
padding: 10px;
input {
border: none;
}
.todo-title {
font-size: 1.5rem;
}
.todo-description {
color: #555;
}
}
.todo-v-container {
display: flex;
flex-direction: row;
flex-grow: 1;
}
</style> </style>

View File

@ -5,7 +5,7 @@
* https://basebox.tech * https://basebox.tech
*/ */
import { store } from "../store"; import {showError, store} from "../store";
import { createRouter, createWebHistory } from 'vue-router' import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue' import HomeView from '../views/HomeView.vue'
import OAUthError from "../components/FatalError.vue"; import OAUthError from "../components/FatalError.vue";
@ -47,13 +47,8 @@ router.beforeEach(async (to, from) => {
} catch (err) { } catch (err) {
const errorMsg = `Failed to get session info from basebox/finish OpenID Connect login: ${err}`; const errorMsg = `Failed to get session info from basebox/finish OpenID Connect login: ${err}`;
console.error(errorMsg); console.error(errorMsg);
/* show error component */ /* show error */
return { showError(errorMsg);
name: "oauth-error",
params: {
errorMsg
}
}
} }
/* We have to create the logged-in user explicitly; see comment for `createUser()` */ /* We have to create the logged-in user explicitly; see comment for `createUser()` */
@ -62,13 +57,7 @@ router.beforeEach(async (to, from) => {
} catch (err) { } catch (err) {
const errorMsg = `Failed to create user: ${err}`; const errorMsg = `Failed to create user: ${err}`;
console.error(errorMsg); console.error(errorMsg);
/* show error component */ showError(errorMsg);
return {
name: "oauth-error",
params: {
errorMsg
}
}
} }
return {name: 'home'}; return {name: 'home'};

View File

@ -17,7 +17,7 @@ export const store = reactive({
/** basebox session data */ /** basebox session data */
session: {}, session: {},
/** Fatal errort message, if any */ /** Fatal error message, if any */
fatalError: "", fatalError: "",
}); });
@ -36,5 +36,16 @@ export function clearSession() {
store.session = {}; store.session = {};
} }
/**
* Show an error.
*/
export function showError(message) {
store.fatalError = message;
}
/**
* Clear error.
*/
export function clearError() {
store.fatalError = "";
}