Skip to content

Commit

Permalink
Merge pull request #5 from sb5m/general-order
Browse files Browse the repository at this point in the history
changed project structure
  • Loading branch information
sb5m authored Apr 27, 2024
2 parents ccbb2d4 + b716461 commit cf37e68
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 14 deletions.
File renamed without changes.
14 changes: 10 additions & 4 deletions src/components/taskChecker.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ export function checkTasks(logs) {

const currentTime = new Date().getTime();

logs.forEach(log => {
if (log.isTask) { // Check if it's a task
const updatedLogs = logs.map(log => {
if (log.isTask) {
const [datePart, timePart] = log.timestamp.split(', ');
const [day, month, year] = datePart.split('/').map(Number);
const [hour, minute, second] = timePart.split(':').map(Number);
Expand All @@ -19,12 +19,18 @@ export function checkTasks(logs) {
const confirmed = window.confirm(confirmMessage);
if (confirmed) {
console.log("User confirmed to continue.");
// You can put further actions here if the user confirms
return { ...log, isTask: false }; // Create a new log object with isTask set to false
} else {
console.log("User canceled the operation.");
// You can put actions for cancellation here
return log; // Return original log if the user cancels
}
}
}
return log; // Return original log if it's not a task
});


console.log('Updated logs:', updatedLogs);

localStorage.setItem('Logs', JSON.stringify(updatedLogs));
}
4 changes: 2 additions & 2 deletions src/router.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createRouter, createWebHistory } from 'vue-router';
import Todo from './components/Dashboard.vue';
import LogMod from './components/LogMod.vue';
import Todo from './views/Dashboard.vue';
import LogMod from './views/LogMod.vue';

const routes = [
{
Expand Down
File renamed without changes.
11 changes: 6 additions & 5 deletions src/components/Dashboard.vue → src/views/Dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@
</template>

<script>
import './Variables.css';
import '../assets/css/Variables.css';
import './Dashboard.css';
import LogComments from './LogComments.vue';
import MainDisclaimer from "./MainDisclaimer.vue";
import { checkTasks } from './taskChecker.js';
import LogComments from '../components/LogComments.vue';
import MainDisclaimer from "../components/MainDisclaimer.vue";
import { checkTasks } from '../components/taskChecker.js';
/**
* @typedef {Object} Log
Expand Down Expand Up @@ -187,13 +187,14 @@ export default {
// Default log values here
if (newLogContent.trim() !== '') {
const timestamp = new Date().toLocaleString();
this.logs.push({
id: this.logIdCounter++,
content: newLogContent,
list: listNumber,
done: false,
extraInfo: "",
timestamp: new Date().toLocaleString(),
timestamp: timestamp,
highlightedRed: false,
highlightedGreen: false,
isTask: false
Expand Down
File renamed without changes.
12 changes: 9 additions & 3 deletions src/components/LogMod.vue → src/views/LogMod.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,19 @@ export default {
},
watch: {
selectedLogId(newId) {
this.log = this.logs.find(log => log.id === parseInt(newId));
}
this.log = this.logs.find(log => log.id === parseInt(newId)) || {};
}
},
methods: {
saveLogChanges() {
console.log("Log details saved:", this.log);
localStorage.setItem('Logs', JSON.stringify(this.logs));
const index = this.logs.findIndex(log => log.id === this.log.id);
if (index !== -1) {
this.logs[index] = this.log;
localStorage.setItem('Logs', JSON.stringify(this.logs));
} else {
console.error("Log not found in logs array.");
}
},
validateTimestamp() {
// Regular expression for validating timestamp format: DD/MM/YYYY, HH:MM:SS
Expand Down

0 comments on commit cf37e68

Please sign in to comment.